As in #516 and #654, some code may ignore the documentation warning that stdin "may be replaced with file-like objects", and assume it's a "regular text file like those returned by the open() function", including buffer and related attributes.
This was discovered by the CPython argparse unit tests:
10:05:43.526 I File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/stdlib-common.imy/argparse.py", line 2555, in _get_value
10:05:43.526 I result = type_func(arg_string)
10:05:43.526 I ^^^^^^^^^^^^^^^^^^^^^
10:05:43.526 I File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/stdlib-common.imy/argparse.py", line 1309, in __call__
10:05:43.526 I return _sys.stdin.buffer if 'b' in self._mode else _sys.stdin
10:05:43.526 I ^^^^^^^^^^^^^^^^^
10:05:43.526 I AttributeError: 'EmptyInputStream' object has no attribute 'buffer'
As of Python 3.13, the default stdin (sys.__stdin__) returns EOF already, both on emulators with API levels 34 and 21, and the Pixel 7. If this applies to older Python versions too, we can just remove the sys.stdin override and the EmptyInputStream class.
As in #516 and #654, some code may ignore the documentation warning that stdin "may be replaced with file-like objects", and assume it's a "regular text file like those returned by the open() function", including
buffer
and related attributes.This was discovered by the CPython argparse unit tests:
As of Python 3.13, the default stdin (
sys.__stdin__
) returns EOF already, both on emulators with API levels 34 and 21, and the Pixel 7. If this applies to older Python versions too, we can just remove thesys.stdin
override and theEmptyInputStream
class.