diff options
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/Modules/main.c b/Modules/main.c index 1282f46..e262552 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -6,6 +6,7 @@ #include <locale.h> #ifdef __VMS +#error "PEP 11: VMS is now unsupported, code will be removed in Python 3.4" #include <unixlib.h> #endif @@ -72,9 +73,6 @@ static char *usage_2 = "\ -O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -q : don't print version and copyright messages on interactive startup\n\ --R : use a pseudo-random salt to make hash() values of various types be\n\ - unpredictable between separate invocations of the interpreter, as\n\ - a defence against denial-of-service attacks\n\ -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\ -S : don't imply 'import site' on initialization\n\ "; @@ -102,13 +100,14 @@ static char *usage_5 = "PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n" " The default module search path uses %s.\n" "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n" -"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\ +"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n" +"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n\ "; static char *usage_6 = "\ -PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\ - as specifying the -R option: a random value is used to seed the hashes of\n\ - str, bytes and datetime objects. It can also be set to an integer\n\ - in the range [0,4294967295] to get hash values with a predictable seed.\n\ +PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\ + to seed the hashes of str, bytes and datetime objects. It can also be\n\ + set to an integer in the range [0,4294967295] to get hash values with a\n\ + predictable seed.\n\ "; static int @@ -225,7 +224,7 @@ RunMainFromImporter(wchar_t *filename) if (importer == NULL) goto error; - if (importer->ob_type == &PyNullImporter_Type) { + if (importer == Py_None) { Py_DECREF(argv0); Py_DECREF(importer); return -1; @@ -345,21 +344,13 @@ Py_Main(int argc, wchar_t **argv) not interpreter options. */ break; } - switch (c) { - case 'E': + if (c == 'E') { Py_IgnoreEnvironmentFlag++; break; - case 'R': - Py_HashRandomizationFlag++; - break; } } - /* The variable is only tested for existence here; _PyRandom_Init will - check its value further. */ - if (!Py_HashRandomizationFlag && - (p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0') - Py_HashRandomizationFlag = 1; + Py_HashRandomizationFlag = 1; _PyRandom_Init(); PySys_ResetWarnOptions(); @@ -466,7 +457,7 @@ Py_Main(int argc, wchar_t **argv) break; case 'R': - /* Already handled above */ + /* Ignored */ break; /* This space reserved for other options */ @@ -533,16 +524,13 @@ Py_Main(int argc, wchar_t **argv) /* Use utf-8 on Mac OS X */ unicode = PyUnicode_FromString(p); #else - wchar_t *wchar; - size_t len; - wchar = _Py_char2wchar(p, &len); - if (wchar == NULL) - continue; - unicode = PyUnicode_FromWideChar(wchar, len); - PyMem_Free(wchar); + unicode = PyUnicode_DecodeLocale(p, "surrogateescape"); #endif - if (unicode == NULL) + if (unicode == NULL) { + /* ignore errors */ + PyErr_Clear(); continue; + } PySys_AddWarnOptionUnicode(unicode); Py_DECREF(unicode); } @@ -617,7 +605,6 @@ Py_Main(int argc, wchar_t **argv) if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') { wchar_t* buffer; size_t len = strlen(p); - size_t r; buffer = malloc(len * sizeof(wchar_t)); if (buffer == NULL) { @@ -625,7 +612,7 @@ Py_Main(int argc, wchar_t **argv) "not enough memory to copy PYTHONEXECUTABLE"); } - r = mbstowcs(buffer, p, len); + mbstowcs(buffer, p, len); Py_SetProgramName(buffer); /* buffer is now handed off - do not free */ } else { |