classification
Title: audioop functions shouldn't accept strings
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: 16682 Superseder:
Assigned To: serhiy.storchaka Nosy List: ezio.melotti, haypo, jason.coombs, jcea, python-dev, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2012-12-14 17:37 by serhiy.storchaka, last changed 2014-03-10 01:35 by python-dev. 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 (haypo) * (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 (haypo) * (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 (haypo) * (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) 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 (jason.coombs) * (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) 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) 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) 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
2014-03-10 01:35:02python-devsetmessages: + msg213004
2013-11-16 12:02:35python-devsetmessages: + msg203030
2013-11-11 17:54:29serhiy.storchakasetstatus: open -> closed

messages: + msg202635
2013-11-11 05:52:11python-devsetmessages: + msg202606
2013-11-11 02:01:23jason.coombssetstatus: closed -> open
nosy: + jason.coombs
messages: + msg202596

2013-11-10 19:46:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-11-10 19:45:08python-devsetnosy: + python-dev
messages: + msg202560
2013-11-09 20:35:35serhiy.storchakasetmessages: + msg202499
2013-10-21 09:45:42serhiy.storchakasetfiles: + audioop_buffer_2.patch
2013-10-21 09:45:18serhiy.storchakasetmessages: + msg200738
2013-10-21 00:38:08hayposetmessages: + msg200675
2013-10-20 10:01:43serhiy.storchakasetfiles: + audioop_buffer.patch
title: Deprecate accepting strings as arguments in audioop functions -> audioop functions shouldn't accept strings
messages: + msg200556

keywords: + patch
stage: needs patch -> patch review
2013-08-22 06:27:48serhiy.storchakasetassignee: serhiy.storchaka
2012-12-15 08:27:43serhiy.storchakasetkeywords: + easy
2012-12-15 00:00:21hayposetmessages: + msg177522
2012-12-14 21:51:59serhiy.storchakasetdependencies: + Document that audioop works with bytes, not strings
messages: + msg177517
2012-12-14 21:43:21ezio.melottisetmessages: + msg177516
2012-12-14 21:37:51serhiy.storchakasetmessages: + msg177515
2012-12-14 21:27:11hayposetmessages: + msg177513
2012-12-14 18:29:03serhiy.storchakasetmessages: + msg177488
2012-12-14 18:22:50ezio.melottisetnosy: + ezio.melotti
messages: + msg177487
2012-12-14 18:06:13jceasetnosy: + jcea
2012-12-14 17:42:27hayposetnosy: + haypo
2012-12-14 17:37:35serhiy.storchakacreate