Update comments and docs regarding recent addition to use __package__ for Python module imports
This commit is contained in:
parent
6b5da094b2
commit
75638e3371
2 changed files with 4 additions and 2 deletions
|
|
@ -6137,7 +6137,8 @@ pure Python module uses to find the C/C++ module is as follows:
|
|||
|
||||
<ol>
|
||||
<li><p>The pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is
|
||||
located in. The package name is determined from the <tt>__name__</tt>
|
||||
located in. The package name is determined from the <tt>__package__</tt>
|
||||
attribute if available, see <a href="https://www.python.org/dev/peps/pep-0366/">PEP 366</a>, otherwise it is derived from the <tt>__name__</tt>
|
||||
attribute given to foo.py by the Python loader that imported
|
||||
foo.py. If foo.py is not in a package then _foo is loaded
|
||||
as a global module.</p>
|
||||
|
|
|
|||
|
|
@ -701,7 +701,8 @@ public:
|
|||
* onwards (implicit relative imports raised a DeprecationWarning in 2.6,
|
||||
* and fail in 2.7 onwards).
|
||||
*
|
||||
* First determine the shadow wrappers package based on the __name__ it
|
||||
* First check for __package__ which is available from 2.6 onwards, see PEP366.
|
||||
* Next determine the shadow wrappers package based on the __name__ it
|
||||
* was given by the importer that loaded it. Then construct a name for
|
||||
* the module based on the package name and the module name (we know the
|
||||
* module name). Use importlib to try and load it. If an attempt to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue