diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-12-13 18:06:53 (GMT) |
---|---|---|
committer | Brett Cannon <54418+brettcannon@users.noreply.github.com> | 2019-12-13 18:06:53 (GMT) |
commit | 8289e27393395ee903bd096d42e07c112d7f15c6 (patch) | |
tree | 42bddfaadcd4bc0e56844ec11c61083f4354df00 /Lib/doctest.py | |
parent | 025a602af7ee284d8db6955c26016f3f27d35536 (diff) | |
download | cpython-8289e27393395ee903bd096d42e07c112d7f15c6.zip cpython-8289e27393395ee903bd096d42e07c112d7f15c6.tar.gz cpython-8289e27393395ee903bd096d42e07c112d7f15c6.tar.bz2 |
bpo-36406: Handle namespace packages in doctest (GH-12520)
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 8fca628..0229951 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1059,7 +1059,8 @@ class DocTestFinder: if module is None: filename = None else: - filename = getattr(module, '__file__', module.__name__) + # __file__ can be None for namespace packages. + filename = getattr(module, '__file__', None) or module.__name__ if filename[-4:] == ".pyc": filename = filename[:-1] return self._parser.get_doctest(docstring, globs, name, |