Issue #25791: Raise an ImportWarning when __spec__ or __package__ are
not defined for a relative import.
This is the start of work to try and clean up import semantics to rely
more on a module's spec than on the myriad attributes that get set on
a module. Thanks to Rose Ames for the patch.
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
index f7dbbee..a5b9be2 100644
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -209,7 +209,12 @@
* The ``pyvenv`` script has been deprecated in favour of ``python3 -m venv``.
This prevents confusion as to what Python interpreter ``pyvenv`` is
connected to and thus what Python interpreter will be used by the virtual
- environment. See :issue:`25154`.
+ environment. (Contributed by Brett Cannon in :issue:`25154`.)
+
+* When performing a relative import, falling back on ``__name__`` and
+ ``__path__`` from the calling module when ``__spec__`` or
+ ``__package__`` are not defined now raises an :exc:`ImportWarning`.
+ (Contributed by Rose Ames in :issue:`25791`.)
Removed
@@ -251,6 +256,10 @@
:mod:`wave`. This means they will export new symbols when ``import *``
is used. See :issue:`23883`.
+* When performing a relative import, ``__spec__.parent`` is used
+ is ``__spec__`` is defined instead of ``__package__``.
+ (Contributed by Rose Ames in :issue:`25791`.)
+
Changes in the C API
--------------------