Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use PyStructSequence_NewType
  • Loading branch information
tiran committed Apr 21, 2022
commit 3ed3bf2d1d5dfbf9a56c357b44ab78ed63a32f99
13 changes: 6 additions & 7 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2697,7 +2697,7 @@ PyDoc_STRVAR(emscripten_info__doc__,
\n\
WebAssembly Emscripten platform information.");

static PyTypeObject EmscriptenInfoType;
static PyTypeObject *EmscriptenInfoType;

static PyStructSequence_Field emscripten_info_fields[] = {
{"emscripten_version", "Emscripten version (major, minor, micro)"},
Expand Down Expand Up @@ -2737,7 +2737,7 @@ make_emscripten_info(void)
char *ua;
int pos = 0;

emscripten_info = PyStructSequence_New(&EmscriptenInfoType);
emscripten_info = PyStructSequence_New(EmscriptenInfoType);
if (emscripten_info == NULL) {
return NULL;
}
Expand Down Expand Up @@ -2927,10 +2927,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
}

#ifdef __EMSCRIPTEN__
if (EmscriptenInfoType.tp_name == NULL) {
if (_PyStructSequence_InitType(&EmscriptenInfoType,
&emscripten_info_desc,
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
if (EmscriptenInfoType == NULL) {
EmscriptenInfoType = PyStructSequence_NewType(&emscripten_info_desc);
if (EmscriptenInfoType == NULL) {
goto type_init_failed;
}
}
Expand Down Expand Up @@ -3183,7 +3182,7 @@ _PySys_Fini(PyInterpreterState *interp)
_PyStructSequence_FiniType(&Hash_InfoType);
_PyStructSequence_FiniType(&AsyncGenHooksType);
#ifdef __EMSCRIPTEN__
_PyStructSequence_FiniType(&EmscriptenInfoType);
Py_CLEAR(EmscriptenInfoType);
#endif
}
}
Expand Down