Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8d5dd98a
Commit
8d5dd98a
authored
Dec 30, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added InterpolationSyntaxError to __all__
- added docstring to exceptions
parent
81e4aa70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
Lib/ConfigParser.py
Lib/ConfigParser.py
+25
-4
No files found.
Lib/ConfigParser.py
View file @
8d5dd98a
...
@@ -89,9 +89,10 @@ ConfigParser -- responsible for for parsing a list of
...
@@ -89,9 +89,10 @@ ConfigParser -- responsible for for parsing a list of
import
re
import
re
__all__
=
[
"NoSectionError"
,
"DuplicateSectionError"
,
"NoOptionError"
,
__all__
=
[
"NoSectionError"
,
"DuplicateSectionError"
,
"NoOptionError"
,
"InterpolationError"
,
"InterpolationDepthError"
,
"ParsingError"
,
"InterpolationError"
,
"InterpolationDepthError"
,
"MissingSectionHeaderError"
,
"ConfigParser"
,
"InterpolationSyntaxError"
,
"ParsingError"
,
"MissingSectionHeaderError"
,
"ConfigParser"
,
"DEFAULTSECT"
,
"MAX_INTERPOLATION_DEPTH"
]
"DEFAULTSECT"
,
"MAX_INTERPOLATION_DEPTH"
]
DEFAULTSECT
=
"DEFAULT"
DEFAULTSECT
=
"DEFAULT"
...
@@ -102,24 +103,34 @@ MAX_INTERPOLATION_DEPTH = 10
...
@@ -102,24 +103,34 @@ MAX_INTERPOLATION_DEPTH = 10
# exception classes
# exception classes
class
Error
(
Exception
):
class
Error
(
Exception
):
"""Base class for ConfigParser exceptions."""
def
__init__
(
self
,
msg
=
''
):
def
__init__
(
self
,
msg
=
''
):
self
.
_msg
=
msg
self
.
_msg
=
msg
Exception
.
__init__
(
self
,
msg
)
Exception
.
__init__
(
self
,
msg
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
_msg
return
self
.
_msg
__str__
=
__repr__
__str__
=
__repr__
class
NoSectionError
(
Error
):
class
NoSectionError
(
Error
):
"""Raised when no section matches a requested option."""
def
__init__
(
self
,
section
):
def
__init__
(
self
,
section
):
Error
.
__init__
(
self
,
'No section: %s'
%
section
)
Error
.
__init__
(
self
,
'No section: %s'
%
section
)
self
.
section
=
section
self
.
section
=
section
class
DuplicateSectionError
(
Error
):
class
DuplicateSectionError
(
Error
):
"""Raised when a section is multiply-created."""
def
__init__
(
self
,
section
):
def
__init__
(
self
,
section
):
Error
.
__init__
(
self
,
"Section %s already exists"
%
section
)
Error
.
__init__
(
self
,
"Section %s already exists"
%
section
)
self
.
section
=
section
self
.
section
=
section
class
NoOptionError
(
Error
):
class
NoOptionError
(
Error
):
"""A requested option was not found."""
def
__init__
(
self
,
option
,
section
):
def
__init__
(
self
,
option
,
section
):
Error
.
__init__
(
self
,
"No option `%s' in section: %s"
%
Error
.
__init__
(
self
,
"No option `%s' in section: %s"
%
(
option
,
section
))
(
option
,
section
))
...
@@ -127,6 +138,8 @@ class NoOptionError(Error):
...
@@ -127,6 +138,8 @@ class NoOptionError(Error):
self
.
section
=
section
self
.
section
=
section
class
InterpolationError
(
Error
):
class
InterpolationError
(
Error
):
"""A string substitution required a setting which was not available."""
def
__init__
(
self
,
reference
,
option
,
section
,
rawval
):
def
__init__
(
self
,
reference
,
option
,
section
,
rawval
):
Error
.
__init__
(
self
,
Error
.
__init__
(
self
,
"Bad value substitution:
\
n
"
"Bad value substitution:
\
n
"
...
@@ -139,9 +152,13 @@ class InterpolationError(Error):
...
@@ -139,9 +152,13 @@ class InterpolationError(Error):
self
.
option
=
option
self
.
option
=
option
self
.
section
=
section
self
.
section
=
section
class
InterpolationSyntaxError
(
Error
):
pass
class
InterpolationSyntaxError
(
Error
):
"""Raised when the source text into which substitutions are made
does not conform to the required syntax."""
class
InterpolationDepthError
(
Error
):
class
InterpolationDepthError
(
Error
):
"""Raised when substitutions are nested too deeply."""
def
__init__
(
self
,
option
,
section
,
rawval
):
def
__init__
(
self
,
option
,
section
,
rawval
):
Error
.
__init__
(
self
,
Error
.
__init__
(
self
,
"Value interpolation too deeply recursive:
\
n
"
"Value interpolation too deeply recursive:
\
n
"
...
@@ -153,6 +170,8 @@ class InterpolationDepthError(Error):
...
@@ -153,6 +170,8 @@ class InterpolationDepthError(Error):
self
.
section
=
section
self
.
section
=
section
class
ParsingError
(
Error
):
class
ParsingError
(
Error
):
"""Raised when a configuration file does not follow legal syntax."""
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
Error
.
__init__
(
self
,
'File contains parsing errors: %s'
%
filename
)
Error
.
__init__
(
self
,
'File contains parsing errors: %s'
%
filename
)
self
.
filename
=
filename
self
.
filename
=
filename
...
@@ -163,6 +182,8 @@ class ParsingError(Error):
...
@@ -163,6 +182,8 @@ class ParsingError(Error):
self
.
_msg
=
self
.
_msg
+
'
\
n
\
t
[line %2d]: %s'
%
(
lineno
,
line
)
self
.
_msg
=
self
.
_msg
+
'
\
n
\
t
[line %2d]: %s'
%
(
lineno
,
line
)
class
MissingSectionHeaderError
(
ParsingError
):
class
MissingSectionHeaderError
(
ParsingError
):
"""Raised when a key-value pair is found before any section header."""
def
__init__
(
self
,
filename
,
lineno
,
line
):
def
__init__
(
self
,
filename
,
lineno
,
line
):
Error
.
__init__
(
Error
.
__init__
(
self
,
self
,
...
...
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