Skip to content

Commit 6edcc74

Browse files
Update the funccode retrieval
1 parent b3e9f73 commit 6edcc74

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Lib/pdb.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,11 @@ def find_function(funcname, filename):
139139
if funcdef:
140140
try:
141141
code = compile(funcdef, filename, 'exec')
142-
for const in code.co_consts:
143-
if isinstance(const, CodeType) and const.co_name == funcname:
144-
funccode = const
145-
break
146-
else:
147-
continue
148142
except SyntaxError:
149143
continue
144+
# We should always be able to find the code object here
145+
funccode = next(const for const in code.co_consts if
146+
isinstance(const, CodeType) and const.co_name == funcname)
150147
lineno_offset = find_first_executable_line(funccode)
151148
return funcname, filename, funcstart + lineno_offset - 1
152149
return None

0 commit comments

Comments
 (0)