]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 41753:
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Feb 2006 09:19:45 +0000 (09:19 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 21 Feb 2006 09:19:45 +0000 (09:19 +0000)
  Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
  Also bug #1435487 (dup).

Misc/NEWS
Parser/tokenizer.c

index 3721a727395bb089e329c80fc0b0fc249f8aa3c9..d6f064bb96d3c95ab950516c9d307fe4b2c9a6d9 100644 (file)
--- 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.
index e128e85a5e1298b207b2e13761455c01bf189ac7..43c3ed6f670bc5827201fe9ce264320f9581d5e2 100644 (file)
@@ -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;
 }