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
176916a9
Kaydet (Commit)
176916a9
authored
Eyl 27, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Allow internal whitespace in keys.
Closes SF bug #583248; backporting to r22-maint branch.
üst
2ca041fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
ConfigParser.py
Lib/ConfigParser.py
+4
-3
test_cfgparser.py
Lib/test/test_cfgparser.py
+6
-0
No files found.
Lib/ConfigParser.py
Dosyayı görüntüle @
176916a9
...
@@ -418,7 +418,7 @@ class ConfigParser:
...
@@ -418,7 +418,7 @@ class ConfigParser:
r'\]'
# ]
r'\]'
# ]
)
)
OPTCRE
=
re
.
compile
(
OPTCRE
=
re
.
compile
(
r'(?P<option>[^:=\s]
+)'
# very permissive!
r'(?P<option>[^:=\s]
[^:=]*)'
# very permissive!
r'\s*(?P<vi>[:=])\s*'
# any number of space/tab,
r'\s*(?P<vi>[:=])\s*'
# any number of space/tab,
# followed by separator
# followed by separator
# (either : or =), followed
# (either : or =), followed
...
@@ -448,7 +448,8 @@ class ConfigParser:
...
@@ -448,7 +448,8 @@ class ConfigParser:
# comment or blank line?
# comment or blank line?
if
line
.
strip
()
==
''
or
line
[
0
]
in
'#;'
:
if
line
.
strip
()
==
''
or
line
[
0
]
in
'#;'
:
continue
continue
if
line
.
split
(
None
,
1
)[
0
]
.
lower
()
==
'rem'
and
line
[
0
]
in
"rR"
:
# no leading whitespace
if
line
.
split
(
None
,
1
)[
0
]
.
lower
()
==
'rem'
and
line
[
0
]
in
"rR"
:
# no leading whitespace
continue
continue
# continuation line?
# continuation line?
if
line
[
0
]
.
isspace
()
and
cursect
is
not
None
and
optname
:
if
line
[
0
]
.
isspace
()
and
cursect
is
not
None
and
optname
:
...
@@ -488,7 +489,7 @@ class ConfigParser:
...
@@ -488,7 +489,7 @@ class ConfigParser:
# allow empty values
# allow empty values
if
optval
==
'""'
:
if
optval
==
'""'
:
optval
=
''
optval
=
''
optname
=
self
.
optionxform
(
optname
)
optname
=
self
.
optionxform
(
optname
.
rstrip
()
)
cursect
[
optname
]
=
optval
cursect
[
optname
]
=
optval
else
:
else
:
# a non-fatal parsing error occurred. set up the
# a non-fatal parsing error occurred. set up the
...
...
Lib/test/test_cfgparser.py
Dosyayı görüntüle @
176916a9
...
@@ -16,6 +16,7 @@ def basic(src):
...
@@ -16,6 +16,7 @@ def basic(src):
r'Internationalized Stuff'
,
r'Internationalized Stuff'
,
r'Long Line'
,
r'Long Line'
,
r'Section\with$weird
%
characters['
'
\t
'
,
r'Section\with$weird
%
characters['
'
\t
'
,
r'Spaces'
,
r'Spacey Bar'
,
r'Spacey Bar'
,
],
],
"unexpected list of section names"
)
"unexpected list of section names"
)
...
@@ -26,6 +27,8 @@ def basic(src):
...
@@ -26,6 +27,8 @@ def basic(src):
verify
(
cf
.
get
(
'Foo Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Foo Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Spacey Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Spacey Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Commented Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Commented Bar'
,
'foo'
,
raw
=
1
)
==
'bar'
)
verify
(
cf
.
get
(
'Spaces'
,
'key with spaces'
,
raw
=
1
)
==
'value'
)
verify
(
cf
.
get
(
'Spaces'
,
'another with spaces'
,
raw
=
1
)
==
'splat!'
)
verify
(
'__name__'
not
in
cf
.
options
(
"Foo Bar"
),
verify
(
'__name__'
not
in
cf
.
options
(
"Foo Bar"
),
'__name__ "option" should not be exposed by the API!'
)
'__name__ "option" should not be exposed by the API!'
)
...
@@ -225,6 +228,9 @@ foo[bg]: Bulgarian
...
@@ -225,6 +228,9 @@ foo[bg]: Bulgarian
foo=Default
foo=Default
foo[en]=English
foo[en]=English
foo[de]=Deutsch
foo[de]=Deutsch
[Spaces]
key with spaces : value
another with spaces = splat!
"""
)
"""
)
write
(
"""[Long Line]
write
(
"""[Long Line]
foo: this line is much, much longer than my editor
foo: this line is much, much longer than my editor
...
...
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