Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6660:bb86bb76d61d | 6661:99955b65408d |
|---|---|
| 457 char *filename; | 457 char *filename; |
| 458 { | 458 { |
| 459 PyObject *m, *d, *v, *w; | 459 PyObject *m, *d, *v, *w; |
| 460 node *n; | 460 node *n; |
| 461 perrdetail err; | 461 perrdetail err; |
| 462 char *ps1, *ps2; | 462 char *ps1 = "", *ps2 = ""; |
| 463 v = PySys_GetObject("ps1"); | 463 v = PySys_GetObject("ps1"); |
| 464 if (v != NULL) { | |
| 465 v = PyObject_Str(v); | |
| 466 if (v == NULL) | |
| 467 PyErr_Clear(); | |
| 468 else if (PyString_Check(v)) | |
| 469 ps1 = PyString_AsString(v); | |
| 470 } | |
| 464 w = PySys_GetObject("ps2"); | 471 w = PySys_GetObject("ps2"); |
| 465 if (v != NULL && PyString_Check(v)) { | 472 if (w != NULL) { |
| 466 Py_INCREF(v); | 473 w = PyObject_Str(w); |
| 467 ps1 = PyString_AsString(v); | 474 if (w == NULL) |
| 468 } | 475 PyErr_Clear(); |
| 469 else { | 476 else if (PyString_Check(w)) |
| 470 v = NULL; | 477 ps2 = PyString_AsString(w); |
| 471 ps1 = ""; | |
| 472 } | |
| 473 if (w != NULL && PyString_Check(w)) { | |
| 474 Py_INCREF(w); | |
| 475 ps2 = PyString_AsString(w); | |
| 476 } | |
| 477 else { | |
| 478 w = NULL; | |
| 479 ps2 = ""; | |
| 480 } | 478 } |
| 481 Py_BEGIN_ALLOW_THREADS | 479 Py_BEGIN_ALLOW_THREADS |
| 482 n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, | 480 n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, |
| 483 Py_single_input, ps1, ps2, &err); | 481 Py_single_input, ps1, ps2, &err); |
| 484 Py_END_ALLOW_THREADS | 482 Py_END_ALLOW_THREADS |
