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
625cb26d
Commit
625cb26d
authored
Jan 03, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audioop: adpcm2lin() and lin2adpcm() now raises a TypeError instead of a
SystemError if the state type is invalid.
parent
3d7f9fe7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
Lib/test/test_audioop.py
Lib/test/test_audioop.py
+5
-0
Modules/audioop.c
Modules/audioop.c
+6
-0
No files found.
Lib/test/test_audioop.py
View file @
625cb26d
...
@@ -269,6 +269,11 @@ class TestAudioop(unittest.TestCase):
...
@@ -269,6 +269,11 @@ class TestAudioop(unittest.TestCase):
self
.
assertEqual
(
audioop
.
lin2adpcm
(
b'
\
0
'
*
w
*
10
,
w
,
None
),
self
.
assertEqual
(
audioop
.
lin2adpcm
(
b'
\
0
'
*
w
*
10
,
w
,
None
),
(
b'
\
0
'
*
5
,
(
0
,
0
)))
(
b'
\
0
'
*
5
,
(
0
,
0
)))
def
test_invalid_adpcm_state
(
self
):
# state must be a tuple or None, not an integer
self
.
assertRaises
(
TypeError
,
audioop
.
adpcm2lin
,
b'
\
0
'
,
1
,
555
)
self
.
assertRaises
(
TypeError
,
audioop
.
lin2adpcm
,
b'
\
0
'
,
1
,
555
)
def
test_lin2alaw
(
self
):
def
test_lin2alaw
(
self
):
self
.
assertEqual
(
audioop
.
lin2alaw
(
datas
[
1
],
1
),
self
.
assertEqual
(
audioop
.
lin2alaw
(
datas
[
1
],
1
),
b'
\
xd5
\
x87
\
xa4
\
x24
\
xaa
\
x2a
\
x5a
'
)
b'
\
xd5
\
x87
\
xa4
\
x24
\
xaa
\
x2a
\
x5a
'
)
...
...
Modules/audioop.c
View file @
625cb26d
...
@@ -1525,6 +1525,9 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
...
@@ -1525,6 +1525,9 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
/* First time, it seems. Set defaults */
/* First time, it seems. Set defaults */
valpred
=
0
;
valpred
=
0
;
index
=
0
;
index
=
0
;
}
else
if
(
!
PyTuple_Check
(
state
))
{
PyErr_SetString
(
PyExc_TypeError
,
"state must be a tuple or None"
);
goto
exit
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
goto
exit
;
goto
exit
;
...
@@ -1631,6 +1634,9 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
...
@@ -1631,6 +1634,9 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
/* First time, it seems. Set defaults */
/* First time, it seems. Set defaults */
valpred
=
0
;
valpred
=
0
;
index
=
0
;
index
=
0
;
}
else
if
(
!
PyTuple_Check
(
state
))
{
PyErr_SetString
(
PyExc_TypeError
,
"state must be a tuple or None"
);
goto
exit
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
))
goto
exit
;
goto
exit
;
...
...
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