[New-bugs-announce] [issue42053] fwalk: incorrect boolean test for non-fd arguments

dubiousjim report at bugs.python.org
Fri Oct 16 13:31:45 EDT 2020


New submission from dubiousjim <dubiousjim at gmail.com>:

`Lib/os.py` has at line 464, in definition of `fwalk`:

```
if not isinstance(top, int) or not hasattr(top, '__index__'):
```

If I understand this test correctly, it should be requiring that the name/fd is NEITHER an int NOR has an __index__ method. As written, anything which fails the left-hand side (and so is an int) will probably have an __index__ method, so the right-hand side is idle.

Proposed fix: change `or` to `and`.

----------
components: Library (Lib)
messages: 378725
nosy: dubiousjim
priority: normal
severity: normal
status: open
title: fwalk: incorrect boolean test for non-fd arguments
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42053>
_______________________________________


More information about the New-bugs-announce mailing list