Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93f0665

Browse files
committed
Issue #11726: clarify linecache doc: linecache is written to cache Python
source files, even if "it works" with other text files encoded to UTF-8.
1 parent 6a318d4 commit 93f0665

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Doc/library/linecache.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99

1010
--------------
1111

12-
The :mod:`linecache` module allows one to get any line from any file, while
12+
The :mod:`linecache` module allows one to get any line from a Python source file, while
1313
attempting to optimize internally, using a cache, the common case where many
1414
lines are read from a single file. This is used by the :mod:`traceback` module
1515
to retrieve source lines for inclusion in the formatted traceback.
1616

17+
The :func:`tokenize.open` function is used to open Python source files. This
18+
function uses :func:`tokenize.detect_encoding` to get the encoding of the
19+
Python source file.
20+
1721
The :mod:`linecache` module defines the following functions:
1822

1923

@@ -49,4 +53,3 @@ Example::
4953
>>> import linecache
5054
>>> linecache.getline('/etc/passwd', 4)
5155
'sys:x:3:3:sys:/dev:/bin/sh\n'
52-

0 commit comments

Comments
 (0)