Skip to content

Commit ff5fc7d

Browse files
committed
Initial attempt
``` 21 tests altered the execution environment (env changed): test_logging test_pathlib test_profile test_pty test_pulldom test_pwd test_pyclbr test_pyexpat test_pyrepl test_pystats test_resource test_rlcompleter test_robotparser test_sax test_sched test_secrets test_select test_set test_shlex test_str test_thread 5 tests failed: test_capi test_cmd_line_script test_importlib test_repl test_sysconfig ```
1 parent bc9e63d commit ff5fc7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+91
-699
lines changed

Doc/c-api/extension-modules.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ The process of creating an extension module follows several phases:
134134
- By default, Python itself then creates the module object -- that is, it does
135135
the equivalent of calling :py:meth:`~object.__new__` when creating an object.
136136
This step can be overridden using the :c:data:`Py_mod_create` slot.
137-
- Python sets initial module attributes like :attr:`~module.__package__` and
138-
:attr:`~module.__loader__`, and inserts the module object into
139-
:py:attr:`sys.modules`.
137+
- Python sets initial module attributes like :attr:`~module.__loader__`, and
138+
inserts the module object into :py:attr:`sys.modules`.
140139
- Afterwards, the module object is initialized in an extension-specific way
141140
-- the equivalent of :py:meth:`~object.__init__` when creating an object,
142141
or of executing top-level code in a Python-language module.
@@ -150,6 +149,9 @@ where an initialization function returns a fully constructed module.
150149

151150
Added support for multi-phase initialization (:pep:`489`).
152151

152+
.. deprecated-removed:: 3.12 3.15
153+
:attr:`~module.__package__`
154+
153155

154156
Multiple module instances
155157
.........................

Doc/c-api/module.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ Module Objects
3333
single: __name__ (module attribute)
3434
single: __doc__ (module attribute)
3535
single: __file__ (module attribute)
36-
single: __package__ (module attribute)
3736
single: __loader__ (module attribute)
3837
3938
Return a new module object with :attr:`module.__name__` set to *name*.
4039
The module's :attr:`!__name__`, :attr:`~module.__doc__`,
41-
:attr:`~module.__package__` and :attr:`~module.__loader__` attributes are
42-
filled in (all but :attr:`!__name__` are set to ``None``). The caller is
43-
responsible for setting a :attr:`~module.__file__` attribute.
40+
and :attr:`~module.__loader__` attributes are filled in (all but
41+
:attr:`!__name__` are set to ``None``). The caller is responsible for
42+
setting a :attr:`~module.__file__` attribute.
4443
4544
Return ``NULL`` with an exception set on error.
4645
@@ -50,6 +49,9 @@ Module Objects
5049
:attr:`~module.__package__` and :attr:`~module.__loader__` are now set to
5150
``None``.
5251
52+
.. deprecated-removed:: 3.12 3.15
53+
:attr:`~module.__package__`
54+
5355
5456
.. c:function:: PyObject* PyModule_New(const char *name)
5557

Doc/library/importlib.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ ABC hierarchy::
367367
- :attr:`module.__file__`
368368
- :attr:`module.__cached__` *(deprecated)*
369369
- :attr:`module.__path__`
370-
- :attr:`module.__package__` *(deprecated)*
371370
- :attr:`module.__loader__` *(deprecated)*
372371

373372
When :meth:`exec_module` is available then backwards-compatible
@@ -385,6 +384,9 @@ ABC hierarchy::
385384
other responsibilities of :meth:`load_module` when
386385
:meth:`exec_module` is implemented.
387386

387+
.. deprecated-removed:: 3.12 3.15
388+
:attr:`~module.__package__` is no longer set.
389+
388390

389391
.. class:: ResourceLoader
390392

@@ -1271,7 +1273,6 @@ find and load modules.
12711273

12721274
(Read-only) The fully qualified name of the package the module is in (or the
12731275
empty string for a top-level module).
1274-
See :attr:`module.__package__`.
12751276
If the module is a package then this is the same as :attr:`name`.
12761277

12771278
.. attribute:: has_location

Doc/library/runpy.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The :mod:`runpy` module provides two functions:
5050
overridden by :func:`run_module`.
5151

5252
The special global variables ``__name__``, ``__spec__``, ``__file__``,
53-
``__cached__``, ``__loader__`` and ``__package__`` are set in the globals
53+
``__cached__``, and ``__loader__`` are set in the globals
5454
dictionary before the module code is executed. (Note that this is a
5555
minimal set of variables - other variables may be set implicitly as an
5656
interpreter implementation detail.)
@@ -63,7 +63,7 @@ The :mod:`runpy` module provides two functions:
6363
module (that is, ``__spec__.name`` will always be *mod_name* or
6464
``mod_name + '.__main__'``, never *run_name*).
6565

