blob: 56b8bc28a0e7723cf71a1939e3447f0984ebcce4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
https://github.com/cython/cython/pull/5210
https://github.com/cython/cython/pull/5211
--- contrib/tools/cython/Cython/Utility/Embed.c (19fe9379d5dd7e26afd2405b1890080712d1892c)
+++ contrib/tools/cython/Cython/Utility/Embed.c (bdf71953ac311b76dcfb2ffd7ec4b71a018ed416)
@@ -28,6 +28,7 @@ static int __Pyx_main(int argc, wchar_t **argv) {
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
#endif
+#if PY_VERSION_HEX < 0x03080000
if (argc && argv) {
Py_InitArgcArgv(argc, argv);
Py_SetProgramName(argv[0]);
@@ -35,6 +36,38 @@ static int __Pyx_main(int argc, wchar_t **argv) {
Py_Initialize();
if (argc && argv)
PySys_SetArgv(argc, argv);
+#else
+ {
+ PyStatus status;
+
+ PyConfig config;
+ PyConfig_InitPythonConfig(&config);
+ // Disable parsing command line arguments
+ config.parse_argv = 0;
+
+ if (argc && argv) {
+ status = PyConfig_SetString(&config, &config.program_name, argv[0]);
+ if (PyStatus_Exception(status)) {
+ PyConfig_Clear(&config);
+ return 1;
+ }
+
+ status = PyConfig_SetArgv(&config, argc, argv);
+ if (PyStatus_Exception(status)) {
+ PyConfig_Clear(&config);
+ return 1;
+ }
+ }
+
+ status = Py_InitializeFromConfig(&config);
+ if (PyStatus_Exception(status)) {
+ PyConfig_Clear(&config);
+ return 1;
+ }
+
+ PyConfig_Clear(&config);
+ }
+#endif
{ /* init module '%(module_name)s' as '__main__' */
PyObject* m = NULL;
%(module_is_main)s = 1;
|