[Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen (original) (raw)
Terry Reedy tjreedy at udel.edu
Thu Oct 29 21:22:15 EDT 2015
- Previous message (by thread): [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
- Next message (by thread): [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/29/2015 11:59 AM, Laura Creighton wrote:
see the following: lac at smartwheels:~/junk$ echo "print ('hello there')" >string.py lac at smartwheels:~/junk$ idle-python3.5 hello there Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/idlelib/run.py", line 10, in from idlelib import CallTips File "/usr/lib/python3.5/idlelib/CallTips.py", line 16, in from idlelib.HyperParser import HyperParser File "/usr/lib/python3.5/idlelib/HyperParser.py", line 14, in ASCIIIDCHARS = frozenset(string.asciiletters + string.digits + "") AttributeError: module 'string' has no attribute 'asciiletters' IDLE then produces a popup that says: IDLE's subprocess didn't make connection. Either IDLE can't stat a subprocess por personal firewall software is blocking the connection. -------- I think that life would be a whole lot easier for people if instead we got a message: Warning: local file /u/lac/junk/string.py shadows module named string in the Standard Library I think that it is python exec that would have to do this -- though of course the popup could also warn about shadowing in general, instead of sending people on wild goose chases over their firewalls. Would this be hard to do?
Leaving IDLE aside, the reason '' is added to sys.path is so that people can import their own modules. This is very useful. Shadowing is the result of putting it at the front. I have long thought this a dubious choice. If '' were instead appended, people could still import modules that did not duplicate stdlib names. Anyone who wanted shadowing could move '' to the front. But then shadowing would be intentional, not an accident.
-- Terry Jan Reedy
- Previous message (by thread): [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
- Next message (by thread): [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]