summaryrefslogtreecommitdiffstats
path: root/Lib/aifc.py
diff options
context:
space:
mode:
authorSandro Tosi <sandro.tosi@gmail.com>2012-01-01 21:53:08 (GMT)
committerSandro Tosi <sandro.tosi@gmail.com>2012-01-01 21:53:08 (GMT)
commit70efbefcc5c26e675c064f50dd2c64cc375f20ac (patch)
treeeb51bc9cfa64c72ceb573271537c8a053310dd1a /Lib/aifc.py
parentbdd5354700d2ebafc98375ef2982fbcbb42b1ba5 (diff)
downloadcpython-70efbefcc5c26e675c064f50dd2c64cc375f20ac.zip
cpython-70efbefcc5c26e675c064f50dd2c64cc375f20ac.tar.gz
cpython-70efbefcc5c26e675c064f50dd2c64cc375f20ac.tar.bz2
Issue #13594: various fixes to aifc module; patch by Oleg Plakhotnyuk
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r--Lib/aifc.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 4646285..7774325 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -539,8 +539,7 @@ class Aifc_write:
self._aifc = 1 # AIFF-C is default
def __del__(self):
- if self._file:
- self.close()
+ self.close()
#
# User visible methods.
@@ -643,8 +642,8 @@ class Aifc_write:
raise Error('marker ID must be > 0')
if pos < 0:
raise Error('marker position must be >= 0')
- if not isinstance(name, str):
- raise Error('marker name must be a string')
+ if not isinstance(name, bytes):
+ raise Error('marker name must be bytes')
for i in range(len(self._markers)):
if id == self._markers[i][0]:
self._markers[i] = id, pos, name
@@ -681,19 +680,21 @@ class Aifc_write:
self._patchheader()
def close(self):
- self._ensure_header_written(0)
- if self._datawritten & 1:
- # quick pad to even size
- self._file.write(b'\x00')
- self._datawritten = self._datawritten + 1
- self._writemarkers()
- if self._nframeswritten != self._nframes or \
- self._datalength != self._datawritten or \
- self._marklength:
- self._patchheader()
- # Prevent ref cycles
- self._convert = None
- self._file.close()
+ if self._file:
+ self._ensure_header_written(0)
+ if self._datawritten & 1:
+ # quick pad to even size
+ self._file.write(b'\x00')
+ self._datawritten = self._datawritten + 1
+ self._writemarkers()
+ if self._nframeswritten != self._nframes or \
+ self._datalength != self._datawritten or \
+ self._marklength:
+ self._patchheader()
+ # Prevent ref cycles
+ self._convert = None
+ self._file.close()
+ self._file = None
#
# Internal methods.