Karthikeyan Singaravelan <[email protected]> added the comment:
It's not necessarily the first line. The code is executed with the context of
the given file. Hence the corresponding line number of error from traceback
with respect to file is printed.
$ cat /tmp/passwd
line 1
line 2
line 3
line 4
$ python3 -c 'compile("\n\n\nyield", "/tmp/passwd", "exec")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/passwd", line 4
line 4
^
SyntaxError: 'yield' outside function
----------
nosy: +xtreak
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38985>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com