mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #22493: Warning message emitted by using inline flags in the middle of
regular expression now contains a (truncated) regex pattern. Patch by Tim Graham.
This commit is contained in:
parent
8761e59f36
commit
abf275af58
3 changed files with 26 additions and 4 deletions
|
@ -1323,8 +1323,21 @@ class ReTests(unittest.TestCase):
|
|||
self.assertTrue(re.match('(?ixu) ' + upper_char, lower_char))
|
||||
self.assertTrue(re.match('(?ixu) ' + lower_char, upper_char))
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertTrue(re.match(upper_char + '(?i)', lower_char))
|
||||
p = upper_char + '(?i)'
|
||||
with self.assertWarns(DeprecationWarning) as warns:
|
||||
self.assertTrue(re.match(p, lower_char))
|
||||
self.assertEqual(
|
||||
str(warns.warnings[0].message),
|
||||
'Flags not at the start of the expression %s' % p
|
||||
)
|
||||
|
||||
p = upper_char + '(?i)%s' % ('.?' * 100)
|
||||
with self.assertWarns(DeprecationWarning) as warns:
|
||||
self.assertTrue(re.match(p, lower_char))
|
||||
self.assertEqual(
|
||||
str(warns.warnings[0].message),
|
||||
'Flags not at the start of the expression %s (truncated)' % p[:20]
|
||||
)
|
||||
|
||||
def test_dollar_matches_twice(self):
|
||||
"$ matches the end of string, and just before the terminating \n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue