From 1781d55eb34f94029e50970232635fc5082378cb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 21 Jan 2022 03:30:20 +0100 Subject: bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736) The _curses module now creates its ncurses_version type as a heap type using PyStructSequence_NewType(), rather than using a static type. * Move _PyStructSequence_FiniType() definition to pycore_structseq.h. * test.pythoninfo: log curses.ncurses_version. --- Objects/floatobject.c | 1 + Objects/longobject.c | 1 + Objects/structseq.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'Objects') diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 88f25d6b8c..68be7acaa2 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -12,6 +12,7 @@ #include "pycore_object.h" // _PyObject_Init() #include "pycore_pymath.h" // _Py_ADJUST_ERANGE1() #include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_structseq.h" // _PyStructSequence_FiniType() #include #include diff --git a/Objects/longobject.c b/Objects/longobject.c index 5aa53dd91c..7721f40adb 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -9,6 +9,7 @@ #include "pycore_object.h" // _PyObject_InitVar() #include "pycore_pystate.h" // _Py_IsMainInterpreter() #include "pycore_runtime.h" // _PY_NSMALLPOSINTS +#include "pycore_structseq.h" // _PyStructSequence_FiniType() #include #include diff --git a/Objects/structseq.c b/Objects/structseq.c index f8bf9477f2..dfefae8928 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -563,7 +563,7 @@ _PyStructSequence_FiniType(PyTypeObject *type) PyTypeObject * -PyStructSequence_NewType(PyStructSequence_Desc *desc) +_PyStructSequence_NewType(PyStructSequence_Desc *desc, unsigned long tp_flags) { PyMemberDef *members; PyTypeObject *type; @@ -596,7 +596,7 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc) spec.name = desc->name; spec.basicsize = sizeof(PyStructSequence) - sizeof(PyObject *); spec.itemsize = sizeof(PyObject *); - spec.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC; + spec.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | tp_flags; spec.slots = slots; type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type); @@ -615,6 +615,13 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc) } +PyTypeObject * +PyStructSequence_NewType(PyStructSequence_Desc *desc) +{ + return _PyStructSequence_NewType(desc, 0); +} + + /* runtime lifecycle */ PyStatus _PyStructSequence_InitState(PyInterpreterState *interp) -- cgit v1.2.1