On 5/14/2022 12:40 AM, Guido van Rossum wrote:
So the "current working directory" is the directory containing the file, right? That would explain the behavior.

Standard import shadowing.

Probably "Edit with IDLE" should be changed. I have no idea where that is defined.

I presume somewhere in PCBuild. Steve Dower knows and is in charge of the Windows installer.

In 3.11 we should be able to make that use the new -P option, which doesn't insert the working directory at the front of sys.path.

This would only solve the issue for that one of many ways to start IDLE. Example: Entering command 'py -m idlelib', with or without the name of the file added, in a directory with a shadow module.

Traceback...
ImportError: cannot import name 'InteractiveInterpreter' from 'code' (F:\dev\tem\code.py)

The difference is that the import exception is printed:
(Yes, it would be nice to display such exceptions in a tkinter message box when not starting from a terminal.)

In IDLE's deprecated but not intentionally disabled original mode, in which both IDLE and user code are executed in the same process, the working directory would need to be present when executing user code, or its absence would have to be documented. In the former case, delayed imports would have to be more careful.


--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QAMOWEQYZGW73TKTTRREC7LT2DJEZNB7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to