Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
50451eb9
Commit
50451eb9
authored
May 30, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
Original patch by David Moore.
parent
1ad08a55
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
Lib/test/test_audioop.py
Lib/test/test_audioop.py
+17
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/audioop.c
Modules/audioop.c
+1
-1
No files found.
Lib/test/test_audioop.py
View file @
50451eb9
...
@@ -363,6 +363,9 @@ class TestAudioop(unittest.TestCase):
...
@@ -363,6 +363,9 @@ class TestAudioop(unittest.TestCase):
(
b''
,
(
-
2
,
((
0
,
0
),))))
(
b''
,
(
-
2
,
((
0
,
0
),))))
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
)[
0
],
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
)[
0
],
datas
[
w
])
datas
[
w
])
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
,
1
,
0
)[
0
],
datas
[
w
])
state
=
None
state
=
None
d1
,
state
=
audioop
.
ratecv
(
b'
\
x00
\
x01
\
x02
'
,
1
,
1
,
8000
,
16000
,
state
)
d1
,
state
=
audioop
.
ratecv
(
b'
\
x00
\
x01
\
x02
'
,
1
,
1
,
8000
,
16000
,
state
)
d2
,
state
=
audioop
.
ratecv
(
b'
\
x00
\
x01
\
x02
'
,
1
,
1
,
8000
,
16000
,
state
)
d2
,
state
=
audioop
.
ratecv
(
b'
\
x00
\
x01
\
x02
'
,
1
,
1
,
8000
,
16000
,
state
)
...
@@ -378,6 +381,20 @@ class TestAudioop(unittest.TestCase):
...
@@ -378,6 +381,20 @@ class TestAudioop(unittest.TestCase):
self
.
assertEqual
(
d
,
d0
)
self
.
assertEqual
(
d
,
d0
)
self
.
assertEqual
(
state
,
state0
)
self
.
assertEqual
(
state
,
state0
)
expected
=
{
1
:
packs
[
1
](
0
,
0x0d
,
0x37
,
-
0x26
,
0x55
,
-
0x4b
,
-
0x14
),
2
:
packs
[
2
](
0
,
0x0da7
,
0x3777
,
-
0x2630
,
0x5673
,
-
0x4a64
,
-
0x129a
),
3
:
packs
[
3
](
0
,
0x0da740
,
0x377776
,
-
0x262fca
,
0x56740c
,
-
0x4a62fd
,
-
0x1298c0
),
4
:
packs
[
4
](
0
,
0x0da740da
,
0x37777776
,
-
0x262fc962
,
0x56740da6
,
-
0x4a62fc96
,
-
0x1298bf26
),
}
for
w
in
1
,
2
,
3
,
4
:
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
,
3
,
1
)[
0
],
expected
[
w
])
self
.
assertEqual
(
audioop
.
ratecv
(
datas
[
w
],
w
,
1
,
8000
,
8000
,
None
,
30
,
10
)[
0
],
expected
[
w
])
def
test_reverse
(
self
):
def
test_reverse
(
self
):
for
w
in
1
,
2
,
3
,
4
:
for
w
in
1
,
2
,
3
,
4
:
self
.
assertEqual
(
audioop
.
reverse
(
b''
,
w
),
b''
)
self
.
assertEqual
(
audioop
.
reverse
(
b''
,
w
),
b''
)
...
...
Misc/NEWS
View file @
50451eb9
...
@@ -56,6 +56,9 @@ Core and Builtins
...
@@ -56,6 +56,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
Original patch by David Moore.
- Issue #23840: tokenize.open() now closes the temporary binary file on error
- Issue #23840: tokenize.open() now closes the temporary binary file on error
to fix a resource warning.
to fix a resource warning.
...
...
Modules/audioop.c
View file @
50451eb9
...
@@ -1320,7 +1320,7 @@ audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, int nch
...
@@ -1320,7 +1320,7 @@ audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, int nch
/* divide weightA and weightB by their greatest common divisor */
/* divide weightA and weightB by their greatest common divisor */
d
=
gcd
(
weightA
,
weightB
);
d
=
gcd
(
weightA
,
weightB
);
weightA
/=
d
;
weightA
/=
d
;
weight
A
/=
d
;
weight
B
/=
d
;
if
((
size_t
)
nchannels
>
PY_SIZE_MAX
/
sizeof
(
int
))
{
if
((
size_t
)
nchannels
>
PY_SIZE_MAX
/
sizeof
(
int
))
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment