You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Must import sre_constants to catch re.compile errors. #39129
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.
Activity
jemfinch commentedon Aug 26, 2003
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.
effbot commentedon Aug 26, 2003
Logged In: YES
user_id=38376
afaik, the following has worked since 1.6, and still works
in 2.3:
what Python version are you using?
jemfinch commentedon Aug 26, 2003
Logged In: YES
user_id=99508
Oops, my fault.