diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-03-17 20:43:42 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-03-17 20:43:42 (GMT) |
commit | 259314622750c72de2ef377e77a0b70b8d8b2fb5 (patch) | |
tree | 089ad865c7be59bf68fd72e0d5c18c12d831e345 /Parser/parsetok.c | |
parent | ddaa7064ee81c48adc4fdea327892c29179f7845 (diff) | |
download | cpython-259314622750c72de2ef377e77a0b70b8d8b2fb5.zip cpython-259314622750c72de2ef377e77a0b70b8d8b2fb5.tar.gz cpython-259314622750c72de2ef377e77a0b70b8d8b2fb5.tar.bz2 |
Bug #2301: Don't try decoding the source code into the original
encoding for syntax errors.
Diffstat (limited to 'Parser/parsetok.c')
-rw-r--r-- | Parser/parsetok.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 0b3314e..708c26d 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -213,21 +213,16 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, err_ret->error = E_EOF; err_ret->lineno = tok->lineno; if (tok->buf != NULL) { - char *text = NULL; size_t len; assert(tok->cur - tok->buf < INT_MAX); err_ret->offset = (int)(tok->cur - tok->buf); len = tok->inp - tok->buf; - text = PyTokenizer_RestoreEncoding(tok, len, &err_ret->offset); - if (text == NULL) { - text = (char *) PyObject_MALLOC(len + 1); - if (text != NULL) { - if (len > 0) - strncpy(text, tok->buf, len); - text[len] = '\0'; - } + err_ret->text = (char *) PyObject_MALLOC(len + 1); + if (err_ret->text != NULL) { + if (len > 0) + strncpy(err_ret->text, tok->buf, len); + err_ret->text[len] = '\0'; } - err_ret->text = text; } } else if (tok->encoding != NULL) { node* r = PyNode_New(encoding_decl); |