Navigation Menu

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

json.tool should catch BrokenPipeError #84009

Closed
vstinner opened this issue Mar 2, 2020 · 7 comments
Closed

json.tool should catch BrokenPipeError #84009

vstinner opened this issue Mar 2, 2020 · 7 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@vstinner
Copy link
Member

vstinner commented Mar 2, 2020

BPO 39828
Nosy @vstinner, @corona10, @zmwangx, @miss-islington, @remilapeyre, @hakancelik96
PRs
  • bpo-39828: Fix json.tool to catch BrokenPipeError. #18779
  • [3.8] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). #18894
  • [3.7] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). #18895
  • bpo-42005: Fix CLI of cProfile and profile to catch BrokenPipeError #22643
  • 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 2020-03-10.08:37:56.730>
    created_at = <Date 2020-03-02.15:30:28.518>
    labels = ['library', '3.9']
    title = 'json.tool should catch BrokenPipeError'
    updated_at = <Date 2020-10-11.05:53:53.376>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-10-11.05:53:53.376>
    actor = 'zmwangx'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-10.08:37:56.730>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2020-03-02.15:30:28.518>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39828
    keywords = ['patch']
    message_count = 7.0
    messages = ['363185', '363190', '363369', '363806', '363812', '363813', '363814']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'corona10', 'zmwangx', 'miss-islington', 'remi.lapeyre', 'hakancelik']
    pr_nums = ['18779', '18894', '18895', '22643']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39828'
    versions = ['Python 3.9']

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 2, 2020

    The json.tool module doesn't catch BrokenPipeError:
    -----------------------

    $ echo "{}" | python3 -m json.tool | true
    BrokenPipeError: [Errno 32] Broken pipe
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/usr/lib64/python3.7/json/tool.py", line 45, in <module>
        main()
      File "/usr/lib64/python3.7/json/tool.py", line 41, in main
        outfile.write('\n')
    BrokenPipeError: [Errno 32] Broken pipe

    json.tool should catch BrokenPipeError.

    @vstinner vstinner added 3.9 only security fixes stdlib Python modules in the Lib dir labels Mar 2, 2020
    @hakancelik96
    Copy link
    Mannequin

    hakancelik96 mannequin commented Mar 2, 2020

    I'd like to work on this issue but what should it do when it captures that error.

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 4, 2020

    See also bpo-39851: "tarfile: Exception ignored in (... stdout ...) BrokenPipeError" which is a different but similar issue.

    @vstinner
    Copy link
    Member Author

    New changeset 700cb58 by Dong-hee Na in branch 'master':
    bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779)
    700cb58

    @miss-islington
    Copy link
    Contributor

    New changeset caec8a0 by Dong-hee Na in branch '3.8':
    [3.8] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). (GH-18894)
    caec8a0

    @miss-islington
    Copy link
    Contributor

    New changeset 633957d by Dong-hee Na in branch '3.7':
    [3.7] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). (GH-18895)
    633957d

    @vstinner
    Copy link
    Member Author

    Thanks Dong-hee Na for the fix.

    @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.9 only security fixes stdlib Python modules in the Lib dir
    Projects
    Status: Done
    Development

    No branches or pull requests

    2 participants