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
69976a7f
Kaydet (Commit)
69976a7f
authored
Eyl 12, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9826: Handle recursive repr in collections.OrderedDict.
üst
22450c2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
collections.py
Lib/collections.py
+12
-4
test_collections.py
Lib/test/test_collections.py
+7
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/collections.py
Dosyayı görüntüle @
69976a7f
...
...
@@ -43,6 +43,7 @@ class OrderedDict(dict, MutableMapping):
'''
if
len
(
args
)
>
1
:
raise
TypeError
(
'expected at most 1 arguments, got
%
d'
%
len
(
args
))
self
.
__in_repr
=
False
# detects recursive repr
try
:
self
.
__root
except
AttributeError
:
...
...
@@ -100,10 +101,10 @@ class OrderedDict(dict, MutableMapping):
def
__reduce__
(
self
):
'Return state information for pickling'
items
=
[[
k
,
self
[
k
]]
for
k
in
self
]
tmp
=
self
.
__map
,
self
.
__root
del
self
.
__map
,
self
.
__root
tmp
=
self
.
__map
,
self
.
__root
,
self
.
__in_repr
del
self
.
__map
,
self
.
__root
,
self
.
__in_repr
inst_dict
=
vars
(
self
)
.
copy
()
self
.
__map
,
self
.
__root
=
tmp
self
.
__map
,
self
.
__root
,
self
.
__in_repr
=
tmp
if
inst_dict
:
return
(
self
.
__class__
,
(
items
,),
inst_dict
)
return
self
.
__class__
,
(
items
,)
...
...
@@ -128,9 +129,16 @@ class OrderedDict(dict, MutableMapping):
def
__repr__
(
self
):
'od.__repr__() <==> repr(od)'
if
self
.
__in_repr
:
return
'...'
if
not
self
:
return
'
%
s()'
%
(
self
.
__class__
.
__name__
,)
return
'
%
s(
%
r)'
%
(
self
.
__class__
.
__name__
,
list
(
self
.
items
()))
self
.
__in_repr
=
True
try
:
result
=
'
%
s(
%
r)'
%
(
self
.
__class__
.
__name__
,
list
(
self
.
items
()))
finally
:
self
.
__in_repr
=
False
return
result
def
copy
(
self
):
'od.copy() -> a shallow copy of od'
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
69976a7f
...
...
@@ -908,6 +908,13 @@ class TestOrderedDict(unittest.TestCase):
self
.
assertEqual
(
eval
(
repr
(
od
)),
od
)
self
.
assertEqual
(
repr
(
OrderedDict
()),
"OrderedDict()"
)
def
test_repr_recursive
(
self
):
# See issue #9826
od
=
OrderedDict
.
fromkeys
(
'abc'
)
od
[
'x'
]
=
od
self
.
assertEqual
(
repr
(
od
),
"OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])"
)
def
test_setdefault
(
self
):
pairs
=
[(
'c'
,
1
),
(
'b'
,
2
),
(
'a'
,
3
),
(
'd'
,
4
),
(
'e'
,
5
),
(
'f'
,
6
)]
shuffle
(
pairs
)
...
...
Misc/NEWS
Dosyayı görüntüle @
69976a7f
...
...
@@ -122,6 +122,9 @@ Library
to fetch the original errno, or to filter timeout errors. Now the
original error is re-raised.
- Issue #9826: OrderedDict.__repr__ can now handle self-referential
values: d['x'] = d.
- Issue #9758: When fcntl.ioctl() was called with mutable_flag set to True,
and the passed buffer was exactly 1024 bytes long, the buffer wouldn't
be updated back after the system call. Original patch by Brian Brazil.
...
...
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