Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 47527:52294af4b663 legacy-trunk
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 2a63ab3595a1 |
| children | 6f132a26b22f |
comparison
equal
deleted
inserted
replaced
| 47526:246a802637ad | 47527:52294af4b663 |
|---|---|
| 493 PyFrame_Fini(); | 493 PyFrame_Fini(); |
| 494 PyCFunction_Fini(); | 494 PyCFunction_Fini(); |
| 495 PyTuple_Fini(); | 495 PyTuple_Fini(); |
| 496 PyList_Fini(); | 496 PyList_Fini(); |
| 497 PySet_Fini(); | 497 PySet_Fini(); |
| 498 PyBytes_Fini(); | 498 PyString_Fini(); |
| 499 PyByteArray_Fini(); | 499 PyByteArray_Fini(); |
| 500 PyInt_Fini(); | 500 PyInt_Fini(); |
| 501 PyFloat_Fini(); | 501 PyFloat_Fini(); |
| 502 PyDict_Fini(); | 502 PyDict_Fini(); |
| 503 | 503 |
| 742 flags = &local_flags; | 742 flags = &local_flags; |
| 743 local_flags.cf_flags = 0; | 743 local_flags.cf_flags = 0; |
| 744 } | 744 } |
| 745 v = PySys_GetObject("ps1"); | 745 v = PySys_GetObject("ps1"); |
| 746 if (v == NULL) { | 746 if (v == NULL) { |
| 747 PySys_SetObject("ps1", v = PyBytes_FromString(">>> ")); | 747 PySys_SetObject("ps1", v = PyString_FromString(">>> ")); |
| 748 Py_XDECREF(v); | 748 Py_XDECREF(v); |
| 749 } | 749 } |
| 750 v = PySys_GetObject("ps2"); | 750 v = PySys_GetObject("ps2"); |
| 751 if (v == NULL) { | 751 if (v == NULL) { |
| 752 PySys_SetObject("ps2", v = PyBytes_FromString("... ")); | 752 PySys_SetObject("ps2", v = PyString_FromString("... ")); |
| 753 Py_XDECREF(v); | 753 Py_XDECREF(v); |
| 754 } | 754 } |
| 755 for (;;) { | 755 for (;;) { |
| 756 ret = PyRun_InteractiveOneFlags(fp, filename, flags); | 756 ret = PyRun_InteractiveOneFlags(fp, filename, flags); |
| 757 PRINT_TOTAL_REFS(); | 757 PRINT_TOTAL_REFS(); |
| 794 v = PySys_GetObject("ps1"); | 794 v = PySys_GetObject("ps1"); |
| 795 if (v != NULL) { | 795 if (v != NULL) { |
| 796 v = PyObject_Str(v); | 796 v = PyObject_Str(v); |
| 797 if (v == NULL) | 797 if (v == NULL) |
| 798 PyErr_Clear(); | 798 PyErr_Clear(); |
| 799 else if (PyBytes_Check(v)) | 799 else if (PyString_Check(v)) |
| 800 ps1 = PyBytes_AsString(v); | 800 ps1 = PyString_AsString(v); |
| 801 } | 801 } |
| 802 w = PySys_GetObject("ps2"); | 802 w = PySys_GetObject("ps2"); |
| 803 if (w != NULL) { | 803 if (w != NULL) { |
| 804 w = PyObject_Str(w); | 804 w = PyObject_Str(w); |
| 805 if (w == NULL) | 805 if (w == NULL) |
| 806 PyErr_Clear(); | 806 PyErr_Clear(); |
| 807 else if (PyBytes_Check(w)) | 807 else if (PyString_Check(w)) |
| 808 ps2 = PyBytes_AsString(w); | 808 ps2 = PyString_AsString(w); |
| 809 } | 809 } |
| 810 arena = PyArena_New(); | 810 arena = PyArena_New(); |
| 811 if (arena == NULL) { | 811 if (arena == NULL) { |
| 812 Py_XDECREF(v); | 812 Py_XDECREF(v); |
| 813 Py_XDECREF(w); | 813 Py_XDECREF(w); |
| 896 m = PyImport_AddModule("__main__"); | 896 m = PyImport_AddModule("__main__"); |
| 897 if (m == NULL) | 897 if (m == NULL) |
| 898 return -1; | 898 return -1; |
| 899 d = PyModule_GetDict(m); | 899 d = PyModule_GetDict(m); |
| 900 if (PyDict_GetItemString(d, "__file__") == NULL) { | 900 if (PyDict_GetItemString(d, "__file__") == NULL) { |
| 901 PyObject *f = PyBytes_FromString(filename); | 901 PyObject *f = PyString_FromString(filename); |
| 902 if (f == NULL) | 902 if (f == NULL) |
| 903 return -1; | 903 return -1; |
| 904 if (PyDict_SetItemString(d, "__file__", f) < 0) { | 904 if (PyDict_SetItemString(d, "__file__", f) < 0) { |
| 905 Py_DECREF(f); | 905 Py_DECREF(f); |
| 906 return -1; | 906 return -1; |
| 980 | 980 |
| 981 if (!(v = PyObject_GetAttrString(err, "filename"))) | 981 if (!(v = PyObject_GetAttrString(err, "filename"))) |
| 982 goto finally; | 982 goto finally; |
| 983 if (v == Py_None) | 983 if (v == Py_None) |
| 984 *filename = NULL; | 984 *filename = NULL; |
| 985 else if (! (*filename = PyBytes_AsString(v))) | 985 else if (! (*filename = PyString_AsString(v))) |
| 986 goto finally; | 986 goto finally; |
| 987 | 987 |
| 988 Py_DECREF(v); | 988 Py_DECREF(v); |
| 989 if (!(v = PyObject_GetAttrString(err, "lineno"))) | 989 if (!(v = PyObject_GetAttrString(err, "lineno"))) |
| 990 goto finally; | 990 goto finally; |
| 1012 | 1012 |
| 1013 if (!(v = PyObject_GetAttrString(err, "text"))) | 1013 if (!(v = PyObject_GetAttrString(err, "text"))) |
| 1014 goto finally; | 1014 goto finally; |
| 1015 if (v == Py_None) | 1015 if (v == Py_None) |
| 1016 *text = NULL; | 1016 *text = NULL; |
| 1017 else if (! (*text = PyBytes_AsString(v))) | 1017 else if (! (*text = PyString_AsString(v))) |
| 1018 goto finally; | 1018 goto finally; |
| 1019 Py_DECREF(v); | 1019 Py_DECREF(v); |
| 1020 return 1; | 1020 return 1; |
| 1021 | 1021 |
| 1022 finally: | 1022 finally: |
| 1235 | 1235 |
| 1236 moduleName = PyObject_GetAttrString(exception, "__module__"); | 1236 moduleName = PyObject_GetAttrString(exception, "__module__"); |
| 1237 if (moduleName == NULL) | 1237 if (moduleName == NULL) |
| 1238 err = PyFile_WriteString("<unknown>", f); | 1238 err = PyFile_WriteString("<unknown>", f); |
| 1239 else { | 1239 else { |
| 1240 char* modstr = PyBytes_AsString(moduleName); | 1240 char* modstr = PyString_AsString(moduleName); |
| 1241 if (modstr && strcmp(modstr, "exceptions")) | 1241 if (modstr && strcmp(modstr, "exceptions")) |
| 1242 { | 1242 { |
| 1243 err = PyFile_WriteString(modstr, f); | 1243 err = PyFile_WriteString(modstr, f); |
| 1244 err += PyFile_WriteString(".", f); | 1244 err += PyFile_WriteString(".", f); |
| 1245 } | 1245 } |
| 1259 /* only print colon if the str() of the | 1259 /* only print colon if the str() of the |
| 1260 object is not the empty string | 1260 object is not the empty string |
| 1261 */ | 1261 */ |
| 1262 if (s == NULL) | 1262 if (s == NULL) |
| 1263 err = -1; | 1263 err = -1; |
| 1264 else if (!PyBytes_Check(s) || | 1264 else if (!PyString_Check(s) || |
| 1265 PyBytes_GET_SIZE(s) != 0) | 1265 PyString_GET_SIZE(s) != 0) |
| 1266 err = PyFile_WriteString(": ", f); | 1266 err = PyFile_WriteString(": ", f); |
| 1267 if (err == 0) | 1267 if (err == 0) |
| 1268 err = PyFile_WriteObject(s, f, Py_PRINT_RAW); | 1268 err = PyFile_WriteObject(s, f, Py_PRINT_RAW); |
| 1269 Py_XDECREF(s); | 1269 Py_XDECREF(s); |
| 1270 } | 1270 } |
| 1579 PyObject *type, *value, *tb; | 1579 PyObject *type, *value, *tb; |
| 1580 PyErr_Fetch(&type, &value, &tb); | 1580 PyErr_Fetch(&type, &value, &tb); |
| 1581 if (value != NULL) { | 1581 if (value != NULL) { |
| 1582 u = PyObject_Str(value); | 1582 u = PyObject_Str(value); |
| 1583 if (u != NULL) { | 1583 if (u != NULL) { |
| 1584 msg = PyBytes_AsString(u); | 1584 msg = PyString_AsString(u); |
| 1585 } | 1585 } |
| 1586 } | 1586 } |
| 1587 if (msg == NULL) | 1587 if (msg == NULL) |
| 1588 msg = "unknown decode error"; | 1588 msg = "unknown decode error"; |
| 1589 Py_XDECREF(type); | 1589 Py_XDECREF(type); |
