[Python-ideas] [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
Serhiy Storchaka
storchaka at gmail.com
Sun Nov 1 01:41:03 EST 2015
On 01.11.15 08:06, Steven D'Aprano wrote:
> (1) Beginning with Python 3.6, the default is that the current directory
> is put at the end of sys.path rather than the beginning. Instead of:
>
> >>> print(sys.path)
> ['', '/this', '/that', '/another']
>
> we will have this instead:
>
> >>> print(sys.path)
> ['/this', '/that', '/another', '']
>
> Those who don't shadow installed packages won't notice any
> difference.
>
> Scripts which deliberately or unintentionally shadow installed packages
> will break from this change. I don't have a problem with this. You can't
> fix harmful behaviour without breaking code that depends on that harmful
> behaviour. Additionally, I expect that those who rely on the current
> behaviour will be in a small minority, much fewer than those who will be
> bitten by accidental shadowing into the indefinite future.
Unfortunately this is not such small minority
https://code.openhub.net/search?s=%22sys.path.pop(0)%22&p=0
But we can workaround this problem by adding harmless path at the strt
of sys.path.
sys.path.insert(0, '/non-existing-stub-path')
or
sys.path.insert(0, sys.path[0])
More information about the Python-ideas
mailing list