Skip to content

Fixed issue where calling exit() or quit() from a pyscript would close the whole console #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2019

Conversation

kmvanbrunt
Copy link
Member

This fixes #620

@codecov
Copy link

codecov bot commented Feb 6, 2019

Codecov Report

Merging #623 into master will decrease coverage by 0.1%.
The diff coverage is 68.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #623      +/-   ##
==========================================
- Coverage   93.31%   93.21%   -0.11%     
==========================================
  Files          11       11              
  Lines        3188     3196       +8     
==========================================
+ Hits         2975     2979       +4     
- Misses        213      217       +4
Impacted Files Coverage Δ
cmd2/cmd2.py 94.23% <68.18%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d93134...555f023. Read the comment docs.


except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need something like this to catch a KeyboardInterrupt exception (Ctrl-C) and let that gracefully exit the interactive Python session and drop us back to the console

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I allow the interactive Python session to handle their own exceptions. I did however add KeyboardInterrupt suppression to py and pyscript for when the interactive console isn't running.

@@ -3109,10 +3115,12 @@ def quit():
else:
sys.modules['readline'] = saved_readline

except Exception:
except KeyboardInterrupt:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess this is good.

@tleonhardt tleonhardt added this to the 0.9.8 milestone Feb 6, 2019
@tleonhardt tleonhardt merged commit 911d965 into master Feb 7, 2019
@tleonhardt tleonhardt deleted the pyscript_quit branch February 7, 2019 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add quit() and exit() to pyscript environment
2 participants