D3445: dispatch: shore up exit handling
Yuya Nishihara
yuya at tcha.org
Sun May 6 08:18:01 EDT 2018
IIRC, SystemExit is caught at callcatch and translated to a status code.
> + # The logic here attempts to mimic how CPython's pythonrun.c does things.
> + # Essentially:
> + #
> + # * Exit is controlled by returning a value or raising SystemExit.
> + # * An integer value exits with that exit code.
> + # * A value of ``None`` is interpreted as ``0``.
> + # * A non-integer, non-None value results in that value being printed
> + # and an exit code of ``1``.
> + # * SystemExit can have a ``code`` attribute containing the exit value.
> try:
> - status = (dispatch(req) or 0)
> + code = dispatch(req) or 0
> except error.StdioError as e:
> err = e
> - status = -1
> + code = -1
> + except SystemExit as err:
> + try:
> + code = err.code
> + err = None
> + except AttributeError:
More information about the Mercurial-devel
mailing list