Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-1635741: Convert _sre types to heap types and establish module state (PEP 384) #23393

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

Merged
merged 15 commits into from
Nov 20, 2020
Merged
Prev Previous commit
Next Next commit
Address Heimes' review: Drop using _PyType_GetModuleByDef
  • Loading branch information
Erlend E. Aasland committed Nov 19, 2020
commit bdd133884d3d2be0b99a08db57ca6c6e21cfea74
12 changes: 5 additions & 7 deletions 12 Modules/_sre.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ get_sre_module_state(PyObject *m)
}

static struct PyModuleDef sremodule;
#define get_sre_module_state_by_type(tp) \
(get_sre_module_state(_PyType_GetModuleByDef(tp, &sremodule)))
#define get_sre_module_state_by_class(cls) \
(get_sre_module_state(PyType_GetModule(cls)))

Expand All @@ -275,11 +273,11 @@ static PyObject *pattern_scanner(_sremodulestate *, PatternObject *, PyObject *,

/*[clinic input]
module _sre
class _sre.SRE_Pattern "PatternObject *" "get_sre_module_state_by_type(tp)->Pattern_Type"
class _sre.SRE_Match "MatchObject *" "get_sre_module_state_by_type(tp)->Match_Type"
class _sre.SRE_Scanner "ScannerObject *" "get_sre_module_state_by_type(tp)->Scanner_Type"
class _sre.SRE_Pattern "PatternObject *" "get_sre_module_state_by_class(tp)->Pattern_Type"
class _sre.SRE_Match "MatchObject *" "get_sre_module_state_by_class(tp)->Match_Type"
class _sre.SRE_Scanner "ScannerObject *" "get_sre_module_state_by_class(tp)->Scanner_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=8b48770d8db721b4]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=fe2966e32b66a231]*/

/*[clinic input]
_sre.getcodesize -> int
Expand Down Expand Up @@ -2593,7 +2591,7 @@ static PyObject*
pattern_richcompare(PyObject *lefto, PyObject *righto, int op)
{
PyTypeObject *tp = Py_TYPE(lefto);
_sremodulestate *module_state = get_sre_module_state_by_type(tp);
_sremodulestate *module_state = get_sre_module_state_by_class(tp);
PatternObject *left, *right;
int cmp;

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.