From: Neal Norwitz Date: Tue, 21 Feb 2006 09:19:45 +0000 (+0000) Subject: Backport 41753: X-Git-Tag: v2.4.3c1~59 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f5124e410b4fbd36a6620dfcedb0eaef346b3c4;p=thirdparty%2FPython%2Fcpython.git Backport 41753: Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter. Also bug #1435487 (dup). --- diff --git a/Misc/NEWS b/Misc/NEWS index 3721a727395b..d6f064bb96d3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ What's New in Python 2.4.3c1? Core and builtins ----------------- +- Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter. + - Patch #1400181, fix unicode string formatting to not use the locale. This is how string objects work. u'%f' could use , instead of . for the decimal point. Now both strings and unicode always use periods. diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index e128e85a5e12..43c3ed6f670b 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -289,6 +289,12 @@ check_coding_spec(const char* line, int size, struct tok_state *tok, PyMem_DEL(cs); } } + if (!r) { + cs = tok->encoding; + if (!cs) + cs = "with BOM"; + PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs); + } return r; }