[Python-checkins] cpython (merge 3.6 -> 3.6): merge heads
benjamin.peterson
python-checkins at python.org
Sun Jan 1 23:09:51 EST 2017
https://hg.python.org/cpython/rev/7a682d11bdc0
changeset: 105946:7a682d11bdc0
branch: 3.6
parent: 105943:26862e593371
parent: 105937:410caf255a09
user: Benjamin Peterson <benjamin at python.org>
date: Sun Jan 01 22:09:18 2017 -0600
summary:
merge heads
files:
Lib/inspect.py | 2 +-
Lib/test/test_inspect.py | 5 +++++
Misc/NEWS | 3 +++
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1416,7 +1416,7 @@
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
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -402,6 +402,11 @@
# 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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@
Library
-------
+- Issue #15812: inspect.getframeinfo() now correctly shows the first line of
+ a context. Patch by Sam Breese.
+
- Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list