Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 name of exception for exit()
when exit() is called, it's really raising a special exception that does not dump anything. i'd like to capture this exception but i can't find its name. since there is no stack dump, i can't see what it raises by just doing one. anyone got the name for this (and, if needed, what module it's in)?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
#2 Wrote:exception SystemExit
This exception is raised by the sys.exit() function. It inherits from BaseException instead of Exception so that it is not accidentally caught by code that catches Exception. This allows the exception to properly propagate up and cause the interpreter to exit. When it is not handled, the Python interpreter exits; no stack traceback is printed. The constructor accepts the same optional argument passed to sys.exit(). If the value is an integer, it specifies the system exit status (passed to C’s exit() function); if it is None, the exit status is zero; if it has another type (such as a string), the object’s value is printed and the exit status is one.

A call to sys.exit() is translated into an exception so that clean-up handlers (finally clauses of try statements) can be executed, and so that a debugger can execute a script without running the risk of losing control. The os._exit() function can be used if it is absolutely positively necessary to exit immediately (for example, in the child process after a call to os.fork()).

The exit status or error message that is passed to the constructor. (Defaults to None.)
Skaperen likes this post
the way exit() handles a string can eliminate a few lines of my code that was trying to do the same thing with return.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to fix 'uncaught exception of type NSException' in Python MonsterPython 0 121 Jul-09-2019, 06:52 AM
Last Post: MonsterPython
  problem using custom exception handling in python srm 3 180 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  'Exception Has occured: UnBoundLocalError' caston 1 168 Jun-12-2019, 02:33 PM
Last Post: perfringo
  an easy way to disable exception handling Skaperen 6 446 Jun-02-2019, 10:38 PM
Last Post: Gribouillis
  exception name for a flagged stop Skaperen 1 540 May-31-2019, 04:33 AM
Last Post: heiner55
  exception handling KyawMyo 3 271 May-07-2019, 07:53 AM
Last Post: buran
  Process finished with exit code -107374819 (0xC0000375) mrazko 2 283 Apr-05-2019, 12:46 PM
Last Post: mrazko
  Stack trace shows different exception type than print micseydel 5 543 Apr-01-2019, 10:24 PM
Last Post: micseydel
  Because the emoji appears black and white at the exit ? nerd 3 432 Jan-28-2019, 11:34 PM
Last Post: nerd
  whats the difference between sys.exit() and break? mitmit293 1 404 Jan-27-2019, 09:46 PM
Last Post: ichabod801

Forum Jump:

Users browsing this thread: 1 Guest(s)