From: Serhiy Storchaka Date: Thu, 17 Oct 2013 20:05:19 +0000 (+0300) Subject: Issue #19276: Fixed the wave module on 64-bit big-endian platforms. X-Git-Tag: v3.4.0a4~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b37f97ea5ac9f6b33b0e0269c69539cbb478142;p=python Issue #19276: Fixed the wave module on 64-bit big-endian platforms. --- 5b37f97ea5ac9f6b33b0e0269c69539cbb478142 diff --cc Lib/wave.py index 1c6380eee6,a1daead8ab..0e6628b087 --- a/Lib/wave.py +++ b/Lib/wave.py @@@ -80,15 -80,16 +80,15 @@@ class Error(Exception) WAVE_FORMAT_PCM = 0x0001 - _array_fmts = None, 'b', 'h', None, 'l' + _array_fmts = None, 'b', 'h', None, 'i' -# Determine endian-ness import struct -if struct.pack("h", 1) == b"\000\001": - big_endian = 1 -else: - big_endian = 0 - +import sys from chunk import Chunk +from collections import namedtuple + +_wave_params = namedtuple('_wave_params', + 'nchannels sampwidth framerate nframes comptype compname') class Wave_read: """Variables used in this class: @@@ -430,9 -419,10 +431,10 @@@ class Wave_write nframes = len(data) // (self._sampwidth * self._nchannels) if self._convert: data = self._convert(data) - if self._sampwidth > 1 and big_endian: + if self._sampwidth > 1 and sys.byteorder == 'big': import array data = array.array(_array_fmts[self._sampwidth], data) + assert data.itemsize == self._sampwidth data.byteswap() data.tofile(self._file) self._datawritten = self._datawritten + len(data) * self._sampwidth diff --cc Misc/NEWS index 2a8bfd185d,ebc7d4c4bf..b20fc70561 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,51 -12,71 +10,53 @@@ Projected release date: 2013-10-2 Core and Builtins ----------------- -- Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at - least one place so as to avoid regressions. - -- Issue #19014: memoryview.cast() is now allowed on zero-length views. - -- Issue #19098: Prevent overflow in the compiler when the recursion limit is set - absurdly high. - -- Issue #18942: sys._debugmallocstats() output was damaged on Windows. - -- Issue #18667: Add missing "HAVE_FCHOWNAT" symbol to posix._have_functions. - -- Issue #18368: PyOS_StdioReadline() no longer leaks memory when realloc() - fails. - -- Issue #16741: Fix an error reporting in int(). - -- Issue #17899: Fix rare file descriptor leak in os.listdir(). - -- Issue #18552: Check return value of PyArena_AddPyObject() in - obj2ast_object(). - -- Issue #18560: Fix potential NULL pointer dereference in sum(). +- Issue #4555: All exported C symbols are now prefixed with either + "Py" or "_Py". -- Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0], - prefix and exec_prefix if the operation system does not obey MAXPATHLEN. +- Issue #19219: Speed up marshal.loads(), and make pyc files slightly + (5% to 10%) smaller. -- Issue #18344: Fix potential ref-leaks in _bufferedreader_read_all(). +- Issue #19221: Upgrade Unicode database to version 6.3.0. -- Issue #17872: Fix a segfault in marshal.load() when input stream returns - more bytes than requested. +- Issue #16742: The result of the C callback PyOS_ReadlineFunctionPointer must + now be a string allocated by PyMem_RawMalloc() or PyMem_RawRealloc() (or NULL + if an error occurred), instead of a string allocated by PyMem_Malloc() or + PyMem_Realloc(). -- Issue #18426: Fix NULL pointer dereference in C extension import when - PyModule_GetDef() returns an error. +- Issue #19199: Remove ``PyThreadState.tick_counter`` field -- Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the - tstate is first removed from TLS and then deallocated. +- Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at + least one place so as to avoid regressions. -- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise - OverflowError when an argument of %c format is out of range. +- Issue #19087: Improve bytearray allocation in order to allow cheap popping + of data at the front (slice deletion). -- Issue #18137: Detect integer overflow on precision in float.__format__() - and complex.__format__(). +- Issue #19014: memoryview.cast() is now allowed on zero-length views. -- Issue #18183: Fix various unicode operations on strings with large unicode - codepoints. +- Issue #18690: memoryview is now automatically registered with + collections.abc.Sequence -- Issue #18180: Fix ref leak in _PyImport_GetDynLoadWindows(). +- Issue #19078: memoryview now correctly supports the reversed builtin + (Patch by Claudiu Popa) -- Issue #18038: SyntaxError raised during compilation sources with illegal - encoding now always contains an encoding name. +Library +------- -- Issue #17644: Fix a crash in str.format when curly braces are used in square - brackets. ++- Issue #19276: Fixed the wave module on 64-bit big-endian platforms. + -- Issue #17983: Raise a SyntaxError for a ``global __class__`` statement in a - class body. +- Issue #19266: Rename the new-in-3.4 ``contextlib.ignore`` context manager + to ``contextlib.suppress`` in order to be more consistent with existing + descriptions of that operation elsewhere in the language and standard + library documentation (Patch by Zero Piraeus) -- Issue #17927: Frame objects kept arguments alive if they had been copied into - a cell, even if the cell was cleared. +- Issue #18891: Completed the new email package (provisional) API additions + by adding new classes EmailMessage, MIMEPart, and ContentManager. -Library -------- +- Issue #18468: The re.split, re.findall, and re.sub functions and the group() + and groups() methods of match object now always return a string or a bytes + object. -- Issue #19276: Fixed the wave module on 64-bit big-endian platforms. +- Issue #18725: The textwrap module now supports truncating multiline text. - Issue #18776: atexit callbacks now display their full traceback when they raise an exception.