#2861: [with patch; positive review] scripts do not exit with correct exit code
when sys.exit() is used
----------------------------+-----------------------------------------------
Reporter: ddrake | Owner: was
Type: defect | Status: closed
Priority: major | Milestone: sage-3.3
Component: user interface | Resolution: fixed
Keywords: |
----------------------------+-----------------------------------------------
Comment(by ddrake):
I was going to reopen this ticket, but instead I'll leave this comment as
warning to anyone else trying to use this:
If you do {{{sys.exit(0)}}} in a Sage script, because of preparsing, you
effectively get {{{sys.exit(Integer(0))}}}, which results in the script
exiting with code 1! This is not what anyone would expect! This is because
of [http://docs.python.org/library/sys.html#sys.exit how sys.exit works]
when given non-Python-integer arguments. To make sure that you get the
desired behavior, use {{{int}}} inside the call to get a Python integer:
{{{sys.exit(int(2))}}} or whatever.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/2861#comment:5>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---