| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,4 +52,7 @@ def main(): | |||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | 54 | if __name__ == '__main__': | |
| 55 | - main() | ||
| 55 | + try: | ||
| 56 | + main() | ||
| 57 | + except BrokenPipeError as exc: | ||
| 58 | + sys.exit(exc.errno) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,9 @@ | |||
| 1 | + import errno | ||
| 1 | 2 | import os | |
| 2 | 3 | import sys | |
| 3 | 4 | import textwrap | |
| 4 | 5 | import unittest | |
| 6 | + | ||
| 5 | 7 | from subprocess import Popen, PIPE | |
| 6 | 8 | from test import support | |
| 7 | 9 | from test.support.script_helper import assert_python_ok | |
@@ -149,3 +151,12 @@ def test_sort_keys_flag(self): | |||
| 149 | 151 | self.assertEqual(out.splitlines(), | |
| 150 | 152 | self.expect_without_sort_keys.encode().splitlines()) | |
| 151 | 153 | self.assertEqual(err, b'') | |
| 154 | + | ||
| 155 | + @unittest.skipIf(sys.platform =="win32", "The test is failed with ValueError on Windows") | ||
| 156 | + def test_broken_pipe_error(self): | ||
| 157 | + cmd = [sys.executable, '-m', 'json.tool'] | ||
| 158 | + proc = Popen(cmd, stdout=PIPE, stdin=PIPE) | ||
| 159 | + # bpo-39828: Closing before json.tool attempts to write into stdout. | ||
| 160 | + proc.stdout.close() | ||
| 161 | + proc.communicate(b'"{}"') | ||
| 162 | + self.assertEqual(proc.returncode, errno.EPIPE) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix :mod:`json.tool` to catch :exc:`BrokenPipeError`. Patch by Dong-hee Na. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments