1818 #define MAGIC_OFFSET 8
1919#endif
2020
21+ #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <=7
22+ #define SETUP_ARGV_BY_LEGACY
23+ #else
24+ #define SETUP_ARGV_BY_PYCONFIG
25+ #endif
26+
2127// WIN32 platform use wmain, all string related functions should change to wchar_t version
2228#ifdef WIN32
2329 #define _CHAR wchar_t
@@ -82,7 +88,7 @@ int main(int argc, char *argv[])
8288 }
8389 else
8490 {
85- #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <= 7
91+ #if defined( SETUP_ARGV_BY_LEGACY )
8692 #if defined(WIN32 )
8793 PySys_SetArgv (argc - 1 , argv + 1 );
8894 #else
@@ -109,7 +115,7 @@ int main(int argc, char *argv[])
109115 #endif
110116#else
111117 prependSysPath0 (argv [1 ]);
112- #endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <=7
118+ #endif // SETUP_ARGV_BY_LEGACY
113119 ret = runFile (argv [1 ]);
114120 }
115121 }
@@ -137,7 +143,7 @@ int main(int argc, char *argv[])
137143
138144
139145void initPython (int argc , _CHAR * argv []) {
140- #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <= 7
146+ #if defined( SETUP_ARGV_BY_LEGACY )
141147 #if defined(WIN32 )
142148 Py_SetProgramName (argv [0 ]);
143149 #else
@@ -201,7 +207,7 @@ void initPython(int argc, _CHAR *argv[]) {
201207 }
202208 // Display the error message and exit the process with non-zero exit code
203209 Py_ExitStatusException (status );
204- #endif // ifdef PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <=7
210+ #endif // SETUP_ARGV_BY_LEGACY
205211}
206212
207213
0 commit comments