]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use eval instead of codecs.lookup to trigger UTF-8 generation.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 28 Sep 2011 07:15:11 +0000 (09:15 +0200)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 28 Sep 2011 07:15:11 +0000 (09:15 +0200)
Lib/test/test_sys.py

index ed96d76c4f81434c89bac0a126a06796bfcdc012..9554eefcb7f62af1bc48fee2b8d63f85a7f13ac7 100644 (file)
@@ -857,12 +857,10 @@ class SizeofTest(unittest.TestCase):
         s = chr(0x4000)   # 4 bytes canonical representation
         check(s, size(compactfields) + 4)
         try:
-            # FIXME: codecs.lookup(str) calls encoding.search_function() which
-            # calls __import__ using str in the module name. __import__ encodes
-            # the module name to the file system encoding (which is the locale
-            # encoding), so test_sys fails if the locale encoding is not UTF-8.
-            codecs.lookup(s) # produces 4 bytes UTF-8
-        except LookupError:
+            # eval() will trigger the generation of the UTF-8 representation
+            # as a side effect
+            eval(s)
+        except NameError:
             check(s, size(compactfields) + 4 + 4)
         # TODO: add check that forces the presence of wchar_t representation
         # TODO: add check that forces layout of unicodefields