Issue 2276: Fix use of codecs module in pre-2.3 Python versions.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 20 Dec 2008 14:01:33 +0000 (14:01 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 20 Dec 2008 14:01:33 +0000 (14:01 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@3836 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py

index bdc1bfd2cc2d1aa40b2a117285b04464976c3683..4e89e8d40eea325fced1ac1baf505882fc276c93 100644 (file)
@@ -51,6 +51,19 @@ try:
     import codecs
 except ImportError:
     pass
+else:
+    # TODO(2.2):  Remove when 2.3 becomes the minimal supported version.
+    try:
+        codecs.BOM_UTF8
+    except AttributeError:
+        codecs.BOM_UTF8 = '\xef\xbb\xbf'
+    try:
+        codecs.BOM_UTF16
+    except AttributeError:
+        if sys.byteorder == 'little':
+            codecs.BOM_UTF16 = '\xff\xfe'
+        else:
+            codecs.BOM_UTF16 = '\xfe\xff'
 
 import SCons.Action
 from SCons.Debug import logInstanceCreation