This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Audioop: weightB not divided by GCD, weightA divided twice
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Arfrever, grajagandev, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-05-29 17:20 by grajagandev, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
audioop.patch grajagandev, 2015-05-29 17:20 Patch file (hg diff) to fix this bug. review
Messages (6)
msg244392 - (view) Author: David Moore (grajagandev) * Date: 2015-05-29 17:20
Hi - 

During a code review of Modules/audioop.c I noted that weightB is never divided by the GCD while weightA is divided twice. This is contrary to the comment and appears to be a bug:

    /* divide weightA and weightB by their greatest common divisor */
    d = gcd(weightA, weightB);
    weightA /= d;
    weightA /= d;

The patch file below (hg diff) fixes this issue.
msg244422 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-29 21:59
New changeset 800a55c20b56 by Serhiy Storchaka in branch '3.4':
Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
https://hg.python.org/cpython/rev/800a55c20b56

New changeset 418ab34fd1ce by Serhiy Storchaka in branch '2.7':
Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
https://hg.python.org/cpython/rev/418ab34fd1ce

New changeset fc85a384b16c by Serhiy Storchaka in branch '3.5':
Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
https://hg.python.org/cpython/rev/fc85a384b16c

New changeset 1acb6c88b901 by Serhiy Storchaka in branch 'default':
Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
https://hg.python.org/cpython/rev/1acb6c88b901
msg244423 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-29 21:59
Thank you for your report and patch David.
msg244527 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2015-05-31 08:39
The changed test passes on 3.4 branch, but fails on 2.7 branch:

$ python2.7 -m test.test_audioop
test_add (__main__.TestAudioop) ... ok
test_adpcm2lin (__main__.TestAudioop) ... ok
test_alaw2lin (__main__.TestAudioop) ... ok
test_avg (__main__.TestAudioop) ... ok
test_avgpp (__main__.TestAudioop) ... ok
test_bias (__main__.TestAudioop) ... ok
test_cross (__main__.TestAudioop) ... ok
test_findfactor (__main__.TestAudioop) ... ok
test_findfit (__main__.TestAudioop) ... ok
test_findmax (__main__.TestAudioop) ... ok
test_getsample (__main__.TestAudioop) ... ok
test_issue7673 (__main__.TestAudioop) ... ok
test_lin2adpcm (__main__.TestAudioop) ... ok
test_lin2alaw (__main__.TestAudioop) ... ok
test_lin2lin (__main__.TestAudioop) ... ok
test_lin2ulaw (__main__.TestAudioop) ... ok
test_max (__main__.TestAudioop) ... ok
test_maxpp (__main__.TestAudioop) ... ok
test_minmax (__main__.TestAudioop) ... ok
test_mul (__main__.TestAudioop) ... ok
test_negativelen (__main__.TestAudioop) ... ok
test_ratecv (__main__.TestAudioop) ... ERROR
test_reverse (__main__.TestAudioop) ... ok
test_rms (__main__.TestAudioop) ... ok
test_tomono (__main__.TestAudioop) ... ok
test_tostereo (__main__.TestAudioop) ... ok
test_ulaw2lin (__main__.TestAudioop) ... ok
test_wrongsize (__main__.TestAudioop) ... ok

======================================================================
ERROR: test_ratecv (__main__.TestAudioop)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python2.7/test/test_audioop.py", line 304, in test_ratecv
    3: packs[3](0, 0x0da740, 0x377776, -0x262fca,
KeyError: 3

----------------------------------------------------------------------
Ran 28 tests in 0.009s

FAILED (errors=1)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib64/python2.7/test/test_audioop.py", line 410, in <module>
    test_main()
  File "/usr/lib64/python2.7/test/test_audioop.py", line 407, in test_main
    run_unittest(TestAudioop)
  File "/usr/lib64/python2.7/test/test_support.py", line 1400, in run_unittest
    _run_suite(suite)
  File "/usr/lib64/python2.7/test/test_support.py", line 1383, in _run_suite
    raise TestFailed(err)
test.test_support.TestFailed: Traceback (most recent call last):
  File "/usr/lib64/python2.7/test/test_audioop.py", line 304, in test_ratecv
    3: packs[3](0, 0x0da740, 0x377776, -0x262fca,
KeyError: 3
msg244529 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-31 09:06
New changeset 7d6a6028b104 by Serhiy Storchaka in branch '2.7':
Fixed test_audioop for issue #24326.
https://hg.python.org/cpython/rev/7d6a6028b104
msg244530 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-31 09:06
Thank you Arfrever.
History
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68514
2015-05-31 09:06:49serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg244530

stage: resolved
2015-05-31 09:06:07python-devsetmessages: + msg244529
2015-05-31 08:39:20Arfreversetstatus: closed -> open

nosy: + Arfrever
messages: + msg244527

resolution: fixed -> (no value)
stage: resolved -> (no value)
2015-05-29 21:59:52serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg244423

stage: patch review -> resolved
2015-05-29 21:59:02python-devsetnosy: + python-dev
messages: + msg244422
2015-05-29 19:45:11serhiy.storchakasetassignee: serhiy.storchaka
stage: patch review

nosy: + serhiy.storchaka
versions: + Python 2.7, Python 3.4, Python 3.5
2015-05-29 17:20:05grajagandevcreate