Issue 2360: fix a TypeError from attempts to intern() unicode objects
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 2 Mar 2009 23:10:32 +0000 (23:10 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 2 Mar 2009 23:10:32 +0000 (23:10 +0000)
returned to the ClassicCPPScanner.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4062 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Scanner/ScannerTests.py
src/engine/SCons/Scanner/__init__.py

index 5897240299610e6c032b7cf92c01bc909b4405ea..49dfcfa6f73b0be9f178b01f3d30bd1822bc16d5 100644 (file)
@@ -17,6 +17,8 @@ RELEASE X.X.X - XXX
 
     - Fix scanning of Unicode files for both UTF-16 endian flavors.
 
+    - Fix a TypeError on #include of file names with Unicode characters.
+
 
 
 RELEASE 1.2.0.d20090223 - Mon, 23 Feb 2009 08:41:06 -0800
index e3fa4edce98aef1b4acafa1ba9c8cc9a06f951be..518e0ed40763f3e0dae587513c992e10aae1d910 100644 (file)
@@ -568,6 +568,17 @@ class ClassicCPPTestCase(unittest.TestCase):
             assert n == 'path/bbb', n
             assert i == 'bbb', i
 
+            # TODO(1.5):  remove when 2.2 is minimal; replace ccc
+            # variable in find_include() call below with in-line u'ccc'.
+            try:
+                ccc = eval("u'ccc'")
+            except SyntaxError:
+                ccc = 'ccc'
+
+            n, i = s.find_include(('<', ccc), 'foo', ('path',))
+            assert n == 'path/ccc', n
+            assert i == 'ccc', i
+
         finally:
             SCons.Node.FS.find_file = save
 
index 6863aa14ce9e6a8d11507c4165a1646470b42659..c0d84b97e85b158f4ca21f077addc1a7a626783c 100644 (file)
@@ -405,7 +405,13 @@ class ClassicCPP(Classic):
 
         n = SCons.Node.FS.find_file(include[1], paths)
 
-        return n, intern(include[1])
+        i = include[1]
+        try:
+            i = intern(i)
+        except TypeError:
+            # Probably a unicode object; just don't worry about intern().
+            pass
+        return n, i
 
     def sort_key(self, include):
         return SCons.Node.FS._my_normcase(string.join(include))