Issues #2384 and #3975: Tracebacks were not correctly printed when the source file
contains a ``coding:`` header: the wrong line was displayed, and the encoding was not respected.

Patch by Victor Stinner.
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 18815ae..4edf6d0 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -461,6 +461,14 @@
 	readline = PyObject_GetAttrString(stream, "readline");
 	tok->decoding_readline = readline;
 
+	/* The file has been reopened; parsing will restart from
+	 * the beginning of the file, we have to reset the line number.
+	 * But this function has been called from inside tok_nextc() which
+	 * will increment lineno before it returns. So we set it -1 so that
+	 * the next call to tok_nextc() will start with tok->lineno == 0.
+	 */
+	tok->lineno = -1;
+
   cleanup:
 	Py_XDECREF(stream);
 	Py_XDECREF(io);