summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-04-28 17:06:46 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-04-28 17:06:46 (GMT)
commit003a5e702bcc0eecedb9cac0fae25b183f9525da (patch)
treeb0aa78e4ce87a566bf31a08a2195ce771f50958a /Parser
parent740f53a6006cc8d8897a843394700cd8ec0dc0d6 (diff)
downloadcpython-003a5e702bcc0eecedb9cac0fae25b183f9525da.zip
cpython-003a5e702bcc0eecedb9cac0fae25b183f9525da.tar.gz
cpython-003a5e702bcc0eecedb9cac0fae25b183f9525da.tar.bz2
Use PyErr_Format() in decoding_fgets()
Avoid a buffer of 500 bytes allocated on the stack.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 77fec74..aef081d 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -580,16 +580,14 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
}
}
if (badchar) {
- char buf[500];
/* Need to add 1 to the line number, since this line
has not been counted, yet. */
- sprintf(buf,
+ PyErr_Format(PyExc_SyntaxError,
"Non-UTF-8 code starting with '\\x%.2x' "
"in file %.200s on line %i, "
"but no encoding declared; "
"see http://python.org/dev/peps/pep-0263/ for details",
badchar, tok->filename, tok->lineno + 1);
- PyErr_SetString(PyExc_SyntaxError, buf);
return error_ret(tok);
}
#endif