cpython: ccffce2dde49 (original) (raw)
Mercurial > cpython
changeset 83983:ccffce2dde49
Issue #18084: Use sys.byteorder in wave.py. Original patch by Hideaki Takahashi. [#18084]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Wed, 29 May 2013 23:38:00 +0300 |
parents | bcaaaa00425b |
children | 18ef35afc55d |
files | Lib/wave.py Misc/ACKS |
diffstat | 2 files changed, 4 insertions(+), 8 deletions(-)[+] [-] Lib/wave.py 11 Misc/ACKS 1 |
line wrap: on
line diff
--- a/Lib/wave.py +++ b/Lib/wave.py @@ -82,13 +82,8 @@ WAVE_FORMAT_PCM = 0x0001 _array_fmts = None, 'b', 'h', None, 'l' -# Determine endian-ness import struct -if struct.pack("h", 1) == b"\000\001":
- +import sys from chunk import Chunk from collections import namedtuple @@ -235,7 +230,7 @@ class Wave_read: self._data_seek_needed = 0 if nframes == 0: return b''
if self._sampwidth > 1 and big_endian:[](#l1.22)
if self._sampwidth > 1 and sys.byteorder == 'big':[](#l1.23) # unfortunately the fromfile() method does not take[](#l1.24) # something that only looks like a file object, so[](#l1.25) # we have to reach into the innards of the chunk object[](#l1.26)
@@ -422,7 +417,7 @@ class Wave_write: nframes = len(data) // (self._sampwidth * self._nchannels) if self._convert: data = self._convert(data)
if self._sampwidth > 1 and big_endian:[](#l1.31)
if self._sampwidth > 1 and sys.byteorder == 'big':[](#l1.32) import array[](#l1.33) data = array.array(_array_fmts[self._sampwidth], data)[](#l1.34) data.byteswap()[](#l1.35)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -1222,6 +1222,7 @@ Thenault Sylvain Péter Szabó Amir Szekely Arfrever Frehtes Taifersar Arahesis +Hideaki Takahashi Neil Tallim Geoff Talvola Musashi Tamura