-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Bug report
Bug description:
Using Python 3.12.5 on Windows, the executable built from the following C code produces the output MemoryError
:
#define PY_SSIZE_T_CLEAN
#include <Python.h>
int main(int argc, char *argv[])
{
Py_Initialize();
const char *python_code =
"def func(*args):\n"
" print(args)\n";
PyRun_SimpleString(python_code);
PyObject *main_module = PyImport_AddModule("__main__");
PyObject *main_dict = PyModule_GetDict(main_module);
PyObject *func = PyDict_GetItemString(main_dict, "func");
char data[10] = {0};
PyObject *result = PyObject_CallFunction(func, "iy#", 1, data, 10);
if (!result)
{
PyErr_Print();
}
Py_Finalize();
return 0;
}
The error does not occur when the data
variable is made a global variable. I am using GCC 13.10.0 (MinGW-Builds project) on x86-64 Windows 10. I cannot attach the binary to this issue due to GitHub file type restrictions, but please let me know if I should provide it to you via a different channel.
CPython versions tested on:
3.12
Operating systems tested on:
Windows