Skip to content

Commit

Permalink
Make redirect_std{out,err} yield new stream as context var
Browse files Browse the repository at this point in the history
This matches the implementation, even though this behaviour isn't
actually documented yet. https://bugs.python.org/issue41147 aims
to fix the documentation issue though.

Fixes python#4283.
  • Loading branch information
PeterJCLaw committed Jun 28, 2020
1 parent 0704214 commit 21803ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stdlib/2and3/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if sys.version_info >= (3, 7):
from typing import AsyncContextManager as AbstractAsyncContextManager

_T = TypeVar('_T')
_T_io = TypeVar('_T_io', bound=Optional[IO[str]])
_F = TypeVar('_F', bound=Callable[..., Any])

_ExitFunc = Callable[[Optional[Type[BaseException]],
Expand Down Expand Up @@ -48,12 +49,12 @@ if sys.version_info >= (3, 4):
excinst: Optional[BaseException],
exctb: Optional[TracebackType]) -> bool: ...

class redirect_stdout(ContextManager[None]):
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
class redirect_stdout(ContextManager[_T_io]):
def __init__(self, new_target: _T_io) -> None: ...

if sys.version_info >= (3, 5):
class redirect_stderr(ContextManager[None]):
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
class redirect_stderr(ContextManager[_T_io]):
def __init__(self, new_target: _T_io) -> None: ...

if sys.version_info >= (3,):
class ContextDecorator:
Expand Down

0 comments on commit 21803ef

Please sign in to comment.