diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-10 12:38:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-10 12:38:16 (GMT) |
commit | b99c132bd9030883f7a3482feb5e2b38c02f4188 (patch) | |
tree | cf3a19d8695a6b2355c7db85c0e619fade46e46c /Lib/test/test_re.py | |
parent | ce40e1a081749387aa95c5299694961762745947 (diff) | |
download | cpython-b99c132bd9030883f7a3482feb5e2b38c02f4188.zip cpython-b99c132bd9030883f7a3482feb5e2b38c02f4188.tar.gz cpython-b99c132bd9030883f7a3482feb5e2b38c02f4188.tar.bz2 |
Fixed AttributeError when the regular expression starts from illegal escape.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r-- | Lib/test/test_re.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 2b72c0f..b30abad 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -531,6 +531,20 @@ class ReTests(unittest.TestCase): self.assertEqual(re.search(br"\d\D\w\W\s\S", b"1aa! a", re.LOCALE).group(0), b"1aa! a") + def test_other_escapes(self): + self.assertRaises(re.error, re.compile, "\\") + self.assertEqual(re.match(r"\(", '(').group(), '(') + self.assertIsNone(re.match(r"\(", ')')) + self.assertEqual(re.match(r"\\", '\\').group(), '\\') + self.assertEqual(re.match(r"\y", 'y').group(), 'y') + self.assertIsNone(re.match(r"\y", 'z')) + self.assertEqual(re.match(r"[\]]", ']').group(), ']') + self.assertIsNone(re.match(r"[\]]", '[')) + self.assertEqual(re.match(r"[a\-c]", '-').group(), '-') + self.assertIsNone(re.match(r"[a\-c]", 'b')) + self.assertEqual(re.match(r"[\^a]+", 'a^').group(), 'a^') + self.assertIsNone(re.match(r"[\^a]+", 'b')) + def test_string_boundaries(self): # See http://bugs.python.org/issue10713 self.assertEqual(re.search(r"\b(abc)\b", "abc").group(1), |