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
1c746c28
Kaydet (Commit)
1c746c28
authored
Nis 15, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix minor subclassing issue with collections.Counter
üst
181810b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
collections.py
Lib/collections.py
+2
-2
test_collections.py
Lib/test/test_collections.py
+9
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/collections.py
Dosyayı görüntüle @
1c746c28
...
...
@@ -459,8 +459,8 @@ class Counter(dict):
self
.
update
(
kwds
)
def
copy
(
self
):
'
Like dict.copy() but returns a Counter instance instead of a dict
.'
return
Counter
(
self
)
'
Return a shallow copy
.'
return
self
.
__class__
(
self
)
def
__reduce__
(
self
):
return
self
.
__class__
,
(
dict
(
self
),)
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
1c746c28
...
...
@@ -680,6 +680,15 @@ class TestCounter(unittest.TestCase):
self
.
assertEqual
(
len
(
dup
),
len
(
words
))
self
.
assertEqual
(
type
(
dup
),
type
(
words
))
def
test_copy_subclass
(
self
):
class
MyCounter
(
Counter
):
pass
c
=
MyCounter
(
'slartibartfast'
)
d
=
c
.
copy
()
self
.
assertEqual
(
d
,
c
)
self
.
assertEqual
(
len
(
d
),
len
(
c
))
self
.
assertEqual
(
type
(
d
),
type
(
c
))
def
test_conversions
(
self
):
# Convert to: set, list, dict
s
=
'she sells sea shells by the sea shore'
...
...
Misc/NEWS
Dosyayı görüntüle @
1c746c28
...
...
@@ -58,6 +58,8 @@ Library
- Issue #11467: Fix urlparse behavior when handling urls which contains scheme
specific part only digits. Patch by Santoso Wijaya.
- collections.Counter().copy() now works correctly for subclasses.
- Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
Patch by Santoso Wijaya.
...
...
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