Locale data that contains regex metacharacters are now properly escaped.

Closes bug #1039270.
This commit is contained in:
Brett Cannon 2004-10-06 02:11:37 +00:00
parent 579b3e2416
commit 4f35c71543
3 changed files with 22 additions and 2 deletions

View file

@ -176,6 +176,19 @@ class TimeRETests(unittest.TestCase):
found = compiled_re.match("\w+ 10")
self.failUnless(found, "Escaping failed of format '\w+ 10'")
def test_locale_data_w_regex_metacharacters(self):
# Check that if locale data contains regex metacharacters they are
# escaped properly.
# Discovered by bug #1039270 .
locale_time = _strptime.LocaleTime()
locale_time.timezone = (frozenset(("utc", "gmt",
"Tokyo (standard time)")),
frozenset("Tokyo (daylight time)"))
time_re = _strptime.TimeRE(locale_time)
self.failUnless(time_re.compile("%Z").match("Tokyo (standard time)"),
"locale data that contains regex metacharacters is not"
" properly escaped")
class StrptimeTests(unittest.TestCase):
"""Tests for _strptime.strptime."""