From: stevenknight Date: Mon, 2 Mar 2009 23:10:32 +0000 (+0000) Subject: Issue 2360: fix a TypeError from attempts to intern() unicode objects X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e07923636805ea2c2f49236ffeee67ac3e532cda;p=scons.git Issue 2360: fix a TypeError from attempts to intern() unicode objects returned to the ClassicCPPScanner. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4062 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 58972402..49dfcfa6 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index e3fa4edc..518e0ed4 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -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 diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 6863aa14..c0d84b97 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -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))