This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dutcho
Recipients Dutcho
Date 2019-03-23.11:54:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553342064.53.0.424333207933.issue36406@roundup.psfhosted.org>
In-reply-to
Content
In recent Python, a directory without __init__.py is also a package, and hence can be imported. When this directory/package is empty, and a doctest.testmod() is executed, the behaviour changed from 3.6 to 3.7, which I didn't find in the "what's new" documentation.

Minimal example:
>>> import doctest, os
>>> os.mkdir('empty_package')
>>> import empty_package
>>> doctest.testmod(empty_package)

Python 3.6.8 on Windows 7 prints
TestResults(failed=0, attempted=0)

Python 3.7.2 on Windows 7 raises below TypeError in doctest
Traceback (most recent call last):
  File "bug_empty_package.py", line 4, in <module>
    print(doctest.testmod(empty_package))
  File "...\Python37\lib\doctest.py", line 1949, in testmod
    for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
  File "...\Python37\lib\doctest.py", line 932, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "...\Python37\lib\doctest.py", line 982, in _find
    test = self._get_test(obj, name, module, globs, source_lines)
  File "...\Python37\lib\doctest.py", line 1063, in _get_test
    if filename[-4:] == ".pyc":
TypeError: 'NoneType' object is not subscriptable
History
Date User Action Args
2019-03-23 11:54:24Dutchosetrecipients: + Dutcho
2019-03-23 11:54:24Dutchosetmessageid: <1553342064.53.0.424333207933.issue36406@roundup.psfhosted.org>
2019-03-23 11:54:24Dutcholinkissue36406 messages
2019-03-23 11:54:24Dutchocreate