Kaydet (Commit) 2013ba48 authored tarafından Guido van Rossum's avatar Guido van Rossum

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.
üst dfb4e244
...@@ -148,14 +148,11 @@ def _write_u32(file, x): ...@@ -148,14 +148,11 @@ def _write_u32(file, x):
file.write(chr(int(data[i]))) file.write(chr(int(data[i])))
class Au_read: class Au_read:
## access _file, _soundpos, _hdr_size, _data_size, _encoding, \
## _sampwidth, _framesize, _framerate, _nchannels, \
## _info: private
def __init__(self, f): def __init__(self, f):
if type(f) == type(''): if type(f) == type(''):
import __builtin__ import __builtin__
f = __builtin__.open(f, 'r') f = __builtin__.open(f, 'rb')
self.initfp(f) self.initfp(f)
def __del__(self): def __del__(self):
...@@ -280,14 +277,11 @@ class Au_read: ...@@ -280,14 +277,11 @@ class Au_read:
self._file = None self._file = None
class Au_write: class Au_write:
## access _file, _framerate, _nchannels, _sampwidth, _framesize, \
## _nframes, _nframeswritten, _datawritten, _info, \
## _comptype: private
def __init__(self, f): def __init__(self, f):
if type(f) == type(''): if type(f) == type(''):
import __builtin__ import __builtin__
f = __builtin__.open(f, 'w') f = __builtin__.open(f, 'wb')
self.initfp(f) self.initfp(f)
def __del__(self): def __del__(self):
...@@ -410,7 +404,6 @@ class Au_write: ...@@ -410,7 +404,6 @@ class Au_write:
# #
# private methods # private methods
# #
## if 0: access *: private
def _ensure_header_written(self): def _ensure_header_written(self):
if not self._nframeswritten: if not self._nframeswritten:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment