Message354444
Note that the underlying stat call supports file descriptors, which are non-negative integers. This is a supported and tested capability for genericpath.exists (see GenericTest.test_exists_fd in Lib/test/test_genericpath.py).
False and True are integers with the values 0 and 1:
>>> issubclass(bool, int)
True
>>> False + 0
0
>>> True + 0
1
That can be useful, but there may be cases where we don't want to conflate bools and integers. IMO, a bool should not be supported as a file descriptor. It's likely a bug that should be caught early instead of meaninglessly propagated.
A high-level solution would check for bool instances in genericpath.exists. A low-level solution, to make this policy consistent in general, would be to modify _fd_converter in Modules/posixmodule.c to disallow bool instances. |
|
Date |
User |
Action |
Args |
2019-10-11 12:17:27 | eryksun | set | recipients:
+ eryksun, Mariano Anaya, Nika |
2019-10-11 12:17:27 | eryksun | set | messageid: <1570796247.75.0.235295203615.issue38445@roundup.psfhosted.org> |
2019-10-11 12:17:27 | eryksun | link | issue38445 messages |
2019-10-11 12:17:27 | eryksun | create | |
|