Terry J. Reedy added the comment:

Decorator: as I tried to say in msg270456, the two examples are artificial 
tests stripped to the bare minimum.  So is use of email and charset, other than 
the fact that it exists in 2.7 as well as current 3.x.

The real situation where this issue came up for me is the subprocess that IDLE 
uses to execute user code, separate as much as possible from IDLE code.  
idlelib.run imports tkinter.  It them imports a few other idlelib modules that 
collectively import at least tkinter.font, tkinter.messagebox, and 
tkinter.simpledialog.  These indirect imports change the tkinter module.  
Consequently, when users submit code such as

import tkinter as tk
root = tk.Tk()
myfont = tk.font.Font(...)  # tk.font should raise NameError

it runs.  But when they try to run their 'correct' program directly with 
Python, they get the NameError and must add, for instance, 'import tk.font'.  
IDLE should help people write standard python code, not python with a few 
custom augmentations.

My first attempt to fix this was to have run execute 'del tkinter.font', 
etcetera after the indirect imports are done.  Then users would get the 
NameError they should.  But currently, they would continue getting the 
NameError even after adding the needed import. This is because the first font 
import in *their* code is the second or later font import in the process.  My 
second example is a condensed version of this failure.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to