/* other API */
+PyAPI_FUNC(PyTypeObject *) _PyStructSequence_NewType(
+ PyStructSequence_Desc *desc,
+ unsigned long tp_flags);
+
PyAPI_FUNC(int) _PyStructSequence_InitType(
PyTypeObject *type,
PyStructSequence_Desc *desc,
unsigned long tp_flags);
+extern void _PyStructSequence_FiniType(PyTypeObject *type);
#ifdef __cplusplus
}
PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type,
PyStructSequence_Desc *desc);
#endif
-#ifdef Py_BUILD_CORE
-PyAPI_FUNC(void) _PyStructSequence_FiniType(PyTypeObject *type);
-#endif
PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
info_add('time.get_clock_info(%s)' % clock, clock_info)
+def collect_curses(info_add):
+ try:
+ import curses
+ except ImportError:
+ return
+
+ copy_attr(info_add, 'curses.ncurses_version', curses, 'ncurses_version')
+
+
def collect_datetime(info_add):
try:
import datetime
collect_builtins,
collect_cc,
+ collect_curses,
collect_datetime,
collect_decimal,
collect_expat,
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
-#include "pycore_structseq.h" // PyStructSequence_InitType()
+#include "pycore_structseq.h" // _PyStructSequence_NewType()
#ifdef __hpux
#define STRICT_SYSV_CURSES
\n\
Ncurses version information as a named tuple.");
-static PyTypeObject NcursesVersionType;
-
static PyStructSequence_Field ncurses_version_fields[] = {
{"major", "Major release number"},
{"minor", "Minor release number"},
};
static PyObject *
-make_ncurses_version(void)
+make_ncurses_version(PyTypeObject *type)
{
PyObject *ncurses_version;
int pos = 0;
- ncurses_version = PyStructSequence_New(&NcursesVersionType);
+ ncurses_version = PyStructSequence_New(type);
if (ncurses_version == NULL) {
return NULL;
}
#ifdef NCURSES_VERSION
/* ncurses_version */
- if (NcursesVersionType.tp_name == NULL) {
- if (_PyStructSequence_InitType(&NcursesVersionType,
- &ncurses_version_desc,
- Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
- return NULL;
- }
+ PyTypeObject *version_type;
+ version_type = _PyStructSequence_NewType(&ncurses_version_desc,
+ Py_TPFLAGS_DISALLOW_INSTANTIATION);
+ if (version_type == NULL) {
+ return NULL;
}
- v = make_ncurses_version();
+ v = make_ncurses_version(version_type);
+ Py_DECREF(version_type);
if (v == NULL) {
return NULL;
}
#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 <ctype.h>
#include <float.h>
#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 <ctype.h>
#include <float.h>
PyTypeObject *
-PyStructSequence_NewType(PyStructSequence_Desc *desc)
+_PyStructSequence_NewType(PyStructSequence_Desc *desc, unsigned long tp_flags)
{
PyMemberDef *members;
PyTypeObject *type;
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);
}
+PyTypeObject *
+PyStructSequence_NewType(PyStructSequence_Desc *desc)
+{
+ return _PyStructSequence_NewType(desc, 0);
+}
+
+
/* runtime lifecycle */
PyStatus _PyStructSequence_InitState(PyInterpreterState *interp)
#include "pycore_initconfig.h" // _PyStatus_ERR()
#include "pycore_pyerrors.h" // _PyErr_Format()
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_structseq.h" // _PyStructSequence_FiniType()
#include "pycore_sysmodule.h" // _PySys_Audit()
#include "pycore_traceback.h" // _PyTraceBack_FromFrame()
#include "pycore_pylifecycle.h" // _PyErr_WriteUnraisableDefaultHook()
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "pycore_structseq.h" // PyStructSequence_InitType()
+#include "pycore_structseq.h" // _PyStructSequence_InitType()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "code.h"
Stuff shared by all thread_*.h files is collected here. */
#include "Python.h"
-#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_structseq.h" // _PyStructSequence_FiniType()
#ifndef _POSIX_THREADS
/* This means pthreads are not implemented in libc headers, hence the macro