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

2020-10-16 Thread dubiousjim


New submission from dubiousjim :

`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 
<https://bugs.python.org/issue42053>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28427] WeakValueDictionary next bug (with multithreading)

2017-08-02 Thread dubiousjim

dubiousjim added the comment:

In response to Issue #7105, self._pending_removals was added to 
WeakValueDictionaries (and also WeakKeyDictionaries, but they're not relevant 
to what I'm about to discuss). This was in changesets 58194 to tip and 58195 to 
3.1, back in Jan 2010. In those changesets, the implementation of 
WeakValueDictionary.setdefault acquired a check on self._pending_removals, but 
only after the key lookup had failed. (See lines starting 5.127 in both those 
changesets.)

In changeset 87778, in Dec 2013, this same patch was backported to 2.7.

More recently, in response to the issue discussed above (Issue #28427), similar 
checks were added to WeakValueDictionary.get, but now BEFORE the  key lookup. 
This was in changesets 105851 to 3.5, 105852 to 3.6, 105853 to tip, and 105854 
to 2.7, in Dec 2016. Notably, in the last changeset, the check on 
self._pending_removals on WeakValueDictionary.setdefault is also moved to the 
top of the function, before the key lookup is attempted. This parallels the 
change being made to WeakValueDictionary.get.

However, that change to WeakValueDictionary.setdefault was only made to the 2.7 
branch. If it's correct, then why wasn't the same also done for 3.5, 3.6, and 
tip?

--
nosy: +dubiousjim

___
Python tracker 
<http://bugs.python.org/issue28427>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com