[Python-Dev] PEP 451 update (original) (raw)

Eric Snow ericsnowcurrently at gmail.com
Fri Oct 25 19:22:10 CEST 2013


On Fri, Oct 25, 2013 at 10:24 AM, PJ Eby <pje at telecommunity.com> wrote:

I've not really had time to review this PEP yet, but from skimming discussion to date, the only thing I'm still worried about is whether this will break lazy import schemes that use a module subclass that hooks getattribute and calls reload() in order to perform what's actually an initial load.

IOW, does anything in this proposal rely on a module object having any attributes besides name set at reload() time? That is, is there an assumption that a module being reloaded has 1. Been loaded, and 2. Is being reloaded via the same location, loader, etc. as before? At least through all 2.x, reload() just uses module.name to restart the module find-and-load process, and does not assume that loader is valid in advance. (Also, if this has changed in recent Python versions independent of this PEP, it's a backwards-compatibility break that should be documented somewhere.)

Yeah, this actually changed in 3.3 IIRC, where reload now calls module.loader.load_module(module.name). I'll double-check. PEP 451 simply changes that to be (basically) module.loader.exec_module(module).

-eric



More information about the Python-Dev mailing list