aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-03-05 18:29:08 -0500
committerGitHub <noreply@github.com>2018-03-05 18:29:08 -0500
commitb9650a04a81355c8a7dcd0464c28febfb4bfc0a9 (patch)
tree300f17ad90d32a049c7b0ce53b434679dac86a06 /Lib/inspect.py
parentbpo-33001: Prevent buffer overrun in os.symlink (GH-5989) (diff)
downloadcpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.tar.gz
cpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.tar.bz2
cpython-b9650a04a81355c8a7dcd0464c28febfb4bfc0a9.zip
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 109efc06b26..57c04877c74 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):