diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-11-21 22:58:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-11-21 22:58:57 (GMT) |
commit | 6f7fad16bc2799c3db0e96d4c4ad35676d59251c (patch) | |
tree | 13da6f70da9f002797bebe50f00fe1943de6ebb8 /Lib | |
parent | 4a98a2a57b85447e1a7b1c89920d6eb476027fd0 (diff) | |
download | cpython-6f7fad16bc2799c3db0e96d4c4ad35676d59251c.zip cpython-6f7fad16bc2799c3db0e96d4c4ad35676d59251c.tar.gz cpython-6f7fad16bc2799c3db0e96d4c4ad35676d59251c.tar.bz2 |
Merged revisions 67320 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67320 | benjamin.peterson | 2008-11-21 16:27:24 -0600 (Fri, 21 Nov 2008) | 4 lines
don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_unicodedata.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index 6edda3a..2dfa807 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -4,9 +4,13 @@ (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. -"""#" -import unittest, test.support +""" + +import sys +import unittest import hashlib +import subprocess +import test.support encoding = 'utf-8' @@ -197,6 +201,25 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest): class UnicodeMiscTest(UnicodeDatabaseTest): + def test_failed_import_during_compiling(self): + # Issue 4367 + # Decoding \N escapes requires the unicodedata module. If it can't be + # imported, we shouldn't segfault. + + # This program should raise a SyntaxError in the eval. + code = "import sys;" \ + "sys.modules['unicodedata'] = None;" \ + """eval("'\\\\N{SOFT HYPHEN}'")""" + args = [sys.executable, "-c", code] + # We use a subprocess because the unicodedata module may already have + # been loaded in this process. + popen = subprocess.Popen(args, stderr=subprocess.PIPE) + popen.wait() + self.assertEqual(popen.returncode, 1) + error = "SyntaxError: (unicode error) \\N escapes not supported " \ + "(can't load unicodedata module)" + self.assertTrue(error in popen.stderr.read().decode("ascii")) + def test_decimal_numeric_consistent(self): # Test that decimal and numeric are consistent, # i.e. if a character has a decimal value, |