[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5 (Issue #24669)
yury.selivanov
python-checkins at python.org
Tue Jul 21 18:04:55 CEST 2015
https://hg.python.org/cpython/rev/6629773fef63
changeset: 96978:6629773fef63
parent: 96976:c3fa46d85857
parent: 96977:f02c5bf59fbb
user: Yury Selivanov <yselivanov at sprymix.com>
date: Tue Jul 21 19:04:22 2015 +0300
summary:
Merge 3.5 (Issue #24669)
files:
Lib/inspect.py | 2 +-
Lib/test/inspect_fodder.py | 3 +++
Lib/test/test_inspect.py | 2 ++
Misc/NEWS | 2 ++
4 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -798,7 +798,7 @@
if not hasattr(object, 'co_firstlineno'):
raise OSError('could not find function definition')
lnum = object.co_firstlineno - 1
- pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
+ pat = re.compile(r'^(\s*def\s)|(\s*async\s+def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
while lnum > 0:
if pat.match(lines[lnum]): break
lnum = lnum - 1
diff --git a/Lib/test/inspect_fodder.py b/Lib/test/inspect_fodder.py
--- a/Lib/test/inspect_fodder.py
+++ b/Lib/test/inspect_fodder.py
@@ -66,3 +66,6 @@
pass
def contradiction(self):
pass
+
+async def lobbest(grenade):
+ pass
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
@@ -336,6 +336,7 @@
def test_getfunctions(self):
functions = inspect.getmembers(mod, inspect.isfunction)
self.assertEqual(functions, [('eggs', mod.eggs),
+ ('lobbest', mod.lobbest),
('spam', mod.spam)])
@unittest.skipIf(sys.flags.optimize >= 2,
@@ -393,6 +394,7 @@
def test_getsource(self):
self.assertSourceEqual(git.abuse, 29, 39)
self.assertSourceEqual(mod.StupidGit, 21, 50)
+ self.assertSourceEqual(mod.lobbest, 70, 71)
def test_getsourcefile(self):
self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -64,6 +64,8 @@
- Issue #6549: Remove hyphen from ttk.Style().element options. Only return result
from ttk.Style().configure if a result was generated or a query submitted.
+- Issue #24669: Fix inspect.getsource() for 'async def' functions.
+ Patch by Kai Groner.
What's New in Python 3.5.0 beta 3?
==================================
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list