summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/patches/fix-traceback.patch
blob: 382459adb07d30cfae9d563259a26fa4e4f08f48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
commit 8a9d74e955c9e66e23ca423181d6b4f3b2f35234
merge: 69071b279955ab8dd08fad10b2540b9f6bae2825 efd33904df73f0175583058fedc0d7234cac6b45
author: orivej
date: 2019-07-06T14:14:55+03:00
revision: 5216942

    Fix tracebacks in py2 import_test and do not read builtin source from FS. DEVTOOLS-5629
    
    REVIEW: 869505
    Note: mandatory check (NEED_CHECK) was skipped

--- a/Lib/linecache.py	(69071b279955ab8dd08fad10b2540b9f6bae2825)
+++ b/Lib/linecache.py	(8a9d74e955c9e66e23ca423181d6b4f3b2f35234)
@@ -111,6 +111,7 @@ def updatecache(filename, module_globals=None):
         import os
         import sys
         import tokenize
+        import __res
     except ImportError:
         # These import can fail if the interpreter is shutting down
         return []
@@ -120,6 +121,12 @@ def updatecache(filename, module_globals=None):
     if not filename or (filename.startswith('<') and filename.endswith('>')):
         return []
 
+    # Do not read builtin code from the filesystem.
+    if data := __res.resfs_read(__res.py_src_key(filename)):
+        lines = data.decode('UTF-8').splitlines(keepends=True)
+        cache[filename] = len(data), None, lines, filename
+        return cache[filename][2]
+
     fullname = filename
     try:
         stat = os.stat(fullname)