Issue #17998: Fix an internal error in regular expression engine.
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 18a81a2..2be5f5c 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -897,6 +897,16 @@
         with self.assertRaisesRegexp(sre_constants.error, '\?foo'):
             re.compile('(?P<?foo>)')
 
+    def test_issue17998(self):
+        for reps in '*', '+', '?', '{1}':
+            for mod in '', '?':
+                pattern = '.' + reps + mod + 'yz'
+                self.assertEqual(re.compile(pattern, re.S).findall('xyz'),
+                                 ['xyz'], msg=pattern)
+                pattern = pattern.encode()
+                self.assertEqual(re.compile(pattern, re.S).findall(b'xyz'),
+                                 [b'xyz'], msg=pattern)
+
 
 def run_re_tests():
     from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR