]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #11726: Fix linecache example in the doc
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 18 Mar 2015 13:16:50 +0000 (14:16 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 18 Mar 2015 13:16:50 +0000 (14:16 +0100)
Use a Python source file (linecache.__file__) instead of /etc/passwd.

Modify also linecache docstrings to clarify the linecache is written to cache
Python source files, not any text files.

Doc/library/linecache.rst
Lib/linecache.py

index 0c096ada91559d1ff1002157cc2abb466a4fdf99..e9ec8017633a528b5116e488f077bf72b43034e1 100644 (file)
@@ -51,5 +51,5 @@ The :mod:`linecache` module defines the following functions:
 Example::
 
    >>> import linecache
-   >>> linecache.getline('/etc/passwd', 4)
-   'sys:x:3:3:sys:/dev:/bin/sh\n'
+   >>> linecache.getline(linecache.__file__, 8)
+   'import sys\n'
index 02a9eb52530f46e57d32025866e3f46750a58360..e505b031240bfdcbbe116380852d3a10ec1167ec 100644 (file)
@@ -1,4 +1,4 @@
-"""Cache lines from files.
+"""Cache lines from Python source files.
 
 This is intended to read lines from modules imported -- hence if a filename
 is not found, it will look down the module search path for a file by
@@ -32,7 +32,7 @@ def clearcache():
 
 
 def getlines(filename, module_globals=None):
-    """Get the lines for a file from the cache.
+    """Get the lines for a Python source file from the cache.
     Update the cache if it doesn't contain an entry for this file already."""
 
     if filename in cache: