cpython: 8fac90d0f4cd (original) (raw)

Mercurial > cpython

changeset 74467:8fac90d0f4cd 2.7

Issue #13589: Fix some serialization primitives in the aifc module. Patch by Oleg Plakhotnyuk. [#13589]

Antoine Pitrou solipsis@pitrou.net
date Tue, 17 Jan 2012 17:13:04 +0100
parents f2ef537aaf61
children ef1612a6a4f7
files Lib/aifc.py Lib/test/test_aifc.py Misc/ACKS Misc/NEWS
diffstat 4 files changed, 72 insertions(+), 18 deletions(-)[+] [-] Lib/aifc.py 48 Lib/test/test_aifc.py 38 Misc/ACKS 1 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -162,6 +162,12 @@ def _read_short(file): except struct.error: raise EOFError +def _read_ushort(file):

+ def _read_string(file): length = ord(file.read(1)) if length == 0: @@ -194,13 +200,19 @@ def _read_float(f): # 10 bytes def _write_short(f, x): f.write(struct.pack('>h', x)) +def _write_ushort(f, x):

+ def _write_long(f, x):

+ +def _write_ulong(f, x): f.write(struct.pack('>L', x)) def _write_string(f, s): if len(s) > 255: raise ValueError("string exceeds maximum pstring length")

@@ -218,7 +230,7 @@ def _write_float(f, x): lomant = 0 else: fmant, expon = math.frexp(x)

@@ -234,9 +246,9 @@ def _write_float(f, x): fmant = math.ldexp(fmant - fsmant, 32) fsmant = math.floor(fmant) lomant = long(fsmant)

from chunk import Chunk @@ -840,15 +852,15 @@ class Aifc_write: if self._aifc: self._file.write('AIFC') self._file.write('FVER')

@@ -856,9 +868,9 @@ class Aifc_write: _write_string(self._file, self._compname) self._file.write('SSND') self._ssnd_length_pos = self._file.tell()

def _write_form_length(self, datalength): if self._aifc: @@ -869,8 +881,8 @@ class Aifc_write: else: commlength = 18 verslength = 0

def _patchheader(self): @@ -888,9 +900,9 @@ class Aifc_write: self._file.seek(self._form_length_pos, 0) dummy = self._write_form_length(datalength) self._file.seek(self._nframes_pos, 0)

@@ -905,13 +917,13 @@ class Aifc_write: length = length + len(name) + 1 + 6 if len(name) & 1 == 0: length = length + 1

def open(f, mode=None):

--- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -1,6 +1,7 @@ from test.test_support import findfile, run_unittest, TESTFN import unittest import os +import io import aifc @@ -107,8 +108,45 @@ class AIFCTest(unittest.TestCase): self.assertEqual(testfile.closed, True) +class AIFCLowLevelTest(unittest.TestCase): +

+

+

+ + def test_main(): run_unittest(AIFCTest)

if name == "main":

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -662,6 +662,7 @@ Zach Pincus Michael Piotrowski Antoine Pitrou Jean-François Piéronne +Oleg Plakhotnyuk Guilherme Polo Michael Pomraning Iustin Pop

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -89,6 +89,9 @@ Core and Builtins Library ------- +- Issue #13589: Fix some serialization primitives in the aifc module.