comparison Python/pythonrun.c @ 24539:06f1e2fd05bc legacy-trunk

Patch #534304: Implement phase 1 of PEP 263.
author Martin v. Löwis <martin@v.loewis.de>
date Sun, 04 Aug 2002 17:29:52 +0000
parents 8ee2ab4f2a2d
children 17e95cc06f69
comparison
equal deleted inserted replaced
24538:8d5e0e3f6445 24539:06f1e2fd05bc
1219 1219
1220 static void 1220 static void
1221 err_input(perrdetail *err) 1221 err_input(perrdetail *err)
1222 { 1222 {
1223 PyObject *v, *w, *errtype; 1223 PyObject *v, *w, *errtype;
1224 PyObject* u = NULL;
1224 char *msg = NULL; 1225 char *msg = NULL;
1225 errtype = PyExc_SyntaxError; 1226 errtype = PyExc_SyntaxError;
1226 v = Py_BuildValue("(ziiz)", err->filename, 1227 v = Py_BuildValue("(ziiz)", err->filename,
1227 err->lineno, err->offset, err->text); 1228 err->lineno, err->offset, err->text);
1228 if (err->text != NULL) { 1229 if (err->text != NULL) {
1270 break; 1271 break;
1271 case E_TOODEEP: 1272 case E_TOODEEP:
1272 errtype = PyExc_IndentationError; 1273 errtype = PyExc_IndentationError;
1273 msg = "too many levels of indentation"; 1274 msg = "too many levels of indentation";
1274 break; 1275 break;
1276 case E_DECODE: { /* XXX */
1277 PyThreadState* tstate = PyThreadState_Get();
1278 PyObject* value = tstate->curexc_value;
1279 if (value != NULL) {
1280 u = PyObject_Repr(value);
1281 if (u != NULL) {
1282 msg = PyString_AsString(u);
1283 break;
1284 }
1285 }
1286 }
1275 default: 1287 default:
1276 fprintf(stderr, "error=%d\n", err->error); 1288 fprintf(stderr, "error=%d\n", err->error);
1277 msg = "unknown parsing error"; 1289 msg = "unknown parsing error";
1278 break; 1290 break;
1279 } 1291 }
1280 w = Py_BuildValue("(sO)", msg, v); 1292 w = Py_BuildValue("(sO)", msg, v);
1293 Py_XDECREF(u);
1281 Py_XDECREF(v); 1294 Py_XDECREF(v);
1282 PyErr_SetObject(errtype, w); 1295 PyErr_SetObject(errtype, w);
1283 Py_XDECREF(w); 1296 Py_XDECREF(w);
1284 } 1297 }
1285 1298