Last change
on this file was 391, checked in by dmik, 11 years ago |
python: Merge vendor 2.7.6 to trunk.
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[2] | 1 |
|
---|
| 2 | /* Python interpreter main program for frozen scripts */
|
---|
| 3 |
|
---|
| 4 | #include "Python.h"
|
---|
| 5 |
|
---|
| 6 | #ifdef MS_WINDOWS
|
---|
| 7 | extern void PyWinFreeze_ExeInit(void);
|
---|
| 8 | extern void PyWinFreeze_ExeTerm(void);
|
---|
| 9 | extern int PyInitFrozenExtensions(void);
|
---|
| 10 | #endif
|
---|
| 11 |
|
---|
| 12 | /* Main program */
|
---|
| 13 |
|
---|
| 14 | int
|
---|
| 15 | Py_FrozenMain(int argc, char **argv)
|
---|
| 16 | {
|
---|
[391] | 17 | char *p;
|
---|
| 18 | int n, sts;
|
---|
| 19 | int inspect = 0;
|
---|
| 20 | int unbuffered = 0;
|
---|
[2] | 21 |
|
---|
[391] | 22 | Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
|
---|
[2] | 23 |
|
---|
[391] | 24 | if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
|
---|
| 25 | inspect = 1;
|
---|
| 26 | if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
|
---|
| 27 | unbuffered = 1;
|
---|
[2] | 28 |
|
---|
[391] | 29 | if (unbuffered) {
|
---|
| 30 | setbuf(stdin, (char *)NULL);
|
---|
| 31 | setbuf(stdout, (char *)NULL);
|
---|
| 32 | setbuf(stderr, (char *)NULL);
|
---|
| 33 | }
|
---|
[2] | 34 |
|
---|
| 35 | #ifdef MS_WINDOWS
|
---|
[391] | 36 | PyInitFrozenExtensions();
|
---|
[2] | 37 | #endif /* MS_WINDOWS */
|
---|
[391] | 38 | Py_SetProgramName(argv[0]);
|
---|
| 39 | Py_Initialize();
|
---|
[2] | 40 | #ifdef MS_WINDOWS
|
---|
[391] | 41 | PyWinFreeze_ExeInit();
|
---|
[2] | 42 | #endif
|
---|
| 43 |
|
---|
[391] | 44 | if (Py_VerboseFlag)
|
---|
| 45 | fprintf(stderr, "Python %s\n%s\n",
|
---|
| 46 | Py_GetVersion(), Py_GetCopyright());
|
---|
[2] | 47 |
|
---|
[391] | 48 | PySys_SetArgv(argc, argv);
|
---|
[2] | 49 |
|
---|
[391] | 50 | n = PyImport_ImportFrozenModule("__main__");
|
---|
| 51 | if (n == 0)
|
---|
| 52 | Py_FatalError("__main__ not frozen");
|
---|
| 53 | if (n < 0) {
|
---|
| 54 | PyErr_Print();
|
---|
| 55 | sts = 1;
|
---|
| 56 | }
|
---|
| 57 | else
|
---|
| 58 | sts = 0;
|
---|
[2] | 59 |
|
---|
[391] | 60 | if (inspect && isatty((int)fileno(stdin)))
|
---|
| 61 | sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
|
---|
[2] | 62 |
|
---|
| 63 | #ifdef MS_WINDOWS
|
---|
[391] | 64 | PyWinFreeze_ExeTerm();
|
---|
[2] | 65 | #endif
|
---|
[391] | 66 | Py_Finalize();
|
---|
| 67 | return sts;
|
---|
[2] | 68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.