Skip to content

Checking is stdout/stderr stream terminal causes exception if stream's buffer is detached #2003

Closed

Description

@userzimmermann

If the .buffer of an io module based stream was detached, the stream.isatty() method called in utils.misc.isatty() will raise an exception. #1948 fixes it.

Activity

  1. changed the title [-]check for detached stream buffer in utils.misc.isatty()[/-] [+]Checking is stdout/stderr stream terminal causes exception if stream's buffer is detached[/+] on May 26, 2015
  2. pekkaklarck commented on May 26, 2015

    @pekkaklarck
    Member

    The problem can demonstrated like this on Python 2.7:

    >>> from io import TextIOWrapper, BytesIO
    >>> stream = TextIOWrapper(BytesIO())
    >>> stream.isatty()
    False
    >>> stream.detach()
    <_io.BytesIO object at 0x7f4de4f4ba70>
    >>> stream.isatty()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: underlying buffer has been detached

    Actually using io based streams as stdout/stderr in Python 2 with Robot Framework doesn't seem to be possible. The reason is that these streams only accept Unicode or bytes and Robot's output contains both. This is worth fixing to ease porting to Python 3, though.

  3. self-assigned this
    on May 26, 2015
  4. added this to the 2.9 milestone on May 26, 2015
  5. pekkaklarck commented on May 26, 2015

    @pekkaklarck
    Member

    PR #1948 was merged. This issue is done.

  6. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions