comparison Python/pythonrun.c @ 48660:85b67fb5672b

Rename PyUnicode_AsString -> _PyUnicode_AsString and PyUnicode_AsStringAndSize -> _PyUnicode_AsStringAndSize to mark them for interpreter internal use only. We'll have to rework these APIs or create new ones for the purpose of accessing the UTF-8 representation of Unicode objects for 3.1.
author Marc-André Lemburg <mal@egenix.com>
date Thu, 07 Aug 2008 18:54:33 +0000
parents b51cd5d3795c
children 587cd4f66c2d
comparison
equal deleted inserted replaced
48659:042d16a05016 48660:85b67fb5672b
801 /* Same as hack above, pre-import stderr's codec to avoid recursion 801 /* Same as hack above, pre-import stderr's codec to avoid recursion
802 when import.c tries to write to stderr in verbose mode. */ 802 when import.c tries to write to stderr in verbose mode. */
803 encoding_attr = PyObject_GetAttrString(std, "encoding"); 803 encoding_attr = PyObject_GetAttrString(std, "encoding");
804 if (encoding_attr != NULL) { 804 if (encoding_attr != NULL) {
805 const char * encoding; 805 const char * encoding;
806 encoding = PyUnicode_AsString(encoding_attr); 806 encoding = _PyUnicode_AsString(encoding_attr);
807 if (encoding != NULL) { 807 if (encoding != NULL) {
808 _PyCodec_Lookup(encoding); 808 _PyCodec_Lookup(encoding);
809 } 809 }
810 } 810 }
811 PyErr_Clear(); /* Not a fatal error if codec isn't available */ 811 PyErr_Clear(); /* Not a fatal error if codec isn't available */
907 if (v == NULL || v == Py_None) 907 if (v == NULL || v == Py_None)
908 return -1; 908 return -1;
909 oenc = PyObject_GetAttrString(v, "encoding"); 909 oenc = PyObject_GetAttrString(v, "encoding");
910 if (!oenc) 910 if (!oenc)
911 return -1; 911 return -1;
912 enc = PyUnicode_AsString(oenc); 912 enc = _PyUnicode_AsString(oenc);
913 } 913 }
914 v = PySys_GetObject("ps1"); 914 v = PySys_GetObject("ps1");
915 if (v != NULL) { 915 if (v != NULL) {
916 v = PyObject_Str(v); 916 v = PyObject_Str(v);
917 if (v == NULL) 917 if (v == NULL)
918 PyErr_Clear(); 918 PyErr_Clear();
919 else if (PyUnicode_Check(v)) 919 else if (PyUnicode_Check(v))
920 ps1 = PyUnicode_AsString(v); 920 ps1 = _PyUnicode_AsString(v);
921 } 921 }
922 w = PySys_GetObject("ps2"); 922 w = PySys_GetObject("ps2");
923 if (w != NULL) { 923 if (w != NULL) {
924 w = PyObject_Str(w); 924 w = PyObject_Str(w);
925 if (w == NULL) 925 if (w == NULL)
926 PyErr_Clear(); 926 PyErr_Clear();
927 else if (PyUnicode_Check(w)) 927 else if (PyUnicode_Check(w))
928 ps2 = PyUnicode_AsString(w); 928 ps2 = _PyUnicode_AsString(w);
929 } 929 }
930 arena = PyArena_New(); 930 arena = PyArena_New();
931 if (arena == NULL) { 931 if (arena == NULL) {
932 Py_XDECREF(v); 932 Py_XDECREF(v);
933 Py_XDECREF(w); 933 Py_XDECREF(w);
1099 1099
1100 if (!(v = PyObject_GetAttrString(err, "filename"))) 1100 if (!(v = PyObject_GetAttrString(err, "filename")))
1101 goto finally; 1101 goto finally;
1102 if (v == Py_None) 1102 if (v == Py_None)
1103 *filename = NULL; 1103 *filename = NULL;
1104 else if (! (*filename = PyUnicode_AsString(v))) 1104 else if (! (*filename = _PyUnicode_AsString(v)))
1105 goto finally; 1105 goto finally;
1106 1106
1107 Py_DECREF(v); 1107 Py_DECREF(v);
1108 if (!(v = PyObject_GetAttrString(err, "lineno"))) 1108 if (!(v = PyObject_GetAttrString(err, "lineno")))
1109 goto finally; 1109 goto finally;
1132 if (!(v = PyObject_GetAttrString(err, "text"))) 1132 if (!(v = PyObject_GetAttrString(err, "text")))
1133 goto finally; 1133 goto finally;
1134 if (v == Py_None) 1134 if (v == Py_None)
1135 *text = NULL; 1135 *text = NULL;
1136 else if (!PyUnicode_Check(v) || 1136 else if (!PyUnicode_Check(v) ||
1137 !(*text = PyUnicode_AsString(v))) 1137 !(*text = _PyUnicode_AsString(v)))
1138 goto finally; 1138 goto finally;
1139 Py_DECREF(v); 1139 Py_DECREF(v);
1140 return 1; 1140 return 1;
1141 1141
1142 finally: 1142 finally:
1355 { 1355 {
1356 Py_DECREF(moduleName); 1356 Py_DECREF(moduleName);
1357 err = PyFile_WriteString("<unknown>", f); 1357 err = PyFile_WriteString("<unknown>", f);
1358 } 1358 }
1359 else { 1359 else {
1360 char* modstr = PyUnicode_AsString(moduleName); 1360 char* modstr = _PyUnicode_AsString(moduleName);
1361 if (modstr && strcmp(modstr, "builtins")) 1361 if (modstr && strcmp(modstr, "builtins"))
1362 { 1362 {
1363 err = PyFile_WriteString(modstr, f); 1363 err = PyFile_WriteString(modstr, f);
1364 err += PyFile_WriteString(".", f); 1364 err += PyFile_WriteString(".", f);
1365 } 1365 }
1804 PyObject *type, *value, *tb; 1804 PyObject *type, *value, *tb;
1805 PyErr_Fetch(&type, &value, &tb); 1805 PyErr_Fetch(&type, &value, &tb);
1806 if (value != NULL) { 1806 if (value != NULL) {
1807 u = PyObject_Str(value); 1807 u = PyObject_Str(value);
1808 if (u != NULL) { 1808 if (u != NULL) {
1809 msg = PyUnicode_AsString(u); 1809 msg = _PyUnicode_AsString(u);
1810 } 1810 }
1811 } 1811 }
1812 if (msg == NULL) 1812 if (msg == NULL)
1813 msg = "unknown decode error"; 1813 msg = "unknown decode error";
1814 Py_XDECREF(type); 1814 Py_XDECREF(type);