Skip to content
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: weightB not divided by GCD, weightA divided twice #68514

Closed
grajagandev mannequin opened this issue May 29, 2015 · 6 comments
Closed

Audioop: weightB not divided by GCD, weightA divided twice #68514

grajagandev mannequin opened this issue May 29, 2015 · 6 comments
Assignees
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@grajagandev
Copy link
Mannequin

grajagandev mannequin commented May 29, 2015

BPO 24326
Nosy @serhiy-storchaka
Files
  • audioop.patch: Patch file (hg diff) to fix this bug.
  • 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:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-05-31.09:06:49.587>
    created_at = <Date 2015-05-29.17:20:05.482>
    labels = ['extension-modules', 'type-bug']
    title = 'Audioop: weightB not divided by GCD, weightA divided twice'
    updated_at = <Date 2015-05-31.09:06:49.585>
    user = 'https://bugs.python.org/grajagandev'

    bugs.python.org fields:

    activity = <Date 2015-05-31.09:06:49.585>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-05-31.09:06:49.587>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2015-05-29.17:20:05.482>
    creator = 'grajagandev'
    dependencies = []
    files = ['39549']
    hgrepos = []
    issue_num = 24326
    keywords = ['patch']
    message_count = 6.0
    messages = ['244392', '244422', '244423', '244527', '244529', '244530']
    nosy_count = 4.0
    nosy_names = ['Arfrever', 'python-dev', 'serhiy.storchaka', 'grajagandev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24326'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @grajagandev
    Copy link
    Mannequin Author

    grajagandev mannequin commented May 29, 2015

    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.

    @grajagandev grajagandev mannequin added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels May 29, 2015
    @serhiy-storchaka serhiy-storchaka self-assigned this May 29, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 29, 2015

    New changeset 800a55c20b56 by Serhiy Storchaka in branch '3.4':
    Issue bpo-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 bpo-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 bpo-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 bpo-24326: Fixed audioop.ratecv() with non-default weightB argument.
    https://hg.python.org/cpython/rev/1acb6c88b901

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your report and patch David.

    @Arfrever
    Copy link
    Mannequin

    Arfrever mannequin commented May 31, 2015

    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

    @Arfrever Arfrever mannequin reopened this May 31, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 31, 2015

    New changeset 7d6a6028b104 by Serhiy Storchaka in branch '2.7':
    Fixed test_audioop for issue bpo-24326.
    https://hg.python.org/cpython/rev/7d6a6028b104

    @serhiy-storchaka
    Copy link
    Member

    Thank you Arfrever.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant