Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adapt :mod:`!msvcrt` to :pep:`687`.
43 changes: 23 additions & 20 deletions PC/msvcrtmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,19 +564,6 @@ static struct PyMethodDef msvcrt_functions[] = {
{NULL, NULL}
};


static struct PyModuleDef msvcrtmodule = {
PyModuleDef_HEAD_INIT,
"msvcrt",
NULL,
-1,
msvcrt_functions,
NULL,
NULL,
NULL,
NULL
};

static void
insertint(PyObject *d, char *name, int value)
{
Expand Down Expand Up @@ -605,14 +592,11 @@ insertptr(PyObject *d, char *name, void *value)
}
}

PyMODINIT_FUNC
PyInit_msvcrt(void)
static int
exec_module(PyObject* m)
{
int st;
PyObject *d, *version;
PyObject *m = PyModule_Create(&msvcrtmodule);
if (m == NULL)
return NULL;
d = PyModule_GetDict(m);

/* constants for the locking() function's mode argument */
Expand Down Expand Up @@ -664,10 +648,29 @@ PyInit_msvcrt(void)
_VC_CRT_BUILD_VERSION,
_VC_CRT_RBUILD_VERSION);
st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version);
if (st < 0) return NULL;
if (st < 0) return -1;
#endif
/* make compiler warning quiet if st is unused */
(void)st;

return m;
return 0;

}

static PyModuleDef_Slot msvcrt_slots[] = {
{Py_mod_exec, exec_module},
{0, NULL}
};

static struct PyModuleDef msvcrtmodule = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "msvcrt",
.m_methods = msvcrt_functions,
.m_slots = msvcrt_slots
};

PyMODINIT_FUNC
PyInit_msvcrt(void)
{
return PyModuleDef_Init(&msvcrtmodule);
}