Issue38761
Created on 2019-11-10 11:39 by Nils Kattenbeck, last changed 2019-11-11 04:13 by rhettinger. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17104 | merged | rhettinger, 2019-11-10 21:42 | |
| Messages (5) | |||
|---|---|---|---|
| msg356326 - (view) | Author: Nils Kattenbeck (Nils Kattenbeck) * | Date: 2019-11-10 11:39 | |
Instances of weakref.WeakSet are not instances of Set and therefore not of MutableSet but they are instances of Collection. They however implement all required methods for a MutableSet and Weak(Key|Value)Dictionary are correctly identified. Is this just an oversight or am I missing something? from weakref import WeakKeyDictionary, WeakValueDictionary, WeakSet from collections.abc import MutableMapping, Collection, Set, MutableSet wkdict = WeakKeyDictionary() wvdict = WeakValueDictionary() ws = WeakSet() assert isinstance(wkdict, MutableMapping) assert isinstance(wvdict, MutableMapping) assert isinstance(ws, Collection) assert not isinstance(ws, Set) assert not isinstance(ws, MutableSet) |
|||
| msg356337 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-11-10 21:32 | |
We could register the WeakSet in _collections_abc, right after MutableSet is defined. That module only registered builtins so that it can avoid imports; however, since we know that WeakSet is already loaded, it is reasonable to add an import for registration purposes. This was likely omitted because WeakSet is used in the implementation of the ABC. Marking this as a proposed enhancement rather than as a bug because the collections ABCs are under no obligation to register anything more than the builtins. |
|||
| msg356343 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2019-11-10 23:37 | |
As I wrote between the lines in the PR, this would be a bug in the weakref module, not a bug in collections.abc. |
|||
| msg356349 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-11-11 04:12 | |
New changeset 84ac4376587e35d16b4d0977c4f330d9d04b690a by Raymond Hettinger in branch 'master': bpo-38761: Register WeakSet as a MutableSet (GH-17104) https://github.com/python/cpython/commit/84ac4376587e35d16b4d0977c4f330d9d04b690a |
|||
| msg356350 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-11-11 04:13 | |
Nils, thanks for the report. Guido, thanks for the clarification. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-11-11 04:13:30 | rhettinger | set | status: open -> closed resolution: fixed messages: + msg356350 stage: patch review -> resolved |
| 2019-11-11 04:12:23 | rhettinger | set | messages: + msg356349 |
| 2019-11-10 23:37:39 | gvanrossum | set | messages: + msg356343 |
| 2019-11-10 21:42:36 | rhettinger | set | keywords:
+ patch stage: patch review pull_requests: + pull_request16610 |
| 2019-11-10 21:32:50 | rhettinger | set | versions:
+ Python 3.9, - Python 3.7 nosy: + rhettinger, gvanrossum messages: + msg356337 assignee: rhettinger |
| 2019-11-10 11:39:15 | Nils Kattenbeck | create | |