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

Ignore BrokenPipeError when piping the output of the sysconfig CLI #110786

Closed
FFY00 opened this issue Oct 12, 2023 · 0 comments
Closed

Ignore BrokenPipeError when piping the output of the sysconfig CLI #110786

FFY00 opened this issue Oct 12, 2023 · 0 comments
Labels
3.13 new features, bugs and security fixes topic-sysconfig type-feature A feature request or enhancement

Comments

@FFY00
Copy link
Member

FFY00 commented Oct 12, 2023

Feature or enhancement

Proposal:

I very often pipe the output of the sysconfig CLI to the head utility from coreutils, so that I can check only the "paths" section of the output. This results in a BrokenPipeError exception, as we keep trying to write after the pipe closes.

$ python -m sysconfig | head -n 14
Platform: "linux-x86_64"
Python version: "3.11"
Current installation scheme: "posix_prefix"

Paths:
	data = "/usr"
	include = "/usr/include/python3.11"
	platinclude = "/usr/include/python3.11"
	platlib = "/usr/lib/python3.11/site-packages"
	platstdlib = "/usr/lib/python3.11"
	purelib = "/usr/lib/python3.11/site-packages"
	scripts = "/usr/bin"
	stdlib = "/usr/lib/python3.11"

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib/python3.11/sysconfig.py", line 851, in <module>
    _main()
  File "/usr/lib/python3.11/sysconfig.py", line 847, in _main
    _print_dict('Variables', get_config_vars())
  File "/usr/lib/python3.11/sysconfig.py", line 833, in _print_dict
    print(f'\t{key} = "{value}"')
BrokenPipeError: [Errno 32] Broken pipe

I'd be nice if we could suppress this error.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@FFY00 FFY00 added type-feature A feature request or enhancement topic-sysconfig labels Oct 12, 2023
FFY00 added a commit to FFY00/cpython that referenced this issue Oct 13, 2023
Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/cpython that referenced this issue Oct 13, 2023
Signed-off-by: Filipe Laíns <lains@riseup.net>
@furkanonder furkanonder added the 3.13 new features, bugs and security fixes label Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 new features, bugs and security fixes topic-sysconfig type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants