From 6290bcfc2552b03a4d36ffd773d152d0cfb8a571 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 1 Aug 2010 21:48:47 +0000 Subject: [PATCH] Merged revisions 83452,83457,83466,83471,83475,83480,83486 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ................ r83452 | georg.brandl | 2010-08-01 23:06:46 +0200 (So, 01 Aug 2010) | 25 lines 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. ........ ................ r83457 | georg.brandl | 2010-08-01 23:10:57 +0200 (So, 01 Aug 2010) | 9 lines Merged revisions 83223 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83223 | georg.brandl | 2010-07-29 15:38:37 +0200 (Do, 29 Jul 2010) | 1 line #3874: document HTMLParser.unknown_decl(). ........ ................ r83466 | georg.brandl | 2010-08-01 23:23:50 +0200 (So, 01 Aug 2010) | 29 lines Merged revisions 83160-83161,83166,83168-83169,83171 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83160 | georg.brandl | 2010-07-26 10:51:42 +0200 (Mo, 26 Jul 2010) | 1 line #9381: fix markup. ........ r83161 | georg.brandl | 2010-07-26 11:33:12 +0200 (Mo, 26 Jul 2010) | 1 line Add Brian Quinlan. ........ r83166 | georg.brandl | 2010-07-26 17:11:49 +0200 (Mo, 26 Jul 2010) | 1 line Fix grammar. ........ r83168 | georg.brandl | 2010-07-26 19:00:20 +0200 (Mo, 26 Jul 2010) | 1 line Fix indentation in example. ........ r83169 | georg.brandl | 2010-07-26 19:09:32 +0200 (Mo, 26 Jul 2010) | 1 line Add Reid. ........ r83171 | georg.brandl | 2010-07-26 23:12:13 +0200 (Mo, 26 Jul 2010) | 1 line Clarify. ........ ................ r83471 | georg.brandl | 2010-08-01 23:26:45 +0200 (So, 01 Aug 2010) | 9 lines Merged revisions 83106 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83106 | georg.brandl | 2010-07-23 18:55:26 +0200 (Fr, 23 Jul 2010) | 1 line Fix some markup glitches. ........ ................ r83475 | georg.brandl | 2010-08-01 23:28:47 +0200 (So, 01 Aug 2010) | 9 lines Merged revisions 82965 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82965 | georg.brandl | 2010-07-19 13:28:05 +0200 (Mo, 19 Jul 2010) | 1 line Clarification. Yay importlib! ........ ................ r83480 | georg.brandl | 2010-08-01 23:33:42 +0200 (So, 01 Aug 2010) | 17 lines Merged revisions 82871,82960-82961 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82871 | georg.brandl | 2010-07-14 10:00:22 +0200 (Mi, 14 Jul 2010) | 1 line #9258: fix copy-paste errors. ........ r82960 | georg.brandl | 2010-07-19 08:52:35 +0200 (Mo, 19 Jul 2010) | 1 line Clarify. ........ r82961 | georg.brandl | 2010-07-19 08:57:52 +0200 (Mo, 19 Jul 2010) | 1 line Clarify :option: description. ........ ................ r83486 | georg.brandl | 2010-08-01 23:44:38 +0200 (So, 01 Aug 2010) | 13 lines Merged revisions 82832,82834 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82832 | georg.brandl | 2010-07-12 11:00:29 +0200 (Mo, 12 Jul 2010) | 1 line Take care of duplicate target name warnings. ........ r82834 | georg.brandl | 2010-07-12 11:06:13 +0200 (Mo, 12 Jul 2010) | 1 line Use raw string literals for regexes containing backlash. ........ ................ --- Doc/documenting/markup.rst | 9 +++++---- Doc/faq/extending.rst | 8 +++----- Doc/install/index.rst | 4 ++-- Doc/library/configparser.rst | 27 +++++++++++++++++++++++---- Doc/library/htmlparser.rst | 16 ++++++++++++---- Doc/library/itertools.rst | 2 +- Doc/library/locale.rst | 4 ---- Doc/library/re.rst | 4 ++-- Doc/library/select.rst | 6 +++--- Doc/library/urllib2.rst | 3 ++- Doc/tutorial/classes.rst | 7 +++++-- Doc/whatsnew/2.0.rst | 2 +- Doc/whatsnew/2.5.rst | 2 +- Lib/ConfigParser.py | 11 ++++++----- Misc/developers.txt | 10 ++++++++++ Objects/unicodeobject.c | 6 ++---- 16 files changed, 78 insertions(+), 43 deletions(-) diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst index eec86501d3e..c6f5b7431b5 100644 --- a/Doc/documenting/markup.rst +++ b/Doc/documenting/markup.rst @@ -200,8 +200,8 @@ The directives are: .. describe:: cmdoption - Describes a command line option or switch. Option argument names should be - enclosed in angle brackets. Example:: + Describes a Python command line option or switch. Option argument names + should be enclosed in angle brackets. Example:: .. cmdoption:: -m @@ -502,8 +502,9 @@ in a different style: .. describe:: option - A command-line option to an executable program. The leading hyphen(s) must - be included. + A command-line option of Python. The leading hyphen(s) must be included. + If a matching ``cmdoption`` directive exists, it is linked to. For options + of other programs or scripts, use simple ````code```` markup. .. describe:: program diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst index 5c716fe023e..be5c51c631e 100644 --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -26,6 +26,8 @@ function that is going to be called by the Python interpreter. Global or static C++ objects with constructors are probably not a good idea. +.. _c-wrapper-software: + Writing C is hard; are there any alternatives? ---------------------------------------------- @@ -197,11 +199,7 @@ begin by reading :ref:`the "Extending and Embedding" document whole lot of difference between C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects. -For C++ libraries, you can look at `SIP -`_, `CXX -`_, `Boost -`_, `Weave -`_ or `SWIG `_ +For C++ libraries, see :ref:`c-wrapper-software`. I added a module using the Setup file and the make fails; why? diff --git a/Doc/install/index.rst b/Doc/install/index.rst index 3781ad9e9ab..a5d2671f5ff 100644 --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -314,8 +314,8 @@ The idea behind the "home scheme" is that you build and maintain a personal stash of Python modules. This scheme's name is derived from the idea of a "home" directory on Unix, since it's not unusual for a Unix user to make their home directory have a layout similar to :file:`/usr/` or :file:`/usr/local/`. -This scheme can be used by anyone, regardless of the operating system their -installing for. +This scheme can be used by anyone, regardless of the operating system they +are installing for. Installing a new module distribution is as simple as :: diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 878685c7481..867f0912fda 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -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 ``';'`` 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:: [My Section] @@ -104,6 +116,11 @@ write-back, as will be the keys within each section. .. versionadded:: 2.3 +.. exception:: Error + + Base class for all other configparser exceptions. + + .. exception:: NoSectionError Exception raised when a specified section is not found. @@ -347,11 +364,13 @@ The :class:`ConfigParser` class extends some methods of the .. method:: ConfigParser.get(section, option[, raw[, vars]]) - Get an *option* value for the named *section*. All the ``'%'`` interpolations - are expanded in the return values, based on the defaults passed into the - constructor, as well as the options *vars* provided, unless the *raw* argument - is true. + Get an *option* value for the named *section*. If *vars* is provided, it + must be a dictionary. The *option* is looked up in *vars* (if provided), + *section*, and in *defaults* in that order. + 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]]) diff --git a/Doc/library/htmlparser.rst b/Doc/library/htmlparser.rst index a5c185cd736..7b0ce03a07b 100644 --- a/Doc/library/htmlparser.rst +++ b/Doc/library/htmlparser.rst @@ -148,10 +148,18 @@ An exception is defined as well: .. method:: HTMLParser.handle_decl(decl) - Method called when an SGML declaration is read by the parser. The *decl* - parameter will be the entire contents of the declaration inside the ```` markup. It is intended to be overridden by a derived class; the base - class implementation does nothing. + Method called when an SGML ``doctype`` declaration is read by the parser. + The *decl* parameter will be the entire contents of the declaration inside + the ```` markup. It is intended to be overridden by a derived class; + the base class implementation does nothing. + + +.. method:: HTMLParser.unknown_decl(data) + + Method called when an unrecognized SGML declaration is read by the parser. + The *data* parameter will be the entire contents of the declaration inside + the ```` markup. It is sometimes useful to be be overridden by a + derived class; the base class implementation throws an :exc:`HTMLParseError`. .. method:: HTMLParser.handle_pi(data) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 7156a23a74b..33630a56e77 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -101,7 +101,7 @@ loops that truncate the stream. yield element -.. function:: itertools.chain.from_iterable(iterable) +.. classmethod:: chain.from_iterable(iterable) Alternate constructor for :func:`chain`. Gets chained inputs from a single iterable argument that is evaluated lazily. Equivalent to:: diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst index c8be7afd547..7b4a05f713a 100644 --- a/Doc/library/locale.rst +++ b/Doc/library/locale.rst @@ -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 systems. - .. data:: ERA_YEAR - - Get the year in the relevant era of the locale. - .. data:: ERA_D_T_FMT Get a format string for :func:`strftime` to represent dates and times in a diff --git a/Doc/library/re.rst b/Doc/library/re.rst index d0042d5a7b4..9821047c66c 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1198,9 +1198,9 @@ in each word of a sentence except for the first and last characters:: ... random.shuffle(inner_word) ... return m.group(1) + "".join(inner_word) + m.group(3) >>> text = "Professor Abdolmalek, please report your absences promptly." - >>> re.sub("(\w)(\w+)(\w)", repl, text) + >>> re.sub(r"(\w)(\w+)(\w)", repl, text) 'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.' - >>> re.sub("(\w)(\w+)(\w)", repl, text) + >>> re.sub(r"(\w)(\w+)(\w)", repl, text) 'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.' diff --git a/Doc/library/select.rst b/Doc/library/select.rst index b599d972d46..034756ef5e0 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -44,7 +44,7 @@ The module defines the following: .. function:: kqueue() - (Only supported on BSD.) Returns a kernel queue object object; see section + (Only supported on BSD.) Returns a kernel queue object; see section :ref:`kqueue-objects` below for the methods supported by kqueue objects. .. versionadded:: 2.6 @@ -52,8 +52,8 @@ The module defines the following: .. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0) - (Only supported on BSD.) Returns a kernel event object object; see section - :ref:`kevent-objects` below for the methods supported by kqueue objects. + (Only supported on BSD.) Returns a kernel event object; see section + :ref:`kevent-objects` below for the methods supported by kevent objects. .. versionadded:: 2.6 diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst index 7fcce4f7916..b8f22775364 100644 --- a/Doc/library/urllib2.rst +++ b/Doc/library/urllib2.rst @@ -464,7 +464,8 @@ sorting the handler instances. named :meth:`unknown_open`. Note that the implementation of these methods may involve calls of the parent - :class:`OpenerDirector` instance's :meth:`.open` and :meth:`.error` methods. + :class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` and + :meth:`~OpenerDirector.error` methods. #. Every handler with a method named like :samp:`{protocol}_response` has that method called to post-process the response. diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 1488329431a..3f481b160cc 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -693,7 +693,7 @@ This example shows how it all works:: StopIteration Having seen the mechanics behind the iterator protocol, it is easy to add -iterator behavior to your classes. Define a :meth:`__iter__` method which +iterator behavior to your classes. Define an :meth:`__iter__` method which returns an object with a :meth:`next` method. If the class defines :meth:`next`, then :meth:`__iter__` can just return ``self``:: @@ -710,7 +710,10 @@ returns an object with a :meth:`next` method. If the class defines self.index = self.index - 1 return self.data[self.index] - >>> for char in Reverse('spam'): + >>> rev = Reverse('spam') + >>> iter(rev) + <__main__.Reverse object at 0x00A1DB50> + >>> for char in rev: ... print char ... m diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst index 5fd53d165e3..3bb12b666c7 100644 --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -656,7 +656,7 @@ break. The change which will probably break the most code is tightening up the arguments accepted by some methods. Some methods would take multiple arguments and treat them as a tuple, particularly various list methods such as -:meth:`.append` and :meth:`.insert`. In earlier versions of Python, if ``L`` is +:meth:`append` and :meth:`insert`. In earlier versions of Python, if ``L`` is a list, ``L.append( 1,2 )`` appends the tuple ``(1,2)`` to the list. In Python 2.0 this causes a :exc:`TypeError` exception to be raised, with the message: 'append requires exactly 1 argument; 2 given'. The fix is to simply add an diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst index ca87dbb1ee8..c7f7d586ab5 100644 --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -1765,7 +1765,7 @@ Full documentation for ElementTree is available at http://effbot.org/zone/element-index.htm. ElementTree represents an XML document as a tree of element nodes. The text -content of the document is stored as the :attr:`.text` and :attr:`.tail` +content of the document is stored as the :attr:`text` and :attr:`tail` attributes of (This is one of the major differences between ElementTree and the Document Object Model; in the DOM there are many different types of node, including :class:`TextNode`.) diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index d02b74dc9ba..c72abb7d376 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -515,11 +515,12 @@ class ConfigParser(RawConfigParser): def get(self, section, option, raw=False, vars=None): """Get an option value for a given section. - All % interpolations are expanded in the return values, based on the - defaults passed into the constructor, unless the optional argument - `raw' is true. Additional substitutions may be provided using the - `vars' argument, which must be a dictionary whose contents overrides - any pre-existing defaults. + If `vars' is provided, it must be a dictionary. The option is looked up + in `vars' (if provided), `section', and in `defaults' in that order. + + All % interpolations are expanded in the return values, unless the + optional argument `raw' is true. Values for interpolation keys are + looked up in the same manner as the option. The section DEFAULT is special. """ diff --git a/Misc/developers.txt b/Misc/developers.txt index 2825275aff6..0f2d41d7d3d 100644 --- a/Misc/developers.txt +++ b/Misc/developers.txt @@ -17,6 +17,16 @@ the format to accommodate documentation needs as they arise. Permissions History ------------------- +- Brian Quinlan was given commit access on Jul 26 2010 by GFB, + for work related to PEP 3148. + +- Reid Kleckner was given commit access on Jul 11 2010 by GFB, + for work on the py3k-jit branch, at suggestion of the Unladen + Swallow team. + +- Alexander Belopolsky was given commit access on May 25 2010 + by MvL at suggestion of Mark Dickinson. + - Tim Golden was given commit access on April 21 2010 by MvL, at suggestion of Michael Foord. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 571f607c3c1..d8dab672b60 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -272,8 +272,7 @@ int unicode_resize(register PyUnicodeObject *unicode, reset: /* Reset the object caches */ if (unicode->defenc) { - Py_DECREF(unicode->defenc); - unicode->defenc = NULL; + Py_CLEAR(unicode->defenc); } unicode->hash = -1; @@ -371,8 +370,7 @@ void unicode_dealloc(register PyUnicodeObject *unicode) unicode->length = 0; } if (unicode->defenc) { - Py_DECREF(unicode->defenc); - unicode->defenc = NULL; + Py_CLEAR(unicode->defenc); } /* Add to free list */ *(PyUnicodeObject **)unicode = free_list;