There was an error while loading. Please reload this page.
1 parent 50b82c7 commit 1064a13Copy full SHA for 1064a13
2 files changed
Lib/test/test_traceback.py
@@ -146,6 +146,10 @@ def do_test(firstlines, message, charset, lineno):
146
text, charset, 4)
147
do_test("#!shebang\n# coding: {0}\n".format(charset),
148
text, charset, 5)
149
+ do_test(" \t\f\n# coding: {0}\n".format(charset),
150
+ text, charset, 5)
151
+ # Issue #18960: coding spec should has no effect
152
+ do_test("0\n# coding: GBK\n", "h\xe9 ho", 'utf-8', 5)
153
154
155
class TracebackFormatTests(unittest.TestCase):
Parser/tokenizer.c
@@ -514,14 +514,6 @@ fp_setreadl(struct tok_state *tok, const char* enc)
514
readline = _PyObject_GetAttrId(stream, &PyId_readline);
515
tok->decoding_readline = readline;
516
517
- /* The file has been reopened; parsing will restart from
518
- * the beginning of the file, we have to reset the line number.
519
- * But this function has been called from inside tok_nextc() which
520
- * will increment lineno before it returns. So we set it -1 so that
521
- * the next call to tok_nextc() will start with tok->lineno == 0.
522
- */
523
- tok->lineno = -1;
524
-
525
cleanup:
526
Py_XDECREF(stream);
527
Py_XDECREF(io);
0 commit comments