Terry J. Reedy <tjre...@udel.edu> added the comment:

Reproducer: In Shell, run "input('prompt'),  Without giving a response, so that 
input is left 'executing', switch to editor with valid code, select "Run... 
Customized", unselect "Restart shell", and select OK.  One will twice see and 
have to click away a box with
  The Python Shell window is already executing a command;
   please wait until it is finished.
Then the attribute error error appears.

Explanation: Run Module first compiles the editor code to check for syntax 
errors.  If successful, it 1. restarts the execution process, which *resets 
executing to False*; 2. runs internal commands with runcommand (called twice) 
to change working directory, augment sys.path, and possibly change sys.args.  
3. runs the compiled user code with runcode.  Thus, the buggy 'executing' 
clause cannot be triggered.

Run Customized with "Restart shell" unchecked skips the restart and 'executing' 
may be left True.  If so, runcommand displays the message above and returns 
False, instead of running the command and returning True.  The runscript code 
currently ignores the return and calls runcode anyway. 

Guiding principle: The effect of running with run customized with given 
settings should not depend on whether executable happens to be true when the 
first runcommand is called.  I verified with time.sleep(15) that a statement 
can finish executing and executable reset to False while a user is reading the 
first 'executing' message.  Since setting args has be skipped, the run should 
be stopped.

Fixes:
1. Only display one 'executing' message.  Either make the 2nd runcommand 
conditioned on the first succeeding, or combine the two partial duplicate 
runcommand calls into one.  I will start with the first.


2. Improve the error message.  The user should only run without restart when 
there is a waiting '>>>' prompt and may need to take action (respond to 
input(), close a tkinter window, restart a hung execution).  The message should 
say 'Try again' since execution will not happen.

3. Don't run the users code after the message is given.

4. Fix the AttributeError as specified in my previous message.  For running 
editor code, runcode will again not ever be called with executing True, and it 
may be that the clause could be deleted.  But I am not sure what is possible is 
IDLE is started with both -s (run IDLESTARTUP or PYTHONSTARTUP) and -r file 
(run file), both of which also call runcode.

----------
stage: patch review -> 

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

Reply via email to