Skip to content

Commit

Permalink
Eliminate structseq_new.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Dec 8, 2022
1 parent 7f6d5b8 commit 62179ba
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(node_offset)
STRUCT_FOR_ID(ns)
STRUCT_FOR_ID(nstype)
STRUCT_FOR_ID(nt)
STRUCT_FOR_ID(null)
STRUCT_FOR_ID(number)
STRUCT_FOR_ID(obj)
Expand Down Expand Up @@ -575,6 +576,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(pos)
STRUCT_FOR_ID(pos1)
STRUCT_FOR_ID(pos2)
STRUCT_FOR_ID(posix)
STRUCT_FOR_ID(print_file_and_line)
STRUCT_FOR_ID(priority)
STRUCT_FOR_ID(progress)
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,11 @@ extern char *ctermid_r(char *);
#ifdef MS_WINDOWS
# define INITFUNC PyInit_nt
# define MODNAME "nt"
# define MODNAME_OBJ &_Py_ID(nt)
#else
# define INITFUNC PyInit_posix
# define MODNAME "posix"
# define MODNAME_OBJ &_Py_ID(posix)
#endif

#if defined(__sun)
Expand Down Expand Up @@ -2225,14 +2227,23 @@ static PyStructSequence_Desc waitid_result_desc = {
5
};
#endif
static newfunc structseq_new;

static PyObject *
statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyStructSequence *result;
int i;

PyObject *mod = PyType_GetModule(type);
if (mod == NULL) {
return NULL;
}
_posixstate *state = get_posix_state(mod);
if (state == NULL) {
return NULL;
}
#define structseq_new ((PyTypeObject *)state->StatResultType)->tp_new

result = (PyStructSequence*)structseq_new(type, args, kwds);
if (!result)
return NULL;
Expand Down Expand Up @@ -15925,7 +15936,6 @@ posixmodule_exec(PyObject *m)
}
PyModule_AddObject(m, "stat_result", Py_NewRef(StatResultType));
state->StatResultType = StatResultType;
structseq_new = ((PyTypeObject *)StatResultType)->tp_new;
((PyTypeObject *)StatResultType)->tp_new = statresult_new;

statvfs_result_desc.name = "os.statvfs_result"; /* see issue #19209 */
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ Modules/faulthandler.c - old_stack -
##-----------------------
## initialized once

Modules/posixmodule.c - structseq_new -
Modules/timemodule.c _PyTime_GetClockWithInfo initialized -
Modules/timemodule.c _PyTime_GetProcessTimeWithInfo ticks_per_second -

Expand Down

0 comments on commit 62179ba

Please sign in to comment.