[Python-3000-checkins] r58408 - python/branches/py3k/Parser/tokenizer.c
guido.van.rossum
python-3000-checkins at python.org
Wed Oct 10 20:44:40 CEST 2007
Author: guido.van.rossum
Date: Wed Oct 10 20:44:39 2007
New Revision: 58408
Modified:
python/branches/py3k/Parser/tokenizer.c
Log:
Fix an issue in PyTokenizer_RestoreEncoding() which was treating a PyBytes
object with PyString calls and not checking errors. This caused the display
of syntax errors to be deformed.
Modified: python/branches/py3k/Parser/tokenizer.c
==============================================================================
--- python/branches/py3k/Parser/tokenizer.c (original)
+++ python/branches/py3k/Parser/tokenizer.c Wed Oct 10 20:44:39 2007
@@ -1556,7 +1556,10 @@
Py_DECREF(unicode_text);
}
if (!ret) {
- PyErr_Print();
+ PyErr_Clear();
+ }
+ else {
+ assert(PyBytes_Check(ret));
}
return ret;
}
@@ -1569,8 +1572,8 @@
/* convert source to original encondig */
PyObject *lineobj = dec_utf8(tok->encoding, tok->buf, len);
if (lineobj != NULL) {
- int linelen = PyString_Size(lineobj);
- const char *line = PyString_AsString(lineobj);
+ int linelen = PyBytes_GET_SIZE(lineobj);
+ const char *line = PyBytes_AS_STRING(lineobj);
text = PyObject_MALLOC(linelen + 1);
if (text != NULL && line != NULL) {
if (linelen)
@@ -1582,9 +1585,11 @@
/* adjust error offset */
if (*offset > 1) {
PyObject *offsetobj = dec_utf8(tok->encoding,
- tok->buf, *offset-1);
+ tok->buf,
+ *offset-1);
if (offsetobj) {
- *offset = PyString_Size(offsetobj) + 1;
+ *offset = 1 +
+ PyBytes_GET_SIZE(offsetobj);
Py_DECREF(offsetobj);
}
}
More information about the Python-3000-checkins
mailing list