This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json.tool should catch BrokenPipeError
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: corona10, hakancelik, miss-islington, remi.lapeyre, vstinner, zmwangx
Priority: normal Keywords: patch

Created on 2020-03-02 15:30 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18779 merged corona10, 2020-03-04 16:00
PR 18894 merged corona10, 2020-03-10 07:56
PR 18895 merged corona10, 2020-03-10 08:12
PR 22643 merged zmwangx, 2020-10-11 05:53
Messages (7)
msg363185 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-02 15:30
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.
msg363190 - (view) Author: Hakan Çelik (hakancelik) * Date: 2020-03-02 16:05
I'd like to work on this issue but what should it do when it captures that error.
msg363369 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-04 18:03
See also bpo-39851: "tarfile: Exception ignored in (... stdout ...) BrokenPipeError" which is a different but similar issue.
msg363806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-10 07:41
New changeset 700cb587303461d5a96456c56902cfdd8ad50e2d by Dong-hee Na in branch 'master':
bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779)
https://github.com/python/cpython/commit/700cb587303461d5a96456c56902cfdd8ad50e2d
msg363812 - (view) Author: miss-islington (miss-islington) Date: 2020-03-10 08:14
New changeset caec8a0dfbed04bdb8567782fdff7537529d2232 by Dong-hee Na in branch '3.8':
[3.8] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). (GH-18894)
https://github.com/python/cpython/commit/caec8a0dfbed04bdb8567782fdff7537529d2232
msg363813 - (view) Author: miss-islington (miss-islington) Date: 2020-03-10 08:30
New changeset 633957d7e3f926e20fed023c635ae2216efd2198 by Dong-hee Na in branch '3.7':
[3.7] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). (GH-18895)
https://github.com/python/cpython/commit/633957d7e3f926e20fed023c635ae2216efd2198
msg363814 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-10 08:37
Thanks Dong-hee Na for the fix.
History
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 84009
2020-10-11 05:53:53zmwangxsetnosy: + zmwangx

pull_requests: + pull_request21618
2020-03-10 08:37:56vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg363814

stage: patch review -> resolved
2020-03-10 08:30:55miss-islingtonsetmessages: + msg363813
2020-03-10 08:14:11miss-islingtonsetnosy: + miss-islington
messages: + msg363812
2020-03-10 08:12:56corona10setpull_requests: + pull_request18252
2020-03-10 07:56:54corona10setpull_requests: + pull_request18251
2020-03-10 07:41:50vstinnersetmessages: + msg363806
2020-03-04 18:03:21vstinnersetmessages: + msg363369
2020-03-04 16:00:37corona10setkeywords: + patch
nosy: + corona10

pull_requests: + pull_request18135
stage: patch review
2020-03-02 16:05:30hakanceliksetnosy: + hakancelik
messages: + msg363190
2020-03-02 15:54:58remi.lapeyresetnosy: + remi.lapeyre
2020-03-02 15:30:28vstinnercreate