Issue 16685: audioop functions shouldn't accept strings (original) (raw)

Created on 2012-12-14 17:37 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
audioop_buffer.patch serhiy.storchaka,2013-10-20 10:01 review
audioop_buffer_2.patch serhiy.storchaka,2013-10-21 09:45 review
Messages (18)
msg177477 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-14 17:37
Inadvertently strings accepted as arguments of audioop functions. This is a meaningless behavior and remnant of Python 2. We should drop string support.
msg177487 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-14 18:22
What happens if you pass strings? If it doesn't work we can just fix it to raise an exception and stop returning random results, if it works but bytes should be used instead, we should go through a deprecation process.
msg177488 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-14 18:29
> What happens if you pass strings? They are encoded with UTF-8. See 's#' and 's*' formats in PyArg_ParseTuple() ('y*' recommended for bytes).
msg177513 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-12-14 21:27
Accepting Unicode strings is surprising and must fail. I don't think that a deprecation process is required here.
msg177515 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-14 21:37
> 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?
msg177516 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-14 21:43
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.
msg177517 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-14 21:51
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).
msg177522 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-12-15 00:00
> Should it be fixed in 3.4 only or in all 3.x? Such change cannot be done in a minor release (like 3.3.x), so it can only be done in Python 3.4.
msg200556 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-20 10:01
Here is a patch. Now audioop functions no more accept str, but accept bytes-like objects instead.
msg200675 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-10-21 00:38
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?
msg200738 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-21 09:45
Well. In updated patch I use gotos where it decreases the number of lines (total decreasing is almost 30 lines).
msg202499 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-09 20:35
If there are no objections I will commit last patch tomorrow.
msg202560 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-10 19:45
New changeset bab0cbf86835 by Serhiy Storchaka in branch 'default': Issue #16685: Added support for any bytes-like objects in the audioop module. http://hg.python.org/cpython/rev/bab0cbf86835
msg202596 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2013-11-11 02:01
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
msg202606 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-11 05:52
New changeset 35cd00465624 by Serhiy Storchaka in branch 'default': Fixed compile error on Windows caused by arithmetic with void * pointers http://hg.python.org/cpython/rev/35cd00465624
msg202635 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-11 17:54
Fixed. Thank you Jason.
msg203030 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-16 12:02
New changeset b96f4ee1b08b by Serhiy Storchaka in branch 'default': Issue #16685: Added support for writing any bytes-like objects in the aifc, http://hg.python.org/cpython/rev/b96f4ee1b08b
msg213004 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-10 01:35
New changeset c375697f062e by R David Murray in branch 'default': whatsnew: auidioop.byteswap (#16685). http://hg.python.org/cpython/rev/c375697f062e
History
Date User Action Args
2022-04-11 14:57:39 admin set github: 60889
2014-03-10 01:35:02 python-dev set messages: +
2013-11-16 12:02:35 python-dev set messages: +
2013-11-11 17:54:29 serhiy.storchaka set status: open -> closedmessages: +
2013-11-11 05:52:11 python-dev set messages: +
2013-11-11 02:01:23 jaraco set status: closed -> opennosy: + jaracomessages: +
2013-11-10 19:46:03 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2013-11-10 19:45:08 python-dev set nosy: + python-devmessages: +
2013-11-09 20:35:35 serhiy.storchaka set messages: +
2013-10-21 09:45:42 serhiy.storchaka set files: + audioop_buffer_2.patch
2013-10-21 09:45:18 serhiy.storchaka set messages: +
2013-10-21 00:38:08 vstinner set messages: +
2013-10-20 10:01:43 serhiy.storchaka set files: + audioop_buffer.patchtitle: Deprecate accepting strings as arguments in audioop functions -> audioop functions shouldn't accept stringsmessages: + keywords: + patchstage: needs patch -> patch review
2013-08-22 06:27:48 serhiy.storchaka set assignee: serhiy.storchaka
2012-12-15 08:27:43 serhiy.storchaka set keywords: + easy
2012-12-15 00:00:21 vstinner set messages: +
2012-12-14 21:51:59 serhiy.storchaka set dependencies: + Document that audioop works with bytes, not stringsmessages: +
2012-12-14 21:43:21 ezio.melotti set messages: +
2012-12-14 21:37:51 serhiy.storchaka set messages: +
2012-12-14 21:27:11 vstinner set messages: +
2012-12-14 18:29:03 serhiy.storchaka set messages: +
2012-12-14 18:22:50 ezio.melotti set nosy: + ezio.melottimessages: +
2012-12-14 18:06:13 jcea set nosy: + jcea
2012-12-14 17:42:27 vstinner set nosy: + vstinner
2012-12-14 17:37:35 serhiy.storchaka create