mirror of
https://github.com/python/cpython.git
synced 2025-08-18 15:51:23 +00:00
Merged revisions 83226-83227,83229-83230,83232 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83226 | georg.brandl | 2010-07-29 16:17:12 +0200 (Do, 29 Jul 2010) | 1 line #1090076: explain the behavior of *vars* in get() better. ........ r83227 | georg.brandl | 2010-07-29 16:23:06 +0200 (Do, 29 Jul 2010) | 1 line Use Py_CLEAR(). ........ r83229 | georg.brandl | 2010-07-29 16:32:22 +0200 (Do, 29 Jul 2010) | 1 line #9407: document configparser.Error. ........ r83230 | georg.brandl | 2010-07-29 16:36:11 +0200 (Do, 29 Jul 2010) | 1 line Use correct directive and name. ........ r83232 | georg.brandl | 2010-07-29 16:49:08 +0200 (Do, 29 Jul 2010) | 1 line #9388: remove ERA_YEAR which is never defined in the source code. ........
This commit is contained in:
parent
f0881ab1fe
commit
d070cc5350
5 changed files with 32 additions and 18 deletions
|
@ -41,6 +41,18 @@ section, or values in a special ``DEFAULT`` section. Additional defaults can be
|
||||||
provided on initialization and retrieval. Lines beginning with ``'#'`` or
|
provided on initialization and retrieval. Lines beginning with ``'#'`` or
|
||||||
``';'`` are ignored and may be used to provide comments.
|
``';'`` are ignored and may be used to provide comments.
|
||||||
|
|
||||||
|
Configuration files may include comments, prefixed by specific characters (``#``
|
||||||
|
and ``;``). Comments may appear on their own in an otherwise empty line, or may
|
||||||
|
be entered in lines holding values or spection names. In the latter case, they
|
||||||
|
need to be preceded by a whitespace character to be recognized as a comment.
|
||||||
|
(For backwards compatibility, only ``;`` starts an inline comment, while ``#``
|
||||||
|
does not.)
|
||||||
|
|
||||||
|
On top of the core functionality, :class:`SafeConfigParser` supports
|
||||||
|
interpolation. This means values can contain format strings which refer to
|
||||||
|
other values in the same section, or values in a special ``DEFAULT`` section.
|
||||||
|
Additional defaults can be provided on initialization.
|
||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
[My Section]
|
[My Section]
|
||||||
|
@ -128,6 +140,11 @@ write-back, as will be the keys within each section.
|
||||||
*allow_no_value* was added.
|
*allow_no_value* was added.
|
||||||
|
|
||||||
|
|
||||||
|
.. exception:: Error
|
||||||
|
|
||||||
|
Base class for all other configparser exceptions.
|
||||||
|
|
||||||
|
|
||||||
.. exception:: NoSectionError
|
.. exception:: NoSectionError
|
||||||
|
|
||||||
Exception raised when a specified section is not found.
|
Exception raised when a specified section is not found.
|
||||||
|
@ -371,11 +388,13 @@ The :class:`ConfigParser` class extends some methods of the
|
||||||
|
|
||||||
.. method:: ConfigParser.get(section, option[, raw[, vars]])
|
.. method:: ConfigParser.get(section, option[, raw[, vars]])
|
||||||
|
|
||||||
Get an *option* value for the named *section*. All the ``'%'`` interpolations
|
Get an *option* value for the named *section*. If *vars* is provided, it
|
||||||
are expanded in the return values, based on the defaults passed into the
|
must be a dictionary. The *option* is looked up in *vars* (if provided),
|
||||||
constructor, as well as the options *vars* provided, unless the *raw* argument
|
*section*, and in *defaults* in that order.
|
||||||
is true.
|
|
||||||
|
|
||||||
|
All the ``'%'`` interpolations are expanded in the return values, unless the
|
||||||
|
*raw* argument is true. Values for interpolation keys are looked up in the
|
||||||
|
same manner as the option.
|
||||||
|
|
||||||
.. method:: ConfigParser.items(section[, raw[, vars]])
|
.. method:: ConfigParser.items(section[, raw[, vars]])
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ loops that truncate the stream.
|
||||||
yield element
|
yield element
|
||||||
|
|
||||||
|
|
||||||
.. function:: itertools.chain.from_iterable(iterable)
|
.. classmethod:: chain.from_iterable(iterable)
|
||||||
|
|
||||||
Alternate constructor for :func:`chain`. Gets chained inputs from a
|
Alternate constructor for :func:`chain`. Gets chained inputs from a
|
||||||
single iterable argument that is evaluated lazily. Equivalent to::
|
single iterable argument that is evaluated lazily. Equivalent to::
|
||||||
|
|
|
@ -248,10 +248,6 @@ The :mod:`locale` module defines the following exception and functions:
|
||||||
specified, and therefore you should not assume knowledge of it on different
|
specified, and therefore you should not assume knowledge of it on different
|
||||||
systems.
|
systems.
|
||||||
|
|
||||||
.. data:: ERA_YEAR
|
|
||||||
|
|
||||||
Get the year in the relevant era of the locale.
|
|
||||||
|
|
||||||
.. data:: ERA_D_T_FMT
|
.. data:: ERA_D_T_FMT
|
||||||
|
|
||||||
Get a format string for :func:`strftime` to represent dates and times in a
|
Get a format string for :func:`strftime` to represent dates and times in a
|
||||||
|
|
|
@ -550,11 +550,12 @@ class ConfigParser(RawConfigParser):
|
||||||
def get(self, section, option, raw=False, vars=None):
|
def get(self, section, option, raw=False, vars=None):
|
||||||
"""Get an option value for a given section.
|
"""Get an option value for a given section.
|
||||||
|
|
||||||
All % interpolations are expanded in the return values, based on the
|
If `vars' is provided, it must be a dictionary. The option is looked up
|
||||||
defaults passed into the constructor, unless the optional argument
|
in `vars' (if provided), `section', and in `defaults' in that order.
|
||||||
`raw' is true. Additional substitutions may be provided using the
|
|
||||||
`vars' argument, which must be a dictionary whose contents overrides
|
All % interpolations are expanded in the return values, unless the
|
||||||
any pre-existing defaults.
|
optional argument `raw' is true. Values for interpolation keys are
|
||||||
|
looked up in the same manner as the option.
|
||||||
|
|
||||||
The section DEFAULT is special.
|
The section DEFAULT is special.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -285,8 +285,7 @@ int unicode_resize(register PyUnicodeObject *unicode,
|
||||||
reset:
|
reset:
|
||||||
/* Reset the object caches */
|
/* Reset the object caches */
|
||||||
if (unicode->defenc) {
|
if (unicode->defenc) {
|
||||||
Py_DECREF(unicode->defenc);
|
Py_CLEAR(unicode->defenc);
|
||||||
unicode->defenc = NULL;
|
|
||||||
}
|
}
|
||||||
unicode->hash = -1;
|
unicode->hash = -1;
|
||||||
|
|
||||||
|
@ -384,8 +383,7 @@ void unicode_dealloc(register PyUnicodeObject *unicode)
|
||||||
unicode->length = 0;
|
unicode->length = 0;
|
||||||
}
|
}
|
||||||
if (unicode->defenc) {
|
if (unicode->defenc) {
|
||||||
Py_DECREF(unicode->defenc);
|
Py_CLEAR(unicode->defenc);
|
||||||
unicode->defenc = NULL;
|
|
||||||
}
|
}
|
||||||
/* Add to free list */
|
/* Add to free list */
|
||||||
*(PyUnicodeObject **)unicode = free_list;
|
*(PyUnicodeObject **)unicode = free_list;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue