[Python-bugs-list] [ python-Bugs-795379 ] Must import sre_constants to catch re.compile errors.

SourceForge.net noreply at sourceforge.net
Tue Aug 26 08:19:28 EDT 2003


Bugs item #795379, was opened at 2003-08-26 10:19
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=795379&group_id=5470

Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Fredrik Lundh (effbot)
Summary: Must import sre_constants to catch re.compile errors.

Initial Comment:
It's a bit frustrating not to be able to catch 
exceptions raised by re.compile with just the re 
module.  The fact that sre_constants.error is 
raised is a bit too much implementation showing 
through, IMO. 
 
Anyway, I suggest a exception be added to the re 
module that subclasses sre_constants.error for 
backwards compatibility.  So users can simply 
import re and catch re.error instead of having to 
import re and sre_constants and catch 
sre_constants.error. 

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

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



More information about the Python-bugs-list mailing list