Skip to content

Commit d4090e9

Browse files
committed
fixup! Fix repl
1 parent 023e8ef commit d4090e9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/linecache.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def getlines(filename, module_globals=None):
4545
return []
4646

4747

48-
def _getline_from_code(filename, lineno, module_globals=None):
49-
lines = _getlines_from_code(filename, module_globals)
48+
def _getline_from_code(filename, lineno):
49+
lines = _getlines_from_code(filename)
5050
if 1 <= lineno <= len(lines):
5151
return lines[lineno - 1]
5252
return ''
5353

5454

55-
def _getlines_from_code(code, module_globals=None):
55+
def _getlines_from_code(code):
5656
code_id = id(code)
5757
if code_id in _interactive_cache:
5858
entry = _interactive_cache[code_id]

Lib/test/test_linecache.py

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from importlib.machinery import ModuleSpec
99
from test import support
1010
from test.support import os_helper
11+
from test.support.script_helper import assert_python_ok
1112

1213

1314
FILENAME = linecache.__file__
@@ -311,6 +312,12 @@ def test_invalid_names(self):
311312
# just to be sure that we did not mess with cache
312313
linecache.clearcache()
313314

315+
def test_linecache_python_string(self):
316+
cmdline = "import linecache;assert len(linecache.cache) == 0"
317+
retcode, stdout, stderr = assert_python_ok('-c', cmdline)
318+
self.assertEqual(retcode, 0)
319+
self.assertEqual(stdout, b'')
320+
self.assertEqual(stderr, b'')
314321

315322
class LineCacheInvalidationTests(unittest.TestCase):
316323
def setUp(self):

0 commit comments

Comments
 (0)