[Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen

Paul Moore p.f.moore at gmail.com
Thu Oct 29 14:27:59 EDT 2015

On 29 October 2015 at 17:36, Donald Stufft <donald at stufft.io> wrote:
> On October 29, 2015 at 1:32:31 PM, Nathaniel Smith (njs at pobox.com) wrote:
>> > (I know saying that last part out loud will probably just cause
>> someone to pop out of the woodwork and explain how shadowing the
>> sys module is a great idea and they do it all the time or whatever,
>> but I guess I'll take that risk :-).)
> How about someone saying that I wish the standard library was more easily shadow-able? ;) In 2.x it’s easy to do it by accident because of the implicit relative imports which is of course, crummy. I think it’d be nice if a package could override the standard library in a sane way though. Like how pdb++ does.
> This is already possible if you install stuff as .eggs and the world hasn’t burned down, it’s just not easily possible if you don’t install as eggs.

The idle issues seem to me to demonstrate that shadowing the stdlib is
a bad idea. Of course, consenting adults, and if you override you're
responsible for correctly replacing the functionality, and all that,
but honestly, I don't think it needs to be *easy* to shadow the stdlib
- there's nothing wrong with it being an "advanced" technique that
people have to understand in order to use.

And I don't see pdb++ as a good motivating use case. When are you
going to find code with pdb calls in, that you can't modify to add
"import pdbpp as pdb" at the top, if you want the advanced
functionality? (And if you can't modify the code, what's the point of
debugging it anyway?)

I think the reason the world hasn't burned down because you can shadow
the stdlib with eggs, is because people *don't*. Or to rephrase,
because people don't actually need to shadow the stdlib. But I have no
hard data to support that contention, so if you do, I'll concede the
point (but I don't think there are many packages that *have* to be
shipped as eggs these days, if they did they wouldn't work with pip,
so doesn't that mean that nobody is using the ability of eggs to
shadow the stdlib?)


More information about the Python-Dev mailing list