diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/module.rst | 11 | ||||
-rw-r--r-- | Doc/library/importlib.rst | 2 | ||||
-rw-r--r-- | Doc/reference/import.rst | 4 | ||||
-rw-r--r-- | Doc/whatsnew/3.4.rst | 5 |
4 files changed, 17 insertions, 5 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 65ff8fa..95a0169 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -35,13 +35,20 @@ There are only a few functions special to module objects. single: __name__ (module attribute) single: __doc__ (module attribute) single: __file__ (module attribute) + single: __package__ (module attribute) + single: __loader__ (module attribute) Return a new module object with the :attr:`__name__` attribute set to *name*. - Only the module's :attr:`__doc__` and :attr:`__name__` attributes are filled in; - the caller is responsible for providing a :attr:`__file__` attribute. + The module's :attr:`__name__`, :attr:`__doc__`, :attr:`__package__`, and + :attr:`__loader__` attributes are filled in (all but :attr:`__name__` are set + to ``None``); the caller is responsible for providing a :attr:`__file__` + attribute. .. versionadded:: 3.3 + .. versionchanged:: 3.4 + :attr:`__package__` and :attr:`__loader__` are set to ``None``. + .. c:function:: PyObject* PyModule_New(const char *name) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index aeeb3fd..9cb03be 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -827,7 +827,7 @@ an :term:`importer`. decorator as it subsumes this functionality. .. versionchanged:: 3.4 - Set ``__loader__`` if set to ``None`` as well if the attribute does not + Set ``__loader__`` if set to ``None``, as if the attribute does not exist. diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 4ad4490..9c52435 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -423,8 +423,8 @@ Here are the exact rules used: * If the module has a ``__file__`` attribute, this is used as part of the module's repr. - * If the module has no ``__file__`` but does have a ``__loader__``, then the - loader's repr is used as part of the module's repr. + * If the module has no ``__file__`` but does have a ``__loader__`` that is not + ``None``, then the loader's repr is used as part of the module's repr. * Otherwise, just use the module's ``__name__`` in the repr. diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index ca515f6..9774241 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -231,3 +231,8 @@ that may require changes to your code. :exc:`NotImplementedError` blindly. This will only affect code calling :func:`super` and falling through all the way to the ABCs. For compatibility, catch both :exc:`NotImplementedError` or the appropriate exception as needed. + +* The module type now initializes the :attr:`__package__` and :attr:`__loader__` + attributes to ``None`` by default. To determine if these attributes were set + in a backwards-compatible fashion, use e.g. + ``getattr(module, '__loader__', None) is not None``.
\ No newline at end of file |