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
bdd53547
Commit
bdd53547
authored
Jan 01, 2012
by
Sandro Tosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13680: add lowecase compression type to write header; patch by Oleg Plakhotnyuk
parent
da785fd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
Lib/aifc.py
Lib/aifc.py
+2
-10
Lib/test/test_aifc.py
Lib/test/test_aifc.py
+11
-0
No files found.
Lib/aifc.py
View file @
bdd53547
...
...
@@ -716,18 +716,12 @@ class Aifc_write:
def
_ensure_header_written
(
self
,
datasize
):
if
not
self
.
_nframeswritten
:
if
self
.
_comptype
in
(
b'ULAW'
,
b'
ALAW
'
):
if
self
.
_comptype
in
(
b'ULAW'
,
b'
ulaw'
,
b'ALAW'
,
b'alaw'
,
b'G722
'
):
if
not
self
.
_sampwidth
:
self
.
_sampwidth
=
2
if
self
.
_sampwidth
!=
2
:
raise
Error
(
'sample width must be 2 when compressing '
'with ulaw/ULAW or alaw/ALAW'
)
if
self
.
_comptype
==
b'G722'
:
if
not
self
.
_sampwidth
:
self
.
_sampwidth
=
2
if
self
.
_sampwidth
!=
2
:
raise
Error
(
'sample width must be 2 when compressing '
'with G7.22 (ADPCM)'
)
'with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)'
)
if
not
self
.
_nchannels
:
raise
Error
(
'# channels not specified'
)
if
not
self
.
_sampwidth
:
...
...
@@ -743,8 +737,6 @@ class Aifc_write:
self
.
_convert
=
self
.
_lin2ulaw
elif
self
.
_comptype
in
(
b'alaw'
,
b'ALAW'
):
self
.
_convert
=
self
.
_lin2alaw
else
:
raise
Error
(
'unsupported compression type'
)
def
_write_header
(
self
,
initlength
):
if
self
.
_aifc
and
self
.
_comptype
!=
b'NONE'
:
...
...
Lib/test/test_aifc.py
View file @
bdd53547
from
test.support
import
findfile
,
run_unittest
,
TESTFN
import
unittest
import
os
import
io
import
aifc
...
...
@@ -109,6 +110,16 @@ class AIFCTest(unittest.TestCase):
f
.
close
()
self
.
assertEqual
(
testfile
.
closed
,
True
)
def
test_write_header_comptype_sampwidth
(
self
):
for
comptype
in
(
b'ULAW'
,
b'ulaw'
,
b'ALAW'
,
b'alaw'
,
b'G722'
):
fout
=
self
.
fout
=
aifc
.
open
(
io
.
BytesIO
(),
'wb'
)
fout
.
setnchannels
(
1
)
fout
.
setframerate
(
1
)
fout
.
setcomptype
(
comptype
,
b''
)
fout
.
close
()
self
.
assertEqual
(
fout
.
getsampwidth
(),
2
)
fout
.
initfp
(
None
)
def
test_main
():
run_unittest
(
AIFCTest
)
...
...
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