Eryk Sun <[email protected]> added the comment:
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.
----------
nosy: +eryksun
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38445>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com