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

Subprocess exceptions re-raised in parent process do not have child_traceback attribute #75631

Closed
msekletar mannequin opened this issue Sep 13, 2017 · 4 comments
Closed
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@msekletar
Copy link
Mannequin

msekletar mannequin commented Sep 13, 2017

BPO 31450
Nosy @gpshead, @tiran, @stratakis, @msekletar, @miss-islington
PRs
  • bpo-31450: Remove documentation mentioning that subprocess's child_tr… #11422
  • bpo-31450: Remove documentation mentioning that subprocess's child_tr… #11422
  • bpo-31450: Remove documentation mentioning that subprocess's child_tr… #11422
  • bpo-31450: Remove documentation mentioning that subprocess's child_tr… #11422
  • [3.7] bpo-31450: Remove documentation mentioning that subprocess's child_traceback is available with the parent process (GH-11422) #11426
  • [3.7] bpo-31450: Remove documentation mentioning that subprocess's child_traceback is available with the parent process (GH-11422) #11426
  • [3.7] bpo-31450: Remove documentation mentioning that subprocess's child_traceback is available with the parent process (GH-11422) #11426
  • 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 2019-01-07.15:43:57.994>
    created_at = <Date 2017-09-13.12:25:50.310>
    labels = ['3.7', 'type-bug', 'library']
    title = 'Subprocess exceptions re-raised in parent process do not have child_traceback attribute'
    updated_at = <Date 2019-01-07.15:43:57.994>
    user = 'https://github.com/msekletar'

    bugs.python.org fields:

    activity = <Date 2019-01-07.15:43:57.994>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-07.15:43:57.994>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2017-09-13.12:25:50.310>
    creator = 'msekletar'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31450
    keywords = ['patch', 'patch', 'patch', 'patch']
    message_count = 4.0
    messages = ['302064', '302066', '332945', '332946']
    nosy_count = 5.0
    nosy_names = ['gregory.p.smith', 'christian.heimes', 'cstratak', 'msekletar', 'miss-islington']
    pr_nums = ['11422', '11422', '11422', '11422', '11426', '11426', '11426']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31450'
    versions = ['Python 3.6', 'Python 3.7']

    @msekletar
    Copy link
    Mannequin Author

    msekletar mannequin commented Sep 13, 2017

    Issue
    -----
    Documentation of subprocess module claims that exceptions raised in child process will be re-raised in the parent process and will have child_traceback attribute set [1]. At least on Fedora Rawhide with python-3.6.2 this is not the case.

    Reproducer
    ----------

    $ cat preexec-exception.py
    #!/usr/bin/env python3
    import subprocess
    
    class PreExecCallback:
        def __call__(self):
            raise Exception()
    
    if __name__ == "__main__":
        p = PreExecCallback()
    try:
        subprocess.Popen(['/bin/echo', 'foobar'], preexec_fn=p)
    except subprocess.SubprocessError as e:
        if not hasattr(e, 'child_traceback'):
            print('BUG: Exception happened in child, but exception object does not have child_traceback attribute')
    

    Actual result
    -------------

    $ ./preexec-exception.py 
    BUG: Exception happened in child, but exception object does not have child_traceback attribute

    Expected result
    ---------------
    No output, because child_traceback attribute is present

    Additional info
    ---------------
    I happened to notice this while working with pre-exec callbacks. However, according to https://stackoverflow.com/questions/38433837/subprocess-child-traceback this seems to be the generic problem.

    [1] https://docs.python.org/3/library/subprocess.html#exceptions

    @msekletar msekletar mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 13, 2017
    @tiran
    Copy link
    Member

    tiran commented Sep 13, 2017

    Documentation and implementation are out of sync. Python 3's subprocess module no longer sets child_traceback. I checked 3.3 to master. The assignment has been removed.

    @tiran tiran added the 3.7 (EOL) end of life label Sep 13, 2017
    @gpshead
    Copy link
    Member

    gpshead commented Jan 3, 2019

    New changeset 47a2fce by Gregory P. Smith (Harmandeep Singh) in branch 'master':
    bpo-31450: Remove documentation mentioning that subprocess's child_traceback is available with the parent process (GH-11422)
    47a2fce

    @miss-islington
    Copy link
    Contributor

    New changeset 47c035f by Miss Islington (bot) in branch '3.7':
    bpo-31450: Remove documentation mentioning that subprocess's child_traceback is available with the parent process (GH-11422)
    47c035f

    @vstinner vstinner closed this as completed Jan 7, 2019
    @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
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants