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.

classification
Title: imp.find_module() return value documentation discrepancy
Type: Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: StefanBauerTT, Windson Yang, brett.cannon, docs@python, mdk, miss-islington
Priority: normal Keywords: patch

Created on 2018-11-27 07:27 by StefanBauerTT, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11040 merged Windson Yang, 2018-12-09 01:53
PR 16035 merged miss-islington, 2019-09-12 12:11
PR 16036 merged miss-islington, 2019-09-12 12:11
Messages (7)
msg330495 - (view) Author: Stefan Bauer (TraceTronic) (StefanBauerTT) Date: 2018-11-27 07:27
I’d like to report a discrepancy between the documentation and implementation of the method imp.find_module().

The documentation <https://docs.python.org/3.7/library/imp.html#imp.find_module> currently says “If the module does not live in a file, the returned file is None, pathname is the __empty_string__, […]”

The implementation <https://github.com/python/cpython/blob/master/Lib/imp.py#L272>, on the other hand, returns __None__ for built-in and frozen modules.

Yours,
Stefan
msg330739 - (view) Author: Windson Yang (Windson Yang) * Date: 2018-11-30 00:40
If I understand correctly, this may be better.

Try to find the module name. If path is omitted or None, the list of directory names given by sys.path is searched. If path is built-in or frozen modules, return None instead.

BTW, the dosstring should also be updated, I will not continue search the path if the path in build-in or frozen. and this module is deprecated since version 3.4
msg331489 - (view) Author: Stefan Bauer (TraceTronic) (StefanBauerTT) Date: 2018-12-10 10:45
Hi, thank you for your proposal. However, your version still contains the discepancy. Maybe I formulated the problem not clear, so let's try again:

The documentation should state that "pathname" will be None (not the empty string) for built-in and frozen modules in order to be in line with the implementation.

Thank you very much for your efforts.
Kind regards, Stefan
msg333035 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-01-05 02:54
> The documentation should state that "pathname" will be None (not the empty string) for built-in and frozen modules in order to be in line with the implementation.

Both the "file" and "pathname" will be None for built-in and frozen modules, right? In the PR @ericsnowcurrently suggested add:

>  If the module is built-in or frozen then *file* and *pathname* are both ``None`` and the *description* tuple contains empty...

I think it also works.
msg352134 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2019-09-12 12:10
New changeset 967b84c913c7b09ae2fc86272cb9373415e2beaf by Julien Palard (Windson yang) in branch 'master':
bpo-35325: Doc: imp.find_module() return value documentation discrepancy (GH-11040)
https://github.com/python/cpython/commit/967b84c913c7b09ae2fc86272cb9373415e2beaf
msg352138 - (view) Author: miss-islington (miss-islington) Date: 2019-09-12 12:24
New changeset 01b47c94ca8ef89c5ac5fda0ab1074e73234a738 by Miss Islington (bot) in branch '3.7':
bpo-35325: Doc: imp.find_module() return value documentation discrepancy (GH-11040)
https://github.com/python/cpython/commit/01b47c94ca8ef89c5ac5fda0ab1074e73234a738
msg352139 - (view) Author: miss-islington (miss-islington) Date: 2019-09-12 12:25
New changeset 14afe203d6937069c66b7e9c4a9fc0db49b32c19 by Miss Islington (bot) in branch '3.8':
bpo-35325: Doc: imp.find_module() return value documentation discrepancy (GH-11040)
https://github.com/python/cpython/commit/14afe203d6937069c66b7e9c4a9fc0db49b32c19
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79506
2019-09-12 12:59:05mdksetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-09-12 12:25:57miss-islingtonsetmessages: + msg352139
2019-09-12 12:24:59miss-islingtonsetnosy: + miss-islington
messages: + msg352138
2019-09-12 12:11:08miss-islingtonsetpull_requests: + pull_request15658
2019-09-12 12:11:01miss-islingtonsetpull_requests: + pull_request15657
2019-09-12 12:10:53mdksetnosy: + mdk
messages: + msg352134
2019-01-05 05:28:12xtreaksetnosy: + brett.cannon

versions: - Python 3.4, Python 3.5, Python 3.6
2019-01-05 02:54:51Windson Yangsetmessages: + msg333035
2018-12-10 10:45:28StefanBauerTTsetmessages: + msg331489
2018-12-09 01:53:16Windson Yangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request10277
2018-11-30 00:40:10Windson Yangsetnosy: + Windson Yang

messages: + msg330739
versions: + Python 3.4, Python 3.5, Python 3.6
2018-11-27 07:27:04StefanBauerTTcreate