We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3e9f73 commit 6edcc74Copy full SHA for 6edcc74
Lib/pdb.py
@@ -139,14 +139,11 @@ def find_function(funcname, filename):
139
if funcdef:
140
try:
141
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
148
except SyntaxError:
149
continue
+ # We should always be able to find the code object here
+ funccode = next(const for const in code.co_consts if
+ isinstance(const, CodeType) and const.co_name == funcname)
150
lineno_offset = find_first_executable_line(funccode)
151
return funcname, filename, funcstart + lineno_offset - 1
152
return None
0 commit comments