File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ def pattern(self, format):
249249 processed_format = ''
250250 # The sub() call escapes all characters that might be misconstrued
251251 # as regex syntax.
252- regex_chars = re_compile (r"([\\.^$*+?{}\[\]|])" )
252+ regex_chars = re_compile (r"([\\.^$*+?\(\) {}\[\]|])" )
253253 format = regex_chars .sub (r"\\\1" , format )
254254 whitespace_replacement = re_compile ('\s+' )
255255 format = whitespace_replacement .sub ('\s*' , format )
Original file line number Diff line number Diff line change @@ -333,6 +333,15 @@ def test_defaults(self):
333333 "Default values for strptime() are incorrect;"
334334 " %s != %s" % (strp_output , defaults ))
335335
336+ def test_escaping (self ):
337+ # Make sure all characters that have regex significance are escaped.
338+ # Parentheses are in a purposeful order; will cause an error of
339+ # unbalanced parentheses when the regex is compiled if they are not
340+ # escaped.
341+ # Test instigated by bug #796149 .
342+ need_escaping = ".^$*+?{}\[]|)("
343+ self .failUnless (_strptime .strptime (need_escaping , need_escaping ))
344+
336345class Strptime12AMPMTests (unittest .TestCase ):
337346 """Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
338347
You can’t perform that action at this time.
0 commit comments