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
a2e7acd1
Kaydet (Commit)
a2e7acd1
authored
Ock 01, 2013
tarafından
Łukasz Langa
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
configparser: preserve section order when using `__setitem__` (issue #16820)
üst
e4110dc1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
configparser.py
Lib/configparser.py
+2
-1
test_cfgparser.py
Lib/test/test_cfgparser.py
+26
-0
No files found.
Lib/configparser.py
Dosyayı görüntüle @
a2e7acd1
...
@@ -959,7 +959,8 @@ class RawConfigParser(MutableMapping):
...
@@ -959,7 +959,8 @@ class RawConfigParser(MutableMapping):
# XXX this is not atomic if read_dict fails at any point. Then again,
# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this implementation.
# no update method in configparser is atomic in this implementation.
self
.
remove_section
(
key
)
if
key
in
self
.
_sections
:
self
.
_sections
[
key
]
.
clear
()
self
.
read_dict
({
key
:
value
})
self
.
read_dict
({
key
:
value
})
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
...
...
Lib/test/test_cfgparser.py
Dosyayı görüntüle @
a2e7acd1
...
@@ -797,6 +797,32 @@ boolean {0[0]} NO
...
@@ -797,6 +797,32 @@ boolean {0[0]} NO
self
.
assertEqual
(
set
(
cf
.
sections
()),
set
())
self
.
assertEqual
(
set
(
cf
.
sections
()),
set
())
self
.
assertEqual
(
set
(
cf
[
self
.
default_section
]
.
keys
()),
{
'foo'
})
self
.
assertEqual
(
set
(
cf
[
self
.
default_section
]
.
keys
()),
{
'foo'
})
def
test_setitem
(
self
):
cf
=
self
.
fromstring
(
"""
[section1]
name1 {0[0]} value1
[section2]
name2 {0[0]} value2
[section3]
name3 {0[0]} value3
"""
.
format
(
self
.
delimiters
),
defaults
=
{
"nameD"
:
"valueD"
})
self
.
assertEqual
(
set
(
cf
[
'section1'
]
.
keys
()),
{
'name1'
,
'named'
})
self
.
assertEqual
(
set
(
cf
[
'section2'
]
.
keys
()),
{
'name2'
,
'named'
})
self
.
assertEqual
(
set
(
cf
[
'section3'
]
.
keys
()),
{
'name3'
,
'named'
})
self
.
assertEqual
(
cf
[
'section1'
][
'name1'
],
'value1'
)
self
.
assertEqual
(
cf
[
'section2'
][
'name2'
],
'value2'
)
self
.
assertEqual
(
cf
[
'section3'
][
'name3'
],
'value3'
)
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
cf
[
'section2'
]
=
{
'name22'
:
'value22'
}
self
.
assertEqual
(
set
(
cf
[
'section2'
]
.
keys
()),
{
'name22'
,
'named'
})
self
.
assertEqual
(
cf
[
'section2'
][
'name22'
],
'value22'
)
self
.
assertNotIn
(
'name2'
,
cf
[
'section2'
])
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
cf
[
'section3'
]
=
{}
self
.
assertEqual
(
set
(
cf
[
'section3'
]
.
keys
()),
{
'named'
})
self
.
assertNotIn
(
'name3'
,
cf
[
'section3'
])
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
class
StrictTestCase
(
BasicTestCase
):
class
StrictTestCase
(
BasicTestCase
):
config_class
=
configparser
.
RawConfigParser
config_class
=
configparser
.
RawConfigParser
...
...
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