66-
``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` are
66+
``__file__``, ``__cached__``, and ``__loader__`` are
6767
:ref:`set as normal <import-mod-attrs>` based on the module spec.
6868

6969
If the argument *alter_sys* is supplied and evaluates to :const:`True`,
@@ -98,6 +98,9 @@ The :mod:`runpy` module provides two functions:
9898
``__package__`` are deprecated. See
9999
:class:`~importlib.machinery.ModuleSpec` for alternatives.
100100

101+
.. deprecated-removed:: 3.12 3.15
102+
``__package__``
103+
101104
.. function:: run_path(path_name, init_globals=None, run_name=None)
102105

103106
.. index::
@@ -125,23 +128,23 @@ The :mod:`runpy` module provides two functions:
125128
overridden by :func:`run_path`.
126129

127130
The special global variables ``__name__``, ``__spec__``, ``__file__``,
128-
``__cached__``, ``__loader__`` and ``__package__`` are set in the globals
129-
dictionary before the module code is executed. (Note that this is a
130-
minimal set of variables - other variables may be set implicitly as an
131-
interpreter implementation detail.)
131+
``__cached__``, and ``__loader__`` are set in the globals dictionary before
132+
the module code is executed. (Note that this is a minimal set of variables -
133+
other variables may be set implicitly as an interpreter implementation
134+
detail.)
132135

133136
``__name__`` is set to *run_name* if this optional argument is not
134137
:const:`None` and to ``'<run_path>'`` otherwise.
135138

136139
If *file_path* directly references a script file (whether as source
137140
or as precompiled byte code), then ``__file__`` will be set to
138-
*file_path*, and ``__spec__``, ``__cached__``, ``__loader__`` and
139-
``__package__`` will all be set to :const:`None`.
141+
*file_path*, and ``__spec__``, ``__cached__``, and ``__loader__`` will all
142+
be set to :const:`None`.
140143

141144
If *file_path* is a reference to a valid :data:`sys.path` entry, then
142145
``__spec__`` will be set appropriately for the imported :mod:`__main__`
143146
module (that is, ``__spec__.name`` will always be ``__main__``).
144-
``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` will be
147+
``__file__``, ``__cached__``, and ``__loader__`` will be
145148
:ref:`set as normal <import-mod-attrs>` based on the module spec.
146149

147150
A number of alterations are also made to the :mod:`sys` module. Firstly,

Doc/reference/datamodel.rst

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ Attribute assignment updates the module's namespace dictionary, e.g.,
891891
.. index::
892892
single: __name__ (module attribute)
893893
single: __spec__ (module attribute)
894-
single: __package__ (module attribute)
895894
single: __loader__ (module attribute)
896895
single: __path__ (module attribute)
897896
single: __file__ (module attribute)
@@ -958,51 +957,6 @@ this approach.
958957

959958
.. versionadded:: 3.4
960959

961-
.. attribute:: module.__package__
962-
963-
The :term:`package` a module belongs to.
964-
965-
If the module is top-level (that is, not a part of any specific package)
966-
then the attribute should be set to ``''`` (the empty string). Otherwise,
967-
it should be set to the name of the module's package (which can be equal to
968-
:attr:`module.__name__` if the module itself is a package). See :pep:`366`
969-
for further details.
970-
971-
This attribute is used instead of :attr:`~module.__name__` to calculate
972-
explicit relative imports for main modules. It defaults to ``None`` for
973-
modules created dynamically using the :class:`types.ModuleType` constructor;
974-
use :func:`importlib.util.module_from_spec` instead to ensure the attribute
975-
is set to a :class:`str`.
976-
977-
It is **strongly** recommended that you use
978-
:attr:`module.__spec__.parent <importlib.machinery.ModuleSpec.parent>`
979-
instead of :attr:`!module.__package__`. :attr:`__package__` is now only used
980-
as a fallback if :attr:`!__spec__.parent` is not set, and this fallback
981-
path is deprecated.
982-
983-
.. versionchanged:: 3.4
984-
This attribute now defaults to ``None`` for modules created dynamically
985-
using the :class:`types.ModuleType` constructor.
986-
Previously the attribute was optional.
987-
988-
.. versionchanged:: 3.6
989-
The value of :attr:`!__package__` is expected to be the same as
990-
:attr:`__spec__.parent <importlib.machinery.ModuleSpec.parent>`.
991-
:attr:`__package__` is now only used as a fallback during import
992-
resolution if :attr:`!__spec__.parent` is not defined.
993-
994-
.. versionchanged:: 3.10
995-
:exc:`ImportWarning` is raised if an import resolution falls back to
996-
:attr:`!__package__` instead of
997-
:attr:`__spec__.parent <importlib.machinery.ModuleSpec.parent>`.
998-
999-
.. versionchanged:: 3.12
1000-
Raise :exc:`DeprecationWarning` instead of :exc:`ImportWarning` when
1001-
falling back to :attr:`!__package__` during import resolution.
1002-
1003-
.. deprecated-removed:: 3.13 3.15
1004-
:attr:`!__package__` will cease to be set or taken into consideration
1005-
by the import system or standard library.
1006960

1007961
.. attribute:: module.__loader__
1008962

@@ -1081,6 +1035,9 @@ this approach.
10811035
:attr:`!__cached__` will cease to be set or taken into consideration by
10821036
the import system or standard library.
10831037

1038+
.. deprecated-removed:: 3.12 3.15
1039+
:attr:`~module.__package__`
1040+
10841041
Other writable attributes on module objects
10851042
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10861043

Doc/reference/import.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -948,12 +948,8 @@ subsequent extension in :pep:`420`.
948948
Python 3.3. :pep:`420` also introduced the :meth:`!find_loader` protocol as an
949949
alternative to :meth:`!find_module`.
950950

951-
:pep:`366` describes the addition of the ``__package__`` attribute for
952-
explicit relative imports in main modules.
953-
954951
:pep:`328` introduced absolute and explicit relative imports and initially
955-
proposed ``__name__`` for semantics :pep:`366` would eventually specify for
956-
``__package__``.
952+
proposed ``__name__`` for semantics.
957953

958954
:pep:`338` defines executing modules as scripts.
959955

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ struct _Py_global_strings {
183183
STRUCT_FOR_ID(__or__)
184184
STRUCT_FOR_ID(__orig_class__)
185185
STRUCT_FOR_ID(__origin__)
186-
STRUCT_FOR_ID(__package__)
187186
STRUCT_FOR_ID(__parameters__)
188187
STRUCT_FOR_ID(__path__)
189188
STRUCT_FOR_ID(__pos__)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)