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

SourceForge.net noreply@sourceforge.net
Wed, 02 Jul 2003 05:20:57 -0700


Bugs item #764548, was opened at 2003-07-02 14:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
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.






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

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