Skip to content

wave.open does not work with pathlib.Path files #140952

Closed as duplicate
Closed as duplicate

Description

@mbyrnepr2

Bug report

Bug description:

Scenario 1 - Opening the file for reading

# Opening the file for reading
import wave

from pathlib import Path


AUDIO_FILE = Path("sound.wav")

with wave.open(AUDIO_FILE, "rb") as wave_read:
    pass

Output:

AttributeError: 'PosixPath' object has no attribute 'read'

Scenario 2 - Opening the file for writing

# Opening a file for writing

import wave

from pathlib import Path


AUDIO_FILE = Path("sound.wav")

with wave.open(AUDIO_FILE, "wb") as wave_write:
    wave_write.setnchannels(1)
    wave_write.setsampwidth(2)
    wave_write.setframerate(44100)

Output:

AttributeError: 'PosixPath' object has no attribute 'write'. Did you mean: 'drive'?

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    and removed on Nov 3, 2025
  2. serhiy-storchaka commented on Nov 3, 2025

    @serhiy-storchaka
    Member

    This is a duplicate of #75593.

  3. mbyrnepr2 commented on Nov 3, 2025

    @mbyrnepr2
    ContributorAuthor

    Oh sorry about that!

  4. serhiy-storchaka commented on Nov 4, 2025

    @serhiy-storchaka
    Member

    I have reopened the old issue, so you can just change the issue number in the PR.

  5. mbyrnepr2 commented on Nov 4, 2025

    @mbyrnepr2
    ContributorAuthor

    Many thanks @serhiy-storchaka.
    So, I'll point my PR to the existing issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions