Skip to content

Broken pipes should be handled better in 2.x #45937

Closed

Description

@avassalotti
BPO 1596
Nosy @gvanrossum, @avassalotti, @naufraghi

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 2010-07-09.03:43:21.414>
created_at = <Date 2007-12-11.22:02:26.267>
labels = ['interpreter-core', 'type-feature']
title = 'Broken pipes should be handled better in 2.x'
updated_at = <Date 2010-07-09.03:43:21.413>
user = 'https://github.com/avassalotti'

bugs.python.org fields:

activity = <Date 2010-07-09.03:43:21.413>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2010-07-09.03:43:21.414>
closer = 'terry.reedy'
components = ['Interpreter Core']
creation = <Date 2007-12-11.22:02:26.267>
creator = 'alexandre.vassalotti'
dependencies = []
files = []
hgrepos = []
issue_num = 1596
keywords = []
message_count = 2.0
messages = ['58469', '58470']
nosy_count = 3.0
nosy_names = ['gvanrossum', 'alexandre.vassalotti', 'naufraghi']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1596'
versions = ['Python 2.6', 'Python 2.5']

Activity

  1. avassalotti commented on Dec 11, 2007

    @avassalotti
    MemberAuthor

    I think Python 2.x should mimic, or improve on, the behavior of Py3k for
    handling broken pipes. That is:

    1. Don't print the message "close failed: [Errno 32] Broken pipe",
      from filemodule.c; since this is impossible to override from Python.
    2. Check sys.stdout if it's closed before calling the print routine.
      Raise an IOError if so.

    Finally, here's some examples to illustrate what I am saying:

    alex:~% python -c "print" | head -n0
    close failed: [Errno 32] Broken pipe

    alex:~% python -c "while 1: print" | head -n0
    [The loop continues running, even if the output stream is closed]
    ^C
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    KeyboardInterrupt
    close failed: [Errno 32] Broken pipe
    
    alex:~% py3k -c "print()" | head -n0
    alex:~% py3k -c "while 1: print()" | head -n0
    Traceback (most recent call last):
     ...
    IOError: [Errno 32] Broken pipe
  2. gvanrossum commented on Dec 11, 2007

    @gvanrossum
    Member

    I'll entertain a patch for 2.6.

    For 2.5 I think this smells too much like a feature.

  3. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions