Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 35418:37fa7b6dca9b 2.4
Forward UnicodeDecodeError into SyntaxError for source encoding errors.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 24 Aug 2005 08:39:46 +0000 |
| parents | 28892e6512ba |
| children | 6c3d0a0c1956 |
comparison
equal
deleted
inserted
replaced
| 35416:4896f8334bff | 35418:37fa7b6dca9b |
|---|---|
| 1469 break; | 1469 break; |
| 1470 case E_TOODEEP: | 1470 case E_TOODEEP: |
| 1471 errtype = PyExc_IndentationError; | 1471 errtype = PyExc_IndentationError; |
| 1472 msg = "too many levels of indentation"; | 1472 msg = "too many levels of indentation"; |
| 1473 break; | 1473 break; |
| 1474 case E_DECODE: { /* XXX */ | 1474 case E_DECODE: { |
| 1475 PyThreadState* tstate = PyThreadState_GET(); | 1475 PyObject *type, *value, *tb; |
| 1476 PyObject* value = tstate->curexc_value; | 1476 PyErr_Fetch(&type, &value, &tb); |
| 1477 if (value != NULL) { | 1477 if (value != NULL) { |
| 1478 u = PyObject_Repr(value); | 1478 u = PyObject_Str(value); |
| 1479 if (u != NULL) { | 1479 if (u != NULL) { |
| 1480 msg = PyString_AsString(u); | 1480 msg = PyString_AsString(u); |
| 1481 break; | |
| 1482 } | 1481 } |
| 1483 } | 1482 } |
| 1484 if (msg == NULL) | 1483 if (msg == NULL) |
| 1485 msg = "unknown decode error"; | 1484 msg = "unknown decode error"; |
| 1485 Py_DECREF(type); | |
| 1486 Py_DECREF(value); | |
| 1487 Py_DECREF(tb); | |
| 1486 break; | 1488 break; |
| 1487 } | 1489 } |
| 1488 default: | 1490 default: |
| 1489 fprintf(stderr, "error=%d\n", err->error); | 1491 fprintf(stderr, "error=%d\n", err->error); |
| 1490 msg = "unknown parsing error"; | 1492 msg = "unknown parsing error"; |
