summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2002-12-12 17:37:50 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2002-12-12 17:37:50 (GMT)
commitb28de0d79f6f1bfc7e395a1945167a87bfe95356 (patch)
tree2e4771db60c9a7d0a96b46144944565f30b728ee /Lib
parentb69bb3d0193ea4871d2480a58e48224cb728e4d9 (diff)
downloadcpython-b28de0d79f6f1bfc7e395a1945167a87bfe95356.zip
cpython-b28de0d79f6f1bfc7e395a1945167a87bfe95356.tar.gz
cpython-b28de0d79f6f1bfc7e395a1945167a87bfe95356.tar.bz2
Patch to make _codecs a builtin module. This is necessary since
Python 2.3 will support source code encodings which rely on the builtin codecs being available to the parser. Remove struct dependency from codecs.py
Diffstat (limited to 'Lib')
-rw-r--r--Lib/codecs.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py
index e7967d8..b377979 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -7,7 +7,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""#"
-import struct, __builtin__
+import __builtin__, sys
### Registry and builtin stateless codec functions
@@ -48,11 +48,21 @@ BOM_UTF32_LE = '\xff\xfe\x00\x00'
# UTF-32, big endian
BOM_UTF32_BE = '\x00\x00\xfe\xff'
-# UTF-16, native endianness
-BOM = BOM_UTF16 = struct.pack('=H', 0xFEFF)
+if sys.byteorder == 'little':
-# UTF-32, native endianness
-BOM_UTF32 = struct.pack('=L', 0x0000FEFF)
+ # UTF-16, native endianness
+ BOM = BOM_UTF16 = BOM_UTF16_LE
+
+ # UTF-32, native endianness
+ BOM_UTF32 = BOM_UTF32_LE
+
+else:
+
+ # UTF-16, native endianness
+ BOM = BOM_UTF16 = BOM_UTF16_BE
+
+ # UTF-32, native endianness
+ BOM_UTF32 = BOM_UTF32_BE
# Old broken names (don't use in new code)
BOM32_LE = BOM_UTF16_LE