This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients miss-islington, rhettinger, terry.reedy
Date 2020-03-30.19:07:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585595278.33.0.730002324782.issue38002@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-30 19:07:58terry.reedysetrecipients: + terry.reedy, rhettinger, miss-islington
2020-03-30 19:07:58terry.reedysetmessageid: <1585595278.33.0.730002324782.issue38002@roundup.psfhosted.org>
2020-03-30 19:07:58terry.reedylinkissue38002 messages
2020-03-30 19:07:57terry.reedycreate