[Python-checkins] r68135 - in python/branches/release26-maint: Doc/c-api/arg.rst Doc/c-api/exceptions.rst Doc/distutils/apiref.rst Doc/howto/unicode.rst Doc/library/email.mime.rst Doc/library/json.rst Doc/library/logging.rst Doc/library/multiprocessing.rst Doc/library/new.rst Doc/library/pydoc.rst Doc/library/socketserver.rst Doc/library/urllib2.rst Doc/library/webbrowser.rst Doc/library/winsound.rst Doc/library/xml.etree.elementtree.rst Include/unicodeobject.h Lib/distutils/util.py Lib/inspect.py Lib/pydoc.py Lib/re.py Lib/test/test_deque.py Lib/test/test_dict.py Lib/test/test_file.py Lib/test/test_fileio.py Lib/test/test_set.py Lib/test/test_struct.py Lib/textwrap.py Misc/NEWS Modules/_collectionsmodule.c Modules/_fileio.c Modules/_struct.c Objects/dictobject.c Objects/fileobject.c Objects/setobject.c Tools/pybench/Lists.py
georg.brandl
python-checkins at python.org
Thu Jan 1 16:46:11 CET 2009
Author: georg.brandl
Date: Thu Jan 1 16:46:10 2009
New Revision: 68135
Log:
Merged revisions 67952-67953,67955,67957-67958,67960-67961,67963,67965,67967,67970-67971,67973,67982,67988,67990,67995,68014,68016,68030,68057,68061,68112,68115-68118,68120-68121,68123-68128 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67952 | georg.brandl | 2008-12-27 18:42:40 +0100 (Sat, 27 Dec 2008) | 2 lines
#4752: actually use custom handler in example.
........
r67953 | georg.brandl | 2008-12-27 19:20:04 +0100 (Sat, 27 Dec 2008) | 3 lines
Patch #4739 by David Laban: add symbols to pydoc help topics,
so that ``help('@')`` works as expected.
........
r67955 | georg.brandl | 2008-12-27 19:27:53 +0100 (Sat, 27 Dec 2008) | 3 lines
Follow-up to r67746 in order to restore backwards-compatibility for
those who (monkey-)patch TextWrapper.wordsep_re with a custom RE.
........
r67957 | georg.brandl | 2008-12-27 19:49:19 +0100 (Sat, 27 Dec 2008) | 2 lines
#4754: improve winsound documentation.
........
r67958 | georg.brandl | 2008-12-27 20:02:59 +0100 (Sat, 27 Dec 2008) | 2 lines
#4682: 'b' is actually unsigned char.
........
r67960 | georg.brandl | 2008-12-27 20:04:44 +0100 (Sat, 27 Dec 2008) | 2 lines
#4695: fix backslashery.
........
r67961 | georg.brandl | 2008-12-27 20:06:04 +0100 (Sat, 27 Dec 2008) | 2 lines
Use :samp: role.
........
r67963 | georg.brandl | 2008-12-27 20:11:15 +0100 (Sat, 27 Dec 2008) | 2 lines
#4671: document that pydoc imports modules.
........
r67965 | antoine.pitrou | 2008-12-27 21:34:52 +0100 (Sat, 27 Dec 2008) | 3 lines
Issue #4677: add two list comprehension tests to pybench.
........
r67967 | benjamin.peterson | 2008-12-27 23:18:58 +0100 (Sat, 27 Dec 2008) | 1 line
fix markup
........
r67970 | alexandre.vassalotti | 2008-12-28 02:52:58 +0100 (Sun, 28 Dec 2008) | 2 lines
Fix name mangling of PyUnicode_ClearFreeList.
........
r67971 | alexandre.vassalotti | 2008-12-28 03:10:35 +0100 (Sun, 28 Dec 2008) | 2 lines
Sort UCS-2/UCS-4 name mangling list.
........
r67973 | alexandre.vassalotti | 2008-12-28 03:58:22 +0100 (Sun, 28 Dec 2008) | 2 lines
Document Py_VaBuildValue.
........
r67982 | benjamin.peterson | 2008-12-28 16:37:31 +0100 (Sun, 28 Dec 2008) | 1 line
fix WORD_BIGEDIAN declaration in Universal builds; fixes #4060 and #4728
........
r67988 | ronald.oussoren | 2008-12-28 20:40:56 +0100 (Sun, 28 Dec 2008) | 1 line
Issue4064: architecture string for universal builds on OSX
........
r67990 | ronald.oussoren | 2008-12-28 20:50:40 +0100 (Sun, 28 Dec 2008) | 3 lines
Update the fix for issue4064 to deal correctly with all three variants of
universal builds that are presented by the configure script.
........
r67995 | benjamin.peterson | 2008-12-28 22:16:07 +0100 (Sun, 28 Dec 2008) | 1 line
#4763 PyErr_ExceptionMatches won't blow up with NULL arguments
........
r68014 | benjamin.peterson | 2008-12-29 18:47:42 +0100 (Mon, 29 Dec 2008) | 1 line
#4764 set IOError.filename when trying to open a directory on POSIX platforms
........
r68016 | benjamin.peterson | 2008-12-29 18:56:58 +0100 (Mon, 29 Dec 2008) | 1 line
#4764 in io.open, set IOError.filename when trying to open a directory on POSIX platforms
........
r68030 | benjamin.peterson | 2008-12-29 22:38:14 +0100 (Mon, 29 Dec 2008) | 1 line
fix French
........
r68057 | vinay.sajip | 2008-12-30 08:01:25 +0100 (Tue, 30 Dec 2008) | 1 line
Minor documentation change relating to NullHandler.
........
r68061 | georg.brandl | 2008-12-30 11:15:49 +0100 (Tue, 30 Dec 2008) | 2 lines
#4778: attributes can't be called.
........
r68112 | benjamin.peterson | 2009-01-01 00:48:39 +0100 (Thu, 01 Jan 2009) | 1 line
#4795 inspect.isgeneratorfunction() should return False instead of None
........
r68115 | benjamin.peterson | 2009-01-01 05:04:41 +0100 (Thu, 01 Jan 2009) | 1 line
simplfy code
........
r68116 | georg.brandl | 2009-01-01 12:46:51 +0100 (Thu, 01 Jan 2009) | 2 lines
#4100: note that element children are not necessarily present on "start" events.
........
r68117 | georg.brandl | 2009-01-01 12:53:55 +0100 (Thu, 01 Jan 2009) | 2 lines
#4156: make clear that "protocol" is to be replaced with the protocol name.
........
r68118 | georg.brandl | 2009-01-01 13:00:19 +0100 (Thu, 01 Jan 2009) | 2 lines
#4185: clarify escape behavior of replacement strings.
........
r68120 | georg.brandl | 2009-01-01 13:15:31 +0100 (Thu, 01 Jan 2009) | 4 lines
#4228: Pack negative values the same way as 2.4
in struct's L format.
........
r68121 | georg.brandl | 2009-01-01 13:43:33 +0100 (Thu, 01 Jan 2009) | 2 lines
Point to types module in new module deprecation notice.
........
r68123 | georg.brandl | 2009-01-01 13:52:29 +0100 (Thu, 01 Jan 2009) | 2 lines
#4784: ... on three counts ...
........
r68124 | georg.brandl | 2009-01-01 13:53:19 +0100 (Thu, 01 Jan 2009) | 2 lines
#4782: Fix markup error that hid load() and loads().
........
r68125 | georg.brandl | 2009-01-01 14:02:09 +0100 (Thu, 01 Jan 2009) | 2 lines
#4776: add data_files and package_dir arguments.
........
r68126 | georg.brandl | 2009-01-01 14:05:13 +0100 (Thu, 01 Jan 2009) | 2 lines
Handlers are in the `logging.handlers` module.
........
r68127 | georg.brandl | 2009-01-01 14:14:49 +0100 (Thu, 01 Jan 2009) | 2 lines
#4767: Use correct submodules for all MIME classes.
........
r68128 | antoine.pitrou | 2009-01-01 15:11:22 +0100 (Thu, 01 Jan 2009) | 3 lines
Issue #3680: Reference cycles created through a dict, set or deque iterator did not get collected.
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Doc/c-api/arg.rst
python/branches/release26-maint/Doc/c-api/exceptions.rst
python/branches/release26-maint/Doc/distutils/apiref.rst
python/branches/release26-maint/Doc/howto/unicode.rst
python/branches/release26-maint/Doc/library/email.mime.rst
python/branches/release26-maint/Doc/library/json.rst
python/branches/release26-maint/Doc/library/logging.rst
python/branches/release26-maint/Doc/library/multiprocessing.rst
python/branches/release26-maint/Doc/library/new.rst
python/branches/release26-maint/Doc/library/pydoc.rst
python/branches/release26-maint/Doc/library/socketserver.rst
python/branches/release26-maint/Doc/library/urllib2.rst
python/branches/release26-maint/Doc/library/webbrowser.rst
python/branches/release26-maint/Doc/library/winsound.rst
python/branches/release26-maint/Doc/library/xml.etree.elementtree.rst
python/branches/release26-maint/Include/unicodeobject.h
python/branches/release26-maint/Lib/distutils/util.py
python/branches/release26-maint/Lib/inspect.py
python/branches/release26-maint/Lib/pydoc.py
python/branches/release26-maint/Lib/re.py
python/branches/release26-maint/Lib/test/test_deque.py
python/branches/release26-maint/Lib/test/test_dict.py
python/branches/release26-maint/Lib/test/test_file.py
python/branches/release26-maint/Lib/test/test_fileio.py
python/branches/release26-maint/Lib/test/test_set.py
python/branches/release26-maint/Lib/test/test_struct.py
python/branches/release26-maint/Lib/textwrap.py
python/branches/release26-maint/Misc/NEWS
python/branches/release26-maint/Modules/_collectionsmodule.c
python/branches/release26-maint/Modules/_fileio.c
python/branches/release26-maint/Modules/_struct.c
python/branches/release26-maint/Objects/dictobject.c
python/branches/release26-maint/Objects/fileobject.c
python/branches/release26-maint/Objects/setobject.c
python/branches/release26-maint/Tools/pybench/Lists.py
Modified: python/branches/release26-maint/Doc/c-api/arg.rst
==============================================================================
--- python/branches/release26-maint/Doc/c-api/arg.rst (original)
+++ python/branches/release26-maint/Doc/c-api/arg.rst Thu Jan 1 16:46:10 2009
@@ -136,8 +136,9 @@
them. Instead, the implementation assumes that the string object uses the
encoding passed in as parameter.
-``b`` (integer) [char]
- Convert a Python integer to a tiny int, stored in a C :ctype:`char`.
+``b`` (integer) [unsigned char]
+ Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
+ :ctype:`unsigned char`.
``B`` (integer) [unsigned char]
Convert a Python integer to a tiny int without overflow checking, stored in a C
@@ -533,3 +534,8 @@
If there is an error in the format string, the :exc:`SystemError` exception is
set and *NULL* returned.
+
+.. cfunction:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
+
+ Identical to :cfunc:`Py_BuildValue`, except that it accepts a va_list
+ rather than a variable number of arguments.
Modified: python/branches/release26-maint/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/release26-maint/Doc/c-api/exceptions.rst (original)
+++ python/branches/release26-maint/Doc/c-api/exceptions.rst Thu Jan 1 16:46:10 2009
@@ -73,11 +73,10 @@
.. cfunction:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
- Return true if the *given* exception matches the exception in *exc*. If *exc*
- is a class object, this also returns true when *given* is an instance of a
- subclass. If *exc* is a tuple, all exceptions in the tuple (and recursively in
- subtuples) are searched for a match. If *given* is *NULL*, a memory access
- violation will occur.
+ Return true if the *given* exception matches the exception in *exc*. If
+ *exc* is a class object, this also returns true when *given* is an instance
+ of a subclass. If *exc* is a tuple, all exceptions in the tuple (and
+ recursively in subtuples) are searched for a match.
.. cfunction:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
Modified: python/branches/release26-maint/Doc/distutils/apiref.rst
==============================================================================
--- python/branches/release26-maint/Doc/distutils/apiref.rst (original)
+++ python/branches/release26-maint/Doc/distutils/apiref.rst Thu Jan 1 16:46:10 2009
@@ -88,9 +88,9 @@
| *options* | default options for the setup | a string |
| | script | |
+--------------------+--------------------------------+-------------------------------------------------------------+
- | *license* | The license for the package | |
+ | *license* | The license for the package | a string |
+--------------------+--------------------------------+-------------------------------------------------------------+
- | *keywords* | Descriptive meta-data. See | |
+ | *keywords* | Descriptive meta-data, see | |
| | :pep:`314` | |
+--------------------+--------------------------------+-------------------------------------------------------------+
| *platforms* | | |
@@ -98,6 +98,13 @@
| *cmdclass* | A mapping of command names to | a dictionary |
| | :class:`Command` subclasses | |
+--------------------+--------------------------------+-------------------------------------------------------------+
+ | *data_files* | A list of data files to | a list |
+ | | install | |
+ +--------------------+--------------------------------+-------------------------------------------------------------+
+ | *package_dir* | A mapping of package to | a dictionary |
+ | | directory names | |
+ +--------------------+--------------------------------+-------------------------------------------------------------+
+
.. function:: run_setup(script_name[, script_args=None, stop_after='run'])
@@ -1100,6 +1107,24 @@
For non-POSIX platforms, currently just returns ``sys.platform``.
+ For MacOS X systems the OS version reflects the minimal version on which
+ binaries will run (that is, the value of ``MACOSX_DEPLOYMENT_TARGET``
+ during the build of Python), not the OS version of the current system.
+
+ For universal binary builds on MacOS X the architecture value reflects
+ the univeral binary status instead of the architecture of the current
+ processor. For 32-bit universal binaries the architecture is ``fat``,
+ for 64-bit universal binaries the architecture is ``fat64``, and
+ for 4-way universal binaries the architecture is ``universal``.
+
+ Examples of returned values on MacOS X:
+
+ * ``macosx-10.3-ppc``
+
+ * ``macosx-10.3-fat``
+
+ * ``macosx-10.5-universal``
+
.. % XXX isn't this also provided by some other non-distutils module?
Modified: python/branches/release26-maint/Doc/howto/unicode.rst
==============================================================================
--- python/branches/release26-maint/Doc/howto/unicode.rst (original)
+++ python/branches/release26-maint/Doc/howto/unicode.rst Thu Jan 1 16:46:10 2009
@@ -30,7 +30,7 @@
looking at Apple ][ BASIC programs, published in French-language publications in
the mid-1980s, that had lines like these::
- PRINT "FICHER EST COMPLETE."
+ PRINT "FICHIER EST COMPLETE."
PRINT "CARACTERE NON ACCEPTE."
Those messages should contain accents, and they just look wrong to someone who
Modified: python/branches/release26-maint/Doc/library/email.mime.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/email.mime.rst (original)
+++ python/branches/release26-maint/Doc/library/email.mime.rst Thu Jan 1 16:46:10 2009
@@ -19,6 +19,7 @@
Here are the classes:
+.. currentmodule:: email.mime.base
.. class:: MIMEBase(_maintype, _subtype, **_params)
@@ -39,6 +40,8 @@
:mailheader:`MIME-Version` header (always set to ``1.0``).
+.. currentmodule:: email.mime.nonmultipart
+
.. class:: MIMENonMultipart()
Module: :mod:`email.mime.nonmultipart`
@@ -52,6 +55,8 @@
.. versionadded:: 2.2.2
+.. currentmodule:: email.mime.multipart
+
.. class:: MIMEMultipart([subtype[, boundary[, _subparts[, _params]]]])
Module: :mod:`email.mime.multipart`
@@ -77,6 +82,8 @@
.. versionadded:: 2.2.2
+.. currentmodule:: email.mime.application
+
.. class:: MIMEApplication(_data[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.application`
@@ -99,6 +106,8 @@
.. versionadded:: 2.5
+.. currentmodule:: email.mime.audio
+
.. class:: MIMEAudio(_audiodata[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.audio`
@@ -122,6 +131,8 @@
*_params* are passed straight through to the base class constructor.
+.. currentmodule:: email.mime.image
+
.. class:: MIMEImage(_imagedata[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.image`
@@ -145,6 +156,8 @@
*_params* are passed straight through to the :class:`MIMEBase` constructor.
+.. currentmodule:: email.mime.message
+
.. class:: MIMEMessage(_msg[, _subtype])
Module: :mod:`email.mime.message`
@@ -158,6 +171,8 @@
:mimetype:`rfc822`.
+.. currentmodule:: email.mime.text
+
.. class:: MIMEText(_text[, _subtype[, _charset]])
Module: :mod:`email.mime.text`
Modified: python/branches/release26-maint/Doc/library/json.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/json.rst (original)
+++ python/branches/release26-maint/Doc/library/json.rst Thu Jan 1 16:46:10 2009
@@ -166,7 +166,7 @@
:func:`dump`.
-.. function load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
+.. function:: load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
Deserialize *fp* (a ``.read()``-supporting file-like object containing a JSON
document) to a Python object.
@@ -202,7 +202,7 @@
class.
-.. function loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
+.. function:: loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON
document) to a Python object.
Modified: python/branches/release26-maint/Doc/library/logging.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/logging.rst (original)
+++ python/branches/release26-maint/Doc/library/logging.rst Thu Jan 1 16:46:10 2009
@@ -553,10 +553,10 @@
#. :class:`HTTPHandler` instances send error messages to an HTTP server using
either ``GET`` or ``POST`` semantics.
-The :class:`StreamHandler` and :class:`FileHandler` classes are defined in the
-core logging package. The other handlers are defined in a sub- module,
-:mod:`logging.handlers`. (There is also another sub-module,
-:mod:`logging.config`, for configuration functionality.)
+The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler`
+classes are defined in the core logging package. The other handlers are
+defined in a sub- module, :mod:`logging.handlers`. (There is also another
+sub-module, :mod:`logging.config`, for configuration functionality.)
Logged messages are formatted for presentation through instances of the
:class:`Formatter` class. They are initialized with a format string suitable for
@@ -1544,6 +1544,8 @@
StreamHandler
^^^^^^^^^^^^^
+.. module:: logging.handlers
+
The :class:`StreamHandler` class, located in the core :mod:`logging` package,
sends logging output to streams such as *sys.stdout*, *sys.stderr* or any
file-like object (or, more precisely, any object which supports :meth:`write`
@@ -2050,6 +2052,8 @@
Formatter Objects
-----------------
+.. currentmodule:: logging
+
:class:`Formatter`\ s have the following attributes and methods. They are
responsible for converting a :class:`LogRecord` to (usually) a string which can
be interpreted by either a human or an external system. The base
Modified: python/branches/release26-maint/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/multiprocessing.rst (original)
+++ python/branches/release26-maint/Doc/library/multiprocessing.rst Thu Jan 1 16:46:10 2009
@@ -358,7 +358,7 @@
.. attribute:: daemon
- The process's daemon flag, a Boolean value. This must be called before
+ The process's daemon flag, a Boolean value. This must be set before
:meth:`start` is called.
The initial value is inherited from the creating process.
@@ -1810,9 +1810,9 @@
filesystem.
* An ``'AF_PIPE'`` address is a string of the form
- ``r'\\\\.\\pipe\\PipeName'``. To use :func:`Client` to connect to a named
+ :samp:`r'\\\\.\\pipe\\{PipeName}'`. To use :func:`Client` to connect to a named
pipe on a remote computer called ServerName* one should use an address of the
- form ``r'\\\\ServerName\\pipe\\PipeName'`` instead.
+ form :samp:`r'\\\\{ServerName}\\pipe\\{PipeName}'`` instead.
Note that any string beginning with two backslashes is assumed by default to be
an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address.
Modified: python/branches/release26-maint/Doc/library/new.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/new.rst (original)
+++ python/branches/release26-maint/Doc/library/new.rst Thu Jan 1 16:46:10 2009
@@ -1,4 +1,3 @@
-
:mod:`new` --- Creation of runtime internal objects
===================================================
@@ -7,7 +6,8 @@
:deprecated:
.. deprecated:: 2.6
- The :mod:`new` module has been removed in Python 3.0.
+ The :mod:`new` module has been removed in Python 3.0. Use the :mod:`types`
+ module's classes instead.
.. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
Modified: python/branches/release26-maint/Doc/library/pydoc.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/pydoc.rst (original)
+++ python/branches/release26-maint/Doc/library/pydoc.rst Thu Jan 1 16:46:10 2009
@@ -36,6 +36,13 @@
Unix), and refers to an existing Python source file, then documentation is
produced for that file.
+.. note::
+
+ In order to find objects and their documentation, :mod:`pydoc` imports the
+ module(s) to be documented. Therefore, any code on module level will be
+ executed on that occasion. Use an ``if __name__ == '__main__':`` guard to
+ only execute code when a file is invoked as a script and not just imported.
+
Specifying a :option:`-w` flag before the argument will cause HTML documentation
to be written out to a file in the current directory, instead of displaying text
on the console.
Modified: python/branches/release26-maint/Doc/library/socketserver.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/socketserver.rst (original)
+++ python/branches/release26-maint/Doc/library/socketserver.rst Thu Jan 1 16:46:10 2009
@@ -448,7 +448,7 @@
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
- server = SocketServer.UDPServer((HOST, PORT), BaseUDPRequestHandler)
+ server = SocketServer.UDPServer((HOST, PORT), MyUDPHandler)
server.serve_forever()
This is the client side::
Modified: python/branches/release26-maint/Doc/library/urllib2.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/urllib2.rst (original)
+++ python/branches/release26-maint/Doc/library/urllib2.rst Thu Jan 1 16:46:10 2009
@@ -391,23 +391,23 @@
.. method:: OpenerDirector.add_handler(handler)
- *handler* should be an instance of :class:`BaseHandler`. The following methods
- are searched, and added to the possible chains (note that HTTP errors are a
- special case).
+ *handler* should be an instance of :class:`BaseHandler`. The following
+ methods are searched, and added to the possible chains (note that HTTP errors
+ are a special case).
- * :meth:`protocol_open` --- signal that the handler knows how to open *protocol*
- URLs.
+ * :samp:`{protocol}_open` --- signal that the handler knows how to open
+ *protocol* URLs.
- * :meth:`http_error_type` --- signal that the handler knows how to handle HTTP
- errors with HTTP error code *type*.
+ * :samp:`http_error_{type}` --- signal that the handler knows how to handle
+ HTTP errors with HTTP error code *type*.
- * :meth:`protocol_error` --- signal that the handler knows how to handle errors
- from (non-\ ``http``) *protocol*.
+ * :samp:`{protocol}_error` --- signal that the handler knows how to handle
+ errors from (non-\ ``http``) *protocol*.
- * :meth:`protocol_request` --- signal that the handler knows how to pre-process
- *protocol* requests.
+ * :samp:`{protocol}_request` --- signal that the handler knows how to
+ pre-process *protocol* requests.
- * :meth:`protocol_response` --- signal that the handler knows how to
+ * :samp:`{protocol}_response` --- signal that the handler knows how to
post-process *protocol* responses.
@@ -441,24 +441,24 @@
The order in which these methods are called within each stage is determined by
sorting the handler instances.
-#. Every handler with a method named like :meth:`protocol_request` has that
+#. Every handler with a method named like :samp:`{protocol}_request` has that
method called to pre-process the request.
-#. Handlers with a method named like :meth:`protocol_open` are called to handle
+#. Handlers with a method named like :samp:`{protocol}_open` are called to handle
the request. This stage ends when a handler either returns a non-\ :const:`None`
value (ie. a response), or raises an exception (usually :exc:`URLError`).
Exceptions are allowed to propagate.
In fact, the above algorithm is first tried for methods named
- :meth:`default_open`. If all such methods return :const:`None`, the algorithm
- is repeated for methods named like :meth:`protocol_open`. If all such methods
- return :const:`None`, the algorithm is repeated for methods named
- :meth:`unknown_open`.
+ :meth:`default_open`. If all such methods return :const:`None`, the
+ algorithm is repeated for methods named like :samp:`{protocol}_open`. If all
+ such methods return :const:`None`, the algorithm is repeated for methods
+ 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.
-#. Every handler with a method named like :meth:`protocol_response` has that
+#. Every handler with a method named like :samp:`{protocol}_response` has that
method called to post-process the response.
@@ -514,8 +514,10 @@
.. method:: BaseHandler.protocol_open(req)
:noindex:
+ ("protocol" is to be replaced by the protocol name.)
+
This method is *not* defined in :class:`BaseHandler`, but subclasses should
- define it if they want to handle URLs with the given protocol.
+ define it if they want to handle URLs with the given *protocol*.
This method, if defined, will be called by the parent :class:`OpenerDirector`.
Return values should be the same as for :meth:`default_open`.
@@ -563,8 +565,10 @@
.. method:: BaseHandler.protocol_request(req)
:noindex:
+ ("protocol" is to be replaced by the protocol name.)
+
This method is *not* defined in :class:`BaseHandler`, but subclasses should
- define it if they want to pre-process requests of the given protocol.
+ define it if they want to pre-process requests of the given *protocol*.
This method, if defined, will be called by the parent :class:`OpenerDirector`.
*req* will be a :class:`Request` object. The return value should be a
@@ -574,8 +578,10 @@
.. method:: BaseHandler.protocol_response(req, response)
:noindex:
+ ("protocol" is to be replaced by the protocol name.)
+
This method is *not* defined in :class:`BaseHandler`, but subclasses should
- define it if they want to post-process responses of the given protocol.
+ define it if they want to post-process responses of the given *protocol*.
This method, if defined, will be called by the parent :class:`OpenerDirector`.
*req* will be a :class:`Request` object. *response* will be an object
@@ -660,7 +666,9 @@
.. method:: ProxyHandler.protocol_open(request)
:noindex:
- The :class:`ProxyHandler` will have a method :meth:`protocol_open` for every
+ ("protocol" is to be replaced by the protocol name.)
+
+ The :class:`ProxyHandler` will have a method :samp:`{protocol}_open` for every
*protocol* which has a proxy in the *proxies* dictionary given in the
constructor. The method will modify requests to go through the proxy, by
calling ``request.set_proxy()``, and call the next handler in the chain to
@@ -865,9 +873,10 @@
For 200 error codes, the response object is returned immediately.
For non-200 error codes, this simply passes the job on to the
- :meth:`protocol_error_code` handler methods, via :meth:`OpenerDirector.error`.
- Eventually, :class:`urllib2.HTTPDefaultErrorHandler` will raise an
- :exc:`HTTPError` if no other handler handles the error.
+ :samp:`{protocol}_error_code` handler methods, via
+ :meth:`OpenerDirector.error`. Eventually,
+ :class:`urllib2.HTTPDefaultErrorHandler` will raise an :exc:`HTTPError` if no
+ other handler handles the error.
.. _urllib2-examples:
Modified: python/branches/release26-maint/Doc/library/webbrowser.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/webbrowser.rst (original)
+++ python/branches/release26-maint/Doc/library/webbrowser.rst Thu Jan 1 16:46:10 2009
@@ -172,7 +172,7 @@
Browser Controller Objects
--------------------------
-Browser controllers provide two methods which parallel two of the module-level
+Browser controllers provide these methods which parallel two of the module-level
convenience functions:
Modified: python/branches/release26-maint/Doc/library/winsound.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/winsound.rst (original)
+++ python/branches/release26-maint/Doc/library/winsound.rst Thu Jan 1 16:46:10 2009
@@ -30,8 +30,9 @@
Call the underlying :cfunc:`PlaySound` function from the Platform API. The
*sound* parameter may be a filename, audio data as a string, or ``None``. Its
interpretation depends on the value of *flags*, which can be a bitwise ORed
- combination of the constants described below. If the system indicates an error,
- :exc:`RuntimeError` is raised.
+ combination of the constants described below. If the *sound* parameter is
+ ``None``, any currently playing waveform sound is stopped. If the system
+ indicates an error, :exc:`RuntimeError` is raised.
.. function:: MessageBeep([type=MB_OK])
@@ -108,6 +109,10 @@
Stop playing all instances of the specified sound.
+ .. note::
+
+ This flag is not supported on modern Windows platforms.
+
.. data:: SND_ASYNC
Modified: python/branches/release26-maint/Doc/library/xml.etree.elementtree.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/xml.etree.elementtree.rst (original)
+++ python/branches/release26-maint/Doc/library/xml.etree.elementtree.rst Thu Jan 1 16:46:10 2009
@@ -94,6 +94,16 @@
*events* is a list of events to report back. If omitted, only "end" events are
reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs.
+ .. note::
+
+ :func:`iterparse` only guarantees that it has seen the ">"
+ character of a starting tag when it emits a "start" event, so the
+ attributes are defined, but the contents of the text and tail attributes
+ are undefined at that point. The same applies to the element children;
+ they may or may not be present.
+
+ If you need a fully populated element, look for "end" events instead.
+
.. function:: parse(source[, parser])
Modified: python/branches/release26-maint/Include/unicodeobject.h
==============================================================================
--- python/branches/release26-maint/Include/unicodeobject.h (original)
+++ python/branches/release26-maint/Include/unicodeobject.h Thu Jan 1 16:46:10 2009
@@ -153,6 +153,7 @@
# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode
# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString
# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar
+# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define PyUnicode_Compare PyUnicodeUCS2_Compare
# define PyUnicode_Concat PyUnicodeUCS2_Concat
# define PyUnicode_Contains PyUnicodeUCS2_Contains
@@ -182,13 +183,13 @@
# define PyUnicode_Find PyUnicodeUCS2_Find
# define PyUnicode_Format PyUnicodeUCS2_Format
# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject
+# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat
+# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV
# define PyUnicode_FromObject PyUnicodeUCS2_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal
-# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS2_FromString
# define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize
-# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV
-# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat
+# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS2_GetMax
@@ -209,7 +210,6 @@
# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString
# define _PyUnicode_Fini _PyUnicodeUCS2_Fini
# define _PyUnicode_Init _PyUnicodeUCS2_Init
-# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha
# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit
# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit
@@ -240,6 +240,7 @@
# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode
# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString
# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar
+# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist
# define PyUnicode_Compare PyUnicodeUCS4_Compare
# define PyUnicode_Concat PyUnicodeUCS4_Concat
# define PyUnicode_Contains PyUnicodeUCS4_Contains
@@ -269,13 +270,13 @@
# define PyUnicode_Find PyUnicodeUCS4_Find
# define PyUnicode_Format PyUnicodeUCS4_Format
# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject
+# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
+# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV
# define PyUnicode_FromObject PyUnicodeUCS4_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal
-# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS4_FromString
# define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize
-# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV
-# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
+# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS4_GetMax
@@ -296,7 +297,6 @@
# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString
# define _PyUnicode_Fini _PyUnicodeUCS4_Fini
# define _PyUnicode_Init _PyUnicodeUCS4_Init
-# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha
# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit
# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit
Modified: python/branches/release26-maint/Lib/distutils/util.py
==============================================================================
--- python/branches/release26-maint/Lib/distutils/util.py (original)
+++ python/branches/release26-maint/Lib/distutils/util.py Thu Jan 1 16:46:10 2009
@@ -140,9 +140,13 @@
# 'universal' instead of 'fat'.
machine = 'fat'
+ cflags = get_config_vars().get('CFLAGS')
- if '-arch x86_64' in get_config_vars().get('CFLAGS'):
- machine = 'universal'
+ if '-arch x86_64' in cflags:
+ if '-arch i386' in cflags:
+ machine = 'universal'
+ else:
+ machine = 'fat64'
elif machine in ('PowerPC', 'Power_Macintosh'):
# Pick a sane name for the PPC architecture.
Modified: python/branches/release26-maint/Lib/inspect.py
==============================================================================
--- python/branches/release26-maint/Lib/inspect.py (original)
+++ python/branches/release26-maint/Lib/inspect.py Thu Jan 1 16:46:10 2009
@@ -158,9 +158,8 @@
Generator function objects provides same attributes as functions.
See isfunction.__doc__ for attributes listing."""
- if (isfunction(object) or ismethod(object)) and \
- object.func_code.co_flags & CO_GENERATOR:
- return True
+ return bool((isfunction(object) or ismethod(object)) and
+ object.func_code.co_flags & CO_GENERATOR)
def isgenerator(object):
"""Return true if the object is a generator.
Modified: python/branches/release26-maint/Lib/pydoc.py
==============================================================================
--- python/branches/release26-maint/Lib/pydoc.py (original)
+++ python/branches/release26-maint/Lib/pydoc.py Thu Jan 1 16:46:10 2009
@@ -1574,6 +1574,42 @@
'with': ('with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
'yield': ('yield', ''),
}
+ # Either add symbols to this dictionary or to the symbols dictionary
+ # directly: Whichever is easier. They are merged later.
+ _symbols_inverse = {
+ 'STRINGS' : ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"'),
+ 'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
+ '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
+ 'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
+ 'UNARY' : ('-', '~'),
+ 'AUGMENTEDASSIGNMENT' : ('+=', '-=', '*=', '/=', '%=', '&=', '|=',
+ '^=', '<<=', '>>=', '**=', '//='),
+ 'BITWISE' : ('<<', '>>', '&', '|', '^', '~'),
+ 'COMPLEX' : ('j', 'J')
+ }
+ symbols = {
+ '%': 'OPERATORS FORMATTING',
+ '**': 'POWER',
+ ',': 'TUPLES LISTS FUNCTIONS',
+ '.': 'ATTRIBUTES FLOAT MODULES OBJECTS',
+ '...': 'ELLIPSIS',
+ ':': 'SLICINGS DICTIONARYLITERALS',
+ '@': 'def class',
+ '\\': 'STRINGS',
+ '_': 'PRIVATENAMES',
+ '__': 'PRIVATENAMES SPECIALMETHODS',
+ '`': 'BACKQUOTES',
+ '(': 'TUPLES FUNCTIONS CALLS',
+ ')': 'TUPLES FUNCTIONS CALLS',
+ '[': 'LISTS SUBSCRIPTS SLICINGS',
+ ']': 'LISTS SUBSCRIPTS SLICINGS'
+ }
+ for topic, symbols_ in _symbols_inverse.iteritems():
+ for symbol in symbols_:
+ topics = symbols.get(symbol, topic)
+ if topic not in topics:
+ topics = topics + ' ' + topic
+ symbols[symbol] = topics
topics = {
'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
@@ -1717,10 +1753,12 @@
if type(request) is type(''):
if request == 'help': self.intro()
elif request == 'keywords': self.listkeywords()
+ elif request == 'symbols': self.listsymbols()
elif request == 'topics': self.listtopics()
elif request == 'modules': self.listmodules()
elif request[:8] == 'modules ':
self.listmodules(split(request)[1])
+ elif request in self.symbols: self.showsymbol(request)
elif request in self.keywords: self.showtopic(request)
elif request in self.topics: self.showtopic(request)
elif request: doc(request, 'Help on %s:')
@@ -1766,6 +1804,14 @@
''')
self.list(self.keywords.keys())
+ def listsymbols(self):
+ self.output.write('''
+Here is a list of the punctuation symbols which Python assigns special meaning
+to. Enter any symbol to get more help.
+
+''')
+ self.list(self.symbols.keys())
+
def listtopics(self):
self.output.write('''
Here is a list of available topics. Enter any topic name to get more help.
@@ -1773,7 +1819,7 @@
''')
self.list(self.topics.keys())
- def showtopic(self, topic):
+ def showtopic(self, topic, more_xrefs=''):
try:
import pydoc_topics
except ImportError:
@@ -1787,7 +1833,7 @@
self.output.write('no documentation found for %s\n' % repr(topic))
return
if type(target) is type(''):
- return self.showtopic(target)
+ return self.showtopic(target, more_xrefs)
label, xrefs = target
try:
@@ -1796,6 +1842,8 @@
self.output.write('no documentation found for %s\n' % repr(topic))
return
pager(strip(doc) + '\n')
+ if more_xrefs:
+ xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs:
import StringIO, formatter
buffer = StringIO.StringIO()
@@ -1803,6 +1851,11 @@
'Related help topics: ' + join(split(xrefs), ', ') + '\n')
self.output.write('\n%s\n' % buffer.getvalue())
+ def showsymbol(self, symbol):
+ target = self.symbols[symbol]
+ topic, _, xrefs = target.partition(' ')
+ self.showtopic(topic, xrefs)
+
def listmodules(self, key=''):
if key:
self.output.write('''
Modified: python/branches/release26-maint/Lib/re.py
==============================================================================
--- python/branches/release26-maint/Lib/re.py (original)
+++ python/branches/release26-maint/Lib/re.py Thu Jan 1 16:46:10 2009
@@ -145,7 +145,8 @@
"""Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
- if a callable, it's passed the match object and must return
+ if a string, backslash escapes in it are processed. If it is
+ a callable, it's passed the match object and must return
a replacement string to be used."""
return _compile(pattern, 0).sub(repl, string, count)
@@ -155,7 +156,8 @@
non-overlapping occurrences of the pattern in the source
string by the replacement repl. number is the number of
substitutions that were made. repl can be either a string or a
- callable; if a callable, it's passed the match object and must
+ callable; if a string, backslash escapes in it are processed.
+ If it is a callable, it's passed the match object and must
return a replacement string to be used."""
return _compile(pattern, 0).subn(repl, string, count)
Modified: python/branches/release26-maint/Lib/test/test_deque.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_deque.py (original)
+++ python/branches/release26-maint/Lib/test/test_deque.py Thu Jan 1 16:46:10 2009
@@ -1,7 +1,8 @@
from collections import deque
import unittest
from test import test_support, seq_tests
-from weakref import proxy
+import gc
+import weakref
import copy
import cPickle as pickle
import random
@@ -418,6 +419,22 @@
d.append(1)
gc.collect()
+ def test_container_iterator(self):
+ # Bug # XXX: tp_traverse was not implemented for deque iterator objects
+ class C(object):
+ pass
+ for i in range(2):
+ obj = C()
+ ref = weakref.ref(obj)
+ if i == 0:
+ container = deque([obj, 1])
+ else:
+ container = reversed(deque([obj, 1]))
+ obj.x = iter(container)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
+
class TestVariousIteratorArgs(unittest.TestCase):
def test_constructor(self):
@@ -528,7 +545,7 @@
def test_weakref(self):
d = deque('gallahad')
- p = proxy(d)
+ p = weakref.proxy(d)
self.assertEqual(str(p), str(d))
d = None
self.assertRaises(ReferenceError, str, p)
Modified: python/branches/release26-maint/Lib/test/test_dict.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_dict.py (original)
+++ python/branches/release26-maint/Lib/test/test_dict.py Thu Jan 1 16:46:10 2009
@@ -2,6 +2,7 @@
from test import test_support
import UserDict, random, string
+import gc, weakref
class DictTest(unittest.TestCase):
@@ -554,6 +555,19 @@
pass
d = {}
+ def test_container_iterator(self):
+ # Bug # XXX: tp_traverse was not implemented for dictiter objects
+ class C(object):
+ pass
+ iterators = (dict.iteritems, dict.itervalues, dict.iterkeys)
+ for i in iterators:
+ obj = C()
+ ref = weakref.ref(obj)
+ container = {obj: 1}
+ obj.x = i(container)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
from test import mapping_tests
Modified: python/branches/release26-maint/Lib/test/test_file.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_file.py (original)
+++ python/branches/release26-maint/Lib/test/test_file.py Thu Jan 1 16:46:10 2009
@@ -125,6 +125,19 @@
class OtherFileTests(unittest.TestCase):
+ def testOpenDir(self):
+ this_dir = os.path.dirname(__file__)
+ for mode in (None, "w"):
+ try:
+ if mode:
+ f = open(this_dir, mode)
+ else:
+ f = open(this_dir)
+ except IOError as e:
+ self.assertEqual(e.filename, this_dir)
+ else:
+ self.fail("opening a directory didn't raise an IOError")
+
def testModeStrings(self):
# check invalid mode strings
for mode in ("", "aU", "wU+"):
Modified: python/branches/release26-maint/Lib/test/test_fileio.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_fileio.py (original)
+++ python/branches/release26-maint/Lib/test/test_fileio.py Thu Jan 1 16:46:10 2009
@@ -109,6 +109,7 @@
_fileio._FileIO('.', 'r')
except IOError as e:
self.assertNotEqual(e.errno, 0)
+ self.assertEqual(e.filename, ".")
else:
self.fail("Should have raised IOError")
Modified: python/branches/release26-maint/Lib/test/test_set.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_set.py (original)
+++ python/branches/release26-maint/Lib/test/test_set.py Thu Jan 1 16:46:10 2009
@@ -1,6 +1,7 @@
import unittest
from test import test_support
-from weakref import proxy
+import gc
+import weakref
import operator
import copy
import pickle
@@ -322,6 +323,18 @@
self.assertEqual(sum(elem.hash_count for elem in d), n)
self.assertEqual(d3, dict.fromkeys(d, 123))
+ def test_container_iterator(self):
+ # Bug # XXX: tp_traverse was not implemented for set iterator object
+ class C(object):
+ pass
+ obj = C()
+ ref = weakref.ref(obj)
+ container = set([obj, 1])
+ obj.x = iter(container)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
+
class TestSet(TestJointOps):
thetype = set
@@ -538,7 +551,7 @@
def test_weakref(self):
s = self.thetype('gallahad')
- p = proxy(s)
+ p = weakref.proxy(s)
self.assertEqual(str(p), str(s))
s = None
self.assertRaises(ReferenceError, str, p)
Modified: python/branches/release26-maint/Lib/test/test_struct.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_struct.py (original)
+++ python/branches/release26-maint/Lib/test/test_struct.py Thu Jan 1 16:46:10 2009
@@ -2,6 +2,8 @@
import unittest
import struct
import warnings
+warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated",
+ DeprecationWarning)
from functools import wraps
from test.test_support import TestFailed, verbose, run_unittest
@@ -461,6 +463,11 @@
self.check_float_coerce(endian + fmt, 1.0)
self.check_float_coerce(endian + fmt, 1.5)
+ def test_issue4228(self):
+ # Packing a long may yield either 32 or 64 bits
+ x = struct.pack('L', -1)[:4]
+ self.assertEqual(x, '\xff'*4)
+
def test_unpack_from(self):
test_string = 'abcd01234'
fmt = '4s'
Modified: python/branches/release26-maint/Lib/textwrap.py
==============================================================================
--- python/branches/release26-maint/Lib/textwrap.py (original)
+++ python/branches/release26-maint/Lib/textwrap.py Thu Jan 1 16:46:10 2009
@@ -84,7 +84,7 @@
# splits into
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
# (after stripping out empty strings).
- wordsep_re = (
+ wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'[^\s\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|' # hyphenated words
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
@@ -93,7 +93,7 @@
# "Hello there -- you goof-ball, use the -b option!"
# splits into
# Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/
- wordsep_simple_re = r'(\s+)'
+ wordsep_simple_re = re.compile(r'(\s+)')
# XXX this is not locale- or charset-aware -- string.lowercase
# is US-ASCII only (and therefore English-only)
@@ -124,6 +124,13 @@
self.drop_whitespace = drop_whitespace
self.break_on_hyphens = break_on_hyphens
+ # recompile the regexes for Unicode mode -- done in this clumsy way for
+ # backwards compatibility because it's rather common to monkey-patch
+ # the TextWrapper class' wordsep_re attribute.
+ self.wordsep_re_uni = re.compile(self.wordsep_re.pattern, re.U)
+ self.wordsep_simple_re_uni = re.compile(
+ self.wordsep_simple_re.pattern, re.U)
+
# -- Private methods -----------------------------------------------
# (possibly useful for subclasses to override)
@@ -160,12 +167,17 @@
'use', ' ', 'the', ' ', '-b', ' ', option!'
otherwise.
"""
- flags = re.UNICODE if isinstance(text, unicode) else 0
- if self.break_on_hyphens:
- pat = self.wordsep_re
+ if isinstance(text, unicode):
+ if self.break_on_hyphens:
+ pat = self.wordsep_re_uni
+ else:
+ pat = self.wordsep_simple_re_uni
else:
- pat = self.wordsep_simple_re
- chunks = re.compile(pat, flags).split(text)
+ if self.break_on_hyphens:
+ pat = self.wordsep_re
+ else:
+ pat = self.wordsep_simple_re
+ chunks = pat.split(text)
chunks = filter(None, chunks) # remove empty chunks
return chunks
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Thu Jan 1 16:46:10 2009
@@ -12,9 +12,21 @@
Core and Builtins
-----------------
+- Issue #3680: Reference cycles created through a dict, set or deque iterator
+ did not get collected.
+
- Issue #4701: PyObject_Hash now implicitly calls PyType_Ready on types
where the tp_hash and tp_dict slots are both NULL.
+- Issue #4764: With io.open, IOError.filename is set when trying to open a
+ directory on POSIX systems.
+
+- Issue #4764: IOError.filename is set when trying to open a directory on POSIX
+ systems.
+
+- Issue #4759: None is now allowed as the first argument of
+ bytearray.translate(). It was always allowed for bytes.translate().
+
- Issue #4759: fix a segfault for bytearray.translate(x, None).
- Added test case to ensure attempts to read from a file opened for writing
@@ -138,9 +150,18 @@
Library
-------
+- Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
+ the function is not a generator.
+
- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
+ - Issue #4739: Add pydoc help topics for symbols, so that e.g. help('@')
+ works as expected in the interactive environment.
+
+- Issue #4756: zipfile.is_zipfile() now supports file-like objects. Patch by
+ Gabriel Genellina.
+
- Issue #4646: distutils was choking on empty options arg in the setup
function. Original patch by Thomas Heller.
@@ -206,9 +227,16 @@
- Issue #4730: Fixed the cPickle module to handle correctly astral characters
when protocol 0 is used.
+Tools/Demos
+-----------
+
+- Issue #4677: add two list comprehension tests to pybench.
+
Build
-----
+- Issues #4728 and #4060: WORDS_BIGEDIAN is now correct in Universal builds.
+
- Issue #4389: Add icon to the uninstall entry in "add-and-remove-programs".
- Issue #4289: Remove Cancel button from AdvancedDlg.
@@ -239,6 +267,10 @@
Extension Modules
-----------------
+- Issue #4228: Pack negative values the same way as 2.4 in struct's L format.
+
+- Issue #1040026: Fix os.times result on systems where HZ is incorrect.
+
- Issues #3167, #3682: Fix test_math failures for log, log10 on Solaris,
OpenBSD.
Modified: python/branches/release26-maint/Modules/_collectionsmodule.c
==============================================================================
--- python/branches/release26-maint/Modules/_collectionsmodule.c (original)
+++ python/branches/release26-maint/Modules/_collectionsmodule.c Thu Jan 1 16:46:10 2009
@@ -958,7 +958,7 @@
{
dequeiterobject *it;
- it = PyObject_New(dequeiterobject, &dequeiter_type);
+ it = PyObject_GC_New(dequeiterobject, &dequeiter_type);
if (it == NULL)
return NULL;
it->b = deque->leftblock;
@@ -967,14 +967,22 @@
it->deque = deque;
it->state = deque->state;
it->counter = deque->len;
+ _PyObject_GC_TRACK(it);
return (PyObject *)it;
}
+static int
+dequeiter_traverse(dequeiterobject *dio, visitproc visit, void *arg)
+{
+ Py_VISIT(dio->deque);
+ return 0;
+}
+
static void
dequeiter_dealloc(dequeiterobject *dio)
{
Py_XDECREF(dio->deque);
- Py_TYPE(dio)->tp_free(dio);
+ PyObject_GC_Del(dio);
}
static PyObject *
@@ -1039,9 +1047,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dequeiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -1060,7 +1068,7 @@
{
dequeiterobject *it;
- it = PyObject_New(dequeiterobject, &dequereviter_type);
+ it = PyObject_GC_New(dequeiterobject, &dequereviter_type);
if (it == NULL)
return NULL;
it->b = deque->rightblock;
@@ -1069,6 +1077,7 @@
it->deque = deque;
it->state = deque->state;
it->counter = deque->len;
+ _PyObject_GC_TRACK(it);
return (PyObject *)it;
}
@@ -1121,9 +1130,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dequeiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
Modified: python/branches/release26-maint/Modules/_fileio.c
==============================================================================
--- python/branches/release26-maint/Modules/_fileio.c (original)
+++ python/branches/release26-maint/Modules/_fileio.c Thu Jan 1 16:46:10 2009
@@ -98,7 +98,7 @@
directories, so we need a check. */
static int
-dircheck(PyFileIOObject* self)
+dircheck(PyFileIOObject* self, char *name)
{
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
struct stat buf;
@@ -109,8 +109,8 @@
PyObject *exc;
internal_close(self);
- exc = PyObject_CallFunction(PyExc_IOError, "(is)",
- EISDIR, msg);
+ exc = PyObject_CallFunction(PyExc_IOError, "(iss)",
+ EISDIR, msg, name);
PyErr_SetObject(PyExc_IOError, exc);
Py_XDECREF(exc);
return -1;
@@ -271,7 +271,7 @@
#endif
goto error;
}
- if(dircheck(self) < 0)
+ if(dircheck(self, name) < 0)
goto error;
}
Modified: python/branches/release26-maint/Modules/_struct.c
==============================================================================
--- python/branches/release26-maint/Modules/_struct.c (original)
+++ python/branches/release26-maint/Modules/_struct.c Thu Jan 1 16:46:10 2009
@@ -663,7 +663,7 @@
return -1;
#if (SIZEOF_LONG > SIZEOF_INT)
if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX)))
- return _range_error(f, 0);
+ RANGE_ERROR(x, f, 0, -1);
#endif
y = (int)x;
memcpy(p, (char *)&y, sizeof y);
@@ -675,12 +675,12 @@
{
unsigned long x;
unsigned int y;
- if (get_ulong(v, &x) < 0)
- return _range_error(f, 1);
+ if (get_wrapped_ulong(v, &x) < 0)
+ return -1;
y = (unsigned int)x;
#if (SIZEOF_LONG > SIZEOF_INT)
if (x > ((unsigned long)UINT_MAX))
- return _range_error(f, 1);
+ RANGE_ERROR(y, f, 1, -1);
#endif
memcpy(p, (char *)&y, sizeof y);
return 0;
@@ -700,8 +700,8 @@
np_ulong(char *p, PyObject *v, const formatdef *f)
{
unsigned long x;
- if (get_ulong(v, &x) < 0)
- return _range_error(f, 1);
+ if (get_wrapped_ulong(v, &x) < 0)
+ return -1;
memcpy(p, (char *)&x, sizeof x);
return 0;
}
Modified: python/branches/release26-maint/Objects/dictobject.c
==============================================================================
--- python/branches/release26-maint/Objects/dictobject.c (original)
+++ python/branches/release26-maint/Objects/dictobject.c Thu Jan 1 16:46:10 2009
@@ -2331,7 +2331,7 @@
dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
{
dictiterobject *di;
- di = PyObject_New(dictiterobject, itertype);
+ di = PyObject_GC_New(dictiterobject, itertype);
if (di == NULL)
return NULL;
Py_INCREF(dict);
@@ -2348,6 +2348,7 @@
}
else
di->di_result = NULL;
+ _PyObject_GC_TRACK(di);
return (PyObject *)di;
}
@@ -2356,7 +2357,15 @@
{
Py_XDECREF(di->di_dict);
Py_XDECREF(di->di_result);
- PyObject_Del(di);
+ PyObject_GC_Del(di);
+}
+
+static int
+dictiter_traverse(dictiterobject *di, visitproc visit, void *arg)
+{
+ Py_VISIT(di->di_dict);
+ Py_VISIT(di->di_result);
+ return 0;
}
static PyObject *
@@ -2435,9 +2444,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2507,9 +2516,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2593,9 +2602,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
Modified: python/branches/release26-maint/Objects/fileobject.c
==============================================================================
--- python/branches/release26-maint/Objects/fileobject.c (original)
+++ python/branches/release26-maint/Objects/fileobject.c Thu Jan 1 16:46:10 2009
@@ -132,8 +132,8 @@
if (fstat(fileno(f->f_fp), &buf) == 0 &&
S_ISDIR(buf.st_mode)) {
char *msg = strerror(EISDIR);
- PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)",
- EISDIR, msg);
+ PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(isO)",
+ EISDIR, msg, f->f_name);
PyErr_SetObject(PyExc_IOError, exc);
Py_XDECREF(exc);
return NULL;
Modified: python/branches/release26-maint/Objects/setobject.c
==============================================================================
--- python/branches/release26-maint/Objects/setobject.c (original)
+++ python/branches/release26-maint/Objects/setobject.c Thu Jan 1 16:46:10 2009
@@ -810,7 +810,14 @@
setiter_dealloc(setiterobject *si)
{
Py_XDECREF(si->si_set);
- PyObject_Del(si);
+ PyObject_GC_Del(si);
+}
+
+static int
+setiter_traverse(setiterobject *si, visitproc visit, void *arg)
+{
+ Py_VISIT(si->si_set);
+ return 0;
}
static PyObject *
@@ -888,9 +895,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)setiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -903,7 +910,7 @@
static PyObject *
set_iter(PySetObject *so)
{
- setiterobject *si = PyObject_New(setiterobject, &PySetIter_Type);
+ setiterobject *si = PyObject_GC_New(setiterobject, &PySetIter_Type);
if (si == NULL)
return NULL;
Py_INCREF(so);
@@ -911,6 +918,7 @@
si->si_used = so->used;
si->si_pos = 0;
si->len = so->used;
+ _PyObject_GC_TRACK(si);
return (PyObject *)si;
}
Modified: python/branches/release26-maint/Tools/pybench/Lists.py
==============================================================================
--- python/branches/release26-maint/Tools/pybench/Lists.py (original)
+++ python/branches/release26-maint/Tools/pybench/Lists.py Thu Jan 1 16:46:10 2009
@@ -293,3 +293,58 @@
for i in xrange(self.rounds):
pass
+
+class SimpleListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ n = range(10) * 10
+
+ for i in xrange(self.rounds):
+ l = [x for x in n]
+ l = [x for x in n if x]
+ l = [x for x in n if not x]
+
+ l = [x for x in n]
+ l = [x for x in n if x]
+ l = [x for x in n if not x]
+
+ def calibrate(self):
+
+ n = range(10) * 10
+
+ for i in xrange(self.rounds):
+ pass
+
+class NestedListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ m = range(10)
+ n = range(10)
+
+ for i in xrange(self.rounds):
+ l = [x for x in n for y in m]
+ l = [y for x in n for y in m]
+
+ l = [x for x in n for y in m if y]
+ l = [y for x in n for y in m if x]
+
+ l = [x for x in n for y in m if not y]
+ l = [y for x in n for y in m if not x]
+
+ def calibrate(self):
+
+ m = range(10)
+ n = range(10)
+
+ for i in xrange(self.rounds):
+ pass
More information about the Python-checkins
mailing list