[issue11726] linecache becomes specific to Python scripts in Python 3
report at bugs.python.org
Thu Mar 31 12:08:02 CEST 2011
New submission from STINNER Victor <victor.stinner at haypocalc.com>:
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.
assignee: docs at python
components: Documentation, Library (Lib)
nosy: docs at python, haypo
title: linecache becomes specific to Python scripts in Python 3
versions: Python 3.1, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list