Skip to content

Commit

Permalink
Marked the std streams as possibly be None
Browse files Browse the repository at this point in the history
Closes: python#11778
  • Loading branch information
srittau committed Apr 24, 2024
1 parent 29db988 commit c23403b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 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 builtins import object as _object
from collections.abc import AsyncGenerator, Callable, Sequence
from importlib.abc import PathEntryFinder
Expand Down Expand Up @@ -61,16 +61,17 @@ 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]
Expand Down

0 comments on commit c23403b

Please sign in to comment.