diff options
author | Brett Cannon <bcannon@gmail.com> | 2007-06-03 23:13:41 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2007-06-03 23:13:41 (GMT) |
commit | f7188cefb31371394201ec7f1fd321936f5b37a1 (patch) | |
tree | 3868f9fb097070f6eb3f20bdb265b1cd92cdcb1b /Lib/test/test_strptime.py | |
parent | 994ebed50cb6dbdf96e63ed9f2c0697f2094f262 (diff) | |
download | cpython-f7188cefb31371394201ec7f1fd321936f5b37a1.zip cpython-f7188cefb31371394201ec7f1fd321936f5b37a1.tar.gz cpython-f7188cefb31371394201ec7f1fd321936f5b37a1.tar.bz2 |
Make _strptime.TimeRE().pattern() use ``\s+`` for matching whitespace instead
of ``\s*``. This prevents patterns from "stealing" bits from other patterns in
order to make a match work.
Closes bug #1730389. Will be backported.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r-- | Lib/test/test_strptime.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index f474752..92c722a 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -190,6 +190,15 @@ class TimeRETests(unittest.TestCase): "locale data that contains regex metacharacters is not" " properly escaped") + def test_whitespace_substitution(self): + # When pattern contains whitespace, make sure it is taken into account + # so as to not allow to subpatterns to end up next to each other and + # "steal" characters from each other. + pattern = self.time_re.pattern('%j %H') + self.failUnless(not re.match(pattern, "180")) + self.failUnless(re.match(pattern, "18 0")) + + class StrptimeTests(unittest.TestCase): """Tests for _strptime.strptime.""" |