[Python-checkins] cpython: Issue #18084: Use sys.byteorder in wave.py.

serhiy.storchaka python-checkins at python.org
Wed May 29 22:45:22 CEST 2013


http://hg.python.org/cpython/rev/ccffce2dde49
changeset:   83983:ccffce2dde49
parent:      83977:bcaaaa00425b
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Wed May 29 23:38:00 2013 +0300
summary:
  Issue #18084: Use sys.byteorder in wave.py.
Original patch by Hideaki Takahashi.

files:
  Lib/wave.py |  11 +++--------
  Misc/ACKS   |   1 +
  2 files changed, 4 insertions(+), 8 deletions(-)


diff --git a/Lib/wave.py b/Lib/wave.py
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -82,13 +82,8 @@
 
 _array_fmts = None, 'b', 'h', None, 'l'
 
-# 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
 
@@ -235,7 +230,7 @@
             self._data_seek_needed = 0
         if nframes == 0:
             return b''
-        if self._sampwidth > 1 and big_endian:
+        if self._sampwidth > 1 and sys.byteorder == 'big':
             # unfortunately the fromfile() method does not take
             # something that only looks like a file object, so
             # we have to reach into the innards of the chunk object
@@ -422,7 +417,7 @@
         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)
             data.byteswap()
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1222,6 +1222,7 @@
 Péter Szabó
 Amir Szekely
 Arfrever Frehtes Taifersar Arahesis
+Hideaki Takahashi
 Neil Tallim
 Geoff Talvola
 Musashi Tamura

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list