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
5efea043
Commit
5efea043
authored
Jan 13, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use floor division where needed #7681
parent
ee5383da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
Lib/test/test_wave.py
Lib/test/test_wave.py
+11
-0
Lib/wave.py
Lib/wave.py
+2
-2
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_wave.py
View file @
5efea043
from
test.support
import
TESTFN
,
run_unittest
import
os
import
wave
import
struct
import
unittest
nchannels
=
2
...
...
@@ -38,6 +39,16 @@ class TestWave(unittest.TestCase):
self
.
assertEqual
(
nframes
,
self
.
f
.
getnframes
())
self
.
assertEqual
(
self
.
f
.
readframes
(
nframes
),
output
)
def
test_issue7681
(
self
):
self
.
f
=
wave
.
open
(
TESTFN
,
'wb'
)
self
.
f
.
setnchannels
(
nchannels
)
self
.
f
.
setsampwidth
(
sampwidth
)
self
.
f
.
setframerate
(
framerate
)
# Don't call setnframes, make _write_header divide to figure it out
output
=
b'
\
0
'
*
nframes
*
nchannels
*
sampwidth
self
.
f
.
writeframes
(
output
)
def
test_main
():
run_unittest
(
TestWave
)
...
...
Lib/wave.py
View file @
5efea043
...
...
@@ -240,7 +240,7 @@ class Wave_read:
data
=
array
.
array
(
_array_fmts
[
self
.
_sampwidth
])
nitems
=
nframes
*
self
.
_nchannels
if
nitems
*
self
.
_sampwidth
>
chunk
.
chunksize
-
chunk
.
size_read
:
nitems
=
(
chunk
.
chunksize
-
chunk
.
size_read
)
/
self
.
_sampwidth
nitems
=
(
chunk
.
chunksize
-
chunk
.
size_read
)
/
/
self
.
_sampwidth
data
.
fromfile
(
chunk
.
file
.
file
,
nitems
)
# "tell" data chunk how much was read
chunk
.
size_read
=
chunk
.
size_read
+
nitems
*
self
.
_sampwidth
...
...
@@ -461,7 +461,7 @@ class Wave_write:
def
_write_header
(
self
,
initlength
):
self
.
_file
.
write
(
b'RIFF'
)
if
not
self
.
_nframes
:
self
.
_nframes
=
initlength
/
(
self
.
_nchannels
*
self
.
_sampwidth
)
self
.
_nframes
=
initlength
/
/
(
self
.
_nchannels
*
self
.
_sampwidth
)
self
.
_datalength
=
self
.
_nframes
*
self
.
_nchannels
*
self
.
_sampwidth
self
.
_form_length_pos
=
self
.
_file
.
tell
()
self
.
_file
.
write
(
struct
.
pack
(
'<l4s4slhhllhh4s'
,
...
...
Misc/NEWS
View file @
5efea043
...
...
@@ -209,6 +209,8 @@ C-API
Library
-------
- Issue #7681: Use floor division in appropiate places in the wave module.
- Issue #5372: Drop the reuse of .o files in Distutils' ccompiler (since
Extension extra options may change the output without changing the .c
file). Initial patch by Collin Winter.
...
...
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