Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 43777:0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
No detailed change log; just check out the change log for the py3k-pep3137
branch. The most obvious changes:
- str8 renamed to bytes (PyString at the C level);
- bytes renamed to buffer (PyBytes at the C level);
- PyString and PyUnicode are no longer compatible.
I.e. we now have an immutable bytes type and a mutable bytes type.
The behavior of PyString was modified quite a bit, to make it more
bytes-like. Some changes are still on the to-do list.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 06 Nov 2007 21:34:58 +0000 |
| parents | e510b716bd80 |
| children | ccceaec11442 |
line wrap: on
line diff
--- a/Python/pythonrun.c Tue Nov 06 20:51:31 2007 +0000 +++ b/Python/pythonrun.c Tue Nov 06 21:34:58 2007 +0000 @@ -75,6 +75,7 @@ int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */ int Py_NoSiteFlag; /* Suppress 'import site' */ +int Py_BytesWarningFlag; /* Warn on str(bytes) and str(buffer) */ int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ int Py_FrozenFlag; /* Needed by getpath.c */ int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ @@ -234,6 +235,7 @@ if (pstderr == NULL) Py_FatalError("Py_Initialize: can't set preliminary stderr"); PySys_SetObject("stderr", pstderr); + PySys_SetObject("__stderr__", pstderr); _PyImport_Init(); @@ -261,8 +263,28 @@ #endif /* WITH_THREAD */ warnings_module = PyImport_ImportModule("warnings"); - if (!warnings_module) + if (!warnings_module) { PyErr_Clear(); + } + else { + PyObject *o; + char *action[8]; + + if (Py_BytesWarningFlag > 1) + *action = "error"; + else if (Py_BytesWarningFlag) + *action = "default"; + else + *action = "ignore"; + + o = PyObject_CallMethod(warnings_module, + "simplefilter", "sO", + *action, PyExc_BytesWarning); + if (o == NULL) + Py_FatalError("Py_Initialize: can't initialize" + "warning filter for BytesWarning."); + Py_DECREF(o); + } #if defined(HAVE_LANGINFO_H) && defined(CODESET) /* On Unix, set the file system encoding according to the @@ -743,6 +765,7 @@ PySys_SetObject("stdout", std); Py_DECREF(std); +#if 1 /* Disable this if you have trouble debugging bootstrap stuff */ /* Set sys.stderr, replaces the preliminary stderr */ if (!(std = PyFile_FromFd(fileno(stderr), "<stderr>", "w", -1, NULL, "\n", 0))) { @@ -751,6 +774,7 @@ PySys_SetObject("__stderr__", std); PySys_SetObject("stderr", std); Py_DECREF(std); +#endif if (0) { error: @@ -1339,7 +1363,7 @@ PyArena *arena = PyArena_New(); if (arena == NULL) return NULL; - + mod = PyParser_ASTFromString(str, "<string>", start, flags, arena); if (mod != NULL) ret = run_mod(mod, "<string>", globals, locals, flags, arena); @@ -1356,7 +1380,7 @@ PyArena *arena = PyArena_New(); if (arena == NULL) return NULL; - + mod = PyParser_ASTFromFile(fp, filename, NULL, start, 0, 0, flags, NULL, arena); if (closeit) @@ -1705,7 +1729,7 @@ static void call_py_exitfuncs(void) { - if (pyexitfunc == NULL) + if (pyexitfunc == NULL) return; (*pyexitfunc)();
