Title: `wave.open` does not work with `pathlib.Path` files · Issue #140952 · python/cpython · GitHub
Open Graph Title: `wave.open` does not work with `pathlib.Path` files · Issue #140952 · python/cpython
X Title: `wave.open` does not work with `pathlib.Path` files · Issue #140952 · python/cpython
Description: 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: Attribut...
Open Graph Description: 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, "...
X Description: 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(AUD...
Opengraph URL: https://github.com/python/cpython/issues/140952
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`wave.open` does not work with `pathlib.Path` files","articleBody":"# Bug report\n\n### Bug description:\n\nScenario 1 - Opening the file for reading\n```python\n# Opening the file for reading\nimport wave\n\nfrom pathlib import Path\n\n\nAUDIO_FILE = Path(\"sound.wav\")\n\nwith wave.open(AUDIO_FILE, \"rb\") as wave_read:\n pass\n```\n\nOutput:\n```python\nAttributeError: 'PosixPath' object has no attribute 'read'\n```\n---\n\nScenario 2 - Opening the file for writing\n```python\n# Opening a file for writing\n\nimport wave\n\nfrom pathlib import Path\n\n\nAUDIO_FILE = Path(\"sound.wav\")\n\nwith wave.open(AUDIO_FILE, \"wb\") as wave_write:\n wave_write.setnchannels(1)\n wave_write.setsampwidth(2)\n wave_write.setframerate(44100)\n```\n\nOutput:\n```python\nAttributeError: 'PosixPath' object has no attribute 'write'. Did you mean: 'drive'?\n```\n\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-140951\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mbyrnepr2","@type":"Person","name":"mbyrnepr2"},"datePublished":"2025-11-03T15:47:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/140952/cpython/issues/140952"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3ac0b802-18e1-4091-62b7-8f4fd1e3ebe4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CCC2:146E92:2C37A71:3FA1EFE:6A567A12 |
| html-safe-nonce | c00b21886b2e869475fa8de2185b511a09c6c62d9b400fbc82640e3feee669ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0MyOjE0NkU5MjoyQzM3QTcxOjNGQTFFRkU6NkE1NjdBMTIiLCJ2aXNpdG9yX2lkIjoiNTQwMTk3MTY4OTI4MTQ1MjU2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1f75f5c8e9b3a41ad30bf44854ff49e4abe5a888d89b4bac6194d2f2a223402c |
| hovercard-subject-tag | issue:3582641481 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/140952/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9c4ddede9e826e5a1b9bb6eba500cf7408b634d2a7f813a97e4fde3bdeb6c0e/python/cpython/issues/140952 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9c4ddede9e826e5a1b9bb6eba500cf7408b634d2a7f813a97e4fde3bdeb6c0e/python/cpython/issues/140952 |
| og:image:alt | 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, "... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mbyrnepr2 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b5ee9431dcfce15ab4b001d626e4e3a6ba1acb7be814813a52bbebd9a86ef5 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fc131753d059926755b1ab26f13a2c96a692f5d7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width