Repository navigation
better name for re.error Exception class. #83162
Description
Activity
better error/exception name for re.compile error.
Currently the error raise by re.compile when it fails to compile is
errordefined in sre_constants.py:class error(Exception): """Exception raised for invalid regular expressions.This is quite disturbing as most exception start with an uppercase and have a tiny bit more descriptive name.
Would it be possible to have it renamed as something more explicit like
ReCompileError, and still keeping the potentialerroralias as deprecated ?It is common practice that the module specific exception is called just "error". There is nothing wrong with this.
I do not see a need to introduce a different alias.
See also the discussion about renaming json.loads(): https://mail.python.org/archives/list/python-ideas@python.org/thread/EJTIVQ2ZFSVHALTLRGFCOMOYGZYMKGQU/
Most of the module specific classes are
Error, noterror, at least with an uppercase E you know it's a class.if a novice sees :
error: missing ), unterminated subpattern at position 0
It will be relatively tough or them to figure out that
erroris the type of the exception.Also it's not because something works that you can't improve it ...
Since it affects more than one module I suggest to discuss the idea about renaming exceptions of the Python-Ideas maillist first. Until different decision be made I am closing. Personally I think this is a duplicate of just discussed and rejected idea.
Thanks for the advice I've done that !
Have a good day.
Reopened after discussing on Python-ideas: https://mail.python.org/archives/list/python-ideas@python.org/thread/64NHNY6RD4HQWBSBV6J7XIN7UAHNTQBR/.
- added3.9 (EOL)end of lifeend of lifetype-featureA feature request or enhancementA feature request or enhancement
on Dec 7, 2019 32 remaining items
- added a commit that references this issue
on Jun 7, 2023 - added a commit that references this issue
on Dec 11, 2023 I merged the near-minimal PR with re.error 'updated' only in idlelib. I will do adjusted backports of the idlelib changes to keep the main bodies of its files in sync and then close.
Reacted by achhina
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:
bugs.python.org fields:
Linked PRs