Bug in Python 3.13 wave module? getnchannels() error on cleanup.
Posted by Common_Base657@reddit | Python | View on Reddit | 7 comments
Hey everyone,
I ran into a really strange error today while working with the built-in wave module in Python 3.13 and thought I'd share in case anyone else encounters this or has some insight.
I was trying to do something very basic: generate a simple sine wave and save it as a WAV file using the standard library. My code was the textbook example, using wave.open() inside a with statement to handle the file.
The weird part is that my script runs, but then throws this error right at the end, seemingly during the internal cleanup process after the with block closes the file:
wave.Error: # channels not specified
My code to set the channels (wav_file.setnchannels(1))
is definitely there and in the correct order before writing the frames, so it doesn't seem to be a problem with my script's logic. It feels like the library is failing internally when the file object is being destroyed.
Has anyone else seen this with Python 3.13? Is this a known bug in the new version?
Thanks!
Common_Base657@reddit (OP)
The issue has been resolved turns out the bug was not in the wave module but in my program. My overconfidence didnt spot that bug, after countless try i decided to ask to chatgpt and he points out the mistake i typed "get" instead of "set" so yeahh my bad guys sorry.
fisadev@reddit
In the future, a couple of things when requesting coding help online:
Just advice, hope it's useful :)
kkang_kkang@reddit
Kindly share the whole script to test it
Common_Base657@reddit (OP)
turns out there was no bug in python, there was a small typo mistake in the program and my overconfidence didnt spot that mistake. my bad sorry
Green_Gem_@reddit
And the requirements and project structure to check for namespace pollution.
fizzymagic@reddit
The probability you have found a bug is quite small. And this does not look like a cleanup error.
Common_Base657@reddit (OP)
yaa you're right turns out there was a small typo mistake on the code.