-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audioop functions shouldn't accept strings #60889
Comments
Inadvertently strings accepted as arguments of audioop functions. This is a meaningless behavior and remnant of Python 2. We should drop string support. |
What happens if you pass strings? |
They are encoded with UTF-8. See 's#' and 's*' formats in PyArg_ParseTuple() ('y*' recommended for bytes). |
Accepting Unicode strings is surprising and must fail. I don't think that a deprecation process is required here. |
Should it be fixed in 3.4 only or in all 3.x? |
The deprecation process can be avoided only if passing strings results in a meaningless result. If there are cases where users are passing strings and everything works fine -- even if they should be passing bytes instead -- we should deprecate strings first to warn the users that the "feature" is going to be removed. |
In 2.x it was have a little sense (if you use some 8-bit encoding as default encoding, but the default was 7-bit ascii). But with utf-8 it doesn't have sense and should quickly lead to an unexpected result (or just fail in most cases). |
Such change cannot be done in a minor release (like 3.3.x), so it can |
Here is a patch. Now audioop functions no more accept str, but accept bytes-like objects instead. |
audioop_buffer.patch: In general, I don't like goto in C. But to cleanup something when exiting a function, I like goto to implement something similar to Python try/finally. What do you think Serhiy? |
Well. In updated patch I use gotos where it decreases the number of lines (total decreasing is almost 30 lines). |
If there are no objections I will commit last patch tomorrow. |
New changeset bab0cbf86835 by Serhiy Storchaka in branch 'default': |
The patch as committed causes the Windows 64-bit builds to fail to compile. http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/3187/steps/compile/logs/stdio |
New changeset 35cd00465624 by Serhiy Storchaka in branch 'default': |
Fixed. Thank you Jason. |
New changeset b96f4ee1b08b by Serhiy Storchaka in branch 'default': |
New changeset c375697f062e by R David Murray in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: