Skip to content

The result of TextIOWrapper.detach() should be IO[bytes] #3993

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

For the following example:

import sys, io

if isinstance(sys.stdout, io.TextIOWrapper) and sys.version_info < (3, 7):
    sys.stdout = io.TextIOWrapper(
        sys.stdout.detach(),
        encoding="ascii",
        errors="replace")

I get the following error:

reconfigure36.py:5: error: Argument 1 to "TextIOWrapper" has incompatible type "IOBase"; expected "IO[bytes]"

Should not TextIOWrapper.detach() return IO[bytes] instead of IOBase?

Replacing sys.stdout.detach() with sys.stdout.buffer fixes the complains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions