D3445: dispatch: shore up exit handling
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Sun May 6 08:29:23 EDT 2018
yuja added a comment.
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:
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3445
To: indygreg, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list