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
f7a92673
Kaydet (Commit)
f7a92673
authored
Agu 13, 2015
tarafından
Robert Collins
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #21159: Improve message in configparser.InterpolationMissingOptionError.
Patch from Łukasz Langa.
üst
5e8d47f6
ac37ba07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
18 deletions
+21
-18
configparser.py
Lib/configparser.py
+14
-15
test_configparser.py
Lib/test/test_configparser.py
+4
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/configparser.py
Dosyayı görüntüle @
f7a92673
...
@@ -263,12 +263,9 @@ class InterpolationMissingOptionError(InterpolationError):
...
@@ -263,12 +263,9 @@ class InterpolationMissingOptionError(InterpolationError):
"""A string substitution required a setting which was not available."""
"""A string substitution required a setting which was not available."""
def
__init__
(
self
,
option
,
section
,
rawval
,
reference
):
def
__init__
(
self
,
option
,
section
,
rawval
,
reference
):
msg
=
(
"Bad value substitution:
\n
"
msg
=
(
"Bad value substitution: option {!r} in section {!r} contains "
"
\t
section: [
%
s]
\n
"
"an interpolation key {!r} which is not a valid option name. "
"
\t
option :
%
s
\n
"
"Raw value: {!r}"
.
format
(
option
,
section
,
reference
,
rawval
))
"
\t
key :
%
s
\n
"
"
\t
rawval :
%
s
\n
"
%
(
section
,
option
,
reference
,
rawval
))
InterpolationError
.
__init__
(
self
,
option
,
section
,
msg
)
InterpolationError
.
__init__
(
self
,
option
,
section
,
msg
)
self
.
reference
=
reference
self
.
reference
=
reference
self
.
args
=
(
option
,
section
,
rawval
,
reference
)
self
.
args
=
(
option
,
section
,
rawval
,
reference
)
...
@@ -286,11 +283,11 @@ class InterpolationDepthError(InterpolationError):
...
@@ -286,11 +283,11 @@ class InterpolationDepthError(InterpolationError):
"""Raised when substitutions are nested too deeply."""
"""Raised when substitutions are nested too deeply."""
def
__init__
(
self
,
option
,
section
,
rawval
):
def
__init__
(
self
,
option
,
section
,
rawval
):
msg
=
(
"
Value interpolation too deeply recursive:
\n
"
msg
=
(
"
Recursion limit exceeded in value substitution: option {!r}
"
"
\t
section: [
%
s]
\n
"
"
in section {!r} contains an interpolation key which
"
"
\t
option :
%
s
\n
"
"
cannot be substituted in {} steps. Raw value: {!r}
"
"
\t
rawval :
%
s
\n
"
"
"
.
format
(
option
,
section
,
MAX_INTERPOLATION_DEPTH
,
%
(
section
,
option
,
rawval
))
rawval
))
InterpolationError
.
__init__
(
self
,
option
,
section
,
msg
)
InterpolationError
.
__init__
(
self
,
option
,
section
,
msg
)
self
.
args
=
(
option
,
section
,
rawval
)
self
.
args
=
(
option
,
section
,
rawval
)
...
@@ -406,8 +403,9 @@ class BasicInterpolation(Interpolation):
...
@@ -406,8 +403,9 @@ class BasicInterpolation(Interpolation):
def
_interpolate_some
(
self
,
parser
,
option
,
accum
,
rest
,
section
,
map
,
def
_interpolate_some
(
self
,
parser
,
option
,
accum
,
rest
,
section
,
map
,
depth
):
depth
):
rawval
=
parser
.
get
(
section
,
option
,
raw
=
True
,
fallback
=
rest
)
if
depth
>
MAX_INTERPOLATION_DEPTH
:
if
depth
>
MAX_INTERPOLATION_DEPTH
:
raise
InterpolationDepthError
(
option
,
section
,
r
est
)
raise
InterpolationDepthError
(
option
,
section
,
r
awval
)
while
rest
:
while
rest
:
p
=
rest
.
find
(
"
%
"
)
p
=
rest
.
find
(
"
%
"
)
if
p
<
0
:
if
p
<
0
:
...
@@ -432,7 +430,7 @@ class BasicInterpolation(Interpolation):
...
@@ -432,7 +430,7 @@ class BasicInterpolation(Interpolation):
v
=
map
[
var
]
v
=
map
[
var
]
except
KeyError
:
except
KeyError
:
raise
InterpolationMissingOptionError
(
raise
InterpolationMissingOptionError
(
option
,
section
,
r
est
,
var
)
from
None
option
,
section
,
r
awval
,
var
)
from
None
if
"
%
"
in
v
:
if
"
%
"
in
v
:
self
.
_interpolate_some
(
parser
,
option
,
accum
,
v
,
self
.
_interpolate_some
(
parser
,
option
,
accum
,
v
,
section
,
map
,
depth
+
1
)
section
,
map
,
depth
+
1
)
...
@@ -466,8 +464,9 @@ class ExtendedInterpolation(Interpolation):
...
@@ -466,8 +464,9 @@ class ExtendedInterpolation(Interpolation):
def
_interpolate_some
(
self
,
parser
,
option
,
accum
,
rest
,
section
,
map
,
def
_interpolate_some
(
self
,
parser
,
option
,
accum
,
rest
,
section
,
map
,
depth
):
depth
):
rawval
=
parser
.
get
(
section
,
option
,
raw
=
True
,
fallback
=
rest
)
if
depth
>
MAX_INTERPOLATION_DEPTH
:
if
depth
>
MAX_INTERPOLATION_DEPTH
:
raise
InterpolationDepthError
(
option
,
section
,
r
est
)
raise
InterpolationDepthError
(
option
,
section
,
r
awval
)
while
rest
:
while
rest
:
p
=
rest
.
find
(
"$"
)
p
=
rest
.
find
(
"$"
)
if
p
<
0
:
if
p
<
0
:
...
@@ -504,7 +503,7 @@ class ExtendedInterpolation(Interpolation):
...
@@ -504,7 +503,7 @@ class ExtendedInterpolation(Interpolation):
"More than one ':' found:
%
r"
%
(
rest
,))
"More than one ':' found:
%
r"
%
(
rest
,))
except
(
KeyError
,
NoSectionError
,
NoOptionError
):
except
(
KeyError
,
NoSectionError
,
NoOptionError
):
raise
InterpolationMissingOptionError
(
raise
InterpolationMissingOptionError
(
option
,
section
,
r
est
,
":"
.
join
(
path
))
from
None
option
,
section
,
r
awval
,
":"
.
join
(
path
))
from
None
if
"$"
in
v
:
if
"$"
in
v
:
self
.
_interpolate_some
(
parser
,
opt
,
accum
,
v
,
sect
,
self
.
_interpolate_some
(
parser
,
opt
,
accum
,
v
,
sect
,
dict
(
parser
.
items
(
sect
,
raw
=
True
)),
dict
(
parser
.
items
(
sect
,
raw
=
True
)),
...
...
Lib/test/test_configparser.py
Dosyayı görüntüle @
f7a92673
...
@@ -847,7 +847,8 @@ class ConfigParserTestCase(BasicTestCase, unittest.TestCase):
...
@@ -847,7 +847,8 @@ class ConfigParserTestCase(BasicTestCase, unittest.TestCase):
"something with lots of interpolation (10 steps)"
)
"something with lots of interpolation (10 steps)"
)
e
=
self
.
get_error
(
cf
,
configparser
.
InterpolationDepthError
,
"Foo"
,
"bar11"
)
e
=
self
.
get_error
(
cf
,
configparser
.
InterpolationDepthError
,
"Foo"
,
"bar11"
)
if
self
.
interpolation
==
configparser
.
_UNSET
:
if
self
.
interpolation
==
configparser
.
_UNSET
:
self
.
assertEqual
(
e
.
args
,
(
"bar11"
,
"Foo"
,
"
%(with1)
s"
))
self
.
assertEqual
(
e
.
args
,
(
"bar11"
,
"Foo"
,
"something
%(with11)
s lots of interpolation (11 steps)"
))
elif
isinstance
(
self
.
interpolation
,
configparser
.
LegacyInterpolation
):
elif
isinstance
(
self
.
interpolation
,
configparser
.
LegacyInterpolation
):
self
.
assertEqual
(
e
.
args
,
(
"bar11"
,
"Foo"
,
self
.
assertEqual
(
e
.
args
,
(
"bar11"
,
"Foo"
,
"something
%(with11)
s lots of interpolation (11 steps)"
))
"something
%(with11)
s lots of interpolation (11 steps)"
))
...
@@ -861,7 +862,7 @@ class ConfigParserTestCase(BasicTestCase, unittest.TestCase):
...
@@ -861,7 +862,7 @@ class ConfigParserTestCase(BasicTestCase, unittest.TestCase):
self
.
assertEqual
(
e
.
option
,
"name"
)
self
.
assertEqual
(
e
.
option
,
"name"
)
if
self
.
interpolation
==
configparser
.
_UNSET
:
if
self
.
interpolation
==
configparser
.
_UNSET
:
self
.
assertEqual
(
e
.
args
,
(
'name'
,
'Interpolation Error'
,
self
.
assertEqual
(
e
.
args
,
(
'name'
,
'Interpolation Error'
,
''
,
'reference'
))
'
%(reference)
s
'
,
'reference'
))
elif
isinstance
(
self
.
interpolation
,
configparser
.
LegacyInterpolation
):
elif
isinstance
(
self
.
interpolation
,
configparser
.
LegacyInterpolation
):
self
.
assertEqual
(
e
.
args
,
(
'name'
,
'Interpolation Error'
,
self
.
assertEqual
(
e
.
args
,
(
'name'
,
'Interpolation Error'
,
'
%(reference)
s'
,
'reference'
))
'
%(reference)
s'
,
'reference'
))
...
@@ -1177,7 +1178,7 @@ class ConfigParserTestCaseExtendedInterpolation(BasicTestCase, unittest.TestCase
...
@@ -1177,7 +1178,7 @@ class ConfigParserTestCaseExtendedInterpolation(BasicTestCase, unittest.TestCase
with
self
.
assertRaises
(
exception_class
)
as
cm
:
with
self
.
assertRaises
(
exception_class
)
as
cm
:
cf
[
'interpolated'
][
'$trying'
]
cf
[
'interpolated'
][
'$trying'
]
self
.
assertEqual
(
cm
.
exception
.
reference
,
'dollars:${sick'
)
self
.
assertEqual
(
cm
.
exception
.
reference
,
'dollars:${sick'
)
self
.
assertEqual
(
cm
.
exception
.
args
[
2
],
'}'
)
#rawval
self
.
assertEqual
(
cm
.
exception
.
args
[
2
],
'
${dollars:${sick}
}'
)
#rawval
def
test_case_sensitivity_basic
(
self
):
def
test_case_sensitivity_basic
(
self
):
ini
=
textwrap
.
dedent
(
"""
ini
=
textwrap
.
dedent
(
"""
...
...
Misc/NEWS
Dosyayı görüntüle @
f7a92673
...
@@ -16,6 +16,9 @@ Core and Builtins
...
@@ -16,6 +16,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #21159: Improve message in configparser.InterpolationMissingOptionError.
Patch from Łukasz Langa.
- Issue #24847: Fixes tcltk installer layout of VC runtime DLL
- Issue #24847: Fixes tcltk installer layout of VC runtime DLL
- Issue #24839: platform._syscmd_ver raises DeprecationWarning
- Issue #24839: platform._syscmd_ver raises DeprecationWarning
...
...
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