[issue34681] Incorrect class name Pattern in sre_parse.py

Serhiy Storchaka report at bugs.python.org
Fri Sep 14 12:22:32 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

In 8a3ebf8ca87a7d2989148d7c218974ab4235ca5d, with synchronizing regex engine with SRE 0.9.6, the class State in sre_parse.py was renamed to Pattern and the following comment was added: "master pattern object.  keeps track of global attributes".

This name is incorrect and misleading. This class doesn't represents a pattern in any sense. It just keeps global flags and groups information for parser. There is a class SupParser in sre_parse.py that represents a pattern or its part in intermediate representation, and there is a class Pattern defined in sre.c and exposed publicly, that represents a compiled pattern.

The proposed PR renames Pattern back to State and renames attribute, parameter and variable names for referring to objects of this class from pattern to state. All this is an internal API, but since there may be a third-party that uses it, it is for developer version only.

----------
components: Library (Lib), Regular Expressions
messages: 325359
nosy: effbot, ezio.melotti, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Incorrect class name Pattern in sre_parse.py
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34681>
_______________________________________


More information about the Python-bugs-list mailing list