[issue25509] PyImport_ImportModule inaccurately described
New submission from Memeplex:
The documentation (for 3.5) states that "[PyImport_ImportModule] is a simplified interface to PyImport_ImportModuleEx()" but the current implementation calls PyImport_Import instead, which is a higher level interface that takes into account import hooks. Older versions of PyImport_ImportModule (say 2.0) did call PyImport_ImportModuleEx, but that's no longer the case.
The PyImport_Import* naming convention got a bit messy with the years and maybe I'm not understanding the intention quite well, but it seems to me that the documentation is outdated and that there is a change in semantics for PyImport_ImportModule.
----------
assignee: docs@python
components: Documentation
messages: 253674
nosy: docs@python, memeplex
priority: normal
severity: normal
status: open
title: PyImport_ImportModule inaccurately described
versions: Python 3.5
_______________________________________
Python tracker
Changes by Brett Cannon
Brett Cannon added the comment:
Semantic change was probably because of the lack of import hook support which is required since Python 3.3. So the docs just need to be fixed rather than the semantics.
----------
_______________________________________
Python tracker
Memeplex added the comment:
Brett, I'm not sure about that, notice that the "import hook" as is mentioned in the docs is just the current __import__ in the builtins module (which could have been replaced and in this sense would be a "hook") but not proper import hooks. I think the original distinction between PyImport_ImportModule and PyImport_Import is still sensible today. Originally PyImport_ImportModule directly called the import machinery, while PyImport_Import called it indirectly through builtins.__import__ (which could have been replaced). Now, for some reason, for good or for bad, PyImport_ImportModule also goes through builtins.__import__. The documentation is wrong but what is the fix? Revert PyImport_ImportModule or redocument it?
----------
_______________________________________
Python tracker
Memeplex added the comment:
Well it's like that since 2.1 so I guess the doc is wrong indeee.
----------
_______________________________________
Python tracker
Brett Cannon
Change by Brett Cannon
Change by Brett Cannon
Brett Cannon
participants (2)
-
Brett Cannon
-
Memeplex