]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch to make _codecs a builtin module. This is necessary since
authorMarc-André Lemburg <mal@egenix.com>
Thu, 12 Dec 2002 17:37:50 +0000 (17:37 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Thu, 12 Dec 2002 17:37:50 +0000 (17:37 +0000)
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

Lib/codecs.py
Modules/Setup.config.in
Modules/Setup.dist
setup.py

index e7967d8744c2802bc769f6d981245f4abb46d83f..b377979e2ca582be4fae8d6e509da771865dea2b 100644 (file)
@@ -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
index 14ad6bb2671212f85c43777309561deabac4cb43..fed62e9d8ef610449afaae503048a864f3f3370d 100644 (file)
@@ -10,4 +10,4 @@
 @USE_SIGNAL_MODULE@signal signalmodule.c
 
 # The rest of the modules previously listed in this file are built
-# by the setup.py script in Python 2.1.
+# by the setup.py script in Python 2.1 and later.
index 7b91185c88672a9c30059bdefb042987c269866b..6df361ddf9503787dab48e79a842e4121e01233f 100644 (file)
@@ -111,6 +111,7 @@ PYTHONPATH=$(COREPYTHONPATH)
 posix posixmodule.c            # posix (UNIX) system calls
 errno errnomodule.c            # posix (UNIX) errno values
 _sre _sre.c                    # Fredrik Lundh's new regular expressions
+_codecs _codecsmodule.c                # access to the builtin codecs and codec registry
 
 # The rest of the modules listed in this file are all commented out by
 # default.  Usually they can be detected and built as dynamically
@@ -163,7 +164,6 @@ GLHACK=-Dclear=__GLclear
 #time timemodule.c # -lm # time operations and variables
 #operator operator.c   # operator.add() and similar goodies
 #_weakref _weakref.c   # basic weak reference support
-#_codecs _codecsmodule.c       # access to the builtin codecs and codec registry
 #_testcapi _testcapimodule.c    # Python C API test module
 
 #unicodedata unicodedata.c    # static Unicode character database
index ff7318e0ad5ad48b6c66b348c82bc3f60ed5b6c7..2827af752bb3fd5bc727fbb3b96bd3ee411a1ae2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -313,8 +313,6 @@ class PyBuildExt(build_ext):
                                libraries=math_libs) )
         # operator.add() and similar goodies
         exts.append( Extension('operator', ['operator.c']) )
-        # access to the builtin codecs and codec registry
-        exts.append( Extension('_codecs', ['_codecsmodule.c']) )
         # Python C API test module
         exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
         # static Unicode character database