Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add __module__ check for inspect.getsource
  • Loading branch information
gaogaotiantian committed Jul 21, 2023
commit 7ff082f25ddd3fb4b7b2eca5131a5267042e69cb
3 changes: 2 additions & 1 deletion Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,8 @@ def get_lineno(self):

# First, let's see if there are any method definitions
for member in self.cls.__dict__.values():
if isinstance(member, types.FunctionType):
if isinstance(member, types.FunctionType) and \
Comment thread
gaogaotiantian marked this conversation as resolved.
Outdated
member.__module__ == self.cls.__module__:
for lineno, end_lineno in self.lineno_found:
if lineno <= member.__code__.co_firstlineno <= end_lineno:
return lineno
Expand Down