mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Make sure parentheses are escaped when used in the format string.
Closes bug #796149 . Will be backported.
This commit is contained in:
parent
6676f6edc1
commit
953c6f508b
2 changed files with 10 additions and 1 deletions
|
@ -333,6 +333,15 @@ class StrptimeTests(unittest.TestCase):
|
|||
"Default values for strptime() are incorrect;"
|
||||
" %s != %s" % (strp_output, defaults))
|
||||
|
||||
def test_escaping(self):
|
||||
# Make sure all characters that have regex significance are escaped.
|
||||
# Parentheses are in a purposeful order; will cause an error of
|
||||
# unbalanced parentheses when the regex is compiled if they are not
|
||||
# escaped.
|
||||
# Test instigated by bug #796149 .
|
||||
need_escaping = ".^$*+?{}\[]|)("
|
||||
self.failUnless(_strptime.strptime(need_escaping, need_escaping))
|
||||
|
||||
class Strptime12AMPMTests(unittest.TestCase):
|
||||
"""Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue