No issues found
1 /* Python interpreter main program for frozen scripts */
2
3 #include "Python.h"
4
5 #ifdef MS_WINDOWS
6 extern void PyWinFreeze_ExeInit(void);
7 extern void PyWinFreeze_ExeTerm(void);
8 extern int PyInitFrozenExtensions(void);
9 #endif
10
11 /* Main program */
12
13 int
14 Py_FrozenMain(int argc, char **argv)
15 {
16 char *p;
17 int n, sts;
18 int inspect = 0;
19 int unbuffered = 0;
20
21 Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
22
23 if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
24 inspect = 1;
25 if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
26 unbuffered = 1;
27
28 if (unbuffered) {
29 setbuf(stdin, (char *)NULL);
30 setbuf(stdout, (char *)NULL);
31 setbuf(stderr, (char *)NULL);
32 }
33
34 #ifdef MS_WINDOWS
35 PyInitFrozenExtensions();
36 #endif /* MS_WINDOWS */
37 Py_SetProgramName(argv[0]);
38 Py_Initialize();
39 #ifdef MS_WINDOWS
40 PyWinFreeze_ExeInit();
41 #endif
42
43 if (Py_VerboseFlag)
44 fprintf(stderr, "Python %s\n%s\n",
45 Py_GetVersion(), Py_GetCopyright());
46
47 PySys_SetArgv(argc, argv);
48
49 n = PyImport_ImportFrozenModule("__main__");
50 if (n == 0)
51 Py_FatalError("__main__ not frozen");
52 if (n < 0) {
53 PyErr_Print();
54 sts = 1;
55 }
56 else
57 sts = 0;
58
59 if (inspect && isatty((int)fileno(stdin)))
60 sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
61
62 #ifdef MS_WINDOWS
63 PyWinFreeze_ExeTerm();
64 #endif
65 Py_Finalize();
66 return sts;
67 }