Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 6661:99955b65408d legacy-trunk
Apply str() to sys.ps1 or sys.ps2 before using them as a prompt, so
you can assign an object whose str() evaluates to the current
directory (or whatever).
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 25 Nov 1997 20:58:13 +0000 |
| parents | 83ccf44bf195 |
| children | bc007cf1d6ba |
line wrap: on
line diff
--- a/Python/pythonrun.c Tue Nov 25 20:49:09 1997 +0000 +++ b/Python/pythonrun.c Tue Nov 25 20:58:13 1997 +0000 @@ -459,24 +459,22 @@ PyObject *m, *d, *v, *w; node *n; perrdetail err; - char *ps1, *ps2; + char *ps1 = "", *ps2 = ""; v = PySys_GetObject("ps1"); - w = PySys_GetObject("ps2"); - if (v != NULL && PyString_Check(v)) { - Py_INCREF(v); - ps1 = PyString_AsString(v); + if (v != NULL) { + v = PyObject_Str(v); + if (v == NULL) + PyErr_Clear(); + else if (PyString_Check(v)) + ps1 = PyString_AsString(v); } - else { - v = NULL; - ps1 = ""; - } - if (w != NULL && PyString_Check(w)) { - Py_INCREF(w); - ps2 = PyString_AsString(w); - } - else { - w = NULL; - ps2 = ""; + w = PySys_GetObject("ps2"); + if (w != NULL) { + w = PyObject_Str(w); + if (w == NULL) + PyErr_Clear(); + else if (PyString_Check(w)) + ps2 = PyString_AsString(w); } Py_BEGIN_ALLOW_THREADS n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar,
