This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients docs@python, vstinner
Date 2011-03-31.10:07:51
SpamBayes Score 1.1111999e-06
Marked as misclassified No
Message-id <1301566082.59.0.198488725536.issue11726@psf.upfronthosting.co.za>
In-reply-to
Content
linecache document doesn't tell that the module reads the #coding:xxx cookie to get the encoding of the Python file. linecache reads this cookie since 41665 (May 09 2007).

"The linecache module allows one to get any line from any file, ..."

=> "any file"!

And the example uses /etc/passwd which is not a Python file.

Not only it reads the #coding:xxx cookie, but updatecache() tries also a PEP 302 loader to read the file.

linecache should be marked as very specific to Python scripts, or it should be patched to become more generic (don't read the cookie / use loader by default).

Note: the locale encoding may change between to calls to the linecache module.
History
Date User Action Args
2011-03-31 10:08:02vstinnersetrecipients: + vstinner, docs@python
2011-03-31 10:08:02vstinnersetmessageid: <1301566082.59.0.198488725536.issue11726@psf.upfronthosting.co.za>
2011-03-31 10:07:51vstinnerlinkissue11726 messages
2011-03-31 10:07:51vstinnercreate