[issue28765] _sre.compile(): be more strict on types of indexgroup and groupindex

Serhiy Storchaka report at bugs.python.org
Fri Dec 16 16:30:51 EST 2016


Serhiy Storchaka added the comment:

> Hum, sorry, I don't understand what is the issue with adding a few addition checks in the constructor? Is it a matter of speed?

It is a matter of readability and maintainability. Additional checks adds 21 lines of the code, and they hardcode error messages. I copied currently produced error messages, with hardcoded function name and argument numbers. Changes in PyArg* functions or Argument Clinic that could globally enhance error messages would not affect these ones. Changing the function name or the arguments order would need to change error messages.

> I don't understand your "unpythonic" argument.

Sorry, I used bad wording. I meant that this doesn't follow the practice of CPython code. Builtins and extensions often ignore subclassing and use concrete API for simplicity and speed. Especially in internal functions. The interface of _sre.compile() already is made less general, it no longer works with general sequences and mappings. Ignoring subclassing don't make it much worse.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28765>
_______________________________________


More information about the Python-bugs-list mailing list