[Python-bugs-list] [ python-Bugs-764548 ] SRE doesn't use isinstance

SourceForge.net noreply@sourceforge.net
Wed, 02 Jul 2003 07:54:09 -0700


Bugs item #764548, was opened at 2003-07-02 14:20
Message generated for change (Comment added) made by jvr
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=764548&group_id=5470

Category: Regular Expressions
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ronald Oussoren (ronaldoussoren)
Assigned to: Fredrik Lundh (effbot)
Summary: SRE doesn't use isinstance

Initial Comment:

The following code fails with a TypeError:

#--------------------------------
import re

class MyUnicode(unicode):
   pass

val = MyUnicode("foobar")

r = re.compile(val)
#--------------------------------

This is caused by a check in sre.py: it checks if the
type of the pattern is str or unicode, instead of
testing if the value is an instance of those types.

This is not a completely theoretical problem: PyObjC
uses a subclass of unicode to represent Objective-C
strings.






----------------------------------------------------------------------

>Comment By: Just van Rossum (jvr)
Date: 2003-07-02 16:54

Message:
Logged In: YES 
user_id=92689

Here's a patch that should fix the problem, while remaining 
compatible with 1.5.2. Fredrik, please assign to me if you think 
the patch is ok. Preferably before 2.3 final is out ;-)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=764548&group_id=5470