[Python-checkins] python/dist/src/Lib/test test_re.py,1.44,1.45

jvr@users.sourceforge.net jvr@users.sourceforge.net
Wed, 02 Jul 2003 13:03:06 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv23477/Lib/test

Modified Files:
	test_re.py 
Log Message:
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.


Index: test_re.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** test_re.py	2 Jul 2003 14:36:59 -0000	1.44
--- test_re.py	2 Jul 2003 20:03:04 -0000	1.45
***************
*** 475,478 ****
--- 475,488 ----
                           ('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")