Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b5102e35
Kaydet (Commit)
b5102e35
authored
Eyl 29, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22958: Constructor and update method of weakref.WeakValueDictionary
now accept the self and the dict keyword arguments.
üst
68f5ef22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
test_weakref.py
Lib/test/test_weakref.py
+25
-0
weakref.py
Lib/weakref.py
+15
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_weakref.py
Dosyayı görüntüle @
b5102e35
...
...
@@ -1408,6 +1408,18 @@ class MappingTestCase(TestBase):
dict2
=
weakref
.
WeakValueDictionary
(
dict
)
self
.
assertEqual
(
dict
[
364
],
o
)
def
test_make_weak_valued_dict_misc
(
self
):
# errors
self
.
assertRaises
(
TypeError
,
weakref
.
WeakValueDictionary
.
__init__
)
self
.
assertRaises
(
TypeError
,
weakref
.
WeakValueDictionary
,
{},
{})
self
.
assertRaises
(
TypeError
,
weakref
.
WeakValueDictionary
,
(),
())
# special keyword arguments
o
=
Object
(
3
)
for
kw
in
'self'
,
'dict'
,
'other'
,
'iterable'
:
d
=
weakref
.
WeakValueDictionary
(
**
{
kw
:
o
})
self
.
assertEqual
(
list
(
d
.
keys
()),
[
kw
])
self
.
assertEqual
(
d
[
kw
],
o
)
def
make_weak_valued_dict
(
self
):
dict
=
weakref
.
WeakValueDictionary
()
objects
=
list
(
map
(
Object
,
range
(
self
.
COUNT
)))
...
...
@@ -1488,6 +1500,19 @@ class MappingTestCase(TestBase):
def
test_weak_valued_dict_update
(
self
):
self
.
check_update
(
weakref
.
WeakValueDictionary
,
{
1
:
C
(),
'a'
:
C
(),
C
():
C
()})
# errors
self
.
assertRaises
(
TypeError
,
weakref
.
WeakValueDictionary
.
update
)
d
=
weakref
.
WeakValueDictionary
()
self
.
assertRaises
(
TypeError
,
d
.
update
,
{},
{})
self
.
assertRaises
(
TypeError
,
d
.
update
,
(),
())
self
.
assertEqual
(
list
(
d
.
keys
()),
[])
# special keyword arguments
o
=
Object
(
3
)
for
kw
in
'self'
,
'dict'
,
'other'
,
'iterable'
:
d
=
weakref
.
WeakValueDictionary
()
d
.
update
(
**
{
kw
:
o
})
self
.
assertEqual
(
list
(
d
.
keys
()),
[
kw
])
self
.
assertEqual
(
d
[
kw
],
o
)
def
test_weak_keyed_dict_update
(
self
):
self
.
check_update
(
weakref
.
WeakKeyDictionary
,
...
...
Lib/weakref.py
Dosyayı görüntüle @
b5102e35
...
...
@@ -98,7 +98,13 @@ class WeakValueDictionary(collections.MutableMapping):
# objects are unwrapped on the way out, and we always wrap on the
# way in).
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
*
args
,
**
kw
):
if
not
args
:
raise
TypeError
(
"descriptor '__init__' of 'WeakValueDictionary' "
"object needs an argument"
)
self
,
*
args
=
args
if
len
(
args
)
>
1
:
raise
TypeError
(
'expected at most 1 arguments, got
%
d'
%
len
(
args
))
def
remove
(
wr
,
selfref
=
ref
(
self
)):
self
=
selfref
()
if
self
is
not
None
:
...
...
@@ -252,7 +258,14 @@ class WeakValueDictionary(collections.MutableMapping):
else
:
return
wr
()
def
update
(
self
,
dict
=
None
,
**
kwargs
):
def
update
(
*
args
,
**
kwargs
):
if
not
args
:
raise
TypeError
(
"descriptor 'update' of 'WeakValueDictionary' "
"object needs an argument"
)
self
,
*
args
=
args
if
len
(
args
)
>
1
:
raise
TypeError
(
'expected at most 1 arguments, got
%
d'
%
len
(
args
))
dict
=
args
[
0
]
if
args
else
None
if
self
.
_pending_removals
:
self
.
_commit_removals
()
d
=
self
.
data
...
...
Misc/NEWS
Dosyayı görüntüle @
b5102e35
...
...
@@ -78,6 +78,9 @@ Core and Builtins
Library
-------
-
Issue
#
22958
:
Constructor
and
update
method
of
weakref
.
WeakValueDictionary
now
accept
the
self
and
the
dict
keyword
arguments
.
-
Issue
#
22609
:
Constructor
of
collections
.
UserDict
now
accepts
the
self
keyword
argument
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment