bpo-30397: Add re.Pattern and re.Match. (#1646)
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 91a0319..437fdd2 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -24,8 +24,6 @@
from optparse import _match_abbrev
from optparse import _parse_num
-retype = type(re.compile(''))
-
class InterceptedError(Exception):
def __init__(self,
error_message=None,
@@ -107,7 +105,7 @@
func(*args, **kwargs)
except expected_exception as err:
actual_message = str(err)
- if isinstance(expected_message, retype):
+ if isinstance(expected_message, re.Pattern):
self.assertTrue(expected_message.search(actual_message),
"""\
expected exception message pattern:
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index e9c07a0..9cb426a 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1596,9 +1596,9 @@
def test_compile(self):
# Test return value when given string and pattern as parameter
pattern = re.compile('random pattern')
- self.assertIsInstance(pattern, re._pattern_type)
+ self.assertIsInstance(pattern, re.Pattern)
same_pattern = re.compile(pattern)
- self.assertIsInstance(same_pattern, re._pattern_type)
+ self.assertIsInstance(same_pattern, re.Pattern)
self.assertIs(same_pattern, pattern)
# Test behaviour when not given a string or pattern as parameter
self.assertRaises(TypeError, re.compile, 0)