Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must import sre_constants to catch re.compile errors. #39129

Closed
jemfinch mannequin opened this issue Aug 26, 2003 · 3 comments
Closed

Must import sre_constants to catch re.compile errors. #39129

jemfinch mannequin opened this issue Aug 26, 2003 · 3 comments

Comments

@jemfinch
Copy link
Mannequin

jemfinch mannequin commented Aug 26, 2003

BPO 795379

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2003-08-26.17:10:05.000>
created_at = <Date 2003-08-26.14:19:27.000>
labels = ['expert-regex']
title = 'Must import sre_constants to catch re.compile errors.'
updated_at = <Date 2003-08-26.17:10:05.000>
user = 'https://bugs.python.org/jemfinch'

bugs.python.org fields:

activity = <Date 2003-08-26.17:10:05.000>
actor = 'jemfinch'
assignee = 'effbot'
closed = True
closed_date = None
closer = None
components = ['Regular Expressions']
creation = <Date 2003-08-26.14:19:27.000>
creator = 'jemfinch'
dependencies = []
files = []
hgrepos = []
issue_num = 795379
keywords = []
message_count = 3.0
messages = ['17954', '17955', '17956']
nosy_count = 2.0
nosy_names = ['effbot', 'jemfinch']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue795379'
versions = []

@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented 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.

@jemfinch jemfinch mannequin closed this as completed Aug 26, 2003
@jemfinch jemfinch mannequin assigned effbot Aug 26, 2003
@jemfinch jemfinch mannequin added the topic-regex label Aug 26, 2003
@jemfinch jemfinch mannequin closed this as completed Aug 26, 2003
@jemfinch jemfinch mannequin assigned effbot Aug 26, 2003
@jemfinch jemfinch mannequin added the topic-regex label Aug 26, 2003
@effbot
Copy link
Mannequin

effbot mannequin commented Aug 26, 2003

Logged In: YES
user_id=38376

afaik, the following has worked since 1.6, and still works
in 2.3:

>>> import re
>>> try:
...     re.compile("[]*")
... except re.error:
...     print "oops"
...
oops

what Python version are you using?

@jemfinch
Copy link
Mannequin Author

jemfinch mannequin commented Aug 26, 2003

Logged In: YES
user_id=99508

Oops, my fault.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants