You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is also another, perhaps more common way for sys.stdin, sys.stdout and sys.stderr to be None. On Windows, if you run a file with pythonw.exe (by naming it foo.pyw and double-clicking it, for example), it will run without a command prompt window, and with sys.std* files set to None.
This is how GUI apps usually run on Windows. For code that should work in these GUI apps, you need print(foo, file=sys.stderr) instead of sys.stderr.write(foo), or explicit None checks.
srittau
added a commit
to srittau/typeshed
that referenced
this issue
Apr 24, 2024
Bug Report
File descriptors could be
None
at Python initialization.print()
function implementation handles the case of stdout beingNone
: https://github.com/python/cpython/blob/6078f2033ea15a16cf52fe8d644a95a3be72d2e3/Python/bltinmodule.c#L2060Exception
implementation handles the case of stderr beingNone
: https://github.com/python/cpython/blob/6078f2033ea15a16cf52fe8d644a95a3be72d2e3/Python/errors.c#L1525To Reproduce (unix)
Expected Behavior
I want the real possible types of the previous
sys.std*
variables.Actual Behavior
https://github.com/python/mypy/blob/df35dcf020b3b03a8e3280edf8ada8c6ad8e0da5/mypy/typeshed/stdlib/sys/__init__.pyi#L71-L80
Your Environment
N/A
The text was updated successfully, but these errors were encountered: