-/* Python interpreter main program */\r
+/** @file\r
+ Python interpreter main program.\r
+\r
+ Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>\r
+**/\r
\r
#include "Python.h"\r
#include "osdefs.h"\r
static int orig_argc;\r
\r
/* command line options */\r
-#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?"\r
+#define BASE_OPTS "#3bBc:dEhiJm:OQ:sStuUvVW:xX?"\r
\r
#ifndef RISCOS\r
#define PROGRAM_OPTS BASE_OPTS\r
/* Long usage message, split into parts < 512 bytes */\r
static char *usage_1 = "\\r
Options and arguments (and corresponding environment variables):\n\\r
+-# : alias stderr to stdout for platforms without STDERR output.\n\\r
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\\r
-c cmd : program passed in as string (terminates option list)\n\\r
-d : debug output from parser; also PYTHONDEBUG=x\n\\r
-m mod : run library module as a script (terminates option list)\n\\r
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\\r
-OO : remove doc-strings in addition to the -O optimizations\n\\r
--R : use a pseudo-random salt to make hash() values of various types be\n\\r
- unpredictable between separate invocations of the interpreter, as\n\\r
- a defense against denial-of-service attacks\n\\r
-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\\r
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\\r
-S : don't imply 'import site' on initialization\n\\r
static char *usage_5 = "\\r
PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\\r
The default module search path uses %s.\n\\r
-PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\\r
+PYTHONCASEOK : ignore case in 'import' statements (UEFI default).\n\\r
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\\r
";\r
-static char *usage_6 = "\\r
-PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\\r
- as specifying the -R option: a random value is used to seed the hashes of\n\\r
- str, bytes and datetime objects. It can also be set to an integer\n\\r
- in the range [0,4294967295] to get hash values with a predictable seed.\n\\r
-";\r
\r
\r
static int\r
fputs(usage_3, f);\r
fprintf(f, usage_4, DELIM);\r
fprintf(f, usage_5, DELIM, PYTHONHOMEHELP);\r
- fputs(usage_6, f);\r
}\r
#if defined(__VMS)\r
if (exitcode == 0) {\r
int help = 0;\r
int version = 0;\r
int saw_unbuffered_flag = 0;\r
+ int saw_pound_flag = 0;\r
PyCompilerFlags cf;\r
\r
cf.cf_flags = 0;\r
(including -W and -X options). */\r
_PyOS_opterr = 0; /* prevent printing the error in 1st pass */\r
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {\r
- if (c == 'm' || c == 'c') {\r
- /* -c / -m is the last option: following arguments are\r
- not interpreter options. */\r
- break;\r
- }\r
- switch (c) {\r
+ if (c == 'm' || c == 'c') {\r
+ /* -c / -m is the last option: following arguments are\r
+ not interpreter options. */\r
+ break;\r
+ }\r
+ switch (c) {\r
+ case '#':\r
+ if (saw_pound_flag == 0) {\r
+ if(freopen("stdout:", "w", stderr) == NULL) {\r
+ puts("ERROR: Unable to reopen stderr as an alias to stdout!");\r
+ }\r
+ saw_pound_flag = 0xFF;\r
+ }\r
+ break;\r
case 'E':\r
- Py_IgnoreEnvironmentFlag++;\r
- break;\r
- case 'R':\r
- Py_HashRandomizationFlag++;\r
- break;\r
- }\r
+ Py_IgnoreEnvironmentFlag++;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
}\r
- /* The variable is only tested for existence here; _PyRandom_Init will\r
- check its value further. */\r
- if (!Py_HashRandomizationFlag &&\r
- (p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')\r
- Py_HashRandomizationFlag = 1;\r
-\r
_PyRandom_Init();\r
\r
PySys_ResetWarnOptions();\r
PySys_AddWarnOption(_PyOS_optarg);\r
break;\r
\r
- case 'R':\r
+ case '#':\r
/* Already handled above */\r
break;\r
\r