Skip to content

Commit

Permalink
Marked the std streams as possibly be None (#11826)
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau committed May 21, 2024
1 parent a375953 commit 0a95341
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions stdlib/sys/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import OptExcInfo, ProfileFunction, TraceFunction, structseq
from _typeshed import MaybeNone, OptExcInfo, ProfileFunction, TraceFunction, structseq
from _typeshed.importlib import MetaPathFinderProtocol, PathEntryFinderProtocol
from builtins import object as _object
from collections.abc import AsyncGenerator, Callable, Sequence
Expand Down Expand Up @@ -56,23 +56,24 @@ ps2: object

# TextIO is used instead of more specific types for the standard streams,
# since they are often monkeypatched at runtime. At startup, the objects
# are initialized to instances of TextIOWrapper.
# are initialized to instances of TextIOWrapper, but can also be None under
# some circumstances.
#
# To use methods from TextIOWrapper, use an isinstance check to ensure that
# the streams have not been overridden:
#
# if isinstance(sys.stdout, io.TextIOWrapper):
# sys.stdout.reconfigure(...)
stdin: TextIO
stdout: TextIO
stderr: TextIO
stdin: TextIO | MaybeNone
stdout: TextIO | MaybeNone
stderr: TextIO | MaybeNone

if sys.version_info >= (3, 10):
stdlib_module_names: frozenset[str]

__stdin__: Final[TextIOWrapper] # Contains the original value of stdin
__stdout__: Final[TextIOWrapper] # Contains the original value of stdout
__stderr__: Final[TextIOWrapper] # Contains the original value of stderr
__stdin__: Final[TextIOWrapper | None] # Contains the original value of stdin
__stdout__: Final[TextIOWrapper | None] # Contains the original value of stdout
__stderr__: Final[TextIOWrapper | None] # Contains the original value of stderr
tracebacklimit: int
version: str
api_version: int
Expand Down

0 comments on commit 0a95341

Please sign in to comment.