This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients barry, brett.cannon, eric.snow
Date 2021-10-20.18:38:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CALFfu7BAy=ZcbwzCcz51vayyRFPm-xvKJFEzo66ir4JnbjBtEg@mail.gmail.com>
In-reply-to <1634749883.54.0.793446044283.issue45540@roundup.psfhosted.org>
Content
On Wed, Oct 20, 2021 at 11:11 AM Barry A. Warsaw <report@bugs.python.org> wrote:
> Maybe we should relax the restriction on module.__spec__.parent so that it's writeable just like module.__package__.

Hmm, I hadn't realized __package__ is used in __import__().  That
makes things messier.

Regardless, I expect the primary reason __package__ is writable is
because modules have never had any read-only attrs.

The more important question now is, when is __package__ ever modified?
 I can think of 2 cases:

1. legacy (pre-451) importers set it when they load the module
2. someone wants to customize the import system without writing an importer

With the latter, specifically they are trying to change how the module
is reloaded or submodules are imported.  In that case there should
probably be an explicit way to do so without having to hack the import
machinery.

My only concern with any support/encouragement for modifying the spec
after import is it results in less confidence about how the module was
imported originally.
History
Date User Action Args
2021-10-20 18:38:42eric.snowsetrecipients: + eric.snow, barry, brett.cannon
2021-10-20 18:38:42eric.snowlinkissue45540 messages
2021-10-20 18:38:42eric.snowcreate
Morty Proxy This is a proxified and sanitized view of the page, visit original site.