encoding marker may only appear on the first two lines per PEP263 · Issue #529 · nedbat/coveragepy (original) (raw)

Originally reported by gpshead (Bitbucket: gpshead, GitHub: gpshead)


The file text encoding marker must only be paid attention to if it falls on the first two lines of the file.

(confirmed by testing that a coding marker in a comment on line 3 is ignored in CPython 2.7 and 3.4)

The bug appears to be in https://bitbucket.org/ned/coveragepy/src/eb9f4a94096cca9863352f600994340caf4f6927/coverage/phystokens.py?at=default&fileviewer=file-view-default#phystokens.py-291 phystokens.neuter_encoding_declaration which neuters the first two encoding declarations seen in a file instead of only within the first two lines.