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
bddf0ce5
Commit
bddf0ce5
authored
Dec 17, 2010
by
Łukasz Langa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configparser hype coming up!
parent
009a9c33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
25 deletions
+115
-25
Doc/whatsnew/3.2.rst
Doc/whatsnew/3.2.rst
+115
-25
No files found.
Doc/whatsnew/3.2.rst
View file @
bddf0ce5
...
@@ -1220,33 +1220,20 @@ There is also a convenient command-line interface::
...
@@ -1220,33 +1220,20 @@ There is also a convenient command-line interface::
Paths:
Paths:
data = "C:\Python32"
data = "C:\Python32"
include = "C:\Python32\Include"
include = "C:\Python32\Include" platinclude = "C:\Python32\Include"
platinclude = "C:\Python32\Include"
platlib = "C:\Python32\Lib\site-packages" platstdlib
platlib = "C:\Python32\Lib\site-packages"
= "C:\Python32\Lib" purelib = "C:\Python32\Lib\site-packages" scripts
platstdlib = "C:\Python32\Lib"
= "C:\Python32\Scripts" stdlib = "C:\Python32\Lib"
purelib = "C:\Python32\Lib\site-packages"
scripts = "C:\Python32\Scripts"
stdlib = "C:\Python32\Lib"
Variables:
Variables:
BINDIR = "C:\Python32"
BINDIR = "C:\Python32"
BINLIBDEST = "C:\Python32\Lib"
BINLIBDEST = "C:\Python32\Lib" EXE = ".exe" INCLUDEPY
EXE = ".exe"
= "C:\Python32\Include" LIBDEST = "C:\Python32\Lib" SO = ".pyd"
INCLUDEPY = "C:\Python32\Include"
VERSION = "32" abiflags = "" base = "C:\Python32" exec_prefix
LIBDEST = "C:\Python32\Lib"
= "C:\Python32" platbase = "C:\Python32" prefix = "C:\Python32"
SO = ".pyd"
projectbase = "C:\Python32" py_version = "3.2" py_version_nodot = "32"
VERSION = "32"
py_version_short = "3.2" srcdir = "C:\Python32" userbase
abiflags = ""
= "C:\Documents and Settings\Raymond\Application Data\Python"
base = "C:\Python32"
exec_prefix = "C:\Python32"
platbase = "C:\Python32"
prefix = "C:\Python32"
projectbase = "C:\Python32"
py_version = "3.2"
py_version_nodot = "32"
py_version_short = "3.2"
srcdir = "C:\Python32"
userbase = "C:\Documents and Settings\Raymond\Application Data\Python"
pdb
pdb
---
---
...
@@ -1266,8 +1253,83 @@ The :mod:`pdb` debugger module gained a number of usability improvements:
...
@@ -1266,8 +1253,83 @@ The :mod:`pdb` debugger module gained a number of usability improvements:
the global and local names found in the current scope.
the global and local names found in the current scope.
* breakpoints can be cleared by breakpoint number
* breakpoints can be cleared by breakpoint number
configparser
------------
The :mod:`configparser` module was modified to improve usability and
predictability of the default parser and its supported INI syntax. The old
:class:`ConfigParser` class was removed in favor of :class:`SafeConfigParser`
which has in turn been renamed to :class:`ConfigParser`. Support for inline
comments is now turned off by default and section or option duplicates are not
allowed in a single configuration source.
Config parsers gained a new API based on the mapping protocol::
>>> parser = ConfigParser()
>>> parser.read_string("""
... [DEFAULT]
... monty = python
...
... [phrases]
... the = who
... full = metal jacket
... """)
>>> parser['phrases']['full']
'metal jacket'
>>> section = parser['phrases']
>>> section['the']
'who'
>>> section['british'] = '%(the)s %(full)s %(monty)s!'
>>> parser['phrases']['british']
'who metal jacket python!'
>>> 'british' in section
True
The new API is implemented on top of the classical API e.g. custom parser
subclasses should be able to use it without modifications.
The INI file structure accepted by config parsers can now be customized. Users
are able to specify alternative option/value delimiters and comment prefixes,
change the name of the DEFAULT section or switch the interpolation syntax.
Along with support for pluggable interpolation, an additional buildout-like
interpolation handler (ExtendedInterpolation) was introduced::
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
>>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
... 'custom': {'prefix': '/usr/local'}})
>>> parser.read_string("""
... [buildout]
... parts =
... zope9
... instance
... find-links =
... ${buildout:directory}/downloads/dist
...
... [zope9]
... recipe = plone.recipe.zope9install
... location = /opt/zope
...
... [instance]
... recipe = plone.recipe.zope9instance
... zope9-location = ${zope9:location}
... zope-conf = ${custom:prefix}/etc/zope.conf
... """)
>>> parser['buildout']['find-links']
'\n/home/ambv/zope9/downloads/dist'
>>> parser['instance']['zope-conf']
'/usr/local/etc/zope.conf'
>>> instance = parser['instance']
>>> instance['zope-conf']
'/usr/local/etc/zope.conf'
>>> instance['zope9-location']
'/opt/zope'
A number of smaller features were also introduced, like support for specifying
encoding in read operations, specifying fallback values in getters, or reading
directly from dictionaries and strings.
(All changes contributed by Łukasz Langa.)
.. XXX: Various ConfigParser changes
.. XXX: Mention urllib.parse changes
.. XXX: Mention urllib.parse changes
Issue 9873 (Nick Coghlan):
Issue 9873 (Nick Coghlan):
- ASCII byte sequence support in URL parsing
- ASCII byte sequence support in URL parsing
...
@@ -1541,6 +1603,34 @@ Porting to Python 3.2
...
@@ -1541,6 +1603,34 @@ Porting to Python 3.2
This section lists previously described changes and other bugfixes that may
This section lists previously described changes and other bugfixes that may
require changes to your code:
require changes to your code:
* The :mod:`configparser` class :class:`SafeConfigParser` has been updated and
renamed to :class:`ConfigParser` whereas the old :class:`ConfigParser` class
has been removed. This means a couple of minor incompatibilities:
* interpolation syntax is now validated on :meth:`get` and :meth:`set`
operations. In the default interpolation scheme, only two tokens with
percent signs are valid: %(name)s and %%, the latter being an escaped
percent sign. If that is not welcome, consider using
:class:`ExtendedInterpolation` or none at all.
* :meth:`set` and :meth:`add_section` now check whether the given value type
is a string. :mod:`configparser` was never designed to hold non-string
values internally.
* exception is raised on any section or option duplicates that appear when
reading a single source. This exposes mistakes in user configuration.
* inline comments are now disabled by default which means the ``;`` character
can be safeuly used in values (``#`` was never allowed as inline comment).
* comments now can be indented which means for ``;`` and ``#`` to appear at
the start of a line in multiline values, it has to be interpolated. This is
preferable because in INI files a character that is also a comment prefix
cannot be taken for a comment by mistake.
* ``""`` is now a valid value, no longer automatically converted to an empty
string. For empty strings users can use ``"option ="`` in a line.
* The :mod:`nntplib` module was reworked extensively, meaning that its APIs
* The :mod:`nntplib` module was reworked extensively, meaning that its APIs
are often incompatible with the 3.1 APIs.
are often incompatible with the 3.1 APIs.
...
...
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