Skip to content

Commit 62179ba

Browse files
Eliminate structseq_new.
1 parent 7f6d5b8 commit 62179ba

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ struct _Py_global_strings {
537537
STRUCT_FOR_ID(node_offset)
538538
STRUCT_FOR_ID(ns)
539539
STRUCT_FOR_ID(nstype)
540+
STRUCT_FOR_ID(nt)
540541
STRUCT_FOR_ID(null)
541542
STRUCT_FOR_ID(number)
542543
STRUCT_FOR_ID(obj)
@@ -575,6 +576,7 @@ struct _Py_global_strings {
575576
STRUCT_FOR_ID(pos)
576577
STRUCT_FOR_ID(pos1)
577578
STRUCT_FOR_ID(pos2)
579+
STRUCT_FOR_ID(posix)
578580
STRUCT_FOR_ID(print_file_and_line)
579581
STRUCT_FOR_ID(priority)
580582
STRUCT_FOR_ID(progress)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,11 @@ extern char *ctermid_r(char *);
495495
#ifdef MS_WINDOWS
496496
# define INITFUNC PyInit_nt
497497
# define MODNAME "nt"
498+
# define MODNAME_OBJ &_Py_ID(nt)
498499
#else
499500
# define INITFUNC PyInit_posix
500501
# define MODNAME "posix"
502+
# define MODNAME_OBJ &_Py_ID(posix)
501503
#endif
502504

503505
#if defined(__sun)
@@ -2225,14 +2227,23 @@ static PyStructSequence_Desc waitid_result_desc = {
22252227
5
22262228
};
22272229
#endif
2228-
static newfunc structseq_new;
22292230

22302231
static PyObject *
22312232
statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
22322233
{
22332234
PyStructSequence *result;
22342235
int i;
22352236

2237+
PyObject *mod = PyType_GetModule(type);
2238+
if (mod == NULL) {
2239+
return NULL;
2240+
}
2241+
_posixstate *state = get_posix_state(mod);
2242+
if (state == NULL) {
2243+
return NULL;
2244+
}
2245+
#define structseq_new ((PyTypeObject *)state->StatResultType)->tp_new
2246+
22362247
result = (PyStructSequence*)structseq_new(type, args, kwds);
22372248
if (!result)
22382249
return NULL;
@@ -15925,7 +15936,6 @@ posixmodule_exec(PyObject *m)
1592515936
}
1592615937
PyModule_AddObject(m, "stat_result", Py_NewRef(StatResultType));
1592715938
state->StatResultType = StatResultType;
15928-
structseq_new = ((PyTypeObject *)StatResultType)->tp_new;
1592915939
((PyTypeObject *)StatResultType)->tp_new = statresult_new;
1593015940

1593115941
statvfs_result_desc.name = "os.statvfs_result"; /* see issue #19209 */

Tools/c-analyzer/cpython/globals-to-fix.tsv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ Modules/faulthandler.c - old_stack -
390390
##-----------------------
391391
## initialized once
392392

393-
Modules/posixmodule.c - structseq_new -
394393
Modules/timemodule.c _PyTime_GetClockWithInfo initialized -
395394
Modules/timemodule.c _PyTime_GetProcessTimeWithInfo ticks_per_second -
396395

0 commit comments

Comments
 (0)