| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… offending value Include the offending value in wave.Error messages raised by Wave_read._read_fmt_chunk and Wave_write setters (setnchannels, setsampwidth, setframerate). For setframerate, the original value is shown rather than the rounded one to aid debugging.
…e-error-messages
| def _read_fmt_chunk(self, chunk): | ||
| try: | ||
| self._format, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14)) | ||
| self._format, nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14)) |
There was a problem hiding this comment.
Don't change this. It is a breaking change. Previously the attribute would have been already set after passing unpack_from but now it will be deferred.
Sorry, something went wrong.
| rounded = int(round(framerate)) | ||
| if rounded <= 0: | ||
| raise Error(f'bad frame rate: {framerate!r}') | ||
| self._framerate = rounded |
There was a problem hiding this comment.
| rounded = int(round(framerate)) | |
| if rounded <= 0: | |
| raise Error(f'bad frame rate: {framerate!r}') | |
| self._framerate = rounded | |
| rounded_framerate = int(round(framerate)) | |
| if rounded_framerate <= 0: | |
| raise Error(f'bad frame rate: {framerate!r}') | |
| self._framerate = rounded_framerate |
Sorry, something went wrong.
| with self.assertRaisesRegex(wave.Error, | ||
| re.escape(f'bad # of channels: {nchannels!r}')): |
There was a problem hiding this comment.
For readability purposes, can you put the message outside?
message = re.escape(...)
with wave.open(...):
with self.assertRaisesRegex(..., err):
f.setchannels(channels)
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. |
Sorry, something went wrong.
…te, extract test messages
|
I have made the requested changes; please review again
|
Sorry, something went wrong.
|
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
Sorry, something went wrong.
Documentation build overview8 files changed · ± 8 modified ± Modified |
Sorry, something went wrong.
|
Hi @picnixz, gentle ping! All review comments have been addressed. Please let me know if anything else is needed. Thanks! |
Sorry, something went wrong.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
|
Hi @picnixz, this went stale but the requested changes are still in from May 3: reverted the _read_fmt_chunk assignment, renamed to rounded_framerate, extracted the assertRaisesRegex messages. CI is green. Let me know if you want anything else changed. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Include the offending value in wave.Error messages raised by:
Before:
After:
Motivation
Wave_read: Values come from the WAV file header — they never appear
in the traceback. The error message is the only debugging clue.
Wave_write: When values originate from variables, configuration files,
or parsed data rather than literals, the traceback shows the call site but
not the value itself. For example, w.setframerate(config['rate']) raises
bad frame rate with no indication of what config['rate'] was.
This extends the clear-feedback approach introduced in gh-144976, which fixed
the validation order in setframerate to raise immediately at the point of
the mistake. Showing the offending value is the natural next step.
For setframerate, the original value (before int(round())) is shown rather
than the rounded result, so callers see exactly what they passed.
Precedent
Notes