diff options
| author | Benjamin Peterson <benjamin@python.org> | 2017-01-02 04:09:30 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2017-01-02 04:09:30 (GMT) |
| commit | e953a7237668e03b698ca5d241329cc7147c2040 (patch) | |
| tree | 306179651c2f5eb32e085c46142d7f037b14568c /Lib | |
| parent | 6784be1d00c700fce08fd35ce94f0696dedbe493 (diff) | |
| parent | 6215e524a2453c4c4d4e452ba90e8f37de5df5db (diff) | |
| download | cpython-e953a7237668e03b698ca5d241329cc7147c2040.zip cpython-e953a7237668e03b698ca5d241329cc7147c2040.tar.gz cpython-e953a7237668e03b698ca5d241329cc7147c2040.tar.bz2 | |
merge heads
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/inspect.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_inspect.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index e08e9f5..ba7a913 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1416,7 +1416,7 @@ def getframeinfo(frame, context=1): except OSError: lines = index = None else: - start = max(start, 1) + start = max(start, 0) start = max(0, min(start, len(lines) - context)) lines = lines[start:start+context] index = lineno - 1 - start diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 1be9a12..9d9fedc 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -399,6 +399,11 @@ class TestRetrievingSourceCode(GetSourceBase): # Check filename override self.assertEqual(inspect.getmodule(None, modfile), mod) + def test_getframeinfo_get_first_line(self): + frame_info = inspect.getframeinfo(self.fodderModule.fr, 50) + self.assertEqual(frame_info.code_context[0], "# line 1\n") + self.assertEqual(frame_info.code_context[1], "'A module docstring.'\n") + def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) self.assertSourceEqual(mod.StupidGit, 21, 51) |
