Skip to content
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

Different exit status when using -m #59238

Closed
kisielk mannequin opened this issue Jun 7, 2012 · 7 comments
Closed

Different exit status when using -m #59238

kisielk mannequin opened this issue Jun 7, 2012 · 7 comments
Labels
easy type-bug An unexpected behavior, bug, or error

Comments

@kisielk
Copy link
Mannequin

kisielk mannequin commented Jun 7, 2012

BPO 15033
Nosy @ncoghlan, @orsenthil, @merwok
Files
  • exit_code.patch: exit code patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-07-05.02:53:25.462>
    created_at = <Date 2012-06-07.21:13:38.559>
    labels = ['easy', 'type-bug']
    title = 'Different exit status when using -m'
    updated_at = <Date 2012-07-05.02:53:25.441>
    user = 'https://bugs.python.org/kisielk'

    bugs.python.org fields:

    activity = <Date 2012-07-05.02:53:25.441>
    actor = 'orsenthil'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-07-05.02:53:25.462>
    closer = 'orsenthil'
    components = []
    creation = <Date 2012-06-07.21:13:38.559>
    creator = 'kisielk'
    dependencies = []
    files = ['26244']
    hgrepos = []
    issue_num = 15033
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['162501', '162666', '164602', '164603', '164667', '164668', '164669']
    nosy_count = 7.0
    nosy_names = ['ncoghlan', 'orsenthil', 'kisielk', 'eric.araujo', 'Arfrever', 'python-dev', 'jeffknupp']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15033'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    @kisielk
    Copy link
    Mannequin Author

    kisielk mannequin commented Jun 7, 2012

    Python returns a different exit status when an exception is raised and -m is used as opposed to just running a module.

    A short example, let's call it foo.py:

        def main():
            raise ValueError()
    
        if __name__ == '__main__':
            main()

    When run with python foo.py the exit status of the process is 1. If run with python -mfoo the exit status of the process is 255.

    @kisielk kisielk mannequin added the type-bug An unexpected behavior, bug, or error label Jun 7, 2012
    @ncoghlan
    Copy link
    Contributor

    Technically, it returns -1 (which later gets coerced to an unsigned value).

    However, there's no good reason for the inconsistency - the offending line (663) in main.c should be changed to be:

        sts = (RunModule(module, 1) != 0);

    It is currently just:

        sts = RunModule(module, 1);

    An additional test in test_cmd_line_script is also needed to ensure that both variants give a returncode of 1 in the future.

    @merwok merwok added the easy label Jul 2, 2012
    @jeffknupp
    Copy link
    Mannequin

    jeffknupp mannequin commented Jul 3, 2012

    Fixed for 3.3. Does this need to be back ported as well?

    @jeffknupp
    Copy link
    Mannequin

    jeffknupp mannequin commented Jul 3, 2012

    And by 'Fixed' I of course meant 'Patched, awaiting review'.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 5, 2012

    New changeset fcbd3bda7c0f by Senthil Kumaran in branch '3.2':
    Fix issue bpo-15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp
    http://hg.python.org/cpython/rev/fcbd3bda7c0f

    New changeset 1186d68715cc by Senthil Kumaran in branch 'default':
    Fix issue bpo-15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp
    http://hg.python.org/cpython/rev/1186d68715cc

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 5, 2012

    New changeset 55b3de6d701e by Senthil Kumaran in branch '2.7':
    Fix closes issue bpo-15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp
    http://hg.python.org/cpython/rev/55b3de6d701e

    @orsenthil
    Copy link
    Member

    Thanks for the patch Jeff and thanks for the guidance, Nick.
    Committed this in all branches.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants