Skip to content

Commit f0efff0

Browse files
authored
gh-131628: use dock-typing in inspect.getfile
1 parent 64906bb commit f0efff0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/inspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def isgetsetdescriptor(object):
265265
return False
266266

267267
def isfunction(object):
268-
"""Return true if the object is a user-defined function.
268+
"""Return true if the object is a user-defined Python function.
269269
270270
Function objects provide these attributes:
271271
__doc__ documentation string
@@ -828,9 +828,9 @@ def getfile(object):
828828
if object.__module__ == '__main__':
829829
raise OSError('source code not available')
830830
raise TypeError('{!r} is a built-in class'.format(object))
831-
if ismethod(object):
831+
if hasattr(object, '__func__'):
832832
object = object.__func__
833-
if isfunction(object):
833+
if hasattr(object, '__code__'):
834834
object = object.__code__
835835
if istraceback(object):
836836
object = object.tb_frame

0 commit comments

Comments
 (0)