mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Make a few more tests pass with the new I/O library.
Fix the truncate() semantics -- it should not affect the current position. Switch wave.py/chunk.py to struct.unpack_from() to support bytes. Don't use writelines() on binary files (test_fileinput.py).
This commit is contained in:
parent
b6f1fdc90c
commit
dc0b1a1069
6 changed files with 16 additions and 20 deletions
|
|
@ -256,9 +256,9 @@ class Wave_read:
|
|||
#
|
||||
|
||||
def _read_fmt_chunk(self, chunk):
|
||||
wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack('<hhllh', chunk.read(14))
|
||||
wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<hhllh', chunk.read(14))
|
||||
if wFormatTag == WAVE_FORMAT_PCM:
|
||||
sampwidth = struct.unpack('<h', chunk.read(2))[0]
|
||||
sampwidth = struct.unpack_from('<h', chunk.read(2))[0]
|
||||
self._sampwidth = (sampwidth + 7) // 8
|
||||
else:
|
||||
raise Error, 'unknown format: %r' % (wFormatTag,)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue