Skip to content

Commit 1fa11af

Browse files
committed
Merged revisions 83226-83227,83229-83232 via svnmerge from
svn+ssh://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 python#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. ........ r83231 | georg.brandl | 2010-07-29 16:46:07 +0200 (Do, 29 Jul 2010) | 1 line python#9397: remove mention of dbm.bsd which does not exist anymore. ........ r83232 | georg.brandl | 2010-07-29 16:49:08 +0200 (Do, 29 Jul 2010) | 1 line python#9388: remove ERA_YEAR which is never defined in the source code. ........
1 parent 745e86b commit 1fa11af

6 files changed

Lines changed: 39 additions & 27 deletions

File tree

Doc/library/configparser.rst

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ section, or values in a special ``DEFAULT`` section. Additional defaults can be
3535
provided on initialization and retrieval. Lines beginning with ``'#'`` or
3636
``';'`` are ignored and may be used to provide comments.
3737

38+
Configuration files may include comments, prefixed by specific characters (``#``
39+
and ``;``). Comments may appear on their own in an otherwise empty line, or may
40+
be entered in lines holding values or spection names. In the latter case, they
41+
need to be preceded by a whitespace character to be recognized as a comment.
42+
(For backwards compatibility, only ``;`` starts an inline comment, while ``#``
43+
does not.)
44+
45+
On top of the core functionality, :class:`SafeConfigParser` supports
46+
interpolation. This means values can contain format strings which refer to
47+
other values in the same section, or values in a special ``DEFAULT`` section.
48+
Additional defaults can be provided on initialization.
49+
3850
For example::
3951

4052
[My Section]
@@ -100,6 +112,11 @@ write-back, as will be the keys within each section.
100112
The default *dict_type* is :class:`collections.OrderedDict`.
101113

102114

115+
.. exception:: Error
116+
117+
Base class for all other configparser exceptions.
118+
119+
103120
.. exception:: NoSectionError
104121

105122
Exception raised when a specified section is not found.
@@ -331,10 +348,13 @@ The :class:`ConfigParser` class extends some methods of the
331348

332349
.. method:: ConfigParser.get(section, option, raw=False, vars=None)
333350

334-
Get an *option* value for the named *section*. All the ``'%'`` interpolations
335-
are expanded in the return values, based on the defaults passed into the
336-
constructor, as well as the options *vars* provided, unless the *raw* argument
337-
is true.
351+
Get an *option* value for the named *section*. If *vars* is provided, it
352+
must be a dictionary. The *option* is looked up in *vars* (if provided),
353+
*section*, and in *defaults* in that order.
354+
355+
All the ``'%'`` interpolations are expanded in the return values, unless the
356+
*raw* argument is true. Values for interpolation keys are looked up in the
357+
same manner as the option.
338358

339359

340360
.. method:: ConfigParser.items(section, raw=False, vars=None)

Doc/library/dbm.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ the Oracle Berkeley DB.
2121
.. function:: whichdb(filename)
2222

2323
This functionattempts to guess which of the several simple database modules
24-
available --- :mod:`dbm.bsd`, :mod:`dbm.gnu`, :mod:`dbm.ndbm` or
25-
:mod:`dbm.dumb` --- should be used to open a given file.
24+
available --- :mod:`dbm.gnu`, :mod:`dbm.ndbm` or :mod:`dbm.dumb` --- should
25+
be used to open a given file.
2626

2727
Returns one of the following values: ``None`` if the file can't be opened
2828
because it's unreadable or doesn't exist; the empty string (``''``) if the
@@ -227,10 +227,9 @@ Dbm objects behave like mappings (dictionaries), except that keys and values are
227227
always stored as bytes. Printing a ``dbm`` object doesn't print the keys and
228228
values, and the :meth:`items` and :meth:`values` methods are not supported.
229229

230-
This module can be used with the "classic" ndbm interface, the BSD DB
231-
compatibility interface, or the GNU GDBM compatibility interface. On Unix, the
232-
:program:`configure` script will attempt to locate the appropriate header file
233-
to simplify building this module.
230+
This module can be used with the "classic" ndbm interface or the GNU GDBM
231+
compatibility interface. On Unix, the :program:`configure` script will attempt
232+
to locate the appropriate header file to simplify building this module.
234233

235234
.. exception:: error
236235

@@ -246,9 +245,7 @@ to simplify building this module.
246245
.. function:: open(filename[, flag[, mode]])
247246

248247
Open a dbm database and return a ``dbm`` object. The *filename* argument is the
249-
name of the database file (without the :file:`.dir` or :file:`.pag` extensions;
250-
note that the BSD DB implementation of the interface will append the extension
251-
:file:`.db` and only create one file).
248+
name of the database file (without the :file:`.dir` or :file:`.pag` extensions).
252249

253250
The optional *flag* argument must be one of these values:
254251

Doc/library/itertools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ loops that truncate the stream.
9999
yield element
100100

101101

102-
.. function:: itertools.chain.from_iterable(iterable)
102+
.. classmethod:: chain.from_iterable(iterable)
103103

104104
Alternate constructor for :func:`chain`. Gets chained inputs from a
105105
single iterable argument that is evaluated lazily. Equivalent to::

Doc/library/locale.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ The :mod:`locale` module defines the following exception and functions:
244244
specified, and therefore you should not assume knowledge of it on different
245245
systems.
246246

247-
.. data:: ERA_YEAR
248-
249-
Get the year in the relevant era of the locale.
250-
251247
.. data:: ERA_D_T_FMT
252248

253249
Get a format string for :func:`strftime` to represent dates and times in a

Lib/configparser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,12 @@ class ConfigParser(RawConfigParser):
521521
def get(self, section, option, raw=False, vars=None):
522522
"""Get an option value for a given section.
523523
524-
All % interpolations are expanded in the return values, based on the
525-
defaults passed into the constructor, unless the optional argument
526-
`raw' is true. Additional substitutions may be provided using the
527-
`vars' argument, which must be a dictionary whose contents overrides
528-
any pre-existing defaults.
524+
If `vars' is provided, it must be a dictionary. The option is looked up
525+
in `vars' (if provided), `section', and in `defaults' in that order.
526+
527+
All % interpolations are expanded in the return values, unless the
528+
optional argument `raw' is true. Values for interpolation keys are
529+
looked up in the same manner as the option.
529530
530531
The section DEFAULT is special.
531532
"""

Objects/unicodeobject.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ int unicode_resize(register PyUnicodeObject *unicode,
294294
reset:
295295
/* Reset the object caches */
296296
if (unicode->defenc) {
297-
Py_DECREF(unicode->defenc);
298-
unicode->defenc = NULL;
297+
Py_CLEAR(unicode->defenc);
299298
}
300299
unicode->hash = -1;
301300

@@ -414,8 +413,7 @@ void unicode_dealloc(register PyUnicodeObject *unicode)
414413
unicode->length = 0;
415414
}
416415
if (unicode->defenc) {
417-
Py_DECREF(unicode->defenc);
418-
unicode->defenc = NULL;
416+
Py_CLEAR(unicode->defenc);
419417
}
420418
/* Add to free list */
421419
*(PyUnicodeObject **)unicode = free_list;

0 commit comments

Comments
 (0)