summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-03-05 23:29:08 (GMT)
committerGitHub <noreply@github.com>2018-03-05 23:29:08 (GMT)
commitb9650a04a81355c8a7dcd0464c28febfb4bfc0a9 (patch)
tree300f17ad90d32a049c7b0ce53b434679dac86a06 /Lib/inspect.py
parent6921e73e33edc3c61bc2d78ed558eaa22a89a564 (diff)
downloadcpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.zip
cpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.tar.gz
cpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.tar.bz2
bpo-32991: Restore expectation that inspect.getfile raises TypeError on namespace package (GH-5980)
* bpo-32991: Add test capturing expectation. DocTestFinder.find should return an empty list for doctests in a namespace package. * bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 109efc0..57c0487 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -642,13 +642,13 @@ def cleandoc(doc):
def getfile(object):
"""Work out which source or compiled file an object was defined in."""
if ismodule(object):
- if hasattr(object, '__file__'):
+ if getattr(object, '__file__', None):
return object.__file__
raise TypeError('{!r} is a built-in module'.format(object))
if isclass(object):
if hasattr(object, '__module__'):
object = sys.modules.get(object.__module__)
- if hasattr(object, '__file__'):
+ if getattr(object, '__file__', None):
return object.__file__
raise TypeError('{!r} is a built-in class'.format(object))
if ismethod(object):