Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2013ba4

Browse files
committed
Should open files in binary mode!
Also finally get rid of some obsolete commented-out access statements. A note about the previous checkin: I believe it's correct, but I found something strange: the file Lib/test/audiotest.au in the Python distribution was evidently encoded in u-LAW format but had its encoding set to 2, i.e. linear-8. I hope that this is a mistake caused by some conversion program that produced this .au file; I just found it on a website.
1 parent dfb4e24 commit 2013ba4

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

Lib/sunau.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,11 @@ def _write_u32(file, x):
148148
file.write(chr(int(data[i])))
149149

150150
class Au_read:
151-
## access _file, _soundpos, _hdr_size, _data_size, _encoding, \
152-
## _sampwidth, _framesize, _framerate, _nchannels, \
153-
## _info: private
154151

155152
def __init__(self, f):
156153
if type(f) == type(''):
157154
import __builtin__
158-
f = __builtin__.open(f, 'r')
155+
f = __builtin__.open(f, 'rb')
159156
self.initfp(f)
160157

161158
def __del__(self):
@@ -280,14 +277,11 @@ def close(self):
280277
self._file = None
281278

282279
class Au_write:
283-
## access _file, _framerate, _nchannels, _sampwidth, _framesize, \
284-
## _nframes, _nframeswritten, _datawritten, _info, \
285-
## _comptype: private
286280

287281
def __init__(self, f):
288282
if type(f) == type(''):
289283
import __builtin__
290-
f = __builtin__.open(f, 'w')
284+
f = __builtin__.open(f, 'wb')
291285
self.initfp(f)
292286

293287
def __del__(self):
@@ -410,7 +404,6 @@ def close(self):
410404
#
411405
# private methods
412406
#
413-
## if 0: access *: private
414407

415408
def _ensure_header_written(self):
416409
if not self._nframeswritten:

0 commit comments

Comments
 (0)