summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2003-07-02 20:03:04 (GMT)
committerJust van Rossum <just@letterror.com>2003-07-02 20:03:04 (GMT)
commit12723baceab61f8812d68575c962696cc4e77fa1 (patch)
tree6ca9be800da1a9e5f3900302f5e82b883edb0231 /Lib/test/test_re.py
parent5e4e39f12a9ec71650e9d8296b1fb69831c808de (diff)
downloadcpython-12723baceab61f8812d68575c962696cc4e77fa1.zip
cpython-12723baceab61f8812d68575c962696cc4e77fa1.tar.gz
cpython-12723baceab61f8812d68575c962696cc4e77fa1.tar.bz2
Fix and test for bug #764548:
Use isinstance() instead of comparing types directly, to enable subclasses of str and unicode to be used as patterns. Blessed by /F.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 50d7ed4..f724806 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -474,6 +474,16 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.match('(a)((?!(b)*))*', 'abb').groups(),
('a', None, None))
+ def test_bug_764548(self):
+ # bug 764548, re.compile() barfs on str/unicode subclasses
+ try:
+ unicode
+ except NameError:
+ return # no problem if we have no unicode
+ class my_unicode(unicode): pass
+ pat = re.compile(my_unicode("abc"))
+ self.assertEqual(pat.match("xyz"), None)
+
def test_finditer(self):
iter = re.finditer(r":+", "a:b::c:::d")
self.assertEqual([item.group(0) for item in iter],