Title: `Wave_write` does not write `pad byte` · Issue #117716 · python/cpython · GitHub
Open Graph Title: `Wave_write` does not write `pad byte` · Issue #117716 · python/cpython
X Title: `Wave_write` does not write `pad byte` · Issue #117716 · python/cpython
Description: Bug report Bug description: import io import wave test_bytes = b"RIFF&\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x80\xbb\x00\x00\x80\xbb\x00\x00\x01\x00\x08\x00data\x01\x00\x00\x00\x80\x00" r = io.BytesIO(test_bytes) with wave....
Open Graph Description: Bug report Bug description: import io import wave test_bytes = b"RIFF&\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x80\xbb\x00\x00\x80\xbb\x00\x00\x01\x00\x08\x00data\x01\x00\x00\x00\x80\x0...
X Description: Bug report Bug description: import io import wave test_bytes = b"RIFF&\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x80\xbb\x00\x00\x80\xbb\x00\x00\x01\x00\x08\x00data\x01\x00\x00\x...
Opengraph URL: https://github.com/python/cpython/issues/117716
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Wave_write` does not write `pad byte`","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nimport io\nimport wave\n\ntest_bytes = b\"RIFF&\\x00\\x00\\x00WAVEfmt \\x10\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\x80\\xbb\\x00\\x00\\x80\\xbb\\x00\\x00\\x01\\x00\\x08\\x00data\\x01\\x00\\x00\\x00\\x80\\x00\"\n\nr = io.BytesIO(test_bytes)\n\nwith wave.open(r, mode=\"rb\") as rw:\n nframes = rw.getnframes()\n sampwidth = rw.getsampwidth()\n nchannels = rw.getnchannels()\n framerate = rw.getframerate()\n frames = rw.readframes(-1)\n\nassert nframes == 1\nassert sampwidth == 1\nassert nchannels == 1\nassert frames == b\"\\x80\"\n\nw = io.BytesIO()\n\nwith wave.open(w, mode=\"wb\") as ww:\n ww.setsampwidth(sampwidth)\n ww.setnchannels(nchannels)\n ww.setframerate(framerate)\n ww.writeframes(frames)\n\nvalue = w.getvalue()\n\n# b'RIFF%\\x00\\x00\\x00WAVEfmt \\x10\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\x80\\xbb\\x00\\x00\\x80\\xbb\\x00\\x00\\x01\\x00\\x08\\x00data\\x01\\x00\\x00\\x00\\x80'\nprint(value)\n\n# AssertionError\nassert test_bytes == value\nassert test_bytes[-1] == value[-1] == 0\nassert (\n int.from_bytes(test_bytes[4:8], byteorder=\"little\")\n == int.from_bytes(value[4:8], byteorder=\"little\")\n == 38\n)\n```\n\nThe data written is missing the last pad byte`\\x00`.\nAlong with this, the size of the RIFF chunk is also incorrect.\n\nref: https://www.tactilemedia.com/info/MCI_Control_Info.html\n> If the chunk size is an odd number of bytes, a pad byte with value zero is written after ckData.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-145237\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/sabonerune","@type":"Person","name":"sabonerune"},"datePublished":"2024-04-10T16:50:17Z","url":"https://github.com/python/cpython/issues/117716"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:d7e00305-bf33-d10f-3ac0-cb7c52671b4e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9750:3710D1:395CEA:4EF528:6AECCA19 |
| html-safe-nonce | f1934662cb09f4d7da68001b56347ca1627289af56a078f0a2f30d1ba5155956 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzUwOjM3MTBEMTozOTVDRUE6NEVGNTI4OjZBRUNDQTE5IiwidmlzaXRvcl9pZCI6Ijg2NDE0NDM2NjQxMjg0Mjg1NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1afe06a619e81cb11dfc150767e98eb7687571d38157b7bcc9a9405afcdef74c |
| hovercard-subject-tag | issue:2236033953 |
| 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/117716/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ab532fe170ac50810f924c4ea65e25b22edb5d43e82069f0c8ae0d55083c5955/python/cpython/issues/117716 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ab532fe170ac50810f924c4ea65e25b22edb5d43e82069f0c8ae0d55083c5955/python/cpython/issues/117716 |
| og:image:alt | Bug report Bug description: import io import wave test_bytes = b"RIFF&\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x80\xbb\x00\x00\x80\xbb\x00\x00\x01\x00\x08\x00data\x01\x00\x00\x00\x80\x0... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sabonerune |
| hostname | github.com |
| expected-hostname | github.com |
| None | dc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016 |
| 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 | db139f0bf57b59bf9a8c4abb0849924d6c6ca559 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width