mirror of https://github.com/python/cpython
merge heads
This commit is contained in:
commit
e953a72376
|
@ -1416,7 +1416,7 @@ def getframeinfo(frame, context=1):
|
||||||
except OSError:
|
except OSError:
|
||||||
lines = index = None
|
lines = index = None
|
||||||
else:
|
else:
|
||||||
start = max(start, 1)
|
start = max(start, 0)
|
||||||
start = max(0, min(start, len(lines) - context))
|
start = max(0, min(start, len(lines) - context))
|
||||||
lines = lines[start:start+context]
|
lines = lines[start:start+context]
|
||||||
index = lineno - 1 - start
|
index = lineno - 1 - start
|
||||||
|
|
|
@ -399,6 +399,11 @@ class TestRetrievingSourceCode(GetSourceBase):
|
||||||
# Check filename override
|
# Check filename override
|
||||||
self.assertEqual(inspect.getmodule(None, modfile), mod)
|
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):
|
def test_getsource(self):
|
||||||
self.assertSourceEqual(git.abuse, 29, 39)
|
self.assertSourceEqual(git.abuse, 29, 39)
|
||||||
self.assertSourceEqual(mod.StupidGit, 21, 51)
|
self.assertSourceEqual(mod.StupidGit, 21, 51)
|
||||||
|
|
|
@ -208,6 +208,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #15812: inspect.getframeinfo() now correctly shows the first line of
|
||||||
|
a context. Patch by Sam Breese.
|
||||||
|
|
||||||
- Issue #28985: Update authorizer constants in sqlite3 module.
|
- Issue #28985: Update authorizer constants in sqlite3 module.
|
||||||
Patch by Dingyuan Wang.
|
Patch by Dingyuan Wang.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue