diff options
author | Zackery Spytz <zspytz@gmail.com> | 2021-05-21 21:02:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-21 21:02:42 (GMT) |
commit | 6cc8ac949907b9a1c0f73709c6978b7a43e634e3 (patch) | |
tree | 1b7090be88bf4924021aa184bfab53d2297d3d06 /Lib/test | |
parent | 498383c019c1209f6fecf8f64ce44fbf437191da (diff) | |
download | cpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.zip cpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.tar.gz cpython-6cc8ac949907b9a1c0f73709c6978b7a43e634e3.tar.bz2 |
bpo-40736: Improve the error message for re.search() TypeError (GH-23312)
Include the invalid type in the error message.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_re.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index e1b2c79..0ed243d 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -2104,6 +2104,12 @@ ELSE {'tag': 'foo', 'text': None}, {'tag': 'foo', 'text': None}]) + def test_bug_40736(self): + with self.assertRaisesRegex(TypeError, "got 'int'"): + re.search("x*", 5) + with self.assertRaisesRegex(TypeError, "got 'type'"): + re.search("x*", type) + class PatternReprTests(unittest.TestCase): def check(self, pattern, expected): |