comparison Python/pythonrun.c @ 47294:4fe192d48960 legacy-trunk

Renamed PyString to PyBytes
author Christian Heimes <christian@cheimes.de>
date Mon, 26 May 2008 12:51:38 +0000
parents 04bd3690fb1f
children 1062b7dec95b
comparison
equal deleted inserted replaced
47292:abafccfe7501 47294:4fe192d48960
448 PyFrame_Fini(); 448 PyFrame_Fini();
449 PyCFunction_Fini(); 449 PyCFunction_Fini();
450 PyTuple_Fini(); 450 PyTuple_Fini();
451 PyList_Fini(); 451 PyList_Fini();
452 PySet_Fini(); 452 PySet_Fini();
453 PyString_Fini(); 453 PyBytes_Fini();
454 PyByteArray_Fini(); 454 PyByteArray_Fini();
455 PyInt_Fini(); 455 PyInt_Fini();
456 PyFloat_Fini(); 456 PyFloat_Fini();
457 PyDict_Fini(); 457 PyDict_Fini();
458 458
697 flags = &local_flags; 697 flags = &local_flags;
698 local_flags.cf_flags = 0; 698 local_flags.cf_flags = 0;
699 } 699 }
700 v = PySys_GetObject("ps1"); 700 v = PySys_GetObject("ps1");
701 if (v == NULL) { 701 if (v == NULL) {
702 PySys_SetObject("ps1", v = PyString_FromString(">>> ")); 702 PySys_SetObject("ps1", v = PyBytes_FromString(">>> "));
703 Py_XDECREF(v); 703 Py_XDECREF(v);
704 } 704 }
705 v = PySys_GetObject("ps2"); 705 v = PySys_GetObject("ps2");
706 if (v == NULL) { 706 if (v == NULL) {
707 PySys_SetObject("ps2", v = PyString_FromString("... ")); 707 PySys_SetObject("ps2", v = PyBytes_FromString("... "));
708 Py_XDECREF(v); 708 Py_XDECREF(v);
709 } 709 }
710 for (;;) { 710 for (;;) {
711 ret = PyRun_InteractiveOneFlags(fp, filename, flags); 711 ret = PyRun_InteractiveOneFlags(fp, filename, flags);
712 PRINT_TOTAL_REFS(); 712 PRINT_TOTAL_REFS();
749 v = PySys_GetObject("ps1"); 749 v = PySys_GetObject("ps1");
750 if (v != NULL) { 750 if (v != NULL) {
751 v = PyObject_Str(v); 751 v = PyObject_Str(v);
752 if (v == NULL) 752 if (v == NULL)
753 PyErr_Clear(); 753 PyErr_Clear();
754 else if (PyString_Check(v)) 754 else if (PyBytes_Check(v))
755 ps1 = PyString_AsString(v); 755 ps1 = PyBytes_AsString(v);
756 } 756 }
757 w = PySys_GetObject("ps2"); 757 w = PySys_GetObject("ps2");
758 if (w != NULL) { 758 if (w != NULL) {
759 w = PyObject_Str(w); 759 w = PyObject_Str(w);
760 if (w == NULL) 760 if (w == NULL)
761 PyErr_Clear(); 761 PyErr_Clear();
762 else if (PyString_Check(w)) 762 else if (PyBytes_Check(w))
763 ps2 = PyString_AsString(w); 763 ps2 = PyBytes_AsString(w);
764 } 764 }
765 arena = PyArena_New(); 765 arena = PyArena_New();
766 if (arena == NULL) { 766 if (arena == NULL) {
767 Py_XDECREF(v); 767 Py_XDECREF(v);
768 Py_XDECREF(w); 768 Py_XDECREF(w);
851 m = PyImport_AddModule("__main__"); 851 m = PyImport_AddModule("__main__");
852 if (m == NULL) 852 if (m == NULL)
853 return -1; 853 return -1;
854 d = PyModule_GetDict(m); 854 d = PyModule_GetDict(m);
855 if (PyDict_GetItemString(d, "__file__") == NULL) { 855 if (PyDict_GetItemString(d, "__file__") == NULL) {
856 PyObject *f = PyString_FromString(filename); 856 PyObject *f = PyBytes_FromString(filename);
857 if (f == NULL) 857 if (f == NULL)
858 return -1; 858 return -1;
859 if (PyDict_SetItemString(d, "__file__", f) < 0) { 859 if (PyDict_SetItemString(d, "__file__", f) < 0) {
860 Py_DECREF(f); 860 Py_DECREF(f);
861 return -1; 861 return -1;
935 935
936 if (!(v = PyObject_GetAttrString(err, "filename"))) 936 if (!(v = PyObject_GetAttrString(err, "filename")))
937 goto finally; 937 goto finally;
938 if (v == Py_None) 938 if (v == Py_None)
939 *filename = NULL; 939 *filename = NULL;
940 else if (! (*filename = PyString_AsString(v))) 940 else if (! (*filename = PyBytes_AsString(v)))
941 goto finally; 941 goto finally;
942 942
943 Py_DECREF(v); 943 Py_DECREF(v);
944 if (!(v = PyObject_GetAttrString(err, "lineno"))) 944 if (!(v = PyObject_GetAttrString(err, "lineno")))
945 goto finally; 945 goto finally;
967 967
968 if (!(v = PyObject_GetAttrString(err, "text"))) 968 if (!(v = PyObject_GetAttrString(err, "text")))
969 goto finally; 969 goto finally;
970 if (v == Py_None) 970 if (v == Py_None)
971 *text = NULL; 971 *text = NULL;
972 else if (! (*text = PyString_AsString(v))) 972 else if (! (*text = PyBytes_AsString(v)))
973 goto finally; 973 goto finally;
974 Py_DECREF(v); 974 Py_DECREF(v);
975 return 1; 975 return 1;
976 976
977 finally: 977 finally:
1190 1190
1191 moduleName = PyObject_GetAttrString(exception, "__module__"); 1191 moduleName = PyObject_GetAttrString(exception, "__module__");
1192 if (moduleName == NULL) 1192 if (moduleName == NULL)
1193 err = PyFile_WriteString("<unknown>", f); 1193 err = PyFile_WriteString("<unknown>", f);
1194 else { 1194 else {
1195 char* modstr = PyString_AsString(moduleName); 1195 char* modstr = PyBytes_AsString(moduleName);
1196 if (modstr && strcmp(modstr, "exceptions")) 1196 if (modstr && strcmp(modstr, "exceptions"))
1197 { 1197 {
1198 err = PyFile_WriteString(modstr, f); 1198 err = PyFile_WriteString(modstr, f);
1199 err += PyFile_WriteString(".", f); 1199 err += PyFile_WriteString(".", f);
1200 } 1200 }
1214 /* only print colon if the str() of the 1214 /* only print colon if the str() of the
1215 object is not the empty string 1215 object is not the empty string
1216 */ 1216 */
1217 if (s == NULL) 1217 if (s == NULL)
1218 err = -1; 1218 err = -1;
1219 else if (!PyString_Check(s) || 1219 else if (!PyBytes_Check(s) ||
1220 PyString_GET_SIZE(s) != 0) 1220 PyBytes_GET_SIZE(s) != 0)
1221 err = PyFile_WriteString(": ", f); 1221 err = PyFile_WriteString(": ", f);
1222 if (err == 0) 1222 if (err == 0)
1223 err = PyFile_WriteObject(s, f, Py_PRINT_RAW); 1223 err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
1224 Py_XDECREF(s); 1224 Py_XDECREF(s);
1225 } 1225 }
1534 PyObject *type, *value, *tb; 1534 PyObject *type, *value, *tb;
1535 PyErr_Fetch(&type, &value, &tb); 1535 PyErr_Fetch(&type, &value, &tb);
1536 if (value != NULL) { 1536 if (value != NULL) {
1537 u = PyObject_Str(value); 1537 u = PyObject_Str(value);
1538 if (u != NULL) { 1538 if (u != NULL) {
1539 msg = PyString_AsString(u); 1539 msg = PyBytes_AsString(u);
1540 } 1540 }
1541 } 1541 }
1542 if (msg == NULL) 1542 if (msg == NULL)
1543 msg = "unknown decode error"; 1543 msg = "unknown decode error";
1544 Py_XDECREF(type); 1544 Py_XDECREF(type);