mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141982: Fix pdb can't set breakpoints on async functions (#141983)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
parent
2dc28eb8b0
commit
fddc24e4c8
3 changed files with 21 additions and 1 deletions
|
|
@ -130,7 +130,7 @@ def find_first_executable_line(code):
|
|||
return code.co_firstlineno
|
||||
|
||||
def find_function(funcname, filename):
|
||||
cre = re.compile(r'def\s+%s(\s*\[.+\])?\s*[(]' % re.escape(funcname))
|
||||
cre = re.compile(r'(?:async\s+)?def\s+%s(\s*\[.+\])?\s*[(]' % re.escape(funcname))
|
||||
try:
|
||||
fp = tokenize.open(filename)
|
||||
except OSError:
|
||||
|
|
|
|||
|
|
@ -4587,6 +4587,25 @@ def bar():
|
|||
]))
|
||||
self.assertIn('break in bar', stdout)
|
||||
|
||||
@unittest.skipIf(SKIP_CORO_TESTS, "Coroutine tests are skipped")
|
||||
def test_async_break(self):
|
||||
script = """
|
||||
import asyncio
|
||||
|
||||
async def main():
|
||||
pass
|
||||
|
||||
asyncio.run(main())
|
||||
"""
|
||||
commands = """
|
||||
break main
|
||||
continue
|
||||
quit
|
||||
"""
|
||||
stdout, stderr = self.run_pdb_script(script, commands)
|
||||
self.assertRegex(stdout, r"Breakpoint 1 at .*main\.py:5")
|
||||
self.assertIn("pass", stdout)
|
||||
|
||||
def test_issue_59000(self):
|
||||
script = """
|
||||
def foo():
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Allow :mod:`pdb` to set breakpoints on async functions with function names.
|
||||
Loading…
Add table
Add a link
Reference in a new issue