Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue22958

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Constructors of weakref mapping classes don't accept "self" and "dict" keyword arguments
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.4, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:22609Superseder:
Assigned To:Nosy List: benjamin.peterson, fdrake, pitrou, python-dev, rhettinger, serhiy.storchaka
Priority:normalKeywords:needs review, patch

Created on2014-11-27 16:13 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
WeakValueDictionary_pos_only_params.patchserhiy.storchaka,2014-12-09 09:41review
Messages (4)
msg231767 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2014-11-27 16:13
Dict-like types in the weakref module (WeakValueDictionary and WeakKeyDictionary) don't allow to specify key-value pair as keyword arguments if key is "self" or "dict".>>> import weakref>>> class A: pass... >>> a = A()>>> d = weakref.WeakValueDictionary(spam=a)>>> list(d.items())[('spam', <__main__.A object at 0xb6f3f88c>)]>>> weakref.WeakValueDictionary(self=a)Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: __init__() got multiple values for argument 'self'>>> weakref.WeakValueDictionary(dict=a)Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/serhiy/py/cpython/Lib/weakref.py", line 114, in __init__    self.update(*args, **kw)  File "/home/serhiy/py/cpython/Lib/weakref.py", line 261, in update    dict = type({})(dict)TypeError: 'A' object is not iterable>>> d = weakref.WeakValueDictionary()>>> d.update(spam=a)>>> list(d.items())[('spam', <__main__.A object at 0xb6f3f88c>)]>>> d.update(self=a)Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: update() got multiple values for argument 'self'>>> d.update(dict=a)Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/serhiy/py/cpython/Lib/weakref.py", line 261, in update    dict = type({})(dict)TypeError: 'A' object is not iterableRelated issue for the collections module isissue22609. I think weakref mapping classes should be fixed in the same manner.
msg232358 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2014-12-09 09:41
Here is a patch similar to patch fromissue22609 which makes WeakValueDictionary constructor and update accept keyword arguments "self" and "dict".
msg238694 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2015-03-20 15:45
lgtm
msg251885 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-09-29 20:54
New changeset8274fc521e69 by Serhiy Storchaka in branch '2.7':Issue#22958: Constructor and update method of weakref.WeakValueDictionaryhttps://hg.python.org/cpython/rev/8274fc521e69New changeset01c79072d671 by Serhiy Storchaka in branch '3.4':Issue#22958: Constructor and update method of weakref.WeakValueDictionaryhttps://hg.python.org/cpython/rev/01c79072d671New changeset73b6b88ac28a by Serhiy Storchaka in branch '3.5':Issue#22958: Constructor and update method of weakref.WeakValueDictionaryhttps://hg.python.org/cpython/rev/73b6b88ac28aNew changeset815bb6a2d69e by Serhiy Storchaka in branch 'default':Issue#22958: Constructor and update method of weakref.WeakValueDictionaryhttps://hg.python.org/cpython/rev/815bb6a2d69e
History
DateUserActionArgs
2022-04-11 14:58:10adminsetgithub: 67147
2015-09-29 21:00:08serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-09-29 20:54:28python-devsetnosy: +python-dev
messages: +msg251885
2015-05-16 16:11:09serhiy.storchakasetdependencies: +Constructors of some mapping classes don't accept `self` keyword argument
2015-03-20 15:45:45benjamin.petersonsetnosy: +benjamin.peterson
messages: +msg238694
2014-12-09 09:41:08serhiy.storchakasetkeywords: +needs review,patch
files: +WeakValueDictionary_pos_only_params.patch
messages: +msg232358

stage: patch review
2014-11-27 16:13:23serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp