From python-checkins at python.org Thu Oct 1 02:10:13 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 01 Oct 2009 00:10:13 -0000 Subject: [Python-checkins] r75161 - python/branches/py3k/Doc/conf.py Message-ID: Author: benjamin.peterson Date: Thu Oct 1 02:10:13 2009 New Revision: 75161 Log: fix opensearch version Modified: python/branches/py3k/Doc/conf.py Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Thu Oct 1 02:10:13 2009 @@ -86,7 +86,7 @@ } # Output an OpenSearch description file. -html_use_opensearch = 'http://docs.python.org/dev/3.0' +html_use_opensearch = 'http://docs.python.org/dev/3.2' # Additional static files. html_static_path = ['tools/sphinxext/static'] From python-checkins at python.org Thu Oct 1 02:10:50 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 01 Oct 2009 00:10:50 -0000 Subject: [Python-checkins] r75162 - python/branches/release31-maint/Doc/conf.py Message-ID: Author: benjamin.peterson Date: Thu Oct 1 02:10:50 2009 New Revision: 75162 Log: update opensearch Modified: python/branches/release31-maint/Doc/conf.py Modified: python/branches/release31-maint/Doc/conf.py ============================================================================== --- python/branches/release31-maint/Doc/conf.py (original) +++ python/branches/release31-maint/Doc/conf.py Thu Oct 1 02:10:50 2009 @@ -86,7 +86,7 @@ } # Output an OpenSearch description file. -html_use_opensearch = 'http://docs.python.org/dev/3.0' +html_use_opensearch = 'http://docs.python.org/3.1' # Additional static files. html_static_path = ['tools/sphinxext/static'] From python-checkins at python.org Thu Oct 1 02:57:33 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 01 Oct 2009 00:57:33 -0000 Subject: [Python-checkins] r75163 - python/branches/py3k/Doc/conf.py Message-ID: Author: benjamin.peterson Date: Thu Oct 1 02:57:32 2009 New Revision: 75163 Log: more stable url Modified: python/branches/py3k/Doc/conf.py Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Thu Oct 1 02:57:32 2009 @@ -86,7 +86,7 @@ } # Output an OpenSearch description file. -html_use_opensearch = 'http://docs.python.org/dev/3.2' +html_use_opensearch = 'http://docs.python.org/dev/py3k' # Additional static files. html_static_path = ['tools/sphinxext/static'] From python-checkins at python.org Thu Oct 1 03:07:03 2009 From: python-checkins at python.org (senthil.kumaran) Date: Thu, 01 Oct 2009 01:07:03 -0000 Subject: [Python-checkins] r75164 - python/trunk/Lib/test/test_urllib.py Message-ID: Author: senthil.kumaran Date: Thu Oct 1 03:07:03 2009 New Revision: 75164 Log: Fix for issue7026 test_urllib: unsetting missing 'env' variable. Modified: python/trunk/Lib/test/test_urllib.py Modified: python/trunk/Lib/test/test_urllib.py ============================================================================== --- python/trunk/Lib/test/test_urllib.py (original) +++ python/trunk/Lib/test/test_urllib.py Thu Oct 1 03:07:03 2009 @@ -103,7 +103,7 @@ # Delete all proxy related env vars for k, v in os.environ.iteritems(): if 'proxy' in k.lower(): - del env[k] + del self.env[k] def tearDown(self): # Restore all proxy related env vars From python-checkins at python.org Thu Oct 1 03:19:18 2009 From: python-checkins at python.org (senthil.kumaran) Date: Thu, 01 Oct 2009 01:19:18 -0000 Subject: [Python-checkins] r75165 - python/trunk/Lib/test/test_urllib.py Message-ID: Author: senthil.kumaran Date: Thu Oct 1 03:19:18 2009 New Revision: 75165 Log: using dict.unset(k) instead of del dict[k]. consistent with release26-maint Modified: python/trunk/Lib/test/test_urllib.py Modified: python/trunk/Lib/test/test_urllib.py ============================================================================== --- python/trunk/Lib/test/test_urllib.py (original) +++ python/trunk/Lib/test/test_urllib.py Thu Oct 1 03:19:18 2009 @@ -103,7 +103,7 @@ # Delete all proxy related env vars for k, v in os.environ.iteritems(): if 'proxy' in k.lower(): - del self.env[k] + env.unset(k) def tearDown(self): # Restore all proxy related env vars From python-checkins at python.org Thu Oct 1 03:50:13 2009 From: python-checkins at python.org (senthil.kumaran) Date: Thu, 01 Oct 2009 01:50:13 -0000 Subject: [Python-checkins] r75166 - python/trunk/Lib/test/test_urllib.py Message-ID: Author: senthil.kumaran Date: Thu Oct 1 03:50:13 2009 New Revision: 75166 Log: That's self.env.unset(k) and not env.unset(k) I was heading back to the problem. Modified: python/trunk/Lib/test/test_urllib.py Modified: python/trunk/Lib/test/test_urllib.py ============================================================================== --- python/trunk/Lib/test/test_urllib.py (original) +++ python/trunk/Lib/test/test_urllib.py Thu Oct 1 03:50:13 2009 @@ -103,7 +103,7 @@ # Delete all proxy related env vars for k, v in os.environ.iteritems(): if 'proxy' in k.lower(): - env.unset(k) + self.env.unset(k) def tearDown(self): # Restore all proxy related env vars From nnorwitz at gmail.com Thu Oct 1 11:44:26 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 1 Oct 2009 05:44:26 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091001094426.GA10095@python.psfb.org> More important issues: ---------------------- test_urllib2_localnet leaked [-280, 0, 0] references, sum=-280 Less important issues: ---------------------- test_asynchat leaked [-125, 0, 0] references, sum=-125 test_smtplib leaked [85, -88, 0] references, sum=-3 test_socketserver leaked [-77, 0, 0] references, sum=-77 test_ssl leaked [0, -420, 420] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Thu Oct 1 18:13:29 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 16:13:29 -0000 Subject: [Python-checkins] r75167 - python/branches/py3k/Doc/library/math.rst Message-ID: Author: mark.dickinson Date: Thu Oct 1 18:13:29 2009 New Revision: 75167 Log: Fix versionadded for py3k math.gamma Modified: python/branches/py3k/Doc/library/math.rst Modified: python/branches/py3k/Doc/library/math.rst ============================================================================== --- python/branches/py3k/Doc/library/math.rst (original) +++ python/branches/py3k/Doc/library/math.rst Thu Oct 1 18:13:29 2009 @@ -285,7 +285,7 @@ Return the Gamma function at *x*. - .. versionadded:: 2.7 + .. versionadded:: 3.2 Constants From python-checkins at python.org Thu Oct 1 18:24:46 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 01 Oct 2009 16:24:46 -0000 Subject: [Python-checkins] r75168 - python/branches/py3k/Doc/library/io.rst Message-ID: Author: antoine.pitrou Date: Thu Oct 1 18:24:45 2009 New Revision: 75168 Log: Issue #7022: clarification of RawIOBase.read(), suggested by Pascal Chambon. Modified: python/branches/py3k/Doc/library/io.rst Modified: python/branches/py3k/Doc/library/io.rst ============================================================================== --- python/branches/py3k/Doc/library/io.rst (original) +++ python/branches/py3k/Doc/library/io.rst Thu Oct 1 18:24:45 2009 @@ -326,11 +326,14 @@ .. method:: read(n=-1) - Read and return up to *n* bytes from the stream. As a convenience, if - *n* is unspecified or -1, :meth:`readall` is called. Otherwise, - only one system call is ever made. An empty bytes object is returned - on EOF; ``None`` is returned if the object is set not to block and has - no data to read. + Read up to *n* bytes from the object and return them. As a convenience, + if *n* is unspecified or -1, :meth:`readall` is called. Otherwise, + only one system call is ever made. Fewer than *n* bytes may be + returned if the operating system call returns fewer than *n* bytes. + + If 0 bytes are returned, and *n* was not 0, this indicates end of file. + If the object is in non-blocking mode and no bytes are available, + ``None`` is returned. .. method:: readall() From python-checkins at python.org Thu Oct 1 18:27:13 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 01 Oct 2009 16:27:13 -0000 Subject: [Python-checkins] r75169 - in python/branches/release31-maint: Doc/library/io.rst Message-ID: Author: antoine.pitrou Date: Thu Oct 1 18:27:13 2009 New Revision: 75169 Log: Merged revisions 75168 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75168 | antoine.pitrou | 2009-10-01 18:24:45 +0200 (jeu., 01 oct. 2009) | 3 lines Issue #7022: clarification of RawIOBase.read(), suggested by Pascal Chambon. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/io.rst Modified: python/branches/release31-maint/Doc/library/io.rst ============================================================================== --- python/branches/release31-maint/Doc/library/io.rst (original) +++ python/branches/release31-maint/Doc/library/io.rst Thu Oct 1 18:27:13 2009 @@ -326,11 +326,14 @@ .. method:: read(n=-1) - Read and return up to *n* bytes from the stream. As a convenience, if - *n* is unspecified or -1, :meth:`readall` is called. Otherwise, - only one system call is ever made. An empty bytes object is returned - on EOF; ``None`` is returned if the object is set not to block and has - no data to read. + Read up to *n* bytes from the object and return them. As a convenience, + if *n* is unspecified or -1, :meth:`readall` is called. Otherwise, + only one system call is ever made. Fewer than *n* bytes may be + returned if the operating system call returns fewer than *n* bytes. + + If 0 bytes are returned, and *n* was not 0, this indicates end of file. + If the object is in non-blocking mode and no bytes are available, + ``None`` is returned. .. method:: readall() From python-checkins at python.org Thu Oct 1 19:01:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 17:01:26 -0000 Subject: [Python-checkins] r75170 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Thu Oct 1 19:01:25 2009 New Revision: 75170 Log: Blocked revisions 75167 via svnmerge ........ r75167 | mark.dickinson | 2009-10-01 17:13:29 +0100 (Thu, 01 Oct 2009) | 1 line Fix versionadded for py3k math.gamma ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Thu Oct 1 19:08:03 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 01 Oct 2009 17:08:03 -0000 Subject: [Python-checkins] r75171 - python/trunk/Doc/library/io.rst Message-ID: Author: antoine.pitrou Date: Thu Oct 1 19:08:03 2009 New Revision: 75171 Log: Sync the 2.x `io` docs with py3k, with a small note as to the distinction between bytes streams and text streams. Modified: python/trunk/Doc/library/io.rst Modified: python/trunk/Doc/library/io.rst ============================================================================== --- python/trunk/Doc/library/io.rst (original) +++ python/trunk/Doc/library/io.rst Thu Oct 1 19:08:03 2009 @@ -6,11 +6,23 @@ .. moduleauthor:: Guido van Rossum .. moduleauthor:: Mike Verdone .. moduleauthor:: Mark Russell +.. moduleauthor:: Antoine Pitrou +.. moduleauthor:: Amaury Forgeot d'Arc +.. moduleauthor:: Benjamin Peterson .. sectionauthor:: Benjamin Peterson -.. versionadded:: 2.6 -The :mod:`io` module provides the Python interfaces to stream handling. The -built-in :func:`open` function is defined in this module. +The :mod:`io` module provides the Python interfaces to stream handling. +Under Python 2.x, this is proposed as an alternative to the built-in +:class:`file` object, but in Python 3.x it is the default interface to +access files and streams. + +.. note:: + + Since this module has been designed primarily for Python 3.x, you have to + be aware that all uses of "bytes" in this document refer to the + :class:`str` type (of which :class:`bytes` is an alias), and all uses + of "text" refer to the :class:`unicode` type. Furthermore, those two + types are not interchangeable in the :mod:`io` APIs. At the top of the I/O hierarchy is the abstract base class :class:`IOBase`. It defines the basic interface to a stream. Note, however, that there is no @@ -31,10 +43,10 @@ Another :class:`IOBase` subclass, :class:`TextIOBase`, deals with streams whose bytes represent text, and handles encoding and decoding -from and to strings. :class:`TextIOWrapper`, which extends it, is a -buffered text interface to a buffered raw stream +from and to :class:`unicode` strings. :class:`TextIOWrapper`, which extends +it, is a buffered text interface to a buffered raw stream (:class:`BufferedIOBase`). Finally, :class:`StringIO` is an in-memory -stream for text. +stream for unicode text. Argument names are not part of the specification, and only the arguments of :func:`.open` are intended to be used as keyword arguments. @@ -49,16 +61,16 @@ classes. :func:`.open` uses the file's blksize (as obtained by :func:`os.stat`) if possible. -.. function:: open(file[, mode[, buffering[, encoding[, errors[, newline[, closefd=True]]]]]]) +.. function:: open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True) - Open *file* and return a stream. If the file cannot be opened, an - :exc:`IOError` is raised. + Open *file* and return a corresponding stream. If the file cannot be opened, + an :exc:`IOError` is raised. - *file* is either a string giving the name (and the path if the file isn't in - the current working directory) of the file to be opened or a file - descriptor of the file to be opened. (If a file descriptor is given, - for example, from :func:`os.fdopen`, it is closed when the returned - I/O object is closed, unless *closefd* is set to ``False``.) + *file* is either a string giving the name (and the path if the file isn't + in the current working directory) of the file to be opened or an integer + file descriptor of the file to be wrapped. (If a file descriptor is given, + for example, from :func:`os.fdopen`, it is closed when the returned I/O + object is closed, unless *closefd* is set to ``False``.) *mode* is an optional string that specifies the mode in which the file is opened. It defaults to ``'r'`` which means open for reading in text mode. @@ -88,11 +100,11 @@ Python distinguishes between files opened in binary and text modes, even when the underlying operating system doesn't. Files opened in binary mode - (including ``'b'`` in the *mode* argument) return contents as ``bytes`` + (including ``'b'`` in the *mode* argument) return contents as :class:`bytes` objects without any decoding. In text mode (the default, or when ``'t'`` is included in the *mode* argument), the contents of the file are returned as - strings, the bytes having been first decoded using a platform-dependent - encoding or using the specified *encoding* if given. + :class:`unicode` strings, the bytes having been first decoded using a + platform-dependent encoding or using the specified *encoding* if given. *buffering* is an optional integer used to set the buffering policy. By default full buffering is on. Pass 0 to switch buffering off (only allowed @@ -101,19 +113,21 @@ *encoding* is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform - dependent, but any encoding supported by Python can be used. See the - :mod:`codecs` module for the list of supported encodings. + dependent (whatever :func:`locale.getpreferredencoding` returns), but any + encoding supported by Python can be used. See the :mod:`codecs` module for + the list of supported encodings. *errors* is an optional string that specifies how encoding and decoding - errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` - exception if there is an encoding error (the default of ``None`` has the same - effect), or pass ``'ignore'`` to ignore errors. (Note that ignoring encoding - errors can lead to data loss.) ``'replace'`` causes a replacement marker - (such as ``'?'``) to be inserted where there is malformed data. When - writing, ``'xmlcharrefreplace'`` (replace with the appropriate XML character - reference) or ``'backslashreplace'`` (replace with backslashed escape - sequences) can be used. Any other error handling name that has been - registered with :func:`codecs.register_error` is also valid. + errors are to be handled--this cannot be used in binary mode. Pass + ``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding + error (the default of ``None`` has the same effect), or pass ``'ignore'`` to + ignore errors. (Note that ignoring encoding errors can lead to data loss.) + ``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted + where there is malformed data. When writing, ``'xmlcharrefreplace'`` + (replace with the appropriate XML character reference) or + ``'backslashreplace'`` (replace with backslashed escape sequences) can be + used. Any other error handling name that has been registered with + :func:`codecs.register_error` is also valid. *newline* controls how universal newlines works (it only applies to text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It @@ -133,23 +147,26 @@ the other legal values, any ``'\n'`` characters written are translated to the given string. - If *closefd* is ``False`` and a file descriptor rather than a - filename was given, the underlying file descriptor will be kept open - when the file is closed. If a filename is given *closefd* has no - effect but must be ``True`` (the default). - - The type of file object returned by the :func:`.open` function depends - on the mode. When :func:`.open` is used to open a file in a text mode - (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a - :class:`TextIOWrapper`. When used to open a file in a binary mode, - the returned class varies: in read binary mode, it returns a - :class:`BufferedReader`; in write binary and append binary modes, it - returns a :class:`BufferedWriter`, and in read/write mode, it returns - a :class:`BufferedRandom`. - - It is also possible to use a string or bytearray as a file for both reading - and writing. For strings :class:`StringIO` can be used like a file opened in - a text mode, and for bytearrays a :class:`BytesIO` can be used like a + If *closefd* is ``False`` and a file descriptor rather than a filename was + given, the underlying file descriptor will be kept open when the file is + closed. If a filename is given *closefd* has no effect and must be ``True`` + (the default). + + The type of file object returned by the :func:`.open` function depends on the + mode. When :func:`.open` is used to open a file in a text mode (``'w'``, + ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of + :class:`TextIOBase` (specifically :class:`TextIOWrapper`). When used to open + a file in a binary mode with buffering, the returned class is a subclass of + :class:`BufferedIOBase`. The exact class varies: in read binary mode, it + returns a :class:`BufferedReader`; in write binary and append binary modes, + it returns a :class:`BufferedWriter`, and in read/write mode, it returns a + :class:`BufferedRandom`. When buffering is disabled, the raw stream, a + subclass of :class:`RawIOBase`, :class:`FileIO`, is returned. + + It is also possible to use an :class:`unicode` or :class:`bytes` string + as a file for both reading and writing. For :class:`unicode` strings + :class:`StringIO` can be used like a file opened in text mode, + and for :class:`bytes` a :class:`BytesIO` can be used like a file opened in a binary mode. @@ -193,22 +210,25 @@ support are called. The basic type used for binary data read from or written to a file is - :class:`bytes`. :class:`bytearray`\s are accepted too, and in some cases - (such as :class:`readinto`) required. Text I/O classes work with - :class:`str` data. + :class:`bytes` (also known as :class:`str`). :class:`bytearray`\s are + accepted too, and in some cases (such as :class:`readinto`) required. + Text I/O classes work with :class:`unicode` data. Note that calling any method (even inquiries) on a closed stream is undefined. Implementations may raise :exc:`IOError` in this case. IOBase (and its subclasses) support the iterator protocol, meaning that an :class:`IOBase` object can be iterated over yielding the lines in a stream. + Lines are defined slightly differently depending on whether the stream is + a binary stream (yielding :class:`bytes`), or a text stream (yielding + :class:`unicode` strings). See :meth:`readline` below. IOBase is also a context manager and therefore supports the :keyword:`with` statement. In this example, *file* is closed after the :keyword:`with` statement's suite is finished---even if an exception occurs:: - with open('spam.txt', 'w') as file: - file.write('Spam and eggs!') + with io.open('spam.txt', 'w') as file: + file.write(u'Spam and eggs!') :class:`IOBase` provides these data attributes and methods: @@ -244,7 +264,7 @@ Return ``True`` if the stream can be read from. If False, :meth:`read` will raise :exc:`IOError`. - .. method:: readline([limit]) + .. method:: readline(limit=-1) Read and return one line from the stream. If *limit* is specified, at most *limit* bytes will be read. @@ -253,13 +273,13 @@ the *newlines* argument to :func:`.open` can be used to select the line terminator(s) recognized. - .. method:: readlines([hint]) + .. method:: readlines(hint=-1) Read and return a list of lines from the stream. *hint* can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds *hint*. - .. method:: seek(offset[, whence]) + .. method:: seek(offset, whence=SEEK_SET) Change the stream position to the given byte *offset*. *offset* is interpreted relative to the position indicated by *whence*. Values for @@ -286,7 +306,7 @@ Return the current stream position. - .. method:: truncate([size]) + .. method:: truncate(size=None) Truncate the file to at most *size* bytes. *size* defaults to the current file position, as returned by :meth:`tell`. @@ -308,15 +328,23 @@ Base class for raw binary I/O. It inherits :class:`IOBase`. There is no public constructor. + Raw binary I/O typically provides low-level access to an underlying OS + device or API, and does not try to encapsulate it in high-level primitives + (this is left to Buffered I/O and Text I/O, described later in this page). + In addition to the attributes and methods from :class:`IOBase`, RawIOBase provides the following methods: - .. method:: read([n]) + .. method:: read(n=-1) - Read and return all the bytes from the stream until EOF, or if *n* is - specified, up to *n* bytes. Only one system call is ever made. An empty - bytes object is returned on EOF; ``None`` is returned if the object is set - not to block and has no data to read. + Read up to *n* bytes from the object and return them. As a convenience, + if *n* is unspecified or -1, :meth:`readall` is called. Otherwise, + only one system call is ever made. Fewer than *n* bytes may be + returned if the operating system call returns fewer than *n* bytes. + + If 0 bytes are returned, and *n* was not 0, this indicates end of file. + If the object is in non-blocking mode and no bytes are available, + ``None`` is returned. .. method:: readall() @@ -331,32 +359,58 @@ .. method:: write(b) Write the given bytes or bytearray object, *b*, to the underlying raw - stream and return the number of bytes written (This is never less than - ``len(b)``, since if the write fails, an :exc:`IOError` will be raised). + stream and return the number of bytes written. This can be less than + ``len(b)``, depending on specifics of the underlying raw stream, and + especially if it is in non-blocking mode. ``None`` is returned if the + raw stream is set not to block and no single byte could be readily + written to it. .. class:: BufferedIOBase - Base class for streams that support buffering. It inherits :class:`IOBase`. - There is no public constructor. + Base class for binary streams that support some kind of buffering. + It inherits :class:`IOBase`. There is no public constructor. + + The main difference with :class:`RawIOBase` is that methods :meth:`read`, + :meth:`readinto` and :meth:`write` will try (respectively) to read as much + input as requested or to consume all given output, at the expense of + making perhaps more than one system call. + + In addition, those methods can raise :exc:`BlockingIOError` if the + underlying raw stream is in non-blocking mode and cannot take or give + enough data; unlike their :class:`RawIOBase` counterparts, they will + never return ``None``. - The main difference with :class:`RawIOBase` is that the :meth:`read` method - supports omitting the *size* argument, and does not have a default + Besides, the :meth:`read` method does not have a default implementation that defers to :meth:`readinto`. - In addition, :meth:`read`, :meth:`readinto`, and :meth:`write` may raise - :exc:`BlockingIOError` if the underlying raw stream is in non-blocking mode - and not ready; unlike their raw counterparts, they will never return - ``None``. - - A typical implementation should not inherit from a :class:`RawIOBase` - implementation, but wrap one like :class:`BufferedWriter` and - :class:`BufferedReader`. + A typical :class:`BufferedIOBase` implementation should not inherit from a + :class:`RawIOBase` implementation, but wrap one, like + :class:`BufferedWriter` and :class:`BufferedReader` do. - :class:`BufferedIOBase` provides or overrides these methods in addition to + :class:`BufferedIOBase` provides or overrides these members in addition to those from :class:`IOBase`: - .. method:: read([n]) + .. attribute:: raw + + The underlying raw stream (a :class:`RawIOBase` instance) that + :class:`BufferedIOBase` deals with. This is not part of the + :class:`BufferedIOBase` API and may not exist on some implementations. + + .. method:: detach() + + Separate the underlying raw stream from the buffer and return it. + + After the raw stream has been detached, the buffer is in an unusable + state. + + Some buffers, like :class:`BytesIO`, do not have the concept of a single + raw stream to return from this method. They raise + :exc:`UnsupportedOperation`. + + .. versionadded:: 2.7 + + .. method:: read(n=-1) Read and return up to *n* bytes. If the argument is omitted, ``None``, or negative, data is read and returned until EOF is reached. An empty bytes @@ -368,8 +422,15 @@ one raw read will be issued, and a short result does not imply that EOF is imminent. - A :exc:`BlockingIOError` is raised if the underlying raw stream has no - data at the moment. + A :exc:`BlockingIOError` is raised if the underlying raw stream is in + non blocking-mode, and has no data available at the moment. + + .. method:: read1(n=-1) + + Read and return up to *n* bytes, with at most one call to the underlying + raw stream's :meth:`~RawIOBase.read` method. This can be useful if you + are implementing your own buffering on top of a :class:`BufferedIOBase` + object. .. method:: readinto(b) @@ -377,35 +438,47 @@ read. Like :meth:`read`, multiple reads may be issued to the underlying raw - stream, unless the latter is 'interactive.' + stream, unless the latter is 'interactive'. - A :exc:`BlockingIOError` is raised if the underlying raw stream has no - data at the moment. + A :exc:`BlockingIOError` is raised if the underlying raw stream is in + non blocking-mode, and has no data available at the moment. .. method:: write(b) - Write the given bytes or bytearray object, *b*, to the underlying raw - stream and return the number of bytes written (never less than ``len(b)``, - since if the write fails an :exc:`IOError` will be raised). - - A :exc:`BlockingIOError` is raised if the buffer is full, and the - underlying raw stream cannot accept more data at the moment. + Write the given bytes or bytearray object, *b* and return the number + of bytes written (never less than ``len(b)``, since if the write fails + an :exc:`IOError` will be raised). Depending on the actual + implementation, these bytes may be readily written to the underlying + stream, or held in a buffer for performance and latency reasons. + + When in non-blocking mode, a :exc:`BlockingIOError` is raised if the + data needed to be written to the raw stream but it couldn't accept + all the data without blocking. Raw File I/O ------------ -.. class:: FileIO(name[, mode]) +.. class:: FileIO(name, mode='r', closefd=True) - :class:`FileIO` represents a file containing bytes data. It implements - the :class:`RawIOBase` interface (and therefore the :class:`IOBase` - interface, too). + :class:`FileIO` represents an OS-level file containing bytes data. + It implements the :class:`RawIOBase` interface (and therefore the + :class:`IOBase` interface, too). + + The *name* can be one of two things: + + * a string representing the path to the file which will be opened; + * an integer representing the number of an existing OS-level file descriptor + to which the resulting :class:`FileIO` object will give access. The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a ``'+'`` to the mode to allow simultaneous reading and writing. + The :meth:`read` (when called with a positive argument), :meth:`readinto` + and :meth:`write` methods on this class will only make one system call. + In addition to the attributes and methods from :class:`IOBase` and :class:`RawIOBase`, :class:`FileIO` provides the following data attributes and methods: @@ -419,38 +492,19 @@ The file name. This is the file descriptor of the file when no name is given in the constructor. - .. method:: read([n]) - - Read and return at most *n* bytes. Only one system call is made, so it is - possible that less data than was requested is returned. Use :func:`len` - on the returned bytes object to see how many bytes were actually returned. - (In non-blocking mode, ``None`` is returned when no data is available.) - - .. method:: readall() - - Read and return the entire file's contents in a single bytes object. As - much as immediately available is returned in non-blocking mode. If the - EOF has been reached, ``b''`` is returned. - - .. method:: write(b) - - Write the bytes or bytearray object, *b*, to the file, and return - the number actually written. Only one system call is made, so it - is possible that only some of the data is written. - - Note that the inherited ``readinto()`` method should not be used on - :class:`FileIO` objects. - Buffered Streams ---------------- +In many situations, buffered I/O streams will provide higher performance +(bandwidth and latency) than raw I/O streams. Their API is also more usable. + .. class:: BytesIO([initial_bytes]) A stream implementation using an in-memory bytes buffer. It inherits :class:`BufferedIOBase`. - The argument *initial_bytes* is an optional initial bytearray. + The argument *initial_bytes* is an optional initial :class:`bytes`. :class:`BytesIO` provides or overrides these methods in addition to those from :class:`BufferedIOBase` and :class:`IOBase`: @@ -469,10 +523,13 @@ current stream position, as returned by :meth:`tell`. -.. class:: BufferedReader(raw[, buffer_size]) +.. class:: BufferedReader(raw, buffer_size=DEFAULT_BUFFER_SIZE) - A buffer for a readable, sequential :class:`RawIOBase` object. It inherits - :class:`BufferedIOBase`. + A buffer providing higher-level access to a readable, sequential + :class:`RawIOBase` object. It inherits :class:`BufferedIOBase`. + When reading data from this object, a larger amount of data may be + requested from the underlying raw stream, and kept in an internal buffer. + The buffered data can then be returned directly on subsequent reads. The constructor creates a :class:`BufferedReader` for the given readable *raw* stream and *buffer_size*. If *buffer_size* is omitted, @@ -483,11 +540,9 @@ .. method:: peek([n]) - Return 1 (or *n* if specified) bytes from a buffer without advancing the - position. Only a single read on the raw stream is done to satisfy the - call. The number of bytes returned may be less than requested since at - most all the buffer's bytes from the current position to the end are - returned. + Return bytes from the stream without advancing the position. At most one + single read on the raw stream is done to satisfy the call. The number of + bytes returned may be less or more than requested. .. method:: read([n]) @@ -501,15 +556,24 @@ Otherwise, one raw stream read call is made. -.. class:: BufferedWriter(raw[, buffer_size[, max_buffer_size]]) +.. class:: BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE) - A buffer for a writeable sequential RawIO object. It inherits - :class:`BufferedIOBase`. + A buffer providing higher-level access to a writeable, sequential + :class:`RawIOBase` object. It inherits :class:`BufferedIOBase`. + When writing to this object, data is normally held into an internal + buffer. The buffer will be written out to the underlying :class:`RawIOBase` + object under various conditions, including: + + * when the buffer gets too small for all pending data; + * when :meth:`flush()` is called; + * when a :meth:`seek()` is requested (for :class:`BufferedRandom` objects); + * when the :class:`BufferedWriter` object is closed or destroyed. The constructor creates a :class:`BufferedWriter` for the given writeable *raw* stream. If the *buffer_size* is not given, it defaults to - :data:`DEAFULT_BUFFER_SIZE`. If *max_buffer_size* is omitted, it defaults to - twice the buffer size. + :data:`DEFAULT_BUFFER_SIZE`. + + A third argument, *max_buffer_size*, is supported, but unused and deprecated. :class:`BufferedWriter` provides or overrides these methods in addition to those from :class:`BufferedIOBase` and :class:`IOBase`: @@ -521,35 +585,41 @@ .. method:: write(b) - Write the bytes or bytearray object, *b*, onto the raw stream and return - the number of bytes written. A :exc:`BlockingIOError` is raised when the - raw stream blocks. + Write the bytes or bytearray object, *b* and return the number of bytes + written. When in non-blocking mode, a :exc:`BlockingIOError` is raised + if the buffer needs to be written out but the raw stream blocks. -.. class:: BufferedRWPair(reader, writer[, buffer_size[, max_buffer_size]]) +.. class:: BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE) - A combined buffered writer and reader object for a raw stream that can be - written to and read from. It has and supports both :meth:`read`, :meth:`write`, - and their variants. This is useful for sockets and two-way pipes. - It inherits :class:`BufferedIOBase`. + A buffered I/O object giving a combined, higher-level access to two + sequential :class:`RawIOBase` objects: one readable, the other writeable. + It is useful for pairs of unidirectional communication channels + (pipes, for instance). It inherits :class:`BufferedIOBase`. *reader* and *writer* are :class:`RawIOBase` objects that are readable and writeable respectively. If the *buffer_size* is omitted it defaults to - :data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer) - defaults to twice the buffer size. + :data:`DEFAULT_BUFFER_SIZE`. + + A fourth argument, *max_buffer_size*, is supported, but unused and + deprecated. - :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods. + :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods + except for :meth:`~BufferedIOBase.detach`, which raises + :exc:`UnsupportedOperation`. -.. class:: BufferedRandom(raw[, buffer_size[, max_buffer_size]]) +.. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE) A buffered interface to random access streams. It inherits - :class:`BufferedReader` and :class:`BufferedWriter`. + :class:`BufferedReader` and :class:`BufferedWriter`, and further supports + :meth:`seek` and :meth:`tell` functionality. The constructor creates a reader and writer for a seekable raw stream, given in the first argument. If the *buffer_size* is omitted it defaults to - :data:`DEFAULT_BUFFER_SIZE`. The *max_buffer_size* (for the buffered writer) - defaults to twice the buffer size. + :data:`DEFAULT_BUFFER_SIZE`. + + A third argument, *max_buffer_size*, is supported, but unused and deprecated. :class:`BufferedRandom` is capable of anything :class:`BufferedReader` or :class:`BufferedWriter` can do. @@ -560,10 +630,10 @@ .. class:: TextIOBase - Base class for text streams. This class provides a character and line based - interface to stream I/O. There is no :meth:`readinto` method because - Python's character strings are immutable. It inherits :class:`IOBase`. - There is no public constructor. + Base class for text streams. This class provides an unicode character + and line based interface to stream I/O. There is no :meth:`readinto` + method because Python's :class:`unicode` strings are immutable. + It inherits :class:`IOBase`. There is no public constructor. :class:`TextIOBase` provides or overrides these data attributes and methods in addition to those from :class:`IOBase`: @@ -580,27 +650,48 @@ .. attribute:: newlines A string, a tuple of strings, or ``None``, indicating the newlines - translated so far. + translated so far. Depending on the implementation and the initial + constructor flags, this may not be available. + + .. attribute:: buffer + + The underlying binary buffer (a :class:`BufferedIOBase` instance) that + :class:`TextIOBase` deals with. This is not part of the + :class:`TextIOBase` API and may not exist on some implementations. + + .. method:: detach() + + Separate the underlying binary buffer from the :class:`TextIOBase` and + return it. + + After the underlying buffer has been detached, the :class:`TextIOBase` is + in an unusable state. + + Some :class:`TextIOBase` implementations, like :class:`StringIO`, may not + have the concept of an underlying buffer and calling this method will + raise :exc:`UnsupportedOperation`. + + .. versionadded:: 2.7 .. method:: read(n) Read and return at most *n* characters from the stream as a single - :class:`str`. If *n* is negative or ``None``, reads to EOF. + :class:`unicode`. If *n* is negative or ``None``, reads until EOF. .. method:: readline() - Read until newline or EOF and return a single ``str``. If the stream is - already at EOF, an empty string is returned. + Read until newline or EOF and return a single ``unicode``. If the + stream is already at EOF, an empty string is returned. .. method:: write(s) - Write the string *s* to the stream and return the number of characters - written. + Write the :class:`unicode` string *s* to the stream and return the + number of characters written. -.. class:: TextIOWrapper(buffer[, encoding[, errors[, newline[, line_buffering]]]]) +.. class:: TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_buffering=False) - A buffered text stream over a :class:`BufferedIOBase` raw stream, *buffer*. + A buffered text stream over a :class:`BufferedIOBase` binary stream. It inherits :class:`TextIOBase`. *encoding* gives the name of the encoding that the stream will be decoded or @@ -637,21 +728,39 @@ Whether line buffering is enabled. -.. class:: StringIO([initial_value[, encoding[, errors[, newline]]]]) +.. class:: StringIO(initial_value=u'', newline=None) - An in-memory stream for text. It inherits :class:`TextIOWrapper`. + An in-memory stream for unicode text. It inherits :class:`TextIOWrapper`. - Create a new StringIO stream with an inital value, encoding, error handling, - and newline setting. See :class:`TextIOWrapper`\'s constructor for more - information. + The initial value of the buffer (an empty unicode string by default) can + be set by providing *initial_value*. The *newline* argument works like + that of :class:`TextIOWrapper`. The default is to do no newline + translation. :class:`StringIO` provides this method in addition to those from :class:`TextIOWrapper` and its parents: .. method:: getvalue() - Return a ``str`` containing the entire contents of the buffer. + Return a ``unicode`` containing the entire contents of the buffer at any + time before the :class:`StringIO` object's :meth:`close` method is + called. + + Example usage:: + + import io + + output = io.StringIO() + output.write(u'First line.\n') + output.write(u'Second line.\n') + + # Retrieve file contents -- this will be + # u'First line.\nSecond line.\n' + contents = output.getvalue() + # Close object and discard memory buffer -- + # .getvalue() will now raise an exception. + output.close() .. class:: IncrementalNewlineDecoder From python-checkins at python.org Thu Oct 1 19:09:11 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 01 Oct 2009 17:09:11 -0000 Subject: [Python-checkins] r75172 - python/branches/release26-maint Message-ID: Author: antoine.pitrou Date: Thu Oct 1 19:09:11 2009 New Revision: 75172 Log: Blocked revisions 75171 via svnmerge ........ r75171 | antoine.pitrou | 2009-10-01 19:08:03 +0200 (jeu., 01 oct. 2009) | 4 lines Sync the 2.x `io` docs with py3k, with a small note as to the distinction between bytes streams and text streams. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Thu Oct 1 19:09:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 01 Oct 2009 17:09:15 -0000 Subject: [Python-checkins] r75173 - python/branches/py3k Message-ID: Author: antoine.pitrou Date: Thu Oct 1 19:09:15 2009 New Revision: 75173 Log: Blocked revisions 75171 via svnmerge ........ r75171 | antoine.pitrou | 2009-10-01 19:08:03 +0200 (jeu., 01 oct. 2009) | 4 lines Sync the 2.x `io` docs with py3k, with a small note as to the distinction between bytes streams and text streams. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Thu Oct 1 22:11:11 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 20:11:11 -0000 Subject: [Python-checkins] r75174 - python/branches/py3k/Doc/library/cmath.rst Message-ID: Author: mark.dickinson Date: Thu Oct 1 22:11:11 2009 New Revision: 75174 Log: Remove outdated versionchanged entry Modified: python/branches/py3k/Doc/library/cmath.rst Modified: python/branches/py3k/Doc/library/cmath.rst ============================================================================== --- python/branches/py3k/Doc/library/cmath.rst (original) +++ python/branches/py3k/Doc/library/cmath.rst Thu Oct 1 22:11:11 2009 @@ -94,9 +94,6 @@ specified, returns the natural logarithm of *x*. There is one branch cut, from 0 along the negative real axis to -?, continuous from above. - .. versionchanged:: 2.4 - *base* argument added. - .. function:: log10(x) From python-checkins at python.org Thu Oct 1 22:11:14 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 01 Oct 2009 20:11:14 -0000 Subject: [Python-checkins] r75175 - python/trunk/Lib/unittest/case.py Message-ID: Author: georg.brandl Date: Thu Oct 1 22:11:14 2009 New Revision: 75175 Log: Fix some weird whitespace and two other overlong lines. Modified: python/trunk/Lib/unittest/case.py Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Thu Oct 1 22:11:14 2009 @@ -608,8 +608,9 @@ except (TypeError, IndexError, NotImplementedError): differing += ('Unable to index element %d ' 'of second %s\n' % (len1, seq_type_name)) - standardMsg = differing + '\n' + '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(), - pprint.pformat(seq2).splitlines())) + standardMsg = differing + '\n' + '\n'.join( + difflib.ndiff(pprint.pformat(seq1).splitlines(), + pprint.pformat(seq2).splitlines())) msg = self._formatMessage(msg, standardMsg) self.fail(msg) @@ -722,7 +723,8 @@ if key not in actual: missing.append(key) elif value != actual[key]: - mismatched.append('%s, expected: %s, actual: %s' % (key, value, actual[key])) + mismatched.append('%s, expected: %s, actual: %s' % + (key, value, actual[key])) if not (missing or mismatched): return @@ -775,7 +777,8 @@ 'Second argument is not a string')) if first != second: - standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), second.splitlines(True))) + standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), + second.splitlines(True))) self.fail(self._formatMessage(msg, standardMsg)) def assertLess(self, a, b, msg=None): From python-checkins at python.org Thu Oct 1 22:12:12 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 20:12:12 -0000 Subject: [Python-checkins] r75176 - in python/branches/release31-maint: Doc/library/cmath.rst Message-ID: Author: mark.dickinson Date: Thu Oct 1 22:12:11 2009 New Revision: 75176 Log: Merged revisions 75174 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ........ r75174 | mark.dickinson | 2009-10-01 21:11:11 +0100 (Thu, 01 Oct 2009) | 1 line Remove outdated versionchanged entry ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/cmath.rst Modified: python/branches/release31-maint/Doc/library/cmath.rst ============================================================================== --- python/branches/release31-maint/Doc/library/cmath.rst (original) +++ python/branches/release31-maint/Doc/library/cmath.rst Thu Oct 1 22:12:11 2009 @@ -94,9 +94,6 @@ specified, returns the natural logarithm of *x*. There is one branch cut, from 0 along the negative real axis to -?, continuous from above. - .. versionchanged:: 2.4 - *base* argument added. - .. function:: log10(x) From python-checkins at python.org Thu Oct 1 22:20:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 20:20:09 -0000 Subject: [Python-checkins] r75177 - in python/branches/py3k/Doc/library: http.client.rst select.rst site.rst Message-ID: Author: mark.dickinson Date: Thu Oct 1 22:20:09 2009 New Revision: 75177 Log: More versionadded/versionchanged fixes Modified: python/branches/py3k/Doc/library/http.client.rst python/branches/py3k/Doc/library/select.rst python/branches/py3k/Doc/library/site.rst Modified: python/branches/py3k/Doc/library/http.client.rst ============================================================================== --- python/branches/py3k/Doc/library/http.client.rst (original) +++ python/branches/py3k/Doc/library/http.client.rst Thu Oct 1 22:20:09 2009 @@ -384,7 +384,7 @@ Set the debugging level (the amount of debugging output printed). The default debug level is ``0``, meaning no debugging output is printed. - .. versionadded:: 2.7 + .. versionadded:: 3.1 .. method:: HTTPConnection.set_tunnel(host, port=None) Modified: python/branches/py3k/Doc/library/select.rst ============================================================================== --- python/branches/py3k/Doc/library/select.rst (original) +++ python/branches/py3k/Doc/library/select.rst Thu Oct 1 22:20:09 2009 @@ -100,7 +100,7 @@ of up to :const:`PIPE_BUF` bytes. This value is guaranteed by POSIX to be at least 512. Availability: Unix. - .. versionadded:: 2.7 + .. versionadded:: 3.2 .. _epoll-objects: Modified: python/branches/py3k/Doc/library/site.rst ============================================================================== --- python/branches/py3k/Doc/library/site.rst (original) +++ python/branches/py3k/Doc/library/site.rst Thu Oct 1 22:20:09 2009 @@ -120,7 +120,7 @@ Returns a list containing all global site-packages directories (and possibly site-python). - .. versionadded:: 2.7 + .. versionadded:: 3.2 .. function:: getuserbase() @@ -130,7 +130,7 @@ variable ``USER_BASE`` is not initialized yet, this function will also set it. - .. versionadded:: 2.7 + .. versionadded:: 3.2 .. function:: getusersitepackages() @@ -139,7 +139,7 @@ If the global variable ``USER_SITE`` is not initialized yet, this function will also set it. - .. versionadded:: 2.7 + .. versionadded:: 3.2 .. XXX Update documentation .. XXX document python -m site --user-base --user-site From python-checkins at python.org Thu Oct 1 22:21:00 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 20:21:00 -0000 Subject: [Python-checkins] r75178 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Thu Oct 1 22:20:59 2009 New Revision: 75178 Log: Blocked revisions 75177 via svnmerge ........ r75177 | mark.dickinson | 2009-10-01 21:20:09 +0100 (Thu, 01 Oct 2009) | 1 line More versionadded/versionchanged fixes ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Thu Oct 1 22:22:45 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 01 Oct 2009 20:22:45 -0000 Subject: [Python-checkins] r75179 - python/branches/release31-maint/Doc/library/http.client.rst Message-ID: Author: mark.dickinson Date: Thu Oct 1 22:22:45 2009 New Revision: 75179 Log: And one more versionadded fix in release31-maint. Modified: python/branches/release31-maint/Doc/library/http.client.rst Modified: python/branches/release31-maint/Doc/library/http.client.rst ============================================================================== --- python/branches/release31-maint/Doc/library/http.client.rst (original) +++ python/branches/release31-maint/Doc/library/http.client.rst Thu Oct 1 22:22:45 2009 @@ -384,7 +384,7 @@ Set the debugging level (the amount of debugging output printed). The default debug level is ``0``, meaning no debugging output is printed. - .. versionadded:: 2.7 + .. versionadded:: 3.1 .. method:: HTTPConnection.connect() From python-checkins at python.org Thu Oct 1 22:59:31 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 01 Oct 2009 20:59:31 -0000 Subject: [Python-checkins] r75180 - in python/trunk: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: georg.brandl Date: Thu Oct 1 22:59:31 2009 New Revision: 75180 Log: #7031: Add TestCase.assertIsInstance and negated method. Modified: python/trunk/Doc/library/unittest.rst python/trunk/Lib/test/test_unittest.py python/trunk/Lib/unittest/case.py Modified: python/trunk/Doc/library/unittest.rst ============================================================================== --- python/trunk/Doc/library/unittest.rst (original) +++ python/trunk/Doc/library/unittest.rst Thu Oct 1 22:59:31 2009 @@ -955,6 +955,22 @@ .. versionadded:: 2.7 + .. method:: assertIsInstance(obj, cls[, msg]) + + This signals a test failure if *obj* is not an instance of *cls* (which + can be a class or a tuple of classes, as supported by :func:`isinstance`). + + .. versionadded:: 2.7 + + + .. method:: assertNotIsInstance(obj, cls[, msg]) + + The inverse of the :meth:`assertIsInstance` method. This signals a test + failure if *obj* is an instance of *cls*. + + .. versionadded:: 2.7 + + .. method:: assertFalse(expr[, msg]) failIf(expr[, msg]) Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Thu Oct 1 22:59:31 2009 @@ -2500,6 +2500,18 @@ self.assertIsNot(thing, object()) self.assertRaises(self.failureException, self.assertIsNot, thing, thing) + def testAssertIsInstance(self): + thing = [] + self.assertIsInstance(thing, list) + self.assertRaises(self.failureException, self.assertIsInstance, + thing, dict) + + def testAssertNotIsInstance(self): + thing = [] + self.assertNotIsInstance(thing, dict) + self.assertRaises(self.failureException, self.assertNotIsInstance, + thing, list) + def testAssertIn(self): animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'} Modified: python/trunk/Lib/unittest/case.py ============================================================================== --- python/trunk/Lib/unittest/case.py (original) +++ python/trunk/Lib/unittest/case.py Thu Oct 1 22:59:31 2009 @@ -817,6 +817,19 @@ standardMsg = 'unexpectedly None' self.fail(self._formatMessage(msg, standardMsg)) + def assertIsInstance(self, obj, cls, msg=None): + """Same as self.assertTrue(isinstance(obj, cls)), with a nicer + default message.""" + if not isinstance(obj, cls): + standardMsg = '%r is not an instance of %r' % (obj, cls) + self.fail(self._formatMessage(msg, standardMsg)) + + def assertNotIsInstance(self, obj, cls, msg=None): + """Included for symmetry with assertIsInstance.""" + if isinstance(obj, cls): + standardMsg = '%r is an instance of %r' % (obj, cls) + self.fail(self._formatMessage(msg, standardMsg)) + def assertRaisesRegexp(self, expected_exception, expected_regexp, callable_obj=None, *args, **kwargs): """Asserts that the message in a raised exception matches a regexp. From python-checkins at python.org Thu Oct 1 23:02:39 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 01 Oct 2009 21:02:39 -0000 Subject: [Python-checkins] r75181 - python/trunk/Misc/NEWS Message-ID: Author: georg.brandl Date: Thu Oct 1 23:02:39 2009 New Revision: 75181 Log: Add NEWS entry for r75180. Modified: python/trunk/Misc/NEWS Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 1 23:02:39 2009 @@ -390,6 +390,8 @@ Library ------- +- Issue #7031: Add TestCase.assert(Not)IsInstance() methods. + - Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. From ncoghlan at gmail.com Thu Oct 1 23:28:02 2009 From: ncoghlan at gmail.com (Nick Coghlan) Date: Fri, 02 Oct 2009 07:28:02 +1000 Subject: [Python-checkins] r75181 - python/trunk/Misc/NEWS In-Reply-To: <4ac518f4.0567f10a.511a.ffffbdf3SMTPIN_ADDED@mx.google.com> References: <4ac518f4.0567f10a.511a.ffffbdf3SMTPIN_ADDED@mx.google.com> Message-ID: <4AC51EE2.1020809@gmail.com> georg.brandl wrote: > Author: georg.brandl > Date: Thu Oct 1 23:02:39 2009 > New Revision: 75181 > > Log: > Add NEWS entry for r75180. > > Modified: > python/trunk/Misc/NEWS > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Thu Oct 1 23:02:39 2009 > @@ -390,6 +390,8 @@ > Library > ------- > > +- Issue #7031: Add TestCase.assert(Not)IsInstance() methods. > + Hopefully that was meant to say "assertIs(Not)Instance()". And if the other spelling was checked in to unittest... can we change it to the more natural spelling since we aren't constrained by the syntax limitations of the "not isinstance" spelling in a method name? Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- From python-checkins at python.org Thu Oct 1 23:59:05 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 01 Oct 2009 21:59:05 -0000 Subject: [Python-checkins] r75182 - peps/trunk/pep-3101.txt Message-ID: Author: georg.brandl Date: Thu Oct 1 23:59:04 2009 New Revision: 75182 Log: Fix format. Modified: peps/trunk/pep-3101.txt Modified: peps/trunk/pep-3101.txt ============================================================================== --- peps/trunk/pep-3101.txt (original) +++ peps/trunk/pep-3101.txt Thu Oct 1 23:59:04 2009 @@ -794,10 +794,10 @@ References [1] Python Library Reference - String formating operations - http://docs.python.org/library/stdtypes.html#string-formatting-operations + http://docs.python.org/library/stdtypes.html#string-formatting-operations [2] Python Library References - Template strings - http://docs.python.org/library/string.html#string.Template + http://docs.python.org/library/string.html#string.Template [3] [Python-3000] String formating operations in python 3k http://mail.python.org/pipermail/python-3000/2006-April/000285.html From python-checkins at python.org Fri Oct 2 01:39:50 2009 From: python-checkins at python.org (barry.warsaw) Date: Thu, 01 Oct 2009 23:39:50 -0000 Subject: [Python-checkins] r75183 - in python/branches/release26-maint: Include/patchlevel.h Lib/distutils/__init__.py Lib/idlelib/idlever.py Lib/pydoc_topics.py Misc/NEWS Misc/RPM/python-2.6.spec README Message-ID: Author: barry.warsaw Date: Fri Oct 2 01:39:49 2009 New Revision: 75183 Log: Bump to 2.6.3 Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Lib/distutils/__init__.py python/branches/release26-maint/Lib/idlelib/idlever.py python/branches/release26-maint/Lib/pydoc_topics.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Misc/RPM/python-2.6.spec python/branches/release26-maint/README Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Fri Oct 2 01:39:49 2009 @@ -23,11 +23,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 6 #define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.6.3rc1" +#define PY_VERSION "2.6.3" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Lib/distutils/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/__init__.py (original) +++ python/branches/release26-maint/Lib/distutils/__init__.py Fri Oct 2 01:39:49 2009 @@ -22,5 +22,5 @@ # #--start constants-- -__version__ = "2.6.3rc1" +__version__ = "2.6.3" #--end constants-- Modified: python/branches/release26-maint/Lib/idlelib/idlever.py ============================================================================== --- python/branches/release26-maint/Lib/idlelib/idlever.py (original) +++ python/branches/release26-maint/Lib/idlelib/idlever.py Fri Oct 2 01:39:49 2009 @@ -1 +1 @@ -IDLE_VERSION = "2.6.3rc1" +IDLE_VERSION = "2.6.3" Modified: python/branches/release26-maint/Lib/pydoc_topics.py ============================================================================== --- python/branches/release26-maint/Lib/pydoc_topics.py (original) +++ python/branches/release26-maint/Lib/pydoc_topics.py Fri Oct 2 01:39:49 2009 @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Tue Sep 29 18:33:58 2009 +# Autogenerated by Sphinx on Thu Oct 1 19:36:50 2009 topics = {'assert': u'\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError, expression2\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list is recursively defined as\nfollows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` statement in the\n current code block: the name is bound to the object in the current\n local namespace.\n\n * Otherwise: the name is bound to the object in the current global\n namespace.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield a plain integer. If it is negative, the\n sequence\'s length is added to it. The resulting value must be a\n nonnegative integer less than the sequence\'s length, and the\n sequence is asked to assign the assigned object to its item with\n that index. If the index is out of range, ``IndexError`` is raised\n (assignment to a subscripted sequence cannot add new items to a\n list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to (small) integers. If either\n bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n(In the current implementation, the syntax for targets is taken to be\nthe same as for expressions, and invalid syntax is rejected during the\ncode generation phase, causing less detailed error messages.)\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print x\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n', Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Fri Oct 2 01:39:49 2009 @@ -4,6 +4,11 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.6.3 +========================== + +*Release date: 02-Oct-2009* + What's New in Python 2.6.3rc1 ============================= Modified: python/branches/release26-maint/Misc/RPM/python-2.6.spec ============================================================================== --- python/branches/release26-maint/Misc/RPM/python-2.6.spec (original) +++ python/branches/release26-maint/Misc/RPM/python-2.6.spec Fri Oct 2 01:39:49 2009 @@ -34,7 +34,7 @@ %define name python #--start constants-- -%define version 2.6.3rc1 +%define version 2.6.3 %define libver 2.6 #--end constants-- %define release 1pydotorg Modified: python/branches/release26-maint/README ============================================================================== --- python/branches/release26-maint/README (original) +++ python/branches/release26-maint/README Fri Oct 2 01:39:49 2009 @@ -1,5 +1,5 @@ -This is Python version 2.6.3rc1 -=============================== +This is Python version 2.6.3 +============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Python Software Foundation. From python-checkins at python.org Fri Oct 2 01:40:29 2009 From: python-checkins at python.org (barry.warsaw) Date: Thu, 01 Oct 2009 23:40:29 -0000 Subject: [Python-checkins] r75184 - python/tags/r263 Message-ID: Author: barry.warsaw Date: Fri Oct 2 01:40:29 2009 New Revision: 75184 Log: Tagging for 2.6.3 final. Added: python/tags/r263/ - copied from r75183, /python/branches/release26-maint/ From nnorwitz at gmail.com Fri Oct 2 11:44:26 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 2 Oct 2009 05:44:26 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091002094426.GA16597@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 339, 0] references, sum=339 Less important issues: ---------------------- test_file2k leaked [-80, 0, 0] references, sum=-80 test_smtplib leaked [8, -96, 88] references, sum=0 test_socketserver leaked [-80, 0, 0] references, sum=-80 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [282, -282, 0] references, sum=0 From python-checkins at python.org Fri Oct 2 22:23:50 2009 From: python-checkins at python.org (barry.warsaw) Date: Fri, 02 Oct 2009 20:23:50 -0000 Subject: [Python-checkins] r75187 - in python/branches/release26-maint: Include/patchlevel.h Misc/NEWS Message-ID: Author: barry.warsaw Date: Fri Oct 2 22:23:50 2009 New Revision: 75187 Log: Post 2.6.3 cleanup. Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Fri Oct 2 22:23:50 2009 @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.6.3" +#define PY_VERSION "2.6.3+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Fri Oct 2 22:23:50 2009 @@ -4,6 +4,18 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.6.4a1? +============================= + +*Release date: XX-XXX-20XX* + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 2.6.3 ========================== From python-checkins at python.org Fri Oct 2 22:27:35 2009 From: python-checkins at python.org (barry.warsaw) Date: Fri, 02 Oct 2009 20:27:35 -0000 Subject: [Python-checkins] r75188 - peps/trunk/pep-0361.txt Message-ID: Author: barry.warsaw Date: Fri Oct 2 22:27:34 2009 New Revision: 75188 Log: Update dates of Python 2.6 maintenance releases. Modified: peps/trunk/pep-0361.txt Modified: peps/trunk/pep-0361.txt ============================================================================== --- peps/trunk/pep-0361.txt (original) +++ peps/trunk/pep-0361.txt Fri Oct 2 22:27:34 2009 @@ -63,6 +63,9 @@ Nov 06 2008: Python 3.0rc2 released Nov 21 2008: Python 3.0rc3 released Dec 03 2008: Python 3.0 final released + Dec 04 2008: Python 2.6.1 final release + Apr 14 2009: Python 2.6.2 final release + Oct 02 2009: Python 2.6.3 final release See the public `Google calendar`_ From g.brandl at gmx.net Fri Oct 2 23:17:23 2009 From: g.brandl at gmx.net (Georg Brandl) Date: Fri, 02 Oct 2009 23:17:23 +0200 Subject: [Python-checkins] r75181 - python/trunk/Misc/NEWS In-Reply-To: <4AC51EE2.1020809@gmail.com> References: <4ac518f4.0567f10a.511a.ffffbdf3SMTPIN_ADDED@mx.google.com> <4AC51EE2.1020809@gmail.com> Message-ID: Nick Coghlan schrieb: > georg.brandl wrote: >> Author: georg.brandl >> Date: Thu Oct 1 23:02:39 2009 >> New Revision: 75181 >> >> Log: >> Add NEWS entry for r75180. >> >> Modified: >> python/trunk/Misc/NEWS >> >> Modified: python/trunk/Misc/NEWS >> ============================================================================== >> --- python/trunk/Misc/NEWS (original) >> +++ python/trunk/Misc/NEWS Thu Oct 1 23:02:39 2009 >> @@ -390,6 +390,8 @@ >> Library >> ------- >> >> +- Issue #7031: Add TestCase.assert(Not)IsInstance() methods. >> + > > Hopefully that was meant to say "assertIs(Not)Instance()". And if the > other spelling was checked in to unittest... can we change it to the > more natural spelling since we aren't constrained by the syntax > limitations of the "not isinstance" spelling in a method name? No :) The original patch had assertIsNotInstance(), however several reasons were pointed out to me why this is not a good idea, in descending order of importance: * all other methods with "Not" in the negations are assertNot... (except for assertIsNot, but "is not" is an operator) * it has more similarity to "not isinstance" * twisted's trial has that spelling So I think this spelling makes more sense. I'm not going to insist though, since I think nobody's going to use that negated method anyway :) Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. From python-checkins at python.org Sat Oct 3 00:37:52 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 02 Oct 2009 22:37:52 -0000 Subject: [Python-checkins] r75191 - in python/branches/release26-maint/Lib/distutils/tests: test_config.py test_sdist.py Message-ID: Author: tarek.ziade Date: Sat Oct 3 00:37:51 2009 New Revision: 75191 Log: fixed the distutils tests that were not writing in temp Modified: python/branches/release26-maint/Lib/distutils/tests/test_config.py python/branches/release26-maint/Lib/distutils/tests/test_sdist.py Modified: python/branches/release26-maint/Lib/distutils/tests/test_config.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_config.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_config.py Sat Oct 3 00:37:51 2009 @@ -49,13 +49,14 @@ def setUp(self): """Patches the environment.""" + super(PyPIRCCommandTestCase, self).setUp() if os.environ.has_key('HOME'): self._old_home = os.environ['HOME'] else: self._old_home = None - curdir = os.path.dirname(__file__) - os.environ['HOME'] = curdir - self.rc = os.path.join(curdir, '.pypirc') + tempdir = self.mkdtemp() + os.environ['HOME'] = tempdir + self.rc = os.path.join(tempdir, '.pypirc') self.dist = Distribution() class command(PyPIRCCommand): @@ -74,9 +75,8 @@ del os.environ['HOME'] else: os.environ['HOME'] = self._old_home - if os.path.exists(self.rc): - os.remove(self.rc) set_threshold(self.old_threshold) + super(PyPIRCCommandTestCase, self).tearDown() def test_server_registration(self): # This test makes sure PyPIRCCommand knows how to: Modified: python/branches/release26-maint/Lib/distutils/tests/test_sdist.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_sdist.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_sdist.py Sat Oct 3 00:37:51 2009 @@ -12,9 +12,6 @@ from distutils.errors import DistutilsExecError from distutils.spawn import find_executable -CURDIR = os.path.dirname(__file__) -TEMP_PKG = join(CURDIR, 'temppkg') - SETUP_PY = """ from distutils.core import setup import somecode @@ -31,25 +28,24 @@ def setUp(self): super(sdistTestCase, self).setUp() self.old_path = os.getcwd() + self.temp_pkg = os.path.join(self.mkdtemp(), 'temppkg') def tearDown(self): os.chdir(self.old_path) - if os.path.exists(TEMP_PKG): - shutil.rmtree(TEMP_PKG) super(sdistTestCase, self).tearDown() def _init_tmp_pkg(self): - if os.path.exists(TEMP_PKG): - shutil.rmtree(TEMP_PKG) - os.mkdir(TEMP_PKG) - os.mkdir(join(TEMP_PKG, 'somecode')) - os.mkdir(join(TEMP_PKG, 'dist')) + if os.path.exists(self.temp_pkg): + shutil.rmtree(self.temp_pkg) + os.mkdir(self.temp_pkg) + os.mkdir(join(self.temp_pkg, 'somecode')) + os.mkdir(join(self.temp_pkg, 'dist')) # creating a MANIFEST, a package, and a README - self._write(join(TEMP_PKG, 'MANIFEST.in'), MANIFEST_IN) - self._write(join(TEMP_PKG, 'README'), 'xxx') - self._write(join(TEMP_PKG, 'somecode', '__init__.py'), '#') - self._write(join(TEMP_PKG, 'setup.py'), SETUP_PY) - os.chdir(TEMP_PKG) + self._write(join(self.temp_pkg, 'MANIFEST.in'), MANIFEST_IN) + self._write(join(self.temp_pkg, 'README'), 'xxx') + self._write(join(self.temp_pkg, 'somecode', '__init__.py'), '#') + self._write(join(self.temp_pkg, 'setup.py'), SETUP_PY) + os.chdir(self.temp_pkg) def _write(self, path, content): f = open(path, 'w') @@ -65,15 +61,15 @@ self._init_tmp_pkg() # creating VCS directories with some files in them - os.mkdir(join(TEMP_PKG, 'somecode', '.svn')) - self._write(join(TEMP_PKG, 'somecode', '.svn', 'ok.py'), 'xxx') + os.mkdir(join(self.temp_pkg, 'somecode', '.svn')) + self._write(join(self.temp_pkg, 'somecode', '.svn', 'ok.py'), 'xxx') - os.mkdir(join(TEMP_PKG, 'somecode', '.hg')) - self._write(join(TEMP_PKG, 'somecode', '.hg', + os.mkdir(join(self.temp_pkg, 'somecode', '.hg')) + self._write(join(self.temp_pkg, 'somecode', '.hg', 'ok'), 'xxx') - os.mkdir(join(TEMP_PKG, 'somecode', '.git')) - self._write(join(TEMP_PKG, 'somecode', '.git', + os.mkdir(join(self.temp_pkg, 'somecode', '.git')) + self._write(join(self.temp_pkg, 'somecode', '.git', 'ok'), 'xxx') # now building a sdist @@ -96,7 +92,7 @@ cmd.run() # now let's check what we have - dist_folder = join(TEMP_PKG, 'dist') + dist_folder = join(self.temp_pkg, 'dist') files = os.listdir(dist_folder) self.assertEquals(files, ['fake-1.0.zip']) @@ -137,7 +133,7 @@ cmd.run() # making sure we have two files - dist_folder = join(TEMP_PKG, 'dist') + dist_folder = join(self.temp_pkg, 'dist') result = os.listdir(dist_folder) result.sort() self.assertEquals(result, From python-checkins at python.org Sat Oct 3 01:49:48 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 02 Oct 2009 23:49:48 -0000 Subject: [Python-checkins] r75192 - in python/trunk: Doc/distutils/sourcedist.rst Lib/distutils/archive_util.py Lib/distutils/cmd.py Lib/distutils/command/bdist.py Lib/distutils/command/bdist_dumb.py Lib/distutils/command/sdist.py Lib/distutils/tests/test_archive_util.py Lib/distutils/tests/test_sdist.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 3 01:49:48 2009 New Revision: 75192 Log: #6516 added owner/group support for tarfiles in Distutils Modified: python/trunk/Doc/distutils/sourcedist.rst python/trunk/Lib/distutils/archive_util.py python/trunk/Lib/distutils/cmd.py python/trunk/Lib/distutils/command/bdist.py python/trunk/Lib/distutils/command/bdist_dumb.py python/trunk/Lib/distutils/command/sdist.py python/trunk/Lib/distutils/tests/test_archive_util.py python/trunk/Lib/distutils/tests/test_sdist.py python/trunk/Misc/NEWS Modified: python/trunk/Doc/distutils/sourcedist.rst ============================================================================== --- python/trunk/Doc/distutils/sourcedist.rst (original) +++ python/trunk/Doc/distutils/sourcedist.rst Sat Oct 3 01:49:48 2009 @@ -26,16 +26,16 @@ +===========+=========================+=========+ | ``zip`` | zip file (:file:`.zip`) | (1),(3) | +-----------+-------------------------+---------+ -| ``gztar`` | gzip'ed tar file | (2),(4) | +| ``gztar`` | gzip'ed tar file | \(2) | | | (:file:`.tar.gz`) | | +-----------+-------------------------+---------+ -| ``bztar`` | bzip2'ed tar file | \(4) | +| ``bztar`` | bzip2'ed tar file | | | | (:file:`.tar.bz2`) | | +-----------+-------------------------+---------+ | ``ztar`` | compressed tar file | \(4) | | | (:file:`.tar.Z`) | | +-----------+-------------------------+---------+ -| ``tar`` | tar file (:file:`.tar`) | \(4) | +| ``tar`` | tar file (:file:`.tar`) | | +-----------+-------------------------+---------+ Notes: @@ -51,8 +51,16 @@ of the standard Python library since Python 1.6) (4) - requires external utilities: :program:`tar` and possibly one of :program:`gzip`, - :program:`bzip2`, or :program:`compress` + requires the :program:`compress` program. Notice that this format is now + pending for deprecation and will be removed in the future versions of Python. + +When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or ``tar``), you +can specify under Unix the ``owner`` and ``group`` names that will be set for +each member of the archive. + +For example, if you want all files of the archive to be owned by root:: + + python setup.py sdist --owner=root --group=root .. _manifest: Modified: python/trunk/Lib/distutils/archive_util.py ============================================================================== --- python/trunk/Lib/distutils/archive_util.py (original) +++ python/trunk/Lib/distutils/archive_util.py Sat Oct 3 01:49:48 2009 @@ -14,15 +14,55 @@ from distutils.dir_util import mkpath from distutils import log -def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0): +try: + from pwd import getpwnam +except AttributeError: + getpwnam = None + +try: + from grp import getgrnam +except AttributeError: + getgrnam = None + +def _get_gid(name): + """Returns a gid, given a group name.""" + if getgrnam is None or name is None: + return None + try: + result = getgrnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def _get_uid(name): + """Returns an uid, given a user name.""" + if getpwnam is None or name is None: + return None + try: + result = getpwnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, + owner=None, group=None): """Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "compress", "bzip2", or None. - Both "tar" and the compression utility named by 'compress' must be on - the default program search path, so this is probably Unix-specific. + (compress will be deprecated in Python 3.2) + + 'owner' and 'group' can be used to define an owner and a group for the + archive that is being built. If not provided, the current owner and group + will be used. + The output tar file will be named 'base_dir' + ".tar", possibly plus the appropriate compression extension (".gz", ".bz2" or ".Z"). + Returns the output filename. """ tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''} @@ -44,10 +84,23 @@ import tarfile # late import so Python build itself doesn't break log.info('Creating tar archive') + + uid = _get_uid(owner) + gid = _get_gid(group) + + def _set_uid_gid(tarinfo): + if gid is not None: + tarinfo.gid = gid + tarinfo.gname = group + if uid is not None: + tarinfo.uid = uid + tarinfo.uname = owner + return tarinfo + if not dry_run: tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress]) try: - tar.add(base_dir) + tar.add(base_dir, filter=_set_uid_gid) finally: tar.close() @@ -138,7 +191,7 @@ return None def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, - dry_run=0): + dry_run=0, owner=None, group=None): """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific @@ -151,6 +204,9 @@ ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default to the current directory. Returns the name of the archive file. + + 'owner' and 'group' are used when creating a tar archive. By default, + uses the current owner and group. """ save_cwd = os.getcwd() if root_dir is not None: @@ -172,8 +228,12 @@ func = format_info[0] for arg, val in format_info[1]: kwargs[arg] = val - filename = apply(func, (base_name, base_dir), kwargs) + if format != 'zip': + kwargs['owner'] = owner + kwargs['group'] = group + + filename = apply(func, (base_name, base_dir), kwargs) if root_dir is not None: log.debug("changing back to '%s'", save_cwd) os.chdir(save_cwd) Modified: python/trunk/Lib/distutils/cmd.py ============================================================================== --- python/trunk/Lib/distutils/cmd.py (original) +++ python/trunk/Lib/distutils/cmd.py Sat Oct 3 01:49:48 2009 @@ -385,10 +385,11 @@ from distutils.spawn import spawn spawn(cmd, search_path, dry_run= self.dry_run) - def make_archive (self, base_name, format, - root_dir=None, base_dir=None): - return archive_util.make_archive( - base_name, format, root_dir, base_dir, dry_run=self.dry_run) + def make_archive(self, base_name, format, root_dir=None, base_dir=None, + owner=None, group=None): + return archive_util.make_archive(base_name, format, root_dir, + base_dir, dry_run=self.dry_run, + owner=owner, group=group) def make_file(self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): Modified: python/trunk/Lib/distutils/command/bdist.py ============================================================================== --- python/trunk/Lib/distutils/command/bdist.py (original) +++ python/trunk/Lib/distutils/command/bdist.py Sat Oct 3 01:49:48 2009 @@ -40,6 +40,12 @@ "[default: dist]"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), ] boolean_options = ['skip-build'] @@ -81,6 +87,8 @@ self.formats = None self.dist_dir = None self.skip_build = 0 + self.group = None + self.owner = None def finalize_options(self): # have to finalize 'plat_name' before 'bdist_base' @@ -126,6 +134,11 @@ if cmd_name not in self.no_format_option: sub_cmd.format = self.formats[i] + # passing the owner and group names for tar archiving + if cmd_name == 'bdist_dumb': + sub_cmd.owner = self.owner + sub_cmd.group = self.group + # If we're going to need to run this command again, tell it to # keep its temporary files around so subsequent runs go faster. if cmd_name in commands[i+1:]: Modified: python/trunk/Lib/distutils/command/bdist_dumb.py ============================================================================== --- python/trunk/Lib/distutils/command/bdist_dumb.py (original) +++ python/trunk/Lib/distutils/command/bdist_dumb.py Sat Oct 3 01:49:48 2009 @@ -36,6 +36,12 @@ ('relative', None, "build the archive using relative paths" "(default: false)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), ] boolean_options = ['keep-temp', 'skip-build', 'relative'] @@ -53,6 +59,8 @@ self.dist_dir = None self.skip_build = 0 self.relative = 0 + self.owner = None + self.group = None def finalize_options(self): if self.bdist_dir is None: @@ -71,7 +79,7 @@ ('dist_dir', 'dist_dir'), ('plat_name', 'plat_name')) - def run (self): + def run(self): if not self.skip_build: self.run_command('build') @@ -110,7 +118,8 @@ # Make the archive filename = self.make_archive(pseudoinstall_root, - self.format, root_dir=archive_root) + self.format, root_dir=archive_root, + owner=self.owner, group=self.group) if self.distribution.has_ext_modules(): pyversion = get_python_version() else: Modified: python/trunk/Lib/distutils/command/sdist.py ============================================================================== --- python/trunk/Lib/distutils/command/sdist.py (original) +++ python/trunk/Lib/distutils/command/sdist.py Sat Oct 3 01:49:48 2009 @@ -74,6 +74,10 @@ ('medata-check', None, "Ensure that all required elements of meta-data " "are supplied. Warn if any missing. [default]"), + ('owner=', 'u', + "Owner name used when creating a tar file [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file [default: current group]"), ] boolean_options = ['use-defaults', 'prune', @@ -113,6 +117,8 @@ self.archive_files = None self.metadata_check = 1 + self.owner = None + self.group = None def finalize_options(self): if self.manifest is None: @@ -455,7 +461,8 @@ self.formats.append(self.formats.pop(self.formats.index('tar'))) for fmt in self.formats: - file = self.make_archive(base_name, fmt, base_dir=base_dir) + file = self.make_archive(base_name, fmt, base_dir=base_dir, + owner=self.owner, group=self.group) archive_files.append(file) self.distribution.dist_files.append(('sdist', '', file)) Modified: python/trunk/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_archive_util.py (original) +++ python/trunk/Lib/distutils/tests/test_archive_util.py Sat Oct 3 01:49:48 2009 @@ -14,6 +14,13 @@ from test.test_support import check_warnings try: + import grp + import pwd + UID_GID_SUPPORT = True +except ImportError: + UID_GID_SUPPORT = False + +try: import zipfile ZIP_SUPPORT = True except ImportError: @@ -30,7 +37,7 @@ support.LoggingSilencer, unittest.TestCase): - @unittest.skipUnless(zlib, "Requires zlib") + @unittest.skipUnless(zlib, "requires zlib") def test_make_tarball(self): # creating something to tar tmpdir = self.mkdtemp() @@ -41,7 +48,7 @@ tmpdir2 = self.mkdtemp() unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0], - "Source and target should be on same drive") + "source and target should be on same drive") base_name = os.path.join(tmpdir2, 'archive') @@ -202,6 +209,58 @@ base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') + def test_make_archive_owner_group(self): + # testing make_archive with owner and group, with various combinations + # this works even if there's not gid/uid support + if UID_GID_SUPPORT: + group = grp.getgrgid(0)[0] + owner = pwd.getpwuid(0)[0] + else: + group = owner = 'root' + + base_dir, root_dir, base_name = self._create_files() + base_name = os.path.join(self.mkdtemp() , 'archive') + res = make_archive(base_name, 'zip', root_dir, base_dir, owner=owner, + group=group) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'zip', root_dir, base_dir) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'tar', root_dir, base_dir, + owner=owner, group=group) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'tar', root_dir, base_dir, + owner='kjhkjhkjg', group='oihohoh') + self.assertTrue(os.path.exists(res)) + + @unittest.skipUnless(zlib, "Requires zlib") + @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") + def test_tarfile_root_owner(self): + tmpdir, tmpdir2, base_name = self._create_files() + old_dir = os.getcwd() + os.chdir(tmpdir) + group = grp.getgrgid(0)[0] + owner = pwd.getpwuid(0)[0] + try: + archive_name = make_tarball(base_name, 'dist', compress=None, + owner=owner, group=group) + finally: + os.chdir(old_dir) + + # check if the compressed tarball was created + self.assertTrue(os.path.exists(archive_name)) + + # now checks the rights + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, 0) + self.assertEquals(member.gid, 0) + finally: + archive.close() + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: python/trunk/Lib/distutils/tests/test_sdist.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_sdist.py (original) +++ python/trunk/Lib/distutils/tests/test_sdist.py Sat Oct 3 01:49:48 2009 @@ -3,6 +3,7 @@ import unittest import shutil import zipfile +import tarfile # zlib is not used here, but if it's not available # the tests that use zipfile may fail @@ -11,6 +12,13 @@ except ImportError: zlib = None +try: + import grp + import pwd + UID_GID_SUPPORT = True +except ImportError: + UID_GID_SUPPORT = False + from os.path import join import sys import tempfile @@ -288,6 +296,52 @@ cmd.formats = 'supazipa' self.assertRaises(DistutilsOptionError, cmd.finalize_options) + @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") + def test_make_distribution_owner_group(self): + + # check if tar and gzip are installed + if (find_executable('tar') is None or + find_executable('gzip') is None): + return + + # now building a sdist + dist, cmd = self.get_cmd() + + # creating a gztar and specifying the owner+group + cmd.formats = ['gztar'] + cmd.owner = pwd.getpwuid(0)[0] + cmd.group = grp.getgrgid(0)[0] + cmd.ensure_finalized() + cmd.run() + + # making sure we have the good rights + archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, 0) + self.assertEquals(member.gid, 0) + finally: + archive.close() + + # building a sdist again + dist, cmd = self.get_cmd() + + # creating a gztar + cmd.formats = ['gztar'] + cmd.ensure_finalized() + cmd.run() + + # making sure we have the good rights + archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, os.getuid()) + self.assertEquals(member.gid, os.getgid()) + finally: + archive.close() def test_suite(): return unittest.makeSuite(SDistTestCase) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 3 01:49:48 2009 @@ -390,6 +390,9 @@ Library ------- +- Issue #6516: Added owner/group support when creating tar archives in + Distutils. + - Issue #7031: Add TestCase.assert(Not)IsInstance() methods. - Issue #6790: Make it possible again to pass an `array.array` to From python-checkins at python.org Sat Oct 3 01:50:40 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 02 Oct 2009 23:50:40 -0000 Subject: [Python-checkins] r75193 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Sat Oct 3 01:50:40 2009 New Revision: 75193 Log: Blocked revisions 75192 via svnmerge ........ r75192 | tarek.ziade | 2009-10-03 01:49:48 +0200 (Sat, 03 Oct 2009) | 1 line #6516 added owner/group support for tarfiles in Distutils ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 3 01:56:02 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 02 Oct 2009 23:56:02 -0000 Subject: [Python-checkins] r75194 - in python/branches/py3k: Doc/distutils/sourcedist.rst Lib/distutils/archive_util.py Lib/distutils/cmd.py Lib/distutils/command/bdist.py Lib/distutils/command/bdist_dumb.py Lib/distutils/command/sdist.py Lib/distutils/tests/test_archive_util.py Lib/distutils/tests/test_sdist.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 3 01:56:02 2009 New Revision: 75194 Log: Merged revisions 75192 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75192 | tarek.ziade | 2009-10-03 01:49:48 +0200 (Sat, 03 Oct 2009) | 1 line #6516 added owner/group support for tarfiles in Distutils ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/distutils/sourcedist.rst python/branches/py3k/Lib/distutils/archive_util.py python/branches/py3k/Lib/distutils/cmd.py python/branches/py3k/Lib/distutils/command/bdist.py python/branches/py3k/Lib/distutils/command/bdist_dumb.py python/branches/py3k/Lib/distutils/command/sdist.py python/branches/py3k/Lib/distutils/tests/test_archive_util.py python/branches/py3k/Lib/distutils/tests/test_sdist.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Doc/distutils/sourcedist.rst ============================================================================== --- python/branches/py3k/Doc/distutils/sourcedist.rst (original) +++ python/branches/py3k/Doc/distutils/sourcedist.rst Sat Oct 3 01:56:02 2009 @@ -26,16 +26,16 @@ +===========+=========================+=========+ | ``zip`` | zip file (:file:`.zip`) | (1),(3) | +-----------+-------------------------+---------+ -| ``gztar`` | gzip'ed tar file | (2),(4) | +| ``gztar`` | gzip'ed tar file | \(2) | | | (:file:`.tar.gz`) | | +-----------+-------------------------+---------+ -| ``bztar`` | bzip2'ed tar file | \(4) | +| ``bztar`` | bzip2'ed tar file | | | | (:file:`.tar.bz2`) | | +-----------+-------------------------+---------+ | ``ztar`` | compressed tar file | \(4) | | | (:file:`.tar.Z`) | | +-----------+-------------------------+---------+ -| ``tar`` | tar file (:file:`.tar`) | \(4) | +| ``tar`` | tar file (:file:`.tar`) | | +-----------+-------------------------+---------+ Notes: @@ -51,8 +51,16 @@ of the standard Python library since Python 1.6) (4) - requires external utilities: :program:`tar` and possibly one of :program:`gzip`, - :program:`bzip2`, or :program:`compress` + requires the :program:`compress` program. Notice that this format is now + pending for deprecation and will be removed in the future versions of Python. + +When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or ``tar``), you +can specify under Unix the ``owner`` and ``group`` names that will be set for +each member of the archive. + +For example, if you want all files of the archive to be owned by root:: + + python setup.py sdist --owner=root --group=root .. _manifest: Modified: python/branches/py3k/Lib/distutils/archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/archive_util.py (original) +++ python/branches/py3k/Lib/distutils/archive_util.py Sat Oct 3 01:56:02 2009 @@ -14,15 +14,55 @@ from distutils.dir_util import mkpath from distutils import log -def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0): +try: + from pwd import getpwnam +except AttributeError: + getpwnam = None + +try: + from grp import getgrnam +except AttributeError: + getgrnam = None + +def _get_gid(name): + """Returns a gid, given a group name.""" + if getgrnam is None or name is None: + return None + try: + result = getgrnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def _get_uid(name): + """Returns an uid, given a user name.""" + if getpwnam is None or name is None: + return None + try: + result = getpwnam(name) + except KeyError: + result = None + if result is not None: + return result[2] + return None + +def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, + owner=None, group=None): """Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "compress", "bzip2", or None. - Both "tar" and the compression utility named by 'compress' must be on - the default program search path, so this is probably Unix-specific. + (compress will be deprecated in Python 3.2) + + 'owner' and 'group' can be used to define an owner and a group for the + archive that is being built. If not provided, the current owner and group + will be used. + The output tar file will be named 'base_dir' + ".tar", possibly plus the appropriate compression extension (".gz", ".bz2" or ".Z"). + Returns the output filename. """ tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''} @@ -44,10 +84,23 @@ import tarfile # late import so Python build itself doesn't break log.info('Creating tar archive') + + uid = _get_uid(owner) + gid = _get_gid(group) + + def _set_uid_gid(tarinfo): + if gid is not None: + tarinfo.gid = gid + tarinfo.gname = group + if uid is not None: + tarinfo.uid = uid + tarinfo.uname = owner + return tarinfo + if not dry_run: tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress]) try: - tar.add(base_dir) + tar.add(base_dir, filter=_set_uid_gid) finally: tar.close() @@ -137,7 +190,7 @@ return None def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, - dry_run=0): + dry_run=0, owner=None, group=None): """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific @@ -150,6 +203,9 @@ ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default to the current directory. Returns the name of the archive file. + + 'owner' and 'group' are used when creating a tar archive. By default, + uses the current owner and group. """ save_cwd = os.getcwd() if root_dir is not None: @@ -171,6 +227,11 @@ func = format_info[0] for arg, val in format_info[1]: kwargs[arg] = val + + if format != 'zip': + kwargs['owner'] = owner + kwargs['group'] = group + filename = func(base_name, base_dir, **kwargs) if root_dir is not None: Modified: python/branches/py3k/Lib/distutils/cmd.py ============================================================================== --- python/branches/py3k/Lib/distutils/cmd.py (original) +++ python/branches/py3k/Lib/distutils/cmd.py Sat Oct 3 01:56:02 2009 @@ -367,9 +367,11 @@ from distutils.spawn import spawn spawn(cmd, search_path, dry_run=self.dry_run) - def make_archive(self, base_name, format, root_dir=None, base_dir=None): - return archive_util.make_archive(base_name, format, root_dir, base_dir, - dry_run=self.dry_run) + def make_archive(self, base_name, format, root_dir=None, base_dir=None, + owner=None, group=None): + return archive_util.make_archive(base_name, format, root_dir, + base_dir, dry_run=self.dry_run, + owner=owner, group=group) def make_file(self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): Modified: python/branches/py3k/Lib/distutils/command/bdist.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist.py Sat Oct 3 01:56:02 2009 @@ -39,6 +39,12 @@ "[default: dist]"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), ] boolean_options = ['skip-build'] @@ -80,6 +86,8 @@ self.formats = None self.dist_dir = None self.skip_build = 0 + self.group = None + self.owner = None def finalize_options(self): # have to finalize 'plat_name' before 'bdist_base' @@ -125,6 +133,11 @@ if cmd_name not in self.no_format_option: sub_cmd.format = self.formats[i] + # passing the owner and group names for tar archiving + if cmd_name == 'bdist_dumb': + sub_cmd.owner = self.owner + sub_cmd.group = self.group + # If we're going to need to run this command again, tell it to # keep its temporary files around so subsequent runs go faster. if cmd_name in commands[i+1:]: Modified: python/branches/py3k/Lib/distutils/command/bdist_dumb.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist_dumb.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist_dumb.py Sat Oct 3 01:56:02 2009 @@ -36,6 +36,12 @@ ('relative', None, "build the archive using relative paths" "(default: false)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), ] boolean_options = ['keep-temp', 'skip-build', 'relative'] @@ -52,6 +58,8 @@ self.dist_dir = None self.skip_build = 0 self.relative = 0 + self.owner = None + self.group = None def finalize_options(self): if self.bdist_dir is None: @@ -109,7 +117,8 @@ # Make the archive filename = self.make_archive(pseudoinstall_root, - self.format, root_dir=archive_root) + self.format, root_dir=archive_root, + owner=self.owner, group=self.group) if self.distribution.has_ext_modules(): pyversion = get_python_version() else: Modified: python/branches/py3k/Lib/distutils/command/sdist.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/sdist.py (original) +++ python/branches/py3k/Lib/distutils/command/sdist.py Sat Oct 3 01:56:02 2009 @@ -75,6 +75,10 @@ ('medata-check', None, "Ensure that all required elements of meta-data " "are supplied. Warn if any missing. [default]"), + ('owner=', 'u', + "Owner name used when creating a tar file [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file [default: current group]"), ] boolean_options = ['use-defaults', 'prune', @@ -114,6 +118,8 @@ self.archive_files = None self.metadata_check = 1 + self.owner = None + self.group = None def finalize_options(self): if self.manifest is None: @@ -449,7 +455,8 @@ self.formats.append(self.formats.pop(self.formats.index('tar'))) for fmt in self.formats: - file = self.make_archive(base_name, fmt, base_dir=base_dir) + file = self.make_archive(base_name, fmt, base_dir=base_dir, + owner=self.owner, group=self.group) archive_files.append(file) self.distribution.dist_files.append(('sdist', '', file)) Modified: python/branches/py3k/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_archive_util.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_archive_util.py Sat Oct 3 01:56:02 2009 @@ -14,6 +14,13 @@ from test.support import check_warnings try: + import grp + import pwd + UID_GID_SUPPORT = True +except ImportError: + UID_GID_SUPPORT = False + +try: import zipfile ZIP_SUPPORT = True except ImportError: @@ -30,7 +37,7 @@ support.LoggingSilencer, unittest.TestCase): - @unittest.skipUnless(zlib, "Requires zlib") + @unittest.skipUnless(zlib, "requires zlib") def test_make_tarball(self): # creating something to tar tmpdir = self.mkdtemp() @@ -41,7 +48,7 @@ tmpdir2 = self.mkdtemp() unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0], - "Source and target should be on same drive") + "source and target should be on same drive") base_name = os.path.join(tmpdir2, 'archive') @@ -202,6 +209,58 @@ base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') + def test_make_archive_owner_group(self): + # testing make_archive with owner and group, with various combinations + # this works even if there's not gid/uid support + if UID_GID_SUPPORT: + group = grp.getgrgid(0)[0] + owner = pwd.getpwuid(0)[0] + else: + group = owner = 'root' + + base_dir, root_dir, base_name = self._create_files() + base_name = os.path.join(self.mkdtemp() , 'archive') + res = make_archive(base_name, 'zip', root_dir, base_dir, owner=owner, + group=group) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'zip', root_dir, base_dir) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'tar', root_dir, base_dir, + owner=owner, group=group) + self.assertTrue(os.path.exists(res)) + + res = make_archive(base_name, 'tar', root_dir, base_dir, + owner='kjhkjhkjg', group='oihohoh') + self.assertTrue(os.path.exists(res)) + + @unittest.skipUnless(zlib, "Requires zlib") + @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") + def test_tarfile_root_owner(self): + tmpdir, tmpdir2, base_name = self._create_files() + old_dir = os.getcwd() + os.chdir(tmpdir) + group = grp.getgrgid(0)[0] + owner = pwd.getpwuid(0)[0] + try: + archive_name = make_tarball(base_name, 'dist', compress=None, + owner=owner, group=group) + finally: + os.chdir(old_dir) + + # check if the compressed tarball was created + self.assertTrue(os.path.exists(archive_name)) + + # now checks the rights + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, 0) + self.assertEquals(member.gid, 0) + finally: + archive.close() + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: python/branches/py3k/Lib/distutils/tests/test_sdist.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_sdist.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_sdist.py Sat Oct 3 01:56:02 2009 @@ -3,6 +3,7 @@ import unittest import shutil import zipfile +import tarfile # zlib is not used here, but if it's not available # the tests that use zipfile may fail @@ -11,6 +12,13 @@ except ImportError: zlib = None +try: + import grp + import pwd + UID_GID_SUPPORT = True +except ImportError: + UID_GID_SUPPORT = False + from os.path import join import sys import tempfile @@ -288,6 +296,52 @@ cmd.formats = 'supazipa' self.assertRaises(DistutilsOptionError, cmd.finalize_options) + @unittest.skipUnless(zlib, "requires zlib") + @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") + def test_make_distribution_owner_group(self): + + # check if tar and gzip are installed + if (find_executable('tar') is None or + find_executable('gzip') is None): + return + + # now building a sdist + dist, cmd = self.get_cmd() + + # creating a gztar and specifying the owner+group + cmd.formats = ['gztar'] + cmd.owner = pwd.getpwuid(0)[0] + cmd.group = grp.getgrgid(0)[0] + cmd.ensure_finalized() + cmd.run() + + # making sure we have the good rights + archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, 0) + self.assertEquals(member.gid, 0) + finally: + archive.close() + + # building a sdist again + dist, cmd = self.get_cmd() + + # creating a gztar + cmd.formats = ['gztar'] + cmd.ensure_finalized() + cmd.run() + + # making sure we have the good rights + archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz') + archive = tarfile.open(archive_name) + try: + for member in archive.getmembers(): + self.assertEquals(member.uid, os.getuid()) + self.assertEquals(member.gid, os.getgid()) + finally: + archive.close() def test_suite(): return unittest.makeSuite(SDistTestCase) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 3 01:56:02 2009 @@ -1080,6 +1080,9 @@ Library ------- +- Issue #6516: Added owner/group support when creating tar archives in + Distutils. + - Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils. - Issue #6163: Fixed HP-UX runtime library dir options in From python-checkins at python.org Sat Oct 3 01:57:59 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 02 Oct 2009 23:57:59 -0000 Subject: [Python-checkins] r75195 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Sat Oct 3 01:57:59 2009 New Revision: 75195 Log: Blocked revisions 75194 via svnmerge ................ r75194 | tarek.ziade | 2009-10-03 01:56:02 +0200 (Sat, 03 Oct 2009) | 9 lines Merged revisions 75192 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75192 | tarek.ziade | 2009-10-03 01:49:48 +0200 (Sat, 03 Oct 2009) | 1 line #6516 added owner/group support for tarfiles in Distutils ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sat Oct 3 02:07:35 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 00:07:35 -0000 Subject: [Python-checkins] r75196 - in python/trunk/Lib/distutils: archive_util.py dir_util.py filelist.py Message-ID: Author: tarek.ziade Date: Sat Oct 3 02:07:35 2009 New Revision: 75196 Log: removing the last remaning apply() calls Modified: python/trunk/Lib/distutils/archive_util.py python/trunk/Lib/distutils/dir_util.py python/trunk/Lib/distutils/filelist.py Modified: python/trunk/Lib/distutils/archive_util.py ============================================================================== --- python/trunk/Lib/distutils/archive_util.py (original) +++ python/trunk/Lib/distutils/archive_util.py Sat Oct 3 02:07:35 2009 @@ -233,7 +233,7 @@ kwargs['owner'] = owner kwargs['group'] = group - filename = apply(func, (base_name, base_dir), kwargs) + filename = func(base_name, base_dir, **kwargs) if root_dir is not None: log.debug("changing back to '%s'", save_cwd) os.chdir(save_cwd) Modified: python/trunk/Lib/distutils/dir_util.py ============================================================================== --- python/trunk/Lib/distutils/dir_util.py (original) +++ python/trunk/Lib/distutils/dir_util.py Sat Oct 3 02:07:35 2009 @@ -190,7 +190,7 @@ _build_cmdtuple(directory, cmdtuples) for cmd in cmdtuples: try: - apply(cmd[0], (cmd[1],)) + cmd[0](cmd[1]) # remove dir from cache if it's already there abspath = os.path.abspath(cmd[1]) if abspath in _path_created: Modified: python/trunk/Lib/distutils/filelist.py ============================================================================== --- python/trunk/Lib/distutils/filelist.py (original) +++ python/trunk/Lib/distutils/filelist.py Sat Oct 3 02:07:35 2009 @@ -61,7 +61,7 @@ sortable_files.sort() self.files = [] for sort_tuple in sortable_files: - self.files.append(apply(os.path.join, sort_tuple)) + self.files.append(os.path.join(*sort_tuple)) # -- Other miscellaneous utility methods --------------------------- From python-checkins at python.org Sat Oct 3 02:09:36 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 00:09:36 -0000 Subject: [Python-checkins] r75197 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Sat Oct 3 02:09:36 2009 New Revision: 75197 Log: Blocked revisions 75196 via svnmerge ........ r75196 | tarek.ziade | 2009-10-03 02:07:35 +0200 (Sat, 03 Oct 2009) | 1 line removing the last remaning apply() calls ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 3 02:10:24 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 00:10:24 -0000 Subject: [Python-checkins] r75198 - python/branches/py3k Message-ID: Author: tarek.ziade Date: Sat Oct 3 02:10:24 2009 New Revision: 75198 Log: Blocked revisions 75196 via svnmerge ........ r75196 | tarek.ziade | 2009-10-03 02:07:35 +0200 (Sat, 03 Oct 2009) | 1 line removing the last remaning apply() calls ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 3 03:21:39 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 01:21:39 -0000 Subject: [Python-checkins] r75199 - in python/branches/release26-maint: Lib/distutils/tests/test_sysconfig.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 3 03:21:38 2009 New Revision: 75199 Log: Issue #7039: Fixed test_distutils when running tests on an installation with no build Modified: python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_sysconfig.py Sat Oct 3 03:21:38 2009 @@ -30,30 +30,13 @@ sysconfig.get_python_lib(prefix=TESTFN)) def test_get_python_inc(self): - # The check for srcdir is copied from Python's setup.py, - # and is necessary to make this test pass when building - # Python in a directory other than the source directory. - (srcdir,) = sysconfig.get_config_vars('srcdir') - if not srcdir: - inc_dir = sysconfig.get_python_inc() - else: - # This test is not really a proper test: when building - # Python from source, even in the same directory, - # we won't be testing the same thing as when running - # distutils' tests on an installed Python. Nevertheless, - # let's try to do our best: if we are running Python's - # unittests from a build directory that is not the source - # directory, the normal inc_dir will exist, it will just not - # contain anything of interest. - inc_dir = sysconfig.get_python_inc() - self.assert_(os.path.isdir(inc_dir)) - # Now test the source location, to make sure Python.h does - # exist. - inc_dir = os.path.join(os.getcwd(), srcdir, 'Include') - inc_dir = os.path.normpath(inc_dir) - self.assert_(os.path.isdir(inc_dir), inc_dir) + inc_dir = sysconfig.get_python_inc() + # This is not much of a test. We make sure Python.h exists + # in the directory returned by get_python_inc() but we don't know + # it is the correct file. + self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") - self.assert_(os.path.isfile(python_h), python_h) + self.assertTrue(os.path.isfile(python_h), python_h) def test_get_config_vars(self): cvars = sysconfig.get_config_vars() Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sat Oct 3 03:21:38 2009 @@ -15,6 +15,8 @@ Library ------- +- Issue #7039: Fixed distutils.tests.test_sysconfig when running on + installation with no build. What's New in Python 2.6.3 ========================== From python-checkins at python.org Sat Oct 3 10:02:53 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 08:02:53 -0000 Subject: [Python-checkins] r75202 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sat Oct 3 10:02:53 2009 New Revision: 75202 Log: Blocked revisions 75141 via svnmerge ........ r75141 | mark.dickinson | 2009-09-29 20:01:06 +0100 (Tue, 29 Sep 2009) | 3 lines Issue #7019: Unmarshalling of bad long data could produce unnormalized PyLongs. Raise ValueError instead. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 3 10:15:49 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 08:15:49 -0000 Subject: [Python-checkins] r75203 - in python/branches/release26-maint: Lib/test/test_marshal.py Misc/NEWS Python/marshal.c Message-ID: Author: mark.dickinson Date: Sat Oct 3 10:15:49 2009 New Revision: 75203 Log: Issue #7019: An attempt to unmarshal bad long data could produce unnormalized PyLong objects; make it raise ValueError instead. Modified: python/branches/release26-maint/Lib/test/test_marshal.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Python/marshal.c Modified: python/branches/release26-maint/Lib/test/test_marshal.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_marshal.py (original) +++ python/branches/release26-maint/Lib/test/test_marshal.py Sat Oct 3 10:15:49 2009 @@ -262,6 +262,11 @@ testString = 'abc' * size marshal.dumps(testString) + def test_invalid_longs(self): + # Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs + invalid_string = 'l\x02\x00\x00\x00\x00\x00\x00\x00' + self.assertRaises(ValueError, marshal.loads, invalid_string) + def test_main(): test_support.run_unittest(IntTestCase, Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sat Oct 3 10:15:49 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7019: Raise ValueError when unmarshalling bad long data, instead + of producing internally inconsistent Python longs. + Library ------- Modified: python/branches/release26-maint/Python/marshal.c ============================================================================== --- python/branches/release26-maint/Python/marshal.c (original) +++ python/branches/release26-maint/Python/marshal.c Sat Oct 3 10:15:49 2009 @@ -589,7 +589,8 @@ ob->ob_size = n; for (i = 0; i < size; i++) { int digit = r_short(p); - if (digit < 0) { + if (digit < 0 || + (digit == 0 && i == size-1)) { Py_DECREF(ob); PyErr_SetString(PyExc_ValueError, "bad marshal data"); From python-checkins at python.org Sat Oct 3 10:45:59 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 08:45:59 -0000 Subject: [Python-checkins] r75204 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sat Oct 3 10:45:59 2009 New Revision: 75204 Log: Blocked revisions 75157 via svnmerge ........ r75157 | mark.dickinson | 2009-09-30 17:58:01 +0100 (Wed, 30 Sep 2009) | 1 line Fix buggy accuracy test ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 3 12:14:35 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 10:14:35 -0000 Subject: [Python-checkins] r75205 - python/trunk/Doc/library/functions.rst Message-ID: Author: mark.dickinson Date: Sat Oct 3 12:14:34 2009 New Revision: 75205 Log: Issue #7028: Add note to hex() builtin docs pointing to float.hex(). Modified: python/trunk/Doc/library/functions.rst Modified: python/trunk/Doc/library/functions.rst ============================================================================== --- python/trunk/Doc/library/functions.rst (original) +++ python/trunk/Doc/library/functions.rst Sat Oct 3 12:14:34 2009 @@ -510,6 +510,11 @@ Convert an integer number (of any size) to a hexadecimal string. The result is a valid Python expression. + .. note:: + + To obtain a hexadecimal string representation for a float, use the + :meth:`float.hex` method. + .. versionchanged:: 2.4 Formerly only returned an unsigned literal. From python-checkins at python.org Sat Oct 3 12:15:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 10:15:54 -0000 Subject: [Python-checkins] r75206 - in python/branches/release26-maint: Doc/library/functions.rst Message-ID: Author: mark.dickinson Date: Sat Oct 3 12:15:54 2009 New Revision: 75206 Log: Merged revisions 75205 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75205 | mark.dickinson | 2009-10-03 11:14:34 +0100 (Sat, 03 Oct 2009) | 2 lines Issue #7028: Add note to hex() builtin docs pointing to float.hex(). ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/functions.rst Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Sat Oct 3 12:15:54 2009 @@ -510,6 +510,11 @@ Convert an integer number (of any size) to a hexadecimal string. The result is a valid Python expression. + .. note:: + + To obtain a hexadecimal string representation for a float, use the + :meth:`float.hex` method. + .. versionchanged:: 2.4 Formerly only returned an unsigned literal. From python-checkins at python.org Sat Oct 3 12:18:40 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 10:18:40 -0000 Subject: [Python-checkins] r75207 - in python/branches/py3k: Doc/library/functions.rst Message-ID: Author: mark.dickinson Date: Sat Oct 3 12:18:40 2009 New Revision: 75207 Log: Merged revisions 75205 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75205 | mark.dickinson | 2009-10-03 11:14:34 +0100 (Sat, 03 Oct 2009) | 2 lines Issue #7028: Add note to hex() builtin docs pointing to float.hex(). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/functions.rst Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Sat Oct 3 12:18:40 2009 @@ -489,6 +489,11 @@ expression. If *x* is not a Python :class:`int` object, it has to define an :meth:`__index__` method that returns an integer. + .. note:: + + To obtain a hexadecimal string representation for a float, use the + :meth:`float.hex` method. + .. function:: id(object) From python-checkins at python.org Sat Oct 3 12:19:22 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 10:19:22 -0000 Subject: [Python-checkins] r75208 - in python/branches/release31-maint: Doc/library/functions.rst Message-ID: Author: mark.dickinson Date: Sat Oct 3 12:19:21 2009 New Revision: 75208 Log: Merged revisions 75207 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75207 | mark.dickinson | 2009-10-03 11:18:40 +0100 (Sat, 03 Oct 2009) | 9 lines Merged revisions 75205 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75205 | mark.dickinson | 2009-10-03 11:14:34 +0100 (Sat, 03 Oct 2009) | 2 lines Issue #7028: Add note to hex() builtin docs pointing to float.hex(). ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/functions.rst Modified: python/branches/release31-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release31-maint/Doc/library/functions.rst (original) +++ python/branches/release31-maint/Doc/library/functions.rst Sat Oct 3 12:19:21 2009 @@ -489,6 +489,11 @@ expression. If *x* is not a Python :class:`int` object, it has to define an :meth:`__index__` method that returns an integer. + .. note:: + + To obtain a hexadecimal string representation for a float, use the + :meth:`float.hex` method. + .. function:: id(object) From python-checkins at python.org Sat Oct 3 16:52:34 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 14:52:34 -0000 Subject: [Python-checkins] r75209 - python/trunk/Lib/distutils/archive_util.py Message-ID: Author: tarek.ziade Date: Sat Oct 3 16:52:33 2009 New Revision: 75209 Log: now uses the right exception type Modified: python/trunk/Lib/distutils/archive_util.py Modified: python/trunk/Lib/distutils/archive_util.py ============================================================================== --- python/trunk/Lib/distutils/archive_util.py (original) +++ python/trunk/Lib/distutils/archive_util.py Sat Oct 3 16:52:33 2009 @@ -16,12 +16,12 @@ try: from pwd import getpwnam -except AttributeError: +except ImportError: getpwnam = None try: from grp import getgrnam -except AttributeError: +except ImportError: getgrnam = None def _get_gid(name): From python-checkins at python.org Sat Oct 3 16:54:15 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 14:54:15 -0000 Subject: [Python-checkins] r75210 - in python/branches/py3k: Lib/distutils/archive_util.py Message-ID: Author: tarek.ziade Date: Sat Oct 3 16:54:15 2009 New Revision: 75210 Log: Merged revisions 75209 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75209 | tarek.ziade | 2009-10-03 16:52:33 +0200 (Sat, 03 Oct 2009) | 1 line now uses the right exception type ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/archive_util.py Modified: python/branches/py3k/Lib/distutils/archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/archive_util.py (original) +++ python/branches/py3k/Lib/distutils/archive_util.py Sat Oct 3 16:54:15 2009 @@ -16,12 +16,12 @@ try: from pwd import getpwnam -except AttributeError: +except ImportError: getpwnam = None try: from grp import getgrnam -except AttributeError: +except ImportError: getgrnam = None def _get_gid(name): From python-checkins at python.org Sat Oct 3 17:00:15 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 03 Oct 2009 15:00:15 -0000 Subject: [Python-checkins] r75211 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Sat Oct 3 17:00:15 2009 New Revision: 75211 Log: Blocked revisions 75209 via svnmerge ........ r75209 | tarek.ziade | 2009-10-03 16:52:33 +0200 (Sat, 03 Oct 2009) | 1 line now uses the right exception type ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 3 17:06:21 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 15:06:21 -0000 Subject: [Python-checkins] r75212 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: Author: benjamin.peterson Date: Sat Oct 3 17:06:21 2009 New Revision: 75212 Log: revert r75090 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sat Oct 3 17:06:21 2009 @@ -804,8 +804,8 @@ ``f(*args)``. * Removed :func:`callable`. Instead of ``callable(f)`` you can use - ``hasattr(type(f), '__call__')``. The :func:`operator.isCallable` function is - also gone. + ``hasattr(f, '__call__')``. The :func:`operator.isCallable` function + is also gone. * Removed :func:`coerce`. This function no longer serves a purpose now that classic classes are gone. From python-checkins at python.org Sat Oct 3 17:09:46 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 15:09:46 -0000 Subject: [Python-checkins] r75213 - in sandbox/trunk/2to3/lib2to3: fixes/fix_callable.py tests/test_fixers.py Message-ID: Author: benjamin.peterson Date: Sat Oct 3 17:09:46 2009 New Revision: 75213 Log: revert 75212; it's not correct People can use isinstance(x, collections.Callable) if they expect objects with __call__ in their instance dictionaries. Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_callable.py sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_callable.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_callable.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_callable.py Sat Oct 3 17:09:46 2009 @@ -3,7 +3,7 @@ """Fixer for callable(). -This converts callable(obj) into hasattr(type(obj), '__call__').""" +This converts callable(obj) into hasattr(obj, '__call__').""" # Local imports from .. import pytree @@ -27,8 +27,5 @@ def transform(self, node, results): func = results["func"] - new_func = func.clone() - new_func.prefix = u"" - type_call = Call(Name(u"type"), [new_func], prefix=func.prefix) - args = [type_call, String(u', '), String(u"'__call__'")] + args = [func.clone(), String(u', '), String(u"'__call__'")] return Call(Name(u"hasattr"), args, prefix=node.prefix) Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py (original) +++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Sat Oct 3 17:09:46 2009 @@ -2710,16 +2710,16 @@ def test_prefix_preservation(self): b = """callable( x)""" - a = """hasattr( type(x), '__call__')""" + a = """hasattr( x, '__call__')""" self.check(b, a) b = """if callable(x): pass""" - a = """if hasattr(type(x), '__call__'): pass""" + a = """if hasattr(x, '__call__'): pass""" self.check(b, a) def test_callable_call(self): b = """callable(x)""" - a = """hasattr(type(x), '__call__')""" + a = """hasattr(x, '__call__')""" self.check(b, a) def test_callable_should_not_change(self): From python-checkins at python.org Sat Oct 3 17:13:16 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 15:13:16 -0000 Subject: [Python-checkins] r75214 - python/branches/py3k/Doc/whatsnew/3.0.rst Message-ID: Author: benjamin.peterson Date: Sat Oct 3 17:13:15 2009 New Revision: 75214 Log: isinstance(f, collections.Callable) is more correct Modified: python/branches/py3k/Doc/whatsnew/3.0.rst Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sat Oct 3 17:13:15 2009 @@ -804,8 +804,8 @@ ``f(*args)``. * Removed :func:`callable`. Instead of ``callable(f)`` you can use - ``hasattr(f, '__call__')``. The :func:`operator.isCallable` function - is also gone. + ``isinstance(f, collections.Callable)``. The :func:`operator.isCallable` + function is also gone. * Removed :func:`coerce`. This function no longer serves a purpose now that classic classes are gone. From python-checkins at python.org Sat Oct 3 17:14:29 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 15:14:29 -0000 Subject: [Python-checkins] r75215 - in python/branches/release31-maint: Doc/whatsnew/3.0.rst Message-ID: Author: benjamin.peterson Date: Sat Oct 3 17:14:28 2009 New Revision: 75215 Log: Merged revisions 75212,75214 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75212 | benjamin.peterson | 2009-10-03 10:06:21 -0500 (Sat, 03 Oct 2009) | 1 line revert r75090 ........ r75214 | benjamin.peterson | 2009-10-03 10:13:15 -0500 (Sat, 03 Oct 2009) | 1 line isinstance(f, collections.Callable) is more correct ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/whatsnew/3.0.rst Modified: python/branches/release31-maint/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/3.0.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/3.0.rst Sat Oct 3 17:14:28 2009 @@ -804,8 +804,8 @@ ``f(*args)``. * Removed :func:`callable`. Instead of ``callable(f)`` you can use - ``hasattr(type(f), '__call__')``. The :func:`operator.isCallable` function is - also gone. + ``isinstance(f, collections.Callable)``. The :func:`operator.isCallable` + function is also gone. * Removed :func:`coerce`. This function no longer serves a purpose now that classic classes are gone. From python-checkins at python.org Sat Oct 3 18:14:08 2009 From: python-checkins at python.org (ezio.melotti) Date: Sat, 03 Oct 2009 16:14:08 -0000 Subject: [Python-checkins] r75216 - python/branches/py3k/Python/ceval.c Message-ID: Author: ezio.melotti Date: Sat Oct 3 18:14:07 2009 New Revision: 75216 Log: silence with (void) two warnings about computed and unused value of POP() Modified: python/branches/py3k/Python/ceval.c Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Sat Oct 3 18:14:07 2009 @@ -2509,13 +2509,13 @@ PyObject *exit_func; u = TOP(); if (u == Py_None) { - POP(); + (void)POP(); exit_func = TOP(); SET_TOP(u); v = w = Py_None; } else if (PyLong_Check(u)) { - POP(); + (void)POP(); switch(PyLong_AsLong(u)) { case WHY_RETURN: case WHY_CONTINUE: From python-checkins at python.org Sat Oct 3 20:22:21 2009 From: python-checkins at python.org (r.david.murray) Date: Sat, 03 Oct 2009 18:22:21 -0000 Subject: [Python-checkins] r75217 - in python/branches/release31-maint: Lib/test/test_urllib2_localnet.py Message-ID: Author: r.david.murray Date: Sat Oct 3 20:22:21 2009 New Revision: 75217 Log: Merged revisions 75133 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75133 | r.david.murray | 2009-09-29 10:01:08 -0400 (Tue, 29 Sep 2009) | 12 lines Merged revisions 75111 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75111 | r.david.murray | 2009-09-28 12:57:45 -0400 (Mon, 28 Sep 2009) | 5 lines Prevent test_bad_address failure when a domain in the dns search path implements a '*' default rule. Also update comment with a more complete explanation of the difficulties inherent in the test. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_urllib2_localnet.py Modified: python/branches/release31-maint/Lib/test/test_urllib2_localnet.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_urllib2_localnet.py (original) +++ python/branches/release31-maint/Lib/test/test_urllib2_localnet.py Sat Oct 3 20:22:21 2009 @@ -469,14 +469,25 @@ # Make sure proper exception is raised when connecting to a bogus # address. self.assertRaises(IOError, - # SF patch 809915: In Sep 2003, VeriSign started - # highjacking invalid .com and .net addresses to - # boost traffic to their own site. This test - # started failing then. One hopes the .invalid - # domain will be spared to serve its defined - # purpose. + # Given that both VeriSign and various ISPs have in + # the past or are presently hijacking various invalid + # domain name requests in an attempt to boost traffic + # to their own sites, finding a domain name to use + # for this test is difficult. RFC2606 leads one to + # believe that '.invalid' should work, but experience + # seemed to indicate otherwise. Single character + # TLDs are likely to remain invalid, so this seems to + # be the best choice. The trailing '.' prevents a + # related problem: The normal DNS resolver appends + # the domain names from the search path if there is + # no '.' the end and, and if one of those domains + # implements a '*' rule a result is returned. + # However, none of this will prevent the test from + # failing if the ISP hijacks all invalid domain + # requests. The real solution would be to be able to + # parameterize the framework with a mock resolver. urllib.request.urlopen, - "http://sadflkjsasf.i.nvali.d/") + "http://sadflkjsasf.i.nvali.d./") def test_main(): support.run_unittest(ProxyAuthTests, TestUrlopen) From python-checkins at python.org Sat Oct 3 20:46:49 2009 From: python-checkins at python.org (r.david.murray) Date: Sat, 03 Oct 2009 18:46:49 -0000 Subject: [Python-checkins] r75218 - in python/branches/release31-maint: Misc/maintainers.rst Message-ID: Author: r.david.murray Date: Sat Oct 3 20:46:49 2009 New Revision: 75218 Log: Merged revisions 75067 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75067 | r.david.murray | 2009-09-25 22:42:26 -0400 (Fri, 25 Sep 2009) | 4 lines Andrew just committed a patch for curses, so since he's been the maintainer he's on the hook for it in maintainers unless he says otherwise. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/maintainers.rst Modified: python/branches/release31-maint/Misc/maintainers.rst ============================================================================== --- python/branches/release31-maint/Misc/maintainers.rst (original) +++ python/branches/release31-maint/Misc/maintainers.rst Sat Oct 3 20:46:49 2009 @@ -80,7 +80,7 @@ crypt csv ctypes theller -curses +curses andrew.kuchling datetime dbm decimal facundobatista, rhettinger, mark.dickinson From python-checkins at python.org Sat Oct 3 22:07:37 2009 From: python-checkins at python.org (brett.cannon) Date: Sat, 03 Oct 2009 20:07:37 -0000 Subject: [Python-checkins] r75219 - sandbox/trunk/str_fmt_conversion Message-ID: Author: brett.cannon Date: Sat Oct 3 22:07:37 2009 New Revision: 75219 Log: Create a directory to hold preliminary work to convert strings with % formatting to {} formatting. Added: sandbox/trunk/str_fmt_conversion/ From python-checkins at python.org Sat Oct 3 22:13:42 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 20:13:42 -0000 Subject: [Python-checkins] r75220 - python/branches/py3k/Objects/capsule.c Message-ID: Author: mark.dickinson Date: Sat Oct 3 22:13:37 2009 New Revision: 75220 Log: Use size_t instead of int for a PyMem_MALLOC argument; silences a gcc 'comparison always false' warning. Modified: python/branches/py3k/Objects/capsule.c Modified: python/branches/py3k/Objects/capsule.c ============================================================================== --- python/branches/py3k/Objects/capsule.c (original) +++ python/branches/py3k/Objects/capsule.c Sat Oct 3 22:13:37 2009 @@ -197,7 +197,7 @@ PyObject *object = NULL; void *return_value = NULL; char *trace; - int name_length = (strlen(name) + 1) * sizeof(char); + size_t name_length = (strlen(name) + 1) * sizeof(char); char *name_dup = (char *)PyMem_MALLOC(name_length); if (!name_dup) { From python-checkins at python.org Sat Oct 3 22:15:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 03 Oct 2009 20:15:21 -0000 Subject: [Python-checkins] r75221 - in python/branches/release31-maint: Objects/capsule.c Message-ID: Author: mark.dickinson Date: Sat Oct 3 22:15:21 2009 New Revision: 75221 Log: Merged revisions 75220 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75220 | mark.dickinson | 2009-10-03 21:13:37 +0100 (Sat, 03 Oct 2009) | 1 line Use size_t instead of int for a PyMem_MALLOC argument; silences a gcc 'comparison always false' warning. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Objects/capsule.c Modified: python/branches/release31-maint/Objects/capsule.c ============================================================================== --- python/branches/release31-maint/Objects/capsule.c (original) +++ python/branches/release31-maint/Objects/capsule.c Sat Oct 3 22:15:21 2009 @@ -197,7 +197,7 @@ PyObject *object = NULL; void *return_value = NULL; char *trace; - int name_length = (strlen(name) + 1) * sizeof(char); + size_t name_length = (strlen(name) + 1) * sizeof(char); char *name_dup = (char *)PyMem_MALLOC(name_length); if (!name_dup) { From python-checkins at python.org Sat Oct 3 22:22:07 2009 From: python-checkins at python.org (brett.cannon) Date: Sat, 03 Oct 2009 20:22:07 -0000 Subject: [Python-checkins] r75222 - sandbox/trunk/str_fmt_conversion/README Message-ID: Author: brett.cannon Date: Sat Oct 3 22:22:06 2009 New Revision: 75222 Log: Add a README to describe what should end up here. Added: sandbox/trunk/str_fmt_conversion/README Added: sandbox/trunk/str_fmt_conversion/README ============================================================================== --- (empty file) +++ sandbox/trunk/str_fmt_conversion/README Sat Oct 3 22:22:06 2009 @@ -0,0 +1,16 @@ +Purpose +======= + +To come up with an approach to convert % formatting to {} formatting in +strings, e.g. ``"%s to %s"`` to ``"{} to {}"``. This would be to help +transition people from the old way of doing string interpolation to the new +way, especially for pre-existing libraries that rely on the old format style. + + +What to convert +=============== + +Go from the `old way +`__ +to the `new way +`__. From python-checkins at python.org Sat Oct 3 22:23:24 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 20:23:24 -0000 Subject: [Python-checkins] r75223 - in python/trunk: Lib/test/test_augassign.py Misc/NEWS Python/ast.c Message-ID: Author: benjamin.peterson Date: Sat Oct 3 22:23:24 2009 New Revision: 75223 Log: #7050 fix a SystemError when using tuple unpacking and augmented assignment Modified: python/trunk/Lib/test/test_augassign.py python/trunk/Misc/NEWS python/trunk/Python/ast.c Modified: python/trunk/Lib/test/test_augassign.py ============================================================================== --- python/trunk/Lib/test/test_augassign.py (original) +++ python/trunk/Lib/test/test_augassign.py Sat Oct 3 22:23:24 2009 @@ -24,6 +24,9 @@ # new-style division (with -Qnew) self.assertEquals(x, 3.0) + def test_with_unpacking(self): + self.assertRaises(SyntaxError, compile, "x, b += 3", "", "exec") + def testInList(self): x = [2] x[0] += 1 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 3 22:23:24 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7050: Fix a SystemError when trying to use unpacking and augmented + assignment. + - Issue #5329: Fix os.popen* regression from 2.5 with commands as a sequence running through the shell. Patch by Jean-Paul Calderone and Jani Hakala. Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Sat Oct 3 22:23:24 2009 @@ -2097,6 +2097,19 @@ return NULL; if(!set_context(c, expr1, Store, ch)) return NULL; + /* set_context checks that most expressions are not the left side. + Augmented assignments can only have a name, a subscript, or an + attribute on the left, though, so we have to explicitly check for + those. */ + switch (expr1->kind) { + case Name_kind: + case Attribute_kind: + case Subscript_kind: + break; + default: + ast_error(ch, "illegal expression for augmented assignment"); + return NULL; + } ch = CHILD(n, 2); if (TYPE(ch) == testlist) From python-checkins at python.org Sat Oct 3 22:27:14 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 20:27:14 -0000 Subject: [Python-checkins] r75224 - in python/branches/py3k: Lib/test/test_augassign.py Python/ast.c Message-ID: Author: benjamin.peterson Date: Sat Oct 3 22:27:13 2009 New Revision: 75224 Log: Merged revisions 75223 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75223 | benjamin.peterson | 2009-10-03 15:23:24 -0500 (Sat, 03 Oct 2009) | 1 line #7050 fix a SystemError when using tuple unpacking and augmented assignment ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_augassign.py python/branches/py3k/Python/ast.c Modified: python/branches/py3k/Lib/test/test_augassign.py ============================================================================== --- python/branches/py3k/Lib/test/test_augassign.py (original) +++ python/branches/py3k/Lib/test/test_augassign.py Sat Oct 3 22:27:13 2009 @@ -19,6 +19,9 @@ x /= 2 self.assertEquals(x, 3.0) + def test_with_unpacking(self): + self.assertRaises(SyntaxError, compile, "x, b += 3", "", "exec") + def testInList(self): x = [2] x[0] += 1 Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Sat Oct 3 22:27:13 2009 @@ -2115,6 +2115,19 @@ return NULL; if(!set_context(c, expr1, Store, ch)) return NULL; + /* set_context checks that most expressions are not the left side. + Augmented assignments can only have a name, a subscript, or an + attribute on the left, though, so we have to explicitly check for + those. */ + switch (expr1->kind) { + case Name_kind: + case Attribute_kind: + case Subscript_kind: + break; + default: + ast_error(ch, "illegal expression for augmented assignment"); + return NULL; + } ch = CHILD(n, 2); if (TYPE(ch) == testlist) From python-checkins at python.org Sat Oct 3 22:27:54 2009 From: python-checkins at python.org (brett.cannon) Date: Sat, 03 Oct 2009 20:27:54 -0000 Subject: [Python-checkins] r75225 - sandbox/trunk/str_fmt_conversion/README Message-ID: Author: brett.cannon Date: Sat Oct 3 22:27:54 2009 New Revision: 75225 Log: Mention Benjamin's code. Modified: sandbox/trunk/str_fmt_conversion/README Modified: sandbox/trunk/str_fmt_conversion/README ============================================================================== --- sandbox/trunk/str_fmt_conversion/README (original) +++ sandbox/trunk/str_fmt_conversion/README Sat Oct 3 22:27:54 2009 @@ -7,6 +7,13 @@ way, especially for pre-existing libraries that rely on the old format style. +Code Elsewhere +============== + +Benjamin Peterson has code on Launchpad at +https://code.launchpad.net/~gutworth/+junk/mod2format . + + What to convert =============== From python-checkins at python.org Sat Oct 3 22:28:47 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 03 Oct 2009 20:28:47 -0000 Subject: [Python-checkins] r75226 - in python/branches/release31-maint: Lib/test/test_augassign.py Python/ast.c Message-ID: Author: benjamin.peterson Date: Sat Oct 3 22:28:47 2009 New Revision: 75226 Log: Merged revisions 75224 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75224 | benjamin.peterson | 2009-10-03 15:27:13 -0500 (Sat, 03 Oct 2009) | 9 lines Merged revisions 75223 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75223 | benjamin.peterson | 2009-10-03 15:23:24 -0500 (Sat, 03 Oct 2009) | 1 line #7050 fix a SystemError when using tuple unpacking and augmented assignment ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_augassign.py python/branches/release31-maint/Python/ast.c Modified: python/branches/release31-maint/Lib/test/test_augassign.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_augassign.py (original) +++ python/branches/release31-maint/Lib/test/test_augassign.py Sat Oct 3 22:28:47 2009 @@ -19,6 +19,9 @@ x /= 2 self.assertEquals(x, 3.0) + def test_with_unpacking(self): + self.assertRaises(SyntaxError, compile, "x, b += 3", "", "exec") + def testInList(self): x = [2] x[0] += 1 Modified: python/branches/release31-maint/Python/ast.c ============================================================================== --- python/branches/release31-maint/Python/ast.c (original) +++ python/branches/release31-maint/Python/ast.c Sat Oct 3 22:28:47 2009 @@ -2105,6 +2105,19 @@ return NULL; if(!set_context(c, expr1, Store, ch)) return NULL; + /* set_context checks that most expressions are not the left side. + Augmented assignments can only have a name, a subscript, or an + attribute on the left, though, so we have to explicitly check for + those. */ + switch (expr1->kind) { + case Name_kind: + case Attribute_kind: + case Subscript_kind: + break; + default: + ast_error(ch, "illegal expression for augmented assignment"); + return NULL; + } ch = CHILD(n, 2); if (TYPE(ch) == testlist) From python-checkins at python.org Sun Oct 4 00:31:55 2009 From: python-checkins at python.org (brett.cannon) Date: Sat, 03 Oct 2009 22:31:55 -0000 Subject: [Python-checkins] r75227 - sandbox/trunk/str_fmt_conversion/README Message-ID: Author: brett.cannon Date: Sun Oct 4 00:31:55 2009 New Revision: 75227 Log: Mention Vinay's attempt. Modified: sandbox/trunk/str_fmt_conversion/README Modified: sandbox/trunk/str_fmt_conversion/README ============================================================================== --- sandbox/trunk/str_fmt_conversion/README (original) +++ sandbox/trunk/str_fmt_conversion/README Sun Oct 4 00:31:55 2009 @@ -13,6 +13,8 @@ Benjamin Peterson has code on Launchpad at https://code.launchpad.net/~gutworth/+junk/mod2format . +Vinay has an attempt at http://gist.github.com/200936 . + What to convert =============== From nnorwitz at gmail.com Sun Oct 4 00:40:32 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 3 Oct 2009 18:40:32 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091003224032.GA27604@python.psfb.org> More important issues: ---------------------- test_distutils leaked [25, -25, 25] references, sum=25 test_urllib2_localnet leaked [-269, 0, 0] references, sum=-269 Less important issues: ---------------------- test_popen2 leaked [0, -4, 0] references, sum=-4 test_smtplib leaked [-4, 4, 0] references, sum=0 test_socketserver leaked [0, 0, 78] references, sum=78 test_threadedtempfile leaked [0, 94, -94] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Sun Oct 4 11:04:00 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 04 Oct 2009 09:04:00 -0000 Subject: [Python-checkins] r75228 - in python/branches/release26-maint: Lib/logging/__init__.py Lib/test/test___all__.py Misc/NEWS Message-ID: Author: georg.brandl Date: Sun Oct 4 11:03:59 2009 New Revision: 75228 Log: #7052: remove nonexisting NullHandler from logging.__all__. Modified: python/branches/release26-maint/Lib/logging/__init__.py python/branches/release26-maint/Lib/test/test___all__.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/logging/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/logging/__init__.py (original) +++ python/branches/release26-maint/Lib/logging/__init__.py Sun Oct 4 11:03:59 2009 @@ -25,7 +25,7 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', 'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO', - 'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'NullHandler', + 'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig', 'captureWarnings', 'critical', 'debug', 'disable', 'error', 'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass', Modified: python/branches/release26-maint/Lib/test/test___all__.py ============================================================================== --- python/branches/release26-maint/Lib/test/test___all__.py (original) +++ python/branches/release26-maint/Lib/test/test___all__.py Sun Oct 4 11:03:59 2009 @@ -91,6 +91,7 @@ self.check_all("keyword") self.check_all("linecache") self.check_all("locale") + self.check_all("logging") self.check_all("macpath") self.check_all("macurl2path") self.check_all("mailbox") Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Oct 4 11:03:59 2009 @@ -18,9 +18,12 @@ Library ------- +- Issue #7052: Removed nonexisting NullHandler from logging.__all__. + - Issue #7039: Fixed distutils.tests.test_sysconfig when running on installation with no build. + What's New in Python 2.6.3 ========================== From python-checkins at python.org Sun Oct 4 14:20:12 2009 From: python-checkins at python.org (vinay.sajip) Date: Sun, 04 Oct 2009 12:20:12 -0000 Subject: [Python-checkins] r75229 - python/branches/release26-maint/Lib/logging/__init__.py Message-ID: Author: vinay.sajip Date: Sun Oct 4 14:20:12 2009 New Revision: 75229 Log: Issue #7052: Removed captureWarnings from __all__ Modified: python/branches/release26-maint/Lib/logging/__init__.py Modified: python/branches/release26-maint/Lib/logging/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/logging/__init__.py (original) +++ python/branches/release26-maint/Lib/logging/__init__.py Sun Oct 4 14:20:12 2009 @@ -27,7 +27,7 @@ 'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO', 'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig', - 'captureWarnings', 'critical', 'debug', 'disable', 'error', + 'critical', 'debug', 'disable', 'error', 'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass', 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning'] From python-checkins at python.org Sun Oct 4 15:38:38 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 13:38:38 -0000 Subject: [Python-checkins] r75230 - python/trunk/Lib/test/test___all__.py Message-ID: Author: benjamin.peterson Date: Sun Oct 4 15:38:38 2009 New Revision: 75230 Log: test logging Modified: python/trunk/Lib/test/test___all__.py Modified: python/trunk/Lib/test/test___all__.py ============================================================================== --- python/trunk/Lib/test/test___all__.py (original) +++ python/trunk/Lib/test/test___all__.py Sun Oct 4 15:38:38 2009 @@ -91,6 +91,7 @@ self.check_all("keyword") self.check_all("linecache") self.check_all("locale") + self.check_all("logging") self.check_all("macpath") self.check_all("macurl2path") self.check_all("mailbox") From python-checkins at python.org Sun Oct 4 16:49:42 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 14:49:42 -0000 Subject: [Python-checkins] r75231 - in python/branches/py3k: Doc/c-api/init.rst Doc/c-api/unicode.rst Doc/documenting/markup.rst Doc/library/codecs.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/hashlib.rst Doc/library/inspect.rst Doc/library/logging.rst Doc/library/shelve.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/termios.rst Doc/library/threading.rst Doc/library/unittest.rst Doc/tutorial/interpreter.rst Doc/tutorial/modules.rst Doc/whatsnew/2.7.rst Lib/csv.py Lib/getpass.py Lib/inspect.py Lib/logging/__init__.py Lib/multiprocessing/managers.py Lib/platform.py Lib/test/test___all__.py Lib/test/test_csv.py Lib/test/test_socket.py Lib/test/test_unittest.py Lib/textwrap.py Lib/unittest/case.py Lib/unittest/loader.py Lib/unittest/main.py Lib/unittest/suite.py Misc/developers.txt Modules/socketmodule.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 16:49:41 2009 New Revision: 75231 Log: Merged revisions 74779-74786,74793,74795,74811,74860-74861,74863,74876,74886,74896,74901,74903,74908,74912,74930,74933,74943,74946,74952-74955,75015,75019,75032,75068,75076,75095,75098,75102,75129,75139,75230 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74779 | michael.foord | 2009-09-13 11:13:36 -0500 (Sun, 13 Sep 2009) | 1 line Change to tutorial wording for reading text / binary files on Windows. Issue #6301. ........ r74780 | michael.foord | 2009-09-13 11:40:02 -0500 (Sun, 13 Sep 2009) | 1 line Objects that compare equal automatically pass or fail assertAlmostEqual and assertNotAlmostEqual tests on unittest.TestCase. Issue 6567. ........ r74781 | michael.foord | 2009-09-13 11:46:19 -0500 (Sun, 13 Sep 2009) | 1 line Note that sys._getframe is not guaranteed to exist in all implementations of Python, and a corresponding note in inspect.currentframe. Issue 6712. ........ r74782 | michael.foord | 2009-09-13 12:07:46 -0500 (Sun, 13 Sep 2009) | 1 line Tutorial tweaks. Issue 6849. ........ r74783 | michael.foord | 2009-09-13 12:28:35 -0500 (Sun, 13 Sep 2009) | 1 line unittest.TestLoader.loadTestsFromName honors the loader suiteClass attribute. Issue 6866. ........ r74784 | georg.brandl | 2009-09-13 13:15:07 -0500 (Sun, 13 Sep 2009) | 1 line Typo fix. ........ r74785 | michael.foord | 2009-09-13 14:07:03 -0500 (Sun, 13 Sep 2009) | 1 line Test discovery in unittest will only attempt to import modules that are importable; i.e. their names are valid Python identifiers. If an import fails during discovery this will be recorded as an error and test discovery will continue. Issue 6568. ........ r74786 | michael.foord | 2009-09-13 14:08:18 -0500 (Sun, 13 Sep 2009) | 1 line Remove an extraneous space in unittest documentation. ........ r74793 | georg.brandl | 2009-09-14 09:50:47 -0500 (Mon, 14 Sep 2009) | 1 line #6908: fix association of hashlib hash attributes. ........ r74795 | benjamin.peterson | 2009-09-14 22:36:26 -0500 (Mon, 14 Sep 2009) | 1 line Py_SetPythonHome uses static storage #6913 ........ r74811 | georg.brandl | 2009-09-15 15:26:59 -0500 (Tue, 15 Sep 2009) | 1 line Add Armin Ronacher. ........ r74860 | benjamin.peterson | 2009-09-16 21:46:54 -0500 (Wed, 16 Sep 2009) | 1 line kill bare except ........ r74861 | benjamin.peterson | 2009-09-16 22:18:28 -0500 (Wed, 16 Sep 2009) | 1 line pep 8 defaults ........ r74863 | benjamin.peterson | 2009-09-16 22:27:33 -0500 (Wed, 16 Sep 2009) | 1 line rationalize a bit ........ r74876 | georg.brandl | 2009-09-17 11:15:53 -0500 (Thu, 17 Sep 2009) | 1 line #6932: remove paragraph that advises relying on __del__ being called. ........ r74886 | benjamin.peterson | 2009-09-17 16:33:46 -0500 (Thu, 17 Sep 2009) | 1 line use macros ........ r74896 | georg.brandl | 2009-09-18 02:22:41 -0500 (Fri, 18 Sep 2009) | 1 line #6936: for interactive use, quit() is just fine. ........ r74901 | georg.brandl | 2009-09-18 04:14:52 -0500 (Fri, 18 Sep 2009) | 1 line #6905: use better exception messages in inspect when the argument is of the wrong type. ........ r74903 | georg.brandl | 2009-09-18 04:18:27 -0500 (Fri, 18 Sep 2009) | 1 line #6938: "ident" is always a string, so use a format code which works. ........ r74908 | georg.brandl | 2009-09-18 08:57:11 -0500 (Fri, 18 Sep 2009) | 1 line Use str.format() to fix beginner's mistake with %-style string formatting. ........ r74912 | georg.brandl | 2009-09-18 11:19:56 -0500 (Fri, 18 Sep 2009) | 1 line Optimize optimization and fix method name in docstring. ........ r74930 | georg.brandl | 2009-09-18 16:21:41 -0500 (Fri, 18 Sep 2009) | 1 line #6925: rewrite docs for locals() and vars() a bit. ........ r74933 | georg.brandl | 2009-09-18 16:35:59 -0500 (Fri, 18 Sep 2009) | 1 line #6930: clarify description about byteorder handling in UTF decoder routines. ........ r74943 | georg.brandl | 2009-09-19 02:35:07 -0500 (Sat, 19 Sep 2009) | 1 line #6944: the argument to PyArg_ParseTuple should be a tuple, otherwise a SystemError is set. Also clean up another usage of PyArg_ParseTuple. ........ r74946 | georg.brandl | 2009-09-19 03:43:16 -0500 (Sat, 19 Sep 2009) | 1 line Update bug tracker reference. ........ r74952 | georg.brandl | 2009-09-19 05:42:34 -0500 (Sat, 19 Sep 2009) | 1 line #6946: fix duplicate index entries for datetime classes. ........ r74953 | georg.brandl | 2009-09-19 07:04:16 -0500 (Sat, 19 Sep 2009) | 1 line Fix references to threading.enumerate(). ........ r74954 | georg.brandl | 2009-09-19 08:13:56 -0500 (Sat, 19 Sep 2009) | 1 line Add Doug. ........ r74955 | georg.brandl | 2009-09-19 08:20:49 -0500 (Sat, 19 Sep 2009) | 1 line Add Mark Summerfield. ........ r75015 | georg.brandl | 2009-09-22 05:55:08 -0500 (Tue, 22 Sep 2009) | 1 line Fix encoding name. ........ r75019 | vinay.sajip | 2009-09-22 12:23:41 -0500 (Tue, 22 Sep 2009) | 1 line Fixed a typo, and added sections on optimization and using arbitrary objects as messages. ........ r75032 | benjamin.peterson | 2009-09-22 17:15:28 -0500 (Tue, 22 Sep 2009) | 1 line fix typos/rephrase ........ r75068 | benjamin.peterson | 2009-09-25 21:57:59 -0500 (Fri, 25 Sep 2009) | 1 line comment out ugly xxx ........ r75076 | vinay.sajip | 2009-09-26 09:53:32 -0500 (Sat, 26 Sep 2009) | 1 line Tidied up name of parameter in StreamHandler ........ r75095 | michael.foord | 2009-09-27 14:15:41 -0500 (Sun, 27 Sep 2009) | 1 line Test creation moved from TestProgram.parseArgs to TestProgram.createTests exclusively. Issue 6956. ........ r75098 | michael.foord | 2009-09-27 15:08:23 -0500 (Sun, 27 Sep 2009) | 1 line Documentation improvement for load_tests protocol in unittest. Issue 6515. ........ r75102 | skip.montanaro | 2009-09-27 21:12:27 -0500 (Sun, 27 Sep 2009) | 3 lines Patch from Thomas Barr so that csv.Sniffer will set doublequote property. Closes issue 6606. ........ r75129 | vinay.sajip | 2009-09-29 02:08:54 -0500 (Tue, 29 Sep 2009) | 1 line Issue #7014: logging: Improved IronPython 2.6 compatibility. ........ r75139 | raymond.hettinger | 2009-09-29 13:53:24 -0500 (Tue, 29 Sep 2009) | 3 lines Issue 7008: Better document str.title and show how to work around the apostrophe problem. ........ r75230 | benjamin.peterson | 2009-10-04 08:38:38 -0500 (Sun, 04 Oct 2009) | 1 line test logging ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Doc/c-api/unicode.rst python/branches/py3k/Doc/documenting/markup.rst python/branches/py3k/Doc/library/codecs.rst python/branches/py3k/Doc/library/datetime.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/hashlib.rst python/branches/py3k/Doc/library/inspect.rst python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Doc/library/shelve.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Doc/library/termios.rst python/branches/py3k/Doc/library/threading.rst python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Doc/tutorial/interpreter.rst python/branches/py3k/Doc/tutorial/modules.rst python/branches/py3k/Doc/whatsnew/2.7.rst python/branches/py3k/Lib/csv.py python/branches/py3k/Lib/getpass.py python/branches/py3k/Lib/inspect.py python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Lib/multiprocessing/managers.py python/branches/py3k/Lib/platform.py python/branches/py3k/Lib/test/test___all__.py python/branches/py3k/Lib/test/test_csv.py python/branches/py3k/Lib/test/test_socket.py python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/textwrap.py python/branches/py3k/Lib/unittest/case.py python/branches/py3k/Lib/unittest/loader.py python/branches/py3k/Lib/unittest/main.py python/branches/py3k/Lib/unittest/suite.py python/branches/py3k/Misc/developers.txt python/branches/py3k/Modules/socketmodule.c Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Sun Oct 4 16:49:41 2009 @@ -371,6 +371,10 @@ Set the default "home" directory, that is, the location of the standard Python libraries. The libraries are searched in :file:`{home}/lib/python{version}` and :file:`{home}/lib/python{version}`. + The argument should point to a zero-terminated character string in static + storage whose contents will not change for the duration of the program's + execution. No code in the Python interpreter will change the contents of + this storage. .. cfunction:: w_char* Py_GetPythonHome() Modified: python/branches/py3k/Doc/c-api/unicode.rst ============================================================================== --- python/branches/py3k/Doc/c-api/unicode.rst (original) +++ python/branches/py3k/Doc/c-api/unicode.rst Sun Oct 4 16:49:41 2009 @@ -476,10 +476,13 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first four bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the end of input data. + If ``*byteorder`` is zero, and the first four bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output. + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. In a narrow build codepoints outside the BMP will be decoded as surrogate pairs. @@ -500,8 +503,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-32 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) @@ -541,10 +543,14 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first two bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the end of input data. + If ``*byteorder`` is zero, and the first two bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output (where it will result in + either a ``\ufeff`` or a ``\ufffe`` character). + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. If *byteorder* is *NULL*, the codec starts in native order mode. @@ -563,8 +569,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-16 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) Modified: python/branches/py3k/Doc/documenting/markup.rst ============================================================================== --- python/branches/py3k/Doc/documenting/markup.rst (original) +++ python/branches/py3k/Doc/documenting/markup.rst Sun Oct 4 16:49:41 2009 @@ -597,8 +597,10 @@ An important bit of information about an API that a user should be aware of when using whatever bit of API the warning pertains to. The content of the directive should be written in complete sentences and include all appropriate - punctuation. This should only be chosen over ``note`` for information - regarding the possibility of crashes, data loss, or security implications. + punctuation. In the interest of not scaring users away from pages filled + with warnings, this directive should only be chosen over ``note`` for + information regarding the possibility of crashes, data loss, or security + implications. .. describe:: versionadded Modified: python/branches/py3k/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k/Doc/library/codecs.rst (original) +++ python/branches/py3k/Doc/library/codecs.rst Sun Oct 4 16:49:41 2009 @@ -988,7 +988,7 @@ +-----------------+--------------------------------+--------------------------------+ | cp1255 | windows-1255 | Hebrew | +-----------------+--------------------------------+--------------------------------+ -| cp1256 | windows1256 | Arabic | +| cp1256 | windows-1256 | Arabic | +-----------------+--------------------------------+--------------------------------+ | cp1257 | windows-1257 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ Modified: python/branches/py3k/Doc/library/datetime.rst ============================================================================== --- python/branches/py3k/Doc/library/datetime.rst (original) +++ python/branches/py3k/Doc/library/datetime.rst Sun Oct 4 16:49:41 2009 @@ -63,6 +63,7 @@ .. class:: date + :noindex: An idealized naive date, assuming the current Gregorian calendar always was, and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, and @@ -70,6 +71,7 @@ .. class:: time + :noindex: An idealized time, independent of any particular day, assuming that every day has exactly 24\*60\*60 seconds (there is no notion of "leap seconds" here). @@ -78,6 +80,7 @@ .. class:: datetime + :noindex: A combination of a date and a time. Attributes: :attr:`year`, :attr:`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:`microsecond`, @@ -85,6 +88,7 @@ .. class:: timedelta + :noindex: A duration expressing the difference between two :class:`date`, :class:`time`, or :class:`datetime` instances to microsecond resolution. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Sun Oct 4 16:49:41 2009 @@ -600,16 +600,12 @@ .. function:: locals() Update and return a dictionary representing the current local symbol table. + Free variables are returned by :func:`locals` when it is called in function + blocks, but not in class blocks. .. note:: - The contents of this dictionary should not be modified; changes may not - affect the values of local variables used by the interpreter. - - Free variables are returned by :func:`locals` when it is called in a function - block. Modifications of free variables may not affect the values used by the - interpreter. Free variables are not returned in class blocks. - + affect the values of local and free variables used by the interpreter. .. function:: map(function, iterable, ...) @@ -1176,10 +1172,10 @@ .. function:: vars([object]) - Without arguments, return a dictionary corresponding to the current local symbol - table. With a module, class or class instance object as argument (or anything - else that has a :attr:`__dict__` attribute), returns a dictionary corresponding - to the object's symbol table. + Without an argument, act like :func:`locals`. + + With a module, class or class instance object as argument (or anything else that + has a :attr:`__dict__` attribute), return that attribute. .. note:: The returned dictionary should not be modified: Modified: python/branches/py3k/Doc/library/hashlib.rst ============================================================================== --- python/branches/py3k/Doc/library/hashlib.rst (original) +++ python/branches/py3k/Doc/library/hashlib.rst Sun Oct 4 16:49:41 2009 @@ -86,11 +86,11 @@ returned by the constructors: -.. data:: digest_size +.. data:: hash.digest_size The size of the resulting hash in bytes. -.. data:: block_size +.. data:: hash.block_size The internal block size of the hash algorithm in bytes. Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Sun Oct 4 16:49:41 2009 @@ -508,6 +508,11 @@ Return the frame object for the caller's stack frame. + This function relies on Python stack frame support in the interpreter, which + isn't guaranteed to exist in all implementations of Python. If running in + an implementation without Python stack frame support this function returns + ``None``. + .. function:: stack(context=1) Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Sun Oct 4 16:49:41 2009 @@ -57,7 +57,7 @@ import logging LOG_FILENAME = '/tmp/logging_example.out' - logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('This message should go to the log file') @@ -1493,6 +1493,55 @@ 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly. +Using arbitrary objects as messages +----------------------------------- + +In the preceding sections and examples, it has been assumed that the message +passed when logging the event is a string. However, this is not the only +possibility. You can pass an arbitrary object as a message, and its +:meth:`__str__` method will be called when the logging system needs to convert +it to a string representation. In fact, if you want to, you can avoid +computing a string representation altogether - for example, the +:class:`SocketHandler` emits an event by pickling it and sending it over the +wire. + +Optimization +------------ + +Formatting of message arguments is deferred until it cannot be avoided. +However, computing the arguments passed to the logging method can also be +expensive, and you may want to avoid doing it if the logger will just throw +away your event. To decide what to do, you can call the :meth:`isEnabledFor` +method which takes a level argument and returns true if the event would be +created by the Logger for that level of call. You can write code like this:: + + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Message with %s, %s", expensive_func1(), + expensive_func2()) + +so that if the logger's threshold is set above ``DEBUG``, the calls to +:func:`expensive_func1` and :func:`expensive_func2` are never made. + +There are other optimizations which can be made for specific applications which +need more precise control over what logging information is collected. Here's a +list of things you can do to avoid processing during logging which you don't +need: + ++-----------------------------------------------+----------------------------------------+ +| What you don't want to collect | How to avoid collecting it | ++===============================================+========================================+ +| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. | ++-----------------------------------------------+----------------------------------------+ +| Threading information. | Set ``logging.logThreads`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ +| Process information. | Set ``logging.logProcesses`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ + +Also note that the core logging module only includes the basic handlers. If +you don't import :mod:`logging.handlers` and :mod:`logging.config`, they won't +take up any memory. + +.. _handler: Handler Objects --------------- @@ -1608,9 +1657,9 @@ and :meth:`flush` methods). -.. class:: StreamHandler(strm=None) +.. class:: StreamHandler(stream=None) - Returns a new instance of the :class:`StreamHandler` class. If *strm* is + Returns a new instance of the :class:`StreamHandler` class. If *stream* is specified, the instance will use it for logging output; otherwise, *sys.stderr* will be used. Modified: python/branches/py3k/Doc/library/shelve.rst ============================================================================== --- python/branches/py3k/Doc/library/shelve.rst (original) +++ python/branches/py3k/Doc/library/shelve.rst Sun Oct 4 16:49:41 2009 @@ -27,27 +27,39 @@ Because of Python semantics, a shelf cannot know when a mutable persistent-dictionary entry is modified. By default modified objects are - written only when assigned to the shelf (see :ref:`shelve-example`). If - the optional *writeback* parameter is set to *True*, all entries accessed - are cached in memory, and written back at close time; this can make it - handier to mutate mutable entries in the persistent dictionary, but, if - many entries are accessed, it can consume vast amounts of memory for the - cache, and it can make the close operation very slow since all accessed - entries are written back (there is no way to determine which accessed - entries are mutable, nor which ones were actually mutated). + written only when assigned to the shelf (see :ref:`shelve-example`). If the + optional *writeback* parameter is set to *True*, all entries accessed are + cached in memory, and written back on :meth:`sync` and :meth:`close`; this + can make it handier to mutate mutable entries in the persistent dictionary, + but, if many entries are accessed, it can consume vast amounts of memory for + the cache, and it can make the close operation very slow since all accessed + entries are written back (there is no way to determine which accessed entries + are mutable, nor which ones were actually mutated). + + .. note:: + + Do not rely on the shelf being closed automatically; always call + :meth:`close` explicitly when you don't need it any more, or use a + :keyword:`with` statement with :func:`contextlib.closing`. + Shelf objects support all methods supported by dictionaries. This eases the transition from dictionary based scripts to those requiring persistent storage. -One additional method is supported: - +Two additional methods are supported: .. method:: Shelf.sync() - Write back all entries in the cache if the shelf was opened with *writeback* set - to *True*. Also empty the cache and synchronize the persistent dictionary on - disk, if feasible. This is called automatically when the shelf is closed with - :meth:`close`. + Write back all entries in the cache if the shelf was opened with *writeback* + set to :const:`True`. Also empty the cache and synchronize the persistent + dictionary on disk, if feasible. This is called automatically when the shelf + is closed with :meth:`close`. + +.. method:: Shelf.close() + + Synchronize and close the persistent *dict* object. Operations on a closed + shelf will fail with a :exc:`ValueError`. + .. seealso:: @@ -71,11 +83,6 @@ database should be fairly small, and in rare cases key collisions may cause the database to refuse updates. -* Depending on the implementation, closing a persistent dictionary may or may - not be necessary to flush changes to disk. The :meth:`__del__` method of the - :class:`Shelf` class calls the :meth:`close` method, so the programmer generally - need not do this explicitly. - * The :mod:`shelve` module does not support *concurrent* read/write access to shelved objects. (Multiple simultaneous read accesses are safe.) When a program has a shelf open for writing, no other program should have it open for Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Sun Oct 4 16:49:41 2009 @@ -1149,6 +1149,8 @@ >>> titlecase("they're bill's friends.") "They're Bill's Friends." + For 8-bit strings, this method is locale-dependent. + .. method:: str.translate(map) Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sun Oct 4 16:49:41 2009 @@ -337,12 +337,12 @@ does not have to hold true for third-party extensions as it is implementation specific. - The *default* argument allows to define a value which will be returned - if the object type does not provide means to retrieve the size and would - cause a `TypeError`. + If given, *default* will be returned if the object does not provide means to + retrieve the size. Otherwise a `TypeError` will be raised. - :func:`getsizeof` calls the object's __sizeof__ method and adds an additional - garbage collector overhead if the object is managed by the garbage collector. + :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an + additional garbage collector overhead if the object is managed by the garbage + collector. .. function:: _getframe([depth]) @@ -352,7 +352,8 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. + This function should be used for internal and specialized purposes only. It + is not guaranteed to exist in all implementations of Python. .. function:: getprofile() Modified: python/branches/py3k/Doc/library/termios.rst ============================================================================== --- python/branches/py3k/Doc/library/termios.rst (original) +++ python/branches/py3k/Doc/library/termios.rst Sun Oct 4 16:49:41 2009 @@ -89,7 +89,7 @@ :keyword:`finally` statement to ensure that the old tty attributes are restored exactly no matter what happens:: - def getpass(prompt = "Password: "): + def getpass(prompt="Password: "): import termios, sys fd = sys.stdin.fileno() old = termios.tcgetattr(fd) Modified: python/branches/py3k/Doc/library/threading.rst ============================================================================== --- python/branches/py3k/Doc/library/threading.rst (original) +++ python/branches/py3k/Doc/library/threading.rst Sun Oct 4 16:49:41 2009 @@ -23,7 +23,7 @@ .. function:: active_count() Return the number of :class:`Thread` objects currently alive. The returned - count is equal to the length of the list returned by :func:`enumerate`. + count is equal to the length of the list returned by :func:`.enumerate`. .. function:: Condition() @@ -301,7 +301,7 @@ Roughly, a thread is alive from the moment the :meth:`start` method returns until its :meth:`run` method terminates. The module function - :func:`enumerate` returns a list of all alive threads. + :func:`.enumerate` returns a list of all alive threads. .. attribute:: daemon Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Sun Oct 4 16:49:41 2009 @@ -728,6 +728,9 @@ compare equal, the test will fail with the explanation given by *msg*, or :const:`None`. + .. versionchanged:: 3.2 + Objects that compare equal are automatically almost equal. + .. deprecated:: 3.1 :meth:`failUnlessAlmostEqual`. @@ -744,6 +747,9 @@ compare equal, the test will fail with the explanation given by *msg*, or :const:`None`. + .. versionchanged:: 3.2 + Objects that compare equal automatically fail. + .. deprecated:: 3.1 :meth:`failIfAlmostEqual`. @@ -1244,18 +1250,23 @@ Find and return all test modules from the specified start directory, recursing into subdirectories to find them. Only test files that match - *pattern* will be loaded. (Using shell style pattern matching.) + *pattern* will be loaded. (Using shell style pattern matching.) Only + module names that are importable (i.e. are valid Python identifiers) will + be loaded. All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level directory must be specified separately. + If importing a module fails, for example due to a syntax error, then this + will be recorded as a single error and discovery will continue. + If a test package name (directory with :file:`__init__.py`) matches the pattern then the package will be checked for a ``load_tests`` function. If this exists then it will be called with *loader*, *tests*, *pattern*. - If load_tests exists then discovery does *not* recurse into the package, + If load_tests exists then discovery does *not* recurse into the package, ``load_tests`` is responsible for loading all tests in the package. The pattern is deliberately not stored as a loader attribute so that @@ -1263,6 +1274,7 @@ ``load_tests`` does not need to pass this argument in to ``loader.discover()``. + .. versionadded:: 2.7 The following attributes of a :class:`TestLoader` can be configured either by subclassing or assignment on an instance: @@ -1518,6 +1530,10 @@ load_tests Protocol ################### + +.. versionadded:: 2.7 + + Modules or packages can customize how tests are loaded from them during normal test runs or test discovery by implementing a function called ``load_tests``. Modified: python/branches/py3k/Doc/tutorial/interpreter.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/interpreter.rst (original) +++ python/branches/py3k/Doc/tutorial/interpreter.rst Sun Oct 4 16:49:41 2009 @@ -31,7 +31,7 @@ Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn't work, you can exit the interpreter by typing the -following commands: ``import sys; sys.exit()``. +following command: ``quit()``. The interpreter's line-editing features usually aren't very sophisticated. On Unix, whoever installed the interpreter may have enabled support for the GNU Modified: python/branches/py3k/Doc/tutorial/modules.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/modules.rst (original) +++ python/branches/py3k/Doc/tutorial/modules.rst Sun Oct 4 16:49:41 2009 @@ -107,6 +107,10 @@ an unknown set of names into the interpreter, possibly hiding some things you have already defined. +Note that in general the practice of importing ``*`` from a module or package is +frowned upon, since it often causes poorly readable code. However, it is okay to +use it to save typing in interactive sessions. + .. note:: For efficiency reasons, each module is only imported once per interpreter @@ -445,14 +449,9 @@ Now what happens when the user writes ``from sound.effects import *``? Ideally, one would hope that this somehow goes out to the filesystem, finds which -submodules are present in the package, and imports them all. Unfortunately, -this operation does not work very well on Windows platforms, where the -filesystem does not always have accurate information about the case of a -filename. On these platforms, there is no guaranteed way to know whether a file -:file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or -:mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all -file names with a capitalized first letter.) The DOS 8+3 filename restriction -adds another interesting problem for long module names. +submodules are present in the package, and imports them all. This could take a +long time and importing sub-modules might have unwanted side-effects that should +only happen when the sub-module is explicitly imported. The only solution is for the package author to provide an explicit index of the package. The :keyword:`import` statement uses the following convention: if a package's @@ -487,10 +486,9 @@ when the ``from...import`` statement is executed. (This also works when ``__all__`` is defined.) -Note that in general the practice of importing ``*`` from a module or package is -frowned upon, since it often causes poorly readable code. However, it is okay to -use it to save typing in interactive sessions, and certain modules are designed -to export only names that follow certain patterns. +Although certain modules are designed to export only names that follow certain +patterns when you use ``import *``, it is still considered bad practise in +production code. Remember, there is nothing wrong with using ``from Package import specific_submodule``! In fact, this is the recommended notation unless the Modified: python/branches/py3k/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.7.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.7.rst Sun Oct 4 16:49:41 2009 @@ -505,6 +505,13 @@ differences. :meth:`assertDictContainsSubset` checks whether all of the key/value pairs in *first* are found in *second*. + * :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` short-circuit + (automatically pass or fail without checking decimal places) if the objects + are equal. + + * :meth:`loadTestsFromName` properly honors the ``suiteClass`` attribute of + the :class:`TestLoader`. (Fixed by Mark Roddy; :issue:`6866`.) + * A new hook, :meth:`addTypeEqualityFunc` takes a type object and a function. The :meth:`assertEqual` method will use the function when both of the objects being compared are of the specified type. Modified: python/branches/py3k/Lib/csv.py ============================================================================== --- python/branches/py3k/Lib/csv.py (original) +++ python/branches/py3k/Lib/csv.py Sun Oct 4 16:49:41 2009 @@ -165,7 +165,7 @@ Returns a dialect (or None) corresponding to the sample """ - quotechar, delimiter, skipinitialspace = \ + quotechar, doublequote, delimiter, skipinitialspace = \ self._guess_quote_and_delimiter(sample, delimiters) if not delimiter: delimiter, skipinitialspace = self._guess_delimiter(sample, @@ -179,8 +179,8 @@ lineterminator = '\r\n' quoting = QUOTE_MINIMAL # escapechar = '' - doublequote = False + dialect.doublequote = doublequote dialect.delimiter = delimiter # _csv.reader won't accept a quotechar of '' dialect.quotechar = quotechar or '"' @@ -212,8 +212,8 @@ break if not matches: - return ('', None, 0) # (quotechar, delimiter, skipinitialspace) - + # (quotechar, doublequote, delimiter, skipinitialspace) + return ('', False, None, 0) quotes = {} delims = {} spaces = 0 @@ -248,7 +248,19 @@ delim = '' skipinitialspace = 0 - return (quotechar, delim, skipinitialspace) + # if we see an extra quote between delimiters, we've got a + # double quoted format + dq_regexp = re.compile(r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ + {'delim':delim, 'quote':quotechar}, re.MULTILINE) + + + + if dq_regexp.search(data): + doublequote = True + else: + doublequote = False + + return (quotechar, doublequote, delim, skipinitialspace) def _guess_delimiter(self, data, delimiters): Modified: python/branches/py3k/Lib/getpass.py ============================================================================== --- python/branches/py3k/Lib/getpass.py (original) +++ python/branches/py3k/Lib/getpass.py Sun Oct 4 16:49:41 2009 @@ -51,7 +51,7 @@ # If that fails, see if stdin can be controlled. try: fd = sys.stdin.fileno() - except: + except (AttributeError, ValueError): passwd = fallback_getpass(prompt, stream) input = sys.stdin if not stream: Modified: python/branches/py3k/Lib/inspect.py ============================================================================== --- python/branches/py3k/Lib/inspect.py (original) +++ python/branches/py3k/Lib/inspect.py Sun Oct 4 16:49:41 2009 @@ -398,12 +398,12 @@ if ismodule(object): if hasattr(object, '__file__'): return object.__file__ - raise TypeError('arg is a built-in module') + raise TypeError('{!r} is a built-in module'.format(object)) if isclass(object): object = sys.modules.get(object.__module__) if hasattr(object, '__file__'): return object.__file__ - raise TypeError('arg is a built-in class') + raise TypeError('{!r} is a built-in class'.format(object)) if ismethod(object): object = object.__func__ if isfunction(object): @@ -414,8 +414,8 @@ object = object.f_code if iscode(object): return object.co_filename - raise TypeError('arg is not a module, class, method, ' - 'function, traceback, frame, or code object') + raise TypeError('{!r} is not a module, class, method, ' + 'function, traceback, frame, or code object'.format(object)) ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type') @@ -747,7 +747,7 @@ names of the * and ** arguments or None.""" if not iscode(co): - raise TypeError('arg is not a code object') + raise TypeError('{!r} is not a code object'.format(co)) nargs = co.co_argcount names = co.co_varnames @@ -811,7 +811,7 @@ if ismethod(func): func = func.__func__ if not isfunction(func): - raise TypeError('arg is not a Python function') + raise TypeError('{!r} is not a Python function'.format(func)) args, varargs, kwonlyargs, varkw = _getfullargs(func.__code__) return FullArgSpec(args, varargs, varkw, func.__defaults__, kwonlyargs, func.__kwdefaults__, func.__annotations__) @@ -944,7 +944,7 @@ else: lineno = frame.f_lineno if not isframe(frame): - raise TypeError('arg is not a frame or traceback object') + raise TypeError('{!r} is not a frame or traceback object'.format(frame)) filename = getsourcefile(frame) or getfile(frame) if context > 0: Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Sun Oct 4 16:49:41 2009 @@ -282,11 +282,14 @@ else: self.thread = None self.threadName = None - if logMultiprocessing: - from multiprocessing import current_process - self.processName = current_process().name - else: + if not logMultiprocessing: self.processName = None + else: + try: + from multiprocessing import current_process + self.processName = current_process().name + except ImportError: + self.processName = None if logProcesses and hasattr(os, 'getpid'): self.process = os.getpid() else: @@ -745,16 +748,16 @@ sys.stdout or sys.stderr may be used. """ - def __init__(self, strm=None): + def __init__(self, stream=None): """ Initialize the handler. - If strm is not specified, sys.stderr is used. + If stream is not specified, sys.stderr is used. """ Handler.__init__(self) - if strm is None: - strm = sys.stderr - self.stream = strm + if stream is None: + stream = sys.stderr + self.stream = stream def flush(self): """ @@ -1124,7 +1127,11 @@ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ - f = currentframe().f_back + f = currentframe() + #On some versions of IronPython, currentframe() returns None if + #IronPython isn't run with -X:Frames. + if f is not None: + f = f.f_back rv = "(unknown file)", 0, "(unknown function)" while hasattr(f, "f_code"): co = f.f_code @@ -1156,7 +1163,8 @@ """ if _srcfile: #IronPython doesn't track Python frames, so findCaller throws an - #exception. We trap it here so that IronPython can use logging. + #exception on some versions of IronPython. We trap it here so that + #IronPython can use logging. try: fn, lno, func = self.findCaller() except ValueError: Modified: python/branches/py3k/Lib/multiprocessing/managers.py ============================================================================== --- python/branches/py3k/Lib/multiprocessing/managers.py (original) +++ python/branches/py3k/Lib/multiprocessing/managers.py Sun Oct 4 16:49:41 2009 @@ -413,7 +413,7 @@ self.id_to_refcount[ident] -= 1 if self.id_to_refcount[ident] == 0: del self.id_to_obj[ident], self.id_to_refcount[ident] - util.debug('disposing of obj with id %d', ident) + util.debug('disposing of obj with id %r', ident) finally: self.mutex.release() Modified: python/branches/py3k/Lib/platform.py ============================================================================== --- python/branches/py3k/Lib/platform.py (original) +++ python/branches/py3k/Lib/platform.py Sun Oct 4 16:49:41 2009 @@ -10,7 +10,7 @@ """ # This module is maintained by Marc-Andre Lemburg . # If you find problems, please submit bug reports/patches via the -# Python SourceForge Project Page and assign them to "lemburg". +# Python bug tracker (http://bugs.python.org) and assign them to "lemburg". # # Still needed: # * more support for WinCE Modified: python/branches/py3k/Lib/test/test___all__.py ============================================================================== --- python/branches/py3k/Lib/test/test___all__.py (original) +++ python/branches/py3k/Lib/test/test___all__.py Sun Oct 4 16:49:41 2009 @@ -82,6 +82,7 @@ self.check_all("keyword") self.check_all("linecache") self.check_all("locale") + self.check_all("logging") self.check_all("macpath") self.check_all("macurl2path") self.check_all("mailbox") Modified: python/branches/py3k/Lib/test/test_csv.py ============================================================================== --- python/branches/py3k/Lib/test/test_csv.py (original) +++ python/branches/py3k/Lib/test/test_csv.py Sun Oct 4 16:49:41 2009 @@ -767,7 +767,7 @@ 'Harry''s':'Arlington Heights':'IL':'2/1/03':'Kimi Hayes' 'Shark City':'Glendale Heights':'IL':'12/28/02':'Prezence' 'Tommy''s Place':'Blue Island':'IL':'12/28/02':'Blue Sunday/White Crow' -'Stonecutters Seafood and Chop House':'Lemont':'IL':'12/19/02':'Week Back' +'Stonecutters ''Seafood'' and Chop House':'Lemont':'IL':'12/19/02':'Week Back' """ header = '''\ "venue","city","state","date","performers" @@ -826,6 +826,13 @@ self.assertEqual(dialect.delimiter, "|") self.assertEqual(dialect.quotechar, "'") + def test_doublequote(self): + sniffer = csv.Sniffer() + dialect = sniffer.sniff(self.header) + self.assertFalse(dialect.doublequote) + dialect = sniffer.sniff(self.sample2) + self.assertTrue(dialect.doublequote) + if not hasattr(sys, "gettotalrefcount"): if support.verbose: print("*** skipping leakage tests ***") else: Modified: python/branches/py3k/Lib/test/test_socket.py ============================================================================== --- python/branches/py3k/Lib/test/test_socket.py (original) +++ python/branches/py3k/Lib/test/test_socket.py Sun Oct 4 16:49:41 2009 @@ -291,7 +291,7 @@ # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) - except SystemError: + except TypeError: if sys.getrefcount(__name__) != orig: self.fail("socket.getnameinfo loses a reference") Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sun Oct 4 16:49:41 2009 @@ -555,6 +555,47 @@ self.assertEqual(list(suite), [testcase_1]) # "The specifier name is a ``dotted name'' that may resolve ... to + # ... a callable object which returns a TestCase ... instance" + #***************************************************************** + #Override the suiteClass attribute to ensure that the suiteClass + #attribute is used + def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self): + class SubTestSuite(unittest.TestSuite): + pass + m = types.ModuleType('m') + testcase_1 = unittest.FunctionTestCase(lambda: None) + def return_TestCase(): + return testcase_1 + m.return_TestCase = return_TestCase + + loader = unittest.TestLoader() + loader.suiteClass = SubTestSuite + suite = loader.loadTestsFromName('return_TestCase', m) + self.assertTrue(isinstance(suite, loader.suiteClass)) + self.assertEqual(list(suite), [testcase_1]) + + # "The specifier name is a ``dotted name'' that may resolve ... to + # ... a test method within a test case class" + #***************************************************************** + #Override the suiteClass attribute to ensure that the suiteClass + #attribute is used + def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self): + class SubTestSuite(unittest.TestSuite): + pass + m = types.ModuleType('m') + class MyTestCase(unittest.TestCase): + def test(self): + pass + m.testcase_1 = MyTestCase + + loader = unittest.TestLoader() + loader.suiteClass=SubTestSuite + suite = loader.loadTestsFromName('testcase_1.test', m) + self.assertTrue(isinstance(suite, loader.suiteClass)) + + self.assertEqual(list(suite), [MyTestCase('test')]) + + # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # What happens if the callable returns something else? @@ -2953,6 +2994,11 @@ self.assertRaises(self.failureException, self.assertNotAlmostEqual, 0, .1+.1j, places=0) + self.assertAlmostEqual(float('inf'), float('inf')) + self.assertRaises(self.failureException, self.assertNotAlmostEqual, + float('inf'), float('inf')) + + def test_assertRaises(self): def _raise(e): raise e @@ -3387,31 +3433,18 @@ class TestDiscovery(TestCase): # Heavily mocked tests so I can avoid hitting the filesystem - def test_get_module_from_path(self): + def test_get_name_from_path(self): loader = unittest.TestLoader() - - old_import = __import__ - def restore_import(): - builtins.__import__ = old_import - builtins.__import__ = lambda *_: None - self.addCleanup(restore_import) - - expected_module = object() - def del_module(): - del sys.modules['bar.baz'] - sys.modules['bar.baz'] = expected_module - self.addCleanup(del_module) - loader._top_level_dir = '/foo' - module = loader._get_module_from_path('/foo/bar/baz.py') - self.assertEqual(module, expected_module) + name = loader._get_name_from_path('/foo/bar/baz.py') + self.assertEqual(name, 'bar.baz') if not __debug__: # asserts are off return with self.assertRaises(AssertionError): - loader._get_module_from_path('/bar/baz.py') + loader._get_name_from_path('/bar/baz.py') def test_find_tests(self): loader = unittest.TestLoader() @@ -3427,7 +3460,7 @@ os.path.isdir = original_isdir path_lists = [['test1.py', 'test2.py', 'not_a_test.py', 'test_dir', - 'test.foo', 'another_dir'], + 'test.foo', 'test-not-a-module.py', 'another_dir'], ['test3.py', 'test4.py', ]] os.listdir = lambda path: path_lists.pop(0) self.addCleanup(restore_listdir) @@ -3443,16 +3476,16 @@ os.path.isfile = isfile self.addCleanup(restore_isfile) - loader._get_module_from_path = lambda path: path + ' module' + loader._get_module_from_name = lambda path: path + ' module' loader.loadTestsFromModule = lambda module: module + ' tests' loader._top_level_dir = '/foo' suite = list(loader._find_tests('/foo', 'test*.py')) - expected = [os.path.join('/foo', name) + ' module tests' for name in - ('test1.py', 'test2.py')] - expected.extend([os.path.join('/foo', 'test_dir', name) + ' module tests' for name in - ('test3.py', 'test4.py')]) + expected = [name + ' module tests' for name in + ('test1', 'test2')] + expected.extend([('test_dir.%s' % name) + ' module tests' for name in + ('test3', 'test4')]) self.assertEqual(suite, expected) def test_find_tests_with_package(self): @@ -3495,7 +3528,7 @@ def __eq__(self, other): return self.path == other.path - loader._get_module_from_path = lambda path: Module(path) + loader._get_module_from_name = lambda name: Module(name) def loadTestsFromModule(module, use_load_tests): if use_load_tests: raise self.failureException('use_load_tests should be False for packages') @@ -3510,15 +3543,12 @@ # We should have loaded tests from the test_directory package by calling load_tests # and directly from the test_directory2 package self.assertEqual(suite, - ['load_tests', - os.path.join('/foo', 'test_directory2') + ' module tests']) - self.assertEqual(Module.paths, [os.path.join('/foo', 'test_directory'), - os.path.join('/foo', 'test_directory2')]) + ['load_tests', 'test_directory2' + ' module tests']) + self.assertEqual(Module.paths, ['test_directory', 'test_directory2']) # load_tests should have been called once with loader, tests and pattern self.assertEqual(Module.load_tests_args, - [(loader, os.path.join('/foo', 'test_directory') + ' module tests', - 'test*')]) + [(loader, 'test_directory' + ' module tests', 'test*')]) def test_discover(self): loader = unittest.TestLoader() @@ -3558,6 +3588,25 @@ self.assertEqual(loader._top_level_dir, top_level_dir) self.assertEqual(_find_tests_args, [(start_dir, 'pattern')]) + def test_discover_with_modules_that_fail_to_import(self): + loader = unittest.TestLoader() + + listdir = os.listdir + os.listdir = lambda _: ['test_this_does_not_exist.py'] + isfile = os.path.isfile + os.path.isfile = lambda _: True + def restore(): + os.path.isfile = isfile + os.listdir = listdir + self.addCleanup(restore) + + suite = loader.discover('.') + self.assertEqual(suite.countTestCases(), 1) + test = list(list(suite)[0])[0] # extract test from suite + + with self.assertRaises(ImportError): + test.test_this_does_not_exist() + def test_command_line_handling_parseArgs(self): # Haha - take that uninstantiable class program = object.__new__(TestProgram) Modified: python/branches/py3k/Lib/textwrap.py ============================================================================== --- python/branches/py3k/Lib/textwrap.py (original) +++ python/branches/py3k/Lib/textwrap.py Sun Oct 4 16:49:41 2009 @@ -135,7 +135,7 @@ """_split(text : string) -> [string] Split the text to wrap into indivisible chunks. Chunks are - not quite the same as words; see wrap_chunks() for full + not quite the same as words; see _wrap_chunks() for full details. As an example, the text Look, goof-ball -- use the -b option! breaks into the following chunks: @@ -163,9 +163,9 @@ space to two. """ i = 0 - pat = self.sentence_end_re + patsearch = self.sentence_end_re.search while i < len(chunks)-1: - if chunks[i+1] == " " and pat.search(chunks[i]): + if chunks[i+1] == " " and patsearch(chunks[i]): chunks[i+1] = " " i += 2 else: Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Sun Oct 4 16:49:41 2009 @@ -468,7 +468,13 @@ Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). + + If the two objects compare equal then they will automatically + compare almost equal. """ + if first == second: + # shortcut for ite + return if round(abs(second-first), places) != 0: standardMsg = '%r != %r within %r places' % (first, second, places) msg = self._formatMessage(msg, standardMsg) @@ -481,8 +487,10 @@ Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). + + Objects that are equal automatically fail. """ - if round(abs(second-first), places) == 0: + if (first == second) or round(abs(second-first), places) == 0: standardMsg = '%r == %r within %r places' % (first, second, places) msg = self._formatMessage(msg, standardMsg) raise self.failureException(msg) Modified: python/branches/py3k/Lib/unittest/loader.py ============================================================================== --- python/branches/py3k/Lib/unittest/loader.py (original) +++ python/branches/py3k/Lib/unittest/loader.py Sun Oct 4 16:49:41 2009 @@ -1,7 +1,9 @@ """Loading unittests.""" import os +import re import sys +import traceback import types from fnmatch import fnmatch @@ -9,6 +11,26 @@ from . import case, suite, util +# what about .pyc or .pyo (etc) +# we would need to avoid loading the same tests multiple times +# from '.py', '.pyc' *and* '.pyo' +VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE) + + +def _make_failed_import_test(name, suiteClass): + message = 'Failed to import test module: %s' % name + if hasattr(traceback, 'format_exc'): + # Python 2.3 compatibility + # format_exc returns two frames of discover.py as well + message += '\n%s' % traceback.format_exc() + + def testImportFailure(self): + raise ImportError(message) + attrs = {name: testImportFailure} + ModuleImportFailure = type('ModuleImportFailure', (case.TestCase,), attrs) + return suiteClass((ModuleImportFailure(name),)) + + class TestLoader(object): """ This class is responsible for loading tests according to various criteria @@ -79,7 +101,7 @@ inst = parent(name) # static methods follow a different path if not isinstance(getattr(inst, name), types.FunctionType): - return suite.TestSuite([inst]) + return self.suiteClass([inst]) elif isinstance(obj, suite.TestSuite): return obj if hasattr(obj, '__call__'): @@ -87,7 +109,7 @@ if isinstance(test, suite.TestSuite): return test elif isinstance(test, case.TestCase): - return suite.TestSuite([test]) + return self.suiteClass([test]) else: raise TypeError("calling %s returned %s, not a test" % (obj, test)) @@ -156,17 +178,17 @@ tests = list(self._find_tests(start_dir, pattern)) return self.suiteClass(tests) - - def _get_module_from_path(self, path): - """Load a module from a path relative to the top-level directory - of a project. Used by discovery.""" + def _get_name_from_path(self, path): path = os.path.splitext(os.path.normpath(path))[0] - relpath = os.path.relpath(path, self._top_level_dir) - assert not os.path.isabs(relpath), "Path must be within the project" - assert not relpath.startswith('..'), "Path must be within the project" + _relpath = os.path.relpath(path, self._top_level_dir) + assert not os.path.isabs(_relpath), "Path must be within the project" + assert not _relpath.startswith('..'), "Path must be within the project" + + name = _relpath.replace(os.path.sep, '.') + return name - name = relpath.replace(os.path.sep, '.') + def _get_module_from_name(self, name): __import__(name) return sys.modules[name] @@ -176,14 +198,20 @@ for path in paths: full_path = os.path.join(start_dir, path) - # what about __init__.pyc or pyo (etc) - # we would need to avoid loading the same tests multiple times - # from '.py', '.pyc' *and* '.pyo' - if os.path.isfile(full_path) and path.lower().endswith('.py'): + if os.path.isfile(full_path): + if not VALID_MODULE_NAME.match(path): + # valid Python identifiers only + continue + if fnmatch(path, pattern): # if the test file matches, load it - module = self._get_module_from_path(full_path) - yield self.loadTestsFromModule(module) + name = self._get_name_from_path(full_path) + try: + module = self._get_module_from_name(name) + except: + yield _make_failed_import_test(name, self.suiteClass) + else: + yield self.loadTestsFromModule(module) elif os.path.isdir(full_path): if not os.path.isfile(os.path.join(full_path, '__init__.py')): continue @@ -192,7 +220,8 @@ tests = None if fnmatch(path, pattern): # only check load_tests if the package directory itself matches the filter - package = self._get_module_from_path(full_path) + name = self._get_name_from_path(full_path) + package = self._get_module_from_name(name) load_tests = getattr(package, 'load_tests', None) tests = self.loadTestsFromModule(package, use_load_tests=False) Modified: python/branches/py3k/Lib/unittest/main.py ============================================================================== --- python/branches/py3k/Lib/unittest/main.py (original) +++ python/branches/py3k/Lib/unittest/main.py Sun Oct 4 16:49:41 2009 @@ -109,9 +109,9 @@ if opt in ('-v','--verbose'): self.verbosity = 2 if len(args) == 0 and self.defaultTest is None: - self.test = self.testLoader.loadTestsFromModule(self.module) - return - if len(args) > 0: + # createTests will load tests from self.module + self.testNames = None + elif len(args) > 0: self.testNames = args if __name__ == '__main__': # to support python -m unittest ... @@ -123,8 +123,11 @@ self.usageExit(msg) def createTests(self): - self.test = self.testLoader.loadTestsFromNames(self.testNames, - self.module) + if self.testNames is None: + self.test = self.testLoader.loadTestsFromModule(self.module) + else: + self.test = self.testLoader.loadTestsFromNames(self.testNames, + self.module) def _do_discovery(self, argv, Loader=loader.TestLoader): # handle command line args for test discovery Modified: python/branches/py3k/Lib/unittest/suite.py ============================================================================== --- python/branches/py3k/Lib/unittest/suite.py (original) +++ python/branches/py3k/Lib/unittest/suite.py Sun Oct 4 16:49:41 2009 @@ -1,6 +1,7 @@ """TestSuite""" from . import case +from . import util class TestSuite(object): @@ -17,7 +18,7 @@ self.addTests(tests) def __repr__(self): - return "<%s tests=%s>" % (_strclass(self.__class__), list(self)) + return "<%s tests=%s>" % (util.strclass(self.__class__), list(self)) def __eq__(self, other): if not isinstance(other, self.__class__): Modified: python/branches/py3k/Misc/developers.txt ============================================================================== --- python/branches/py3k/Misc/developers.txt (original) +++ python/branches/py3k/Misc/developers.txt Sun Oct 4 16:49:41 2009 @@ -20,6 +20,9 @@ Permissions History ------------------- +- Doug Hellmann was given SVN access on September 19 2009 by GFB, at + suggestion of Jesse Noller, for documentation work. + - Ezio Melotti was given SVN access on June 7 2009 by GFB, for work on and fixes to the documentation. @@ -109,6 +112,13 @@ - Jeffrey Yasskin was given SVN access on 9 August 2007 by NCN, for his work on PEPs and other general patches. +- Mark Summerfield was given SVN access on 1 August 2007 by GFB, + for work on documentation. + +- Armin Ronacher was given SVN access on 23 July 2007 by GFB, + for work on the documentation toolset. He now maintains the + ast module. + - Senthil Kumaran was given SVN access on 16 June 2007 by MvL, for his Summer-of-Code project, mentored by Skip Montanaro. Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Sun Oct 4 16:49:41 2009 @@ -3909,8 +3909,13 @@ flags = flowinfo = scope_id = 0; if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) return NULL; - if (!PyArg_ParseTuple(sa, "si|ii", - &hostp, &port, &flowinfo, &scope_id)) + if (!PyTuple_Check(sa)) { + PyErr_SetString(PyExc_TypeError, + "getnameinfo() argument 1 must be a tuple"); + return NULL; + } + if (!PyArg_ParseTuple(sa, "si|ii", + &hostp, &port, &flowinfo, &scope_id)) return NULL; PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); memset(&hints, 0, sizeof(hints)); @@ -3933,9 +3938,7 @@ switch (res->ai_family) { case AF_INET: { - char *t1; - int t2; - if (PyArg_ParseTuple(sa, "si", &t1, &t2) == 0) { + if (PyTuple_GET_SIZE(sa) != 2) { PyErr_SetString(socket_error, "IPv4 sockaddr must be 2 tuple"); goto fail; From python-checkins at python.org Sun Oct 4 16:54:53 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 14:54:53 -0000 Subject: [Python-checkins] r75232 - in python/branches/release31-maint: Doc/c-api/init.rst Doc/c-api/unicode.rst Doc/documenting/markup.rst Doc/library/codecs.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/hashlib.rst Doc/library/inspect.rst Doc/library/logging.rst Doc/library/shelve.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/termios.rst Doc/library/threading.rst Doc/tutorial/interpreter.rst Doc/tutorial/modules.rst Doc/whatsnew/2.7.rst Lib/csv.py Lib/getpass.py Lib/inspect.py Lib/logging/__init__.py Lib/multiprocessing/managers.py Lib/platform.py Lib/test/test___all__.py Lib/test/test_csv.py Lib/test/test_socket.py Lib/textwrap.py Misc/developers.txt Modules/socketmodule.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 16:54:52 2009 New Revision: 75232 Log: Merged revisions 75231 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75231 | benjamin.peterson | 2009-10-04 09:49:41 -0500 (Sun, 04 Oct 2009) | 166 lines Merged revisions 74779-74786,74793,74795,74811,74860-74861,74863,74876,74886,74896,74901,74903,74908,74912,74930,74933,74943,74946,74952-74955,75015,75019,75032,75068,75076,75095,75098,75102,75129,75139,75230 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74779 | michael.foord | 2009-09-13 11:13:36 -0500 (Sun, 13 Sep 2009) | 1 line Change to tutorial wording for reading text / binary files on Windows. Issue #6301. ........ r74780 | michael.foord | 2009-09-13 11:40:02 -0500 (Sun, 13 Sep 2009) | 1 line Objects that compare equal automatically pass or fail assertAlmostEqual and assertNotAlmostEqual tests on unittest.TestCase. Issue 6567. ........ r74781 | michael.foord | 2009-09-13 11:46:19 -0500 (Sun, 13 Sep 2009) | 1 line Note that sys._getframe is not guaranteed to exist in all implementations of Python, and a corresponding note in inspect.currentframe. Issue 6712. ........ r74782 | michael.foord | 2009-09-13 12:07:46 -0500 (Sun, 13 Sep 2009) | 1 line Tutorial tweaks. Issue 6849. ........ r74783 | michael.foord | 2009-09-13 12:28:35 -0500 (Sun, 13 Sep 2009) | 1 line unittest.TestLoader.loadTestsFromName honors the loader suiteClass attribute. Issue 6866. ........ r74784 | georg.brandl | 2009-09-13 13:15:07 -0500 (Sun, 13 Sep 2009) | 1 line Typo fix. ........ r74785 | michael.foord | 2009-09-13 14:07:03 -0500 (Sun, 13 Sep 2009) | 1 line Test discovery in unittest will only attempt to import modules that are importable; i.e. their names are valid Python identifiers. If an import fails during discovery this will be recorded as an error and test discovery will continue. Issue 6568. ........ r74786 | michael.foord | 2009-09-13 14:08:18 -0500 (Sun, 13 Sep 2009) | 1 line Remove an extraneous space in unittest documentation. ........ r74793 | georg.brandl | 2009-09-14 09:50:47 -0500 (Mon, 14 Sep 2009) | 1 line #6908: fix association of hashlib hash attributes. ........ r74795 | benjamin.peterson | 2009-09-14 22:36:26 -0500 (Mon, 14 Sep 2009) | 1 line Py_SetPythonHome uses static storage #6913 ........ r74811 | georg.brandl | 2009-09-15 15:26:59 -0500 (Tue, 15 Sep 2009) | 1 line Add Armin Ronacher. ........ r74860 | benjamin.peterson | 2009-09-16 21:46:54 -0500 (Wed, 16 Sep 2009) | 1 line kill bare except ........ r74861 | benjamin.peterson | 2009-09-16 22:18:28 -0500 (Wed, 16 Sep 2009) | 1 line pep 8 defaults ........ r74863 | benjamin.peterson | 2009-09-16 22:27:33 -0500 (Wed, 16 Sep 2009) | 1 line rationalize a bit ........ r74876 | georg.brandl | 2009-09-17 11:15:53 -0500 (Thu, 17 Sep 2009) | 1 line #6932: remove paragraph that advises relying on __del__ being called. ........ r74886 | benjamin.peterson | 2009-09-17 16:33:46 -0500 (Thu, 17 Sep 2009) | 1 line use macros ........ r74896 | georg.brandl | 2009-09-18 02:22:41 -0500 (Fri, 18 Sep 2009) | 1 line #6936: for interactive use, quit() is just fine. ........ r74901 | georg.brandl | 2009-09-18 04:14:52 -0500 (Fri, 18 Sep 2009) | 1 line #6905: use better exception messages in inspect when the argument is of the wrong type. ........ r74903 | georg.brandl | 2009-09-18 04:18:27 -0500 (Fri, 18 Sep 2009) | 1 line #6938: "ident" is always a string, so use a format code which works. ........ r74908 | georg.brandl | 2009-09-18 08:57:11 -0500 (Fri, 18 Sep 2009) | 1 line Use str.format() to fix beginner's mistake with %-style string formatting. ........ r74912 | georg.brandl | 2009-09-18 11:19:56 -0500 (Fri, 18 Sep 2009) | 1 line Optimize optimization and fix method name in docstring. ........ r74930 | georg.brandl | 2009-09-18 16:21:41 -0500 (Fri, 18 Sep 2009) | 1 line #6925: rewrite docs for locals() and vars() a bit. ........ r74933 | georg.brandl | 2009-09-18 16:35:59 -0500 (Fri, 18 Sep 2009) | 1 line #6930: clarify description about byteorder handling in UTF decoder routines. ........ r74943 | georg.brandl | 2009-09-19 02:35:07 -0500 (Sat, 19 Sep 2009) | 1 line #6944: the argument to PyArg_ParseTuple should be a tuple, otherwise a SystemError is set. Also clean up another usage of PyArg_ParseTuple. ........ r74946 | georg.brandl | 2009-09-19 03:43:16 -0500 (Sat, 19 Sep 2009) | 1 line Update bug tracker reference. ........ r74952 | georg.brandl | 2009-09-19 05:42:34 -0500 (Sat, 19 Sep 2009) | 1 line #6946: fix duplicate index entries for datetime classes. ........ r74953 | georg.brandl | 2009-09-19 07:04:16 -0500 (Sat, 19 Sep 2009) | 1 line Fix references to threading.enumerate(). ........ r74954 | georg.brandl | 2009-09-19 08:13:56 -0500 (Sat, 19 Sep 2009) | 1 line Add Doug. ........ r74955 | georg.brandl | 2009-09-19 08:20:49 -0500 (Sat, 19 Sep 2009) | 1 line Add Mark Summerfield. ........ r75015 | georg.brandl | 2009-09-22 05:55:08 -0500 (Tue, 22 Sep 2009) | 1 line Fix encoding name. ........ r75019 | vinay.sajip | 2009-09-22 12:23:41 -0500 (Tue, 22 Sep 2009) | 1 line Fixed a typo, and added sections on optimization and using arbitrary objects as messages. ........ r75032 | benjamin.peterson | 2009-09-22 17:15:28 -0500 (Tue, 22 Sep 2009) | 1 line fix typos/rephrase ........ r75068 | benjamin.peterson | 2009-09-25 21:57:59 -0500 (Fri, 25 Sep 2009) | 1 line comment out ugly xxx ........ r75076 | vinay.sajip | 2009-09-26 09:53:32 -0500 (Sat, 26 Sep 2009) | 1 line Tidied up name of parameter in StreamHandler ........ r75095 | michael.foord | 2009-09-27 14:15:41 -0500 (Sun, 27 Sep 2009) | 1 line Test creation moved from TestProgram.parseArgs to TestProgram.createTests exclusively. Issue 6956. ........ r75098 | michael.foord | 2009-09-27 15:08:23 -0500 (Sun, 27 Sep 2009) | 1 line Documentation improvement for load_tests protocol in unittest. Issue 6515. ........ r75102 | skip.montanaro | 2009-09-27 21:12:27 -0500 (Sun, 27 Sep 2009) | 3 lines Patch from Thomas Barr so that csv.Sniffer will set doublequote property. Closes issue 6606. ........ r75129 | vinay.sajip | 2009-09-29 02:08:54 -0500 (Tue, 29 Sep 2009) | 1 line Issue #7014: logging: Improved IronPython 2.6 compatibility. ........ r75139 | raymond.hettinger | 2009-09-29 13:53:24 -0500 (Tue, 29 Sep 2009) | 3 lines Issue 7008: Better document str.title and show how to work around the apostrophe problem. ........ r75230 | benjamin.peterson | 2009-10-04 08:38:38 -0500 (Sun, 04 Oct 2009) | 1 line test logging ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/c-api/init.rst python/branches/release31-maint/Doc/c-api/unicode.rst python/branches/release31-maint/Doc/documenting/markup.rst python/branches/release31-maint/Doc/library/codecs.rst python/branches/release31-maint/Doc/library/datetime.rst python/branches/release31-maint/Doc/library/functions.rst python/branches/release31-maint/Doc/library/hashlib.rst python/branches/release31-maint/Doc/library/inspect.rst python/branches/release31-maint/Doc/library/logging.rst python/branches/release31-maint/Doc/library/shelve.rst python/branches/release31-maint/Doc/library/stdtypes.rst python/branches/release31-maint/Doc/library/sys.rst python/branches/release31-maint/Doc/library/termios.rst python/branches/release31-maint/Doc/library/threading.rst python/branches/release31-maint/Doc/tutorial/interpreter.rst python/branches/release31-maint/Doc/tutorial/modules.rst python/branches/release31-maint/Doc/whatsnew/2.7.rst python/branches/release31-maint/Lib/csv.py python/branches/release31-maint/Lib/getpass.py python/branches/release31-maint/Lib/inspect.py python/branches/release31-maint/Lib/logging/__init__.py python/branches/release31-maint/Lib/multiprocessing/managers.py python/branches/release31-maint/Lib/platform.py python/branches/release31-maint/Lib/test/test___all__.py python/branches/release31-maint/Lib/test/test_csv.py python/branches/release31-maint/Lib/test/test_socket.py python/branches/release31-maint/Lib/textwrap.py python/branches/release31-maint/Misc/developers.txt python/branches/release31-maint/Modules/socketmodule.c Modified: python/branches/release31-maint/Doc/c-api/init.rst ============================================================================== --- python/branches/release31-maint/Doc/c-api/init.rst (original) +++ python/branches/release31-maint/Doc/c-api/init.rst Sun Oct 4 16:54:52 2009 @@ -371,6 +371,10 @@ Set the default "home" directory, that is, the location of the standard Python libraries. The libraries are searched in :file:`{home}/lib/python{version}` and :file:`{home}/lib/python{version}`. + The argument should point to a zero-terminated character string in static + storage whose contents will not change for the duration of the program's + execution. No code in the Python interpreter will change the contents of + this storage. .. cfunction:: w_char* Py_GetPythonHome() Modified: python/branches/release31-maint/Doc/c-api/unicode.rst ============================================================================== --- python/branches/release31-maint/Doc/c-api/unicode.rst (original) +++ python/branches/release31-maint/Doc/c-api/unicode.rst Sun Oct 4 16:54:52 2009 @@ -476,10 +476,13 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first four bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the end of input data. + If ``*byteorder`` is zero, and the first four bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output. + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. In a narrow build codepoints outside the BMP will be decoded as surrogate pairs. @@ -500,8 +503,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-32 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) @@ -541,10 +543,14 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first two bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the end of input data. + If ``*byteorder`` is zero, and the first two bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output (where it will result in + either a ``\ufeff`` or a ``\ufffe`` character). + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. If *byteorder* is *NULL*, the codec starts in native order mode. @@ -563,8 +569,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-16 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) Modified: python/branches/release31-maint/Doc/documenting/markup.rst ============================================================================== --- python/branches/release31-maint/Doc/documenting/markup.rst (original) +++ python/branches/release31-maint/Doc/documenting/markup.rst Sun Oct 4 16:54:52 2009 @@ -597,8 +597,10 @@ An important bit of information about an API that a user should be aware of when using whatever bit of API the warning pertains to. The content of the directive should be written in complete sentences and include all appropriate - punctuation. This should only be chosen over ``note`` for information - regarding the possibility of crashes, data loss, or security implications. + punctuation. In the interest of not scaring users away from pages filled + with warnings, this directive should only be chosen over ``note`` for + information regarding the possibility of crashes, data loss, or security + implications. .. describe:: versionadded Modified: python/branches/release31-maint/Doc/library/codecs.rst ============================================================================== --- python/branches/release31-maint/Doc/library/codecs.rst (original) +++ python/branches/release31-maint/Doc/library/codecs.rst Sun Oct 4 16:54:52 2009 @@ -986,7 +986,7 @@ +-----------------+--------------------------------+--------------------------------+ | cp1255 | windows-1255 | Hebrew | +-----------------+--------------------------------+--------------------------------+ -| cp1256 | windows1256 | Arabic | +| cp1256 | windows-1256 | Arabic | +-----------------+--------------------------------+--------------------------------+ | cp1257 | windows-1257 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ Modified: python/branches/release31-maint/Doc/library/datetime.rst ============================================================================== --- python/branches/release31-maint/Doc/library/datetime.rst (original) +++ python/branches/release31-maint/Doc/library/datetime.rst Sun Oct 4 16:54:52 2009 @@ -63,6 +63,7 @@ .. class:: date + :noindex: An idealized naive date, assuming the current Gregorian calendar always was, and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, and @@ -70,6 +71,7 @@ .. class:: time + :noindex: An idealized time, independent of any particular day, assuming that every day has exactly 24\*60\*60 seconds (there is no notion of "leap seconds" here). @@ -78,6 +80,7 @@ .. class:: datetime + :noindex: A combination of a date and a time. Attributes: :attr:`year`, :attr:`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:`microsecond`, @@ -85,6 +88,7 @@ .. class:: timedelta + :noindex: A duration expressing the difference between two :class:`date`, :class:`time`, or :class:`datetime` instances to microsecond resolution. Modified: python/branches/release31-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release31-maint/Doc/library/functions.rst (original) +++ python/branches/release31-maint/Doc/library/functions.rst Sun Oct 4 16:54:52 2009 @@ -600,16 +600,12 @@ .. function:: locals() Update and return a dictionary representing the current local symbol table. + Free variables are returned by :func:`locals` when it is called in function + blocks, but not in class blocks. .. note:: - The contents of this dictionary should not be modified; changes may not - affect the values of local variables used by the interpreter. - - Free variables are returned by :func:`locals` when it is called in a function - block. Modifications of free variables may not affect the values used by the - interpreter. Free variables are not returned in class blocks. - + affect the values of local and free variables used by the interpreter. .. function:: map(function, iterable, ...) @@ -1172,10 +1168,10 @@ .. function:: vars([object]) - Without arguments, return a dictionary corresponding to the current local symbol - table. With a module, class or class instance object as argument (or anything - else that has a :attr:`__dict__` attribute), returns a dictionary corresponding - to the object's symbol table. + Without an argument, act like :func:`locals`. + + With a module, class or class instance object as argument (or anything else that + has a :attr:`__dict__` attribute), return that attribute. .. note:: The returned dictionary should not be modified: Modified: python/branches/release31-maint/Doc/library/hashlib.rst ============================================================================== --- python/branches/release31-maint/Doc/library/hashlib.rst (original) +++ python/branches/release31-maint/Doc/library/hashlib.rst Sun Oct 4 16:54:52 2009 @@ -86,11 +86,11 @@ returned by the constructors: -.. data:: digest_size +.. data:: hash.digest_size The size of the resulting hash in bytes. -.. data:: block_size +.. data:: hash.block_size The internal block size of the hash algorithm in bytes. Modified: python/branches/release31-maint/Doc/library/inspect.rst ============================================================================== --- python/branches/release31-maint/Doc/library/inspect.rst (original) +++ python/branches/release31-maint/Doc/library/inspect.rst Sun Oct 4 16:54:52 2009 @@ -508,6 +508,11 @@ Return the frame object for the caller's stack frame. + This function relies on Python stack frame support in the interpreter, which + isn't guaranteed to exist in all implementations of Python. If running in + an implementation without Python stack frame support this function returns + ``None``. + .. function:: stack(context=1) Modified: python/branches/release31-maint/Doc/library/logging.rst ============================================================================== --- python/branches/release31-maint/Doc/library/logging.rst (original) +++ python/branches/release31-maint/Doc/library/logging.rst Sun Oct 4 16:54:52 2009 @@ -57,7 +57,7 @@ import logging LOG_FILENAME = '/tmp/logging_example.out' - logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('This message should go to the log file') @@ -1447,6 +1447,55 @@ 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly. +Using arbitrary objects as messages +----------------------------------- + +In the preceding sections and examples, it has been assumed that the message +passed when logging the event is a string. However, this is not the only +possibility. You can pass an arbitrary object as a message, and its +:meth:`__str__` method will be called when the logging system needs to convert +it to a string representation. In fact, if you want to, you can avoid +computing a string representation altogether - for example, the +:class:`SocketHandler` emits an event by pickling it and sending it over the +wire. + +Optimization +------------ + +Formatting of message arguments is deferred until it cannot be avoided. +However, computing the arguments passed to the logging method can also be +expensive, and you may want to avoid doing it if the logger will just throw +away your event. To decide what to do, you can call the :meth:`isEnabledFor` +method which takes a level argument and returns true if the event would be +created by the Logger for that level of call. You can write code like this:: + + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Message with %s, %s", expensive_func1(), + expensive_func2()) + +so that if the logger's threshold is set above ``DEBUG``, the calls to +:func:`expensive_func1` and :func:`expensive_func2` are never made. + +There are other optimizations which can be made for specific applications which +need more precise control over what logging information is collected. Here's a +list of things you can do to avoid processing during logging which you don't +need: + ++-----------------------------------------------+----------------------------------------+ +| What you don't want to collect | How to avoid collecting it | ++===============================================+========================================+ +| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. | ++-----------------------------------------------+----------------------------------------+ +| Threading information. | Set ``logging.logThreads`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ +| Process information. | Set ``logging.logProcesses`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ + +Also note that the core logging module only includes the basic handlers. If +you don't import :mod:`logging.handlers` and :mod:`logging.config`, they won't +take up any memory. + +.. _handler: Handler Objects --------------- @@ -1562,9 +1611,9 @@ and :meth:`flush` methods). -.. class:: StreamHandler(strm=None) +.. class:: StreamHandler(stream=None) - Returns a new instance of the :class:`StreamHandler` class. If *strm* is + Returns a new instance of the :class:`StreamHandler` class. If *stream* is specified, the instance will use it for logging output; otherwise, *sys.stderr* will be used. Modified: python/branches/release31-maint/Doc/library/shelve.rst ============================================================================== --- python/branches/release31-maint/Doc/library/shelve.rst (original) +++ python/branches/release31-maint/Doc/library/shelve.rst Sun Oct 4 16:54:52 2009 @@ -27,27 +27,39 @@ Because of Python semantics, a shelf cannot know when a mutable persistent-dictionary entry is modified. By default modified objects are - written only when assigned to the shelf (see :ref:`shelve-example`). If - the optional *writeback* parameter is set to *True*, all entries accessed - are cached in memory, and written back at close time; this can make it - handier to mutate mutable entries in the persistent dictionary, but, if - many entries are accessed, it can consume vast amounts of memory for the - cache, and it can make the close operation very slow since all accessed - entries are written back (there is no way to determine which accessed - entries are mutable, nor which ones were actually mutated). + written only when assigned to the shelf (see :ref:`shelve-example`). If the + optional *writeback* parameter is set to *True*, all entries accessed are + cached in memory, and written back on :meth:`sync` and :meth:`close`; this + can make it handier to mutate mutable entries in the persistent dictionary, + but, if many entries are accessed, it can consume vast amounts of memory for + the cache, and it can make the close operation very slow since all accessed + entries are written back (there is no way to determine which accessed entries + are mutable, nor which ones were actually mutated). + + .. note:: + + Do not rely on the shelf being closed automatically; always call + :meth:`close` explicitly when you don't need it any more, or use a + :keyword:`with` statement with :func:`contextlib.closing`. + Shelf objects support all methods supported by dictionaries. This eases the transition from dictionary based scripts to those requiring persistent storage. -One additional method is supported: - +Two additional methods are supported: .. method:: Shelf.sync() - Write back all entries in the cache if the shelf was opened with *writeback* set - to *True*. Also empty the cache and synchronize the persistent dictionary on - disk, if feasible. This is called automatically when the shelf is closed with - :meth:`close`. + Write back all entries in the cache if the shelf was opened with *writeback* + set to :const:`True`. Also empty the cache and synchronize the persistent + dictionary on disk, if feasible. This is called automatically when the shelf + is closed with :meth:`close`. + +.. method:: Shelf.close() + + Synchronize and close the persistent *dict* object. Operations on a closed + shelf will fail with a :exc:`ValueError`. + .. seealso:: @@ -71,11 +83,6 @@ database should be fairly small, and in rare cases key collisions may cause the database to refuse updates. -* Depending on the implementation, closing a persistent dictionary may or may - not be necessary to flush changes to disk. The :meth:`__del__` method of the - :class:`Shelf` class calls the :meth:`close` method, so the programmer generally - need not do this explicitly. - * The :mod:`shelve` module does not support *concurrent* read/write access to shelved objects. (Multiple simultaneous read accesses are safe.) When a program has a shelf open for writing, no other program should have it open for Modified: python/branches/release31-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release31-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release31-maint/Doc/library/stdtypes.rst Sun Oct 4 16:54:52 2009 @@ -1148,6 +1148,8 @@ >>> titlecase("they're bill's friends.") "They're Bill's Friends." + For 8-bit strings, this method is locale-dependent. + .. method:: str.translate(map) Modified: python/branches/release31-maint/Doc/library/sys.rst ============================================================================== --- python/branches/release31-maint/Doc/library/sys.rst (original) +++ python/branches/release31-maint/Doc/library/sys.rst Sun Oct 4 16:54:52 2009 @@ -337,12 +337,12 @@ does not have to hold true for third-party extensions as it is implementation specific. - The *default* argument allows to define a value which will be returned - if the object type does not provide means to retrieve the size and would - cause a `TypeError`. + If given, *default* will be returned if the object does not provide means to + retrieve the size. Otherwise a `TypeError` will be raised. - :func:`getsizeof` calls the object's __sizeof__ method and adds an additional - garbage collector overhead if the object is managed by the garbage collector. + :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an + additional garbage collector overhead if the object is managed by the garbage + collector. .. function:: _getframe([depth]) @@ -352,7 +352,8 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. + This function should be used for internal and specialized purposes only. It + is not guaranteed to exist in all implementations of Python. .. function:: getprofile() Modified: python/branches/release31-maint/Doc/library/termios.rst ============================================================================== --- python/branches/release31-maint/Doc/library/termios.rst (original) +++ python/branches/release31-maint/Doc/library/termios.rst Sun Oct 4 16:54:52 2009 @@ -89,7 +89,7 @@ :keyword:`finally` statement to ensure that the old tty attributes are restored exactly no matter what happens:: - def getpass(prompt = "Password: "): + def getpass(prompt="Password: "): import termios, sys fd = sys.stdin.fileno() old = termios.tcgetattr(fd) Modified: python/branches/release31-maint/Doc/library/threading.rst ============================================================================== --- python/branches/release31-maint/Doc/library/threading.rst (original) +++ python/branches/release31-maint/Doc/library/threading.rst Sun Oct 4 16:54:52 2009 @@ -23,7 +23,7 @@ .. function:: active_count() Return the number of :class:`Thread` objects currently alive. The returned - count is equal to the length of the list returned by :func:`enumerate`. + count is equal to the length of the list returned by :func:`.enumerate`. .. function:: Condition() @@ -301,7 +301,7 @@ Roughly, a thread is alive from the moment the :meth:`start` method returns until its :meth:`run` method terminates. The module function - :func:`enumerate` returns a list of all alive threads. + :func:`.enumerate` returns a list of all alive threads. .. attribute:: daemon Modified: python/branches/release31-maint/Doc/tutorial/interpreter.rst ============================================================================== --- python/branches/release31-maint/Doc/tutorial/interpreter.rst (original) +++ python/branches/release31-maint/Doc/tutorial/interpreter.rst Sun Oct 4 16:54:52 2009 @@ -31,7 +31,7 @@ Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn't work, you can exit the interpreter by typing the -following commands: ``import sys; sys.exit()``. +following command: ``quit()``. The interpreter's line-editing features usually aren't very sophisticated. On Unix, whoever installed the interpreter may have enabled support for the GNU Modified: python/branches/release31-maint/Doc/tutorial/modules.rst ============================================================================== --- python/branches/release31-maint/Doc/tutorial/modules.rst (original) +++ python/branches/release31-maint/Doc/tutorial/modules.rst Sun Oct 4 16:54:52 2009 @@ -107,6 +107,10 @@ an unknown set of names into the interpreter, possibly hiding some things you have already defined. +Note that in general the practice of importing ``*`` from a module or package is +frowned upon, since it often causes poorly readable code. However, it is okay to +use it to save typing in interactive sessions. + .. note:: For efficiency reasons, each module is only imported once per interpreter @@ -445,14 +449,9 @@ Now what happens when the user writes ``from sound.effects import *``? Ideally, one would hope that this somehow goes out to the filesystem, finds which -submodules are present in the package, and imports them all. Unfortunately, -this operation does not work very well on Windows platforms, where the -filesystem does not always have accurate information about the case of a -filename. On these platforms, there is no guaranteed way to know whether a file -:file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or -:mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all -file names with a capitalized first letter.) The DOS 8+3 filename restriction -adds another interesting problem for long module names. +submodules are present in the package, and imports them all. This could take a +long time and importing sub-modules might have unwanted side-effects that should +only happen when the sub-module is explicitly imported. The only solution is for the package author to provide an explicit index of the package. The :keyword:`import` statement uses the following convention: if a package's @@ -487,10 +486,9 @@ when the ``from...import`` statement is executed. (This also works when ``__all__`` is defined.) -Note that in general the practice of importing ``*`` from a module or package is -frowned upon, since it often causes poorly readable code. However, it is okay to -use it to save typing in interactive sessions, and certain modules are designed -to export only names that follow certain patterns. +Although certain modules are designed to export only names that follow certain +patterns when you use ``import *``, it is still considered bad practise in +production code. Remember, there is nothing wrong with using ``from Package import specific_submodule``! In fact, this is the recommended notation unless the Modified: python/branches/release31-maint/Doc/whatsnew/2.7.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.7.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.7.rst Sun Oct 4 16:54:52 2009 @@ -505,6 +505,13 @@ differences. :meth:`assertDictContainsSubset` checks whether all of the key/value pairs in *first* are found in *second*. + * :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` short-circuit + (automatically pass or fail without checking decimal places) if the objects + are equal. + + * :meth:`loadTestsFromName` properly honors the ``suiteClass`` attribute of + the :class:`TestLoader`. (Fixed by Mark Roddy; :issue:`6866`.) + * A new hook, :meth:`addTypeEqualityFunc` takes a type object and a function. The :meth:`assertEqual` method will use the function when both of the objects being compared are of the specified type. Modified: python/branches/release31-maint/Lib/csv.py ============================================================================== --- python/branches/release31-maint/Lib/csv.py (original) +++ python/branches/release31-maint/Lib/csv.py Sun Oct 4 16:54:52 2009 @@ -165,7 +165,7 @@ Returns a dialect (or None) corresponding to the sample """ - quotechar, delimiter, skipinitialspace = \ + quotechar, doublequote, delimiter, skipinitialspace = \ self._guess_quote_and_delimiter(sample, delimiters) if not delimiter: delimiter, skipinitialspace = self._guess_delimiter(sample, @@ -179,8 +179,8 @@ lineterminator = '\r\n' quoting = QUOTE_MINIMAL # escapechar = '' - doublequote = False + dialect.doublequote = doublequote dialect.delimiter = delimiter # _csv.reader won't accept a quotechar of '' dialect.quotechar = quotechar or '"' @@ -212,8 +212,8 @@ break if not matches: - return ('', None, 0) # (quotechar, delimiter, skipinitialspace) - + # (quotechar, doublequote, delimiter, skipinitialspace) + return ('', False, None, 0) quotes = {} delims = {} spaces = 0 @@ -248,7 +248,19 @@ delim = '' skipinitialspace = 0 - return (quotechar, delim, skipinitialspace) + # if we see an extra quote between delimiters, we've got a + # double quoted format + dq_regexp = re.compile(r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ + {'delim':delim, 'quote':quotechar}, re.MULTILINE) + + + + if dq_regexp.search(data): + doublequote = True + else: + doublequote = False + + return (quotechar, doublequote, delim, skipinitialspace) def _guess_delimiter(self, data, delimiters): Modified: python/branches/release31-maint/Lib/getpass.py ============================================================================== --- python/branches/release31-maint/Lib/getpass.py (original) +++ python/branches/release31-maint/Lib/getpass.py Sun Oct 4 16:54:52 2009 @@ -51,7 +51,7 @@ # If that fails, see if stdin can be controlled. try: fd = sys.stdin.fileno() - except: + except (AttributeError, ValueError): passwd = fallback_getpass(prompt, stream) input = sys.stdin if not stream: Modified: python/branches/release31-maint/Lib/inspect.py ============================================================================== --- python/branches/release31-maint/Lib/inspect.py (original) +++ python/branches/release31-maint/Lib/inspect.py Sun Oct 4 16:54:52 2009 @@ -398,12 +398,12 @@ if ismodule(object): if hasattr(object, '__file__'): return object.__file__ - raise TypeError('arg is a built-in module') + raise TypeError('{!r} is a built-in module'.format(object)) if isclass(object): object = sys.modules.get(object.__module__) if hasattr(object, '__file__'): return object.__file__ - raise TypeError('arg is a built-in class') + raise TypeError('{!r} is a built-in class'.format(object)) if ismethod(object): object = object.__func__ if isfunction(object): @@ -414,8 +414,8 @@ object = object.f_code if iscode(object): return object.co_filename - raise TypeError('arg is not a module, class, method, ' - 'function, traceback, frame, or code object') + raise TypeError('{!r} is not a module, class, method, ' + 'function, traceback, frame, or code object'.format(object)) ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type') @@ -747,7 +747,7 @@ names of the * and ** arguments or None.""" if not iscode(co): - raise TypeError('arg is not a code object') + raise TypeError('{!r} is not a code object'.format(co)) nargs = co.co_argcount names = co.co_varnames @@ -811,7 +811,7 @@ if ismethod(func): func = func.__func__ if not isfunction(func): - raise TypeError('arg is not a Python function') + raise TypeError('{!r} is not a Python function'.format(func)) args, varargs, kwonlyargs, varkw = _getfullargs(func.__code__) return FullArgSpec(args, varargs, varkw, func.__defaults__, kwonlyargs, func.__kwdefaults__, func.__annotations__) @@ -944,7 +944,7 @@ else: lineno = frame.f_lineno if not isframe(frame): - raise TypeError('arg is not a frame or traceback object') + raise TypeError('{!r} is not a frame or traceback object'.format(frame)) filename = getsourcefile(frame) or getfile(frame) if context > 0: Modified: python/branches/release31-maint/Lib/logging/__init__.py ============================================================================== --- python/branches/release31-maint/Lib/logging/__init__.py (original) +++ python/branches/release31-maint/Lib/logging/__init__.py Sun Oct 4 16:54:52 2009 @@ -271,11 +271,14 @@ else: self.thread = None self.threadName = None - if logMultiprocessing: - from multiprocessing import current_process - self.processName = current_process().name - else: + if not logMultiprocessing: self.processName = None + else: + try: + from multiprocessing import current_process + self.processName = current_process().name + except ImportError: + self.processName = None if logProcesses and hasattr(os, 'getpid'): self.process = os.getpid() else: @@ -734,16 +737,16 @@ sys.stdout or sys.stderr may be used. """ - def __init__(self, strm=None): + def __init__(self, stream=None): """ Initialize the handler. - If strm is not specified, sys.stderr is used. + If stream is not specified, sys.stderr is used. """ Handler.__init__(self) - if strm is None: - strm = sys.stderr - self.stream = strm + if stream is None: + stream = sys.stderr + self.stream = stream def flush(self): """ @@ -1113,7 +1116,11 @@ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ - f = currentframe().f_back + f = currentframe() + #On some versions of IronPython, currentframe() returns None if + #IronPython isn't run with -X:Frames. + if f is not None: + f = f.f_back rv = "(unknown file)", 0, "(unknown function)" while hasattr(f, "f_code"): co = f.f_code @@ -1145,7 +1152,8 @@ """ if _srcfile: #IronPython doesn't track Python frames, so findCaller throws an - #exception. We trap it here so that IronPython can use logging. + #exception on some versions of IronPython. We trap it here so that + #IronPython can use logging. try: fn, lno, func = self.findCaller() except ValueError: Modified: python/branches/release31-maint/Lib/multiprocessing/managers.py ============================================================================== --- python/branches/release31-maint/Lib/multiprocessing/managers.py (original) +++ python/branches/release31-maint/Lib/multiprocessing/managers.py Sun Oct 4 16:54:52 2009 @@ -413,7 +413,7 @@ self.id_to_refcount[ident] -= 1 if self.id_to_refcount[ident] == 0: del self.id_to_obj[ident], self.id_to_refcount[ident] - util.debug('disposing of obj with id %d', ident) + util.debug('disposing of obj with id %r', ident) finally: self.mutex.release() Modified: python/branches/release31-maint/Lib/platform.py ============================================================================== --- python/branches/release31-maint/Lib/platform.py (original) +++ python/branches/release31-maint/Lib/platform.py Sun Oct 4 16:54:52 2009 @@ -10,7 +10,7 @@ """ # This module is maintained by Marc-Andre Lemburg . # If you find problems, please submit bug reports/patches via the -# Python SourceForge Project Page and assign them to "lemburg". +# Python bug tracker (http://bugs.python.org) and assign them to "lemburg". # # Still needed: # * more support for WinCE Modified: python/branches/release31-maint/Lib/test/test___all__.py ============================================================================== --- python/branches/release31-maint/Lib/test/test___all__.py (original) +++ python/branches/release31-maint/Lib/test/test___all__.py Sun Oct 4 16:54:52 2009 @@ -82,6 +82,7 @@ self.check_all("keyword") self.check_all("linecache") self.check_all("locale") + self.check_all("logging") self.check_all("macpath") self.check_all("macurl2path") self.check_all("mailbox") Modified: python/branches/release31-maint/Lib/test/test_csv.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_csv.py (original) +++ python/branches/release31-maint/Lib/test/test_csv.py Sun Oct 4 16:54:52 2009 @@ -767,7 +767,7 @@ 'Harry''s':'Arlington Heights':'IL':'2/1/03':'Kimi Hayes' 'Shark City':'Glendale Heights':'IL':'12/28/02':'Prezence' 'Tommy''s Place':'Blue Island':'IL':'12/28/02':'Blue Sunday/White Crow' -'Stonecutters Seafood and Chop House':'Lemont':'IL':'12/19/02':'Week Back' +'Stonecutters ''Seafood'' and Chop House':'Lemont':'IL':'12/19/02':'Week Back' """ header = '''\ "venue","city","state","date","performers" @@ -826,6 +826,13 @@ self.assertEqual(dialect.delimiter, "|") self.assertEqual(dialect.quotechar, "'") + def test_doublequote(self): + sniffer = csv.Sniffer() + dialect = sniffer.sniff(self.header) + self.assertFalse(dialect.doublequote) + dialect = sniffer.sniff(self.sample2) + self.assertTrue(dialect.doublequote) + if not hasattr(sys, "gettotalrefcount"): if support.verbose: print("*** skipping leakage tests ***") else: Modified: python/branches/release31-maint/Lib/test/test_socket.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_socket.py (original) +++ python/branches/release31-maint/Lib/test/test_socket.py Sun Oct 4 16:54:52 2009 @@ -291,7 +291,7 @@ # On some versions, this loses a reference orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) - except SystemError: + except TypeError: if sys.getrefcount(__name__) != orig: self.fail("socket.getnameinfo loses a reference") Modified: python/branches/release31-maint/Lib/textwrap.py ============================================================================== --- python/branches/release31-maint/Lib/textwrap.py (original) +++ python/branches/release31-maint/Lib/textwrap.py Sun Oct 4 16:54:52 2009 @@ -135,7 +135,7 @@ """_split(text : string) -> [string] Split the text to wrap into indivisible chunks. Chunks are - not quite the same as words; see wrap_chunks() for full + not quite the same as words; see _wrap_chunks() for full details. As an example, the text Look, goof-ball -- use the -b option! breaks into the following chunks: @@ -163,9 +163,9 @@ space to two. """ i = 0 - pat = self.sentence_end_re + patsearch = self.sentence_end_re.search while i < len(chunks)-1: - if chunks[i+1] == " " and pat.search(chunks[i]): + if chunks[i+1] == " " and patsearch(chunks[i]): chunks[i+1] = " " i += 2 else: Modified: python/branches/release31-maint/Misc/developers.txt ============================================================================== --- python/branches/release31-maint/Misc/developers.txt (original) +++ python/branches/release31-maint/Misc/developers.txt Sun Oct 4 16:54:52 2009 @@ -20,6 +20,9 @@ Permissions History ------------------- +- Doug Hellmann was given SVN access on September 19 2009 by GFB, at + suggestion of Jesse Noller, for documentation work. + - Ezio Melotti was given SVN access on June 7 2009 by GFB, for work on and fixes to the documentation. @@ -109,6 +112,13 @@ - Jeffrey Yasskin was given SVN access on 9 August 2007 by NCN, for his work on PEPs and other general patches. +- Mark Summerfield was given SVN access on 1 August 2007 by GFB, + for work on documentation. + +- Armin Ronacher was given SVN access on 23 July 2007 by GFB, + for work on the documentation toolset. He now maintains the + ast module. + - Senthil Kumaran was given SVN access on 16 June 2007 by MvL, for his Summer-of-Code project, mentored by Skip Montanaro. Modified: python/branches/release31-maint/Modules/socketmodule.c ============================================================================== --- python/branches/release31-maint/Modules/socketmodule.c (original) +++ python/branches/release31-maint/Modules/socketmodule.c Sun Oct 4 16:54:52 2009 @@ -3890,8 +3890,13 @@ flags = flowinfo = scope_id = 0; if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) return NULL; - if (!PyArg_ParseTuple(sa, "si|ii", - &hostp, &port, &flowinfo, &scope_id)) + if (!PyTuple_Check(sa)) { + PyErr_SetString(PyExc_TypeError, + "getnameinfo() argument 1 must be a tuple"); + return NULL; + } + if (!PyArg_ParseTuple(sa, "si|ii", + &hostp, &port, &flowinfo, &scope_id)) return NULL; PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); memset(&hints, 0, sizeof(hints)); @@ -3914,9 +3919,7 @@ switch (res->ai_family) { case AF_INET: { - char *t1; - int t2; - if (PyArg_ParseTuple(sa, "si", &t1, &t2) == 0) { + if (PyTuple_GET_SIZE(sa) != 2) { PyErr_SetString(socket_error, "IPv4 sockaddr must be 2 tuple"); goto fail; From python-checkins at python.org Sun Oct 4 17:07:16 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 15:07:16 -0000 Subject: [Python-checkins] r75233 - python/branches/py3k/Doc/library/stdtypes.rst Message-ID: Author: benjamin.peterson Date: Sun Oct 4 17:07:16 2009 New Revision: 75233 Log: remove 8-bit string sentence Modified: python/branches/py3k/Doc/library/stdtypes.rst Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Sun Oct 4 17:07:16 2009 @@ -1149,8 +1149,6 @@ >>> titlecase("they're bill's friends.") "They're Bill's Friends." - For 8-bit strings, this method is locale-dependent. - .. method:: str.translate(map) From python-checkins at python.org Sun Oct 4 17:08:42 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 15:08:42 -0000 Subject: [Python-checkins] r75234 - in python/branches/release31-maint: Doc/library/stdtypes.rst Message-ID: Author: benjamin.peterson Date: Sun Oct 4 17:08:41 2009 New Revision: 75234 Log: Merged revisions 75233 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75233 | benjamin.peterson | 2009-10-04 10:07:16 -0500 (Sun, 04 Oct 2009) | 1 line remove 8-bit string sentence ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/stdtypes.rst Modified: python/branches/release31-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release31-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release31-maint/Doc/library/stdtypes.rst Sun Oct 4 17:08:41 2009 @@ -1148,8 +1148,6 @@ >>> titlecase("they're bill's friends.") "They're Bill's Friends." - For 8-bit strings, this method is locale-dependent. - .. method:: str.translate(map) From python-checkins at python.org Sun Oct 4 17:59:17 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 15:59:17 -0000 Subject: [Python-checkins] r75235 - peps/trunk/pep-3100.txt Message-ID: Author: benjamin.peterson Date: Sun Oct 4 17:59:16 2009 New Revision: 75235 Log: better callable replacement Modified: peps/trunk/pep-3100.txt Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Sun Oct 4 17:59:16 2009 @@ -183,7 +183,7 @@ * ``apply()``: use ``f(*args, **kw)`` instead [2]_ [done] * ``buffer()``: must die (use a bytes() type instead) (?) [2]_ [done] -* ``callable()``: just use hasattr(x, '__call__') (?) [2]_ [done] +* ``callable()``: just use isinstance(x, collections.Callable) (?) [2]_ [done] * ``compile()``: put in ``sys`` (or perhaps in a module of its own) [2]_ * ``coerce()``: no longer needed [2]_ [done] * ``execfile()``, ``reload()``: use ``exec()`` [2]_ [done] From python-checkins at python.org Sun Oct 4 20:38:40 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 04 Oct 2009 18:38:40 -0000 Subject: [Python-checkins] r75236 - in python/trunk: Lib/test/test_signal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Sun Oct 4 20:38:39 2009 New Revision: 75236 Log: Issue #7042: Fix test_signal failure on OS X 10.6 64-bit builds (and also, with luck, on the x86 FreeBSD buildbot), by making sure that some user time is used in test_itimer_virtual. Modified: python/trunk/Lib/test/test_signal.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_signal.py ============================================================================== --- python/trunk/Lib/test/test_signal.py (original) +++ python/trunk/Lib/test/test_signal.py Sun Oct 4 20:38:39 2009 @@ -361,6 +361,8 @@ signal.setitimer(self.itimer, 0.3, 0.2) for i in xrange(100000000): + # use up some virtual time by doing real work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 4 20:38:39 2009 @@ -1436,6 +1436,8 @@ Tests ----- +- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. + - Issue #6806: test_platform failed under OS X 10.6.0 because ``sw_ver`` leaves off the trailing 0 in the version number. From python-checkins at python.org Sun Oct 4 20:41:25 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 04 Oct 2009 18:41:25 -0000 Subject: [Python-checkins] r75237 - in python/branches/release26-maint: Lib/test/test_signal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Sun Oct 4 20:41:25 2009 New Revision: 75237 Log: Merged revisions 75236 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75236 | mark.dickinson | 2009-10-04 19:38:39 +0100 (Sun, 04 Oct 2009) | 4 lines Issue #7042: Fix test_signal failure on OS X 10.6 64-bit builds (and also, with luck, on the x86 FreeBSD buildbot), by making sure that some user time is used in test_itimer_virtual. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_signal.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/test/test_signal.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_signal.py (original) +++ python/branches/release26-maint/Lib/test/test_signal.py Sun Oct 4 20:41:25 2009 @@ -361,6 +361,8 @@ signal.setitimer(self.itimer, 0.3, 0.2) for i in xrange(100000000): + # use up some virtual time by doing real work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Oct 4 20:41:25 2009 @@ -23,6 +23,11 @@ - Issue #7039: Fixed distutils.tests.test_sysconfig when running on installation with no build. +Tests +----- + +- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. + What's New in Python 2.6.3 ========================== From python-checkins at python.org Sun Oct 4 20:43:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 04 Oct 2009 18:43:54 -0000 Subject: [Python-checkins] r75238 - in python/branches/py3k: Lib/test/test_signal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Sun Oct 4 20:43:54 2009 New Revision: 75238 Log: Merged revisions 75236 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75236 | mark.dickinson | 2009-10-04 19:38:39 +0100 (Sun, 04 Oct 2009) | 4 lines Issue #7042: Fix test_signal failure on OS X 10.6 64-bit builds (and also, with luck, on the x86 FreeBSD buildbot), by making sure that some user time is used in test_itimer_virtual. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_signal.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_signal.py ============================================================================== --- python/branches/py3k/Lib/test/test_signal.py (original) +++ python/branches/py3k/Lib/test/test_signal.py Sun Oct 4 20:43:54 2009 @@ -361,6 +361,8 @@ signal.setitimer(self.itimer, 0.3, 0.2) for i in range(100000000): + # use up some virtual time by doing real work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Oct 4 20:43:54 2009 @@ -252,6 +252,8 @@ Tests ----- +- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. + - Fixed tests in importlib.test.source.test_abc_loader that were masking the proper exceptions that should be raised for missing or improper code object bytecode. From python-checkins at python.org Sun Oct 4 20:47:49 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 04 Oct 2009 18:47:49 -0000 Subject: [Python-checkins] r75239 - in python/branches/release31-maint: Lib/test/test_signal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Sun Oct 4 20:47:48 2009 New Revision: 75239 Log: Merged revisions 75238 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75238 | mark.dickinson | 2009-10-04 19:43:54 +0100 (Sun, 04 Oct 2009) | 11 lines Merged revisions 75236 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75236 | mark.dickinson | 2009-10-04 19:38:39 +0100 (Sun, 04 Oct 2009) | 4 lines Issue #7042: Fix test_signal failure on OS X 10.6 64-bit builds (and also, with luck, on the x86 FreeBSD buildbot), by making sure that some user time is used in test_itimer_virtual. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_signal.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/test_signal.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_signal.py (original) +++ python/branches/release31-maint/Lib/test/test_signal.py Sun Oct 4 20:47:48 2009 @@ -361,6 +361,8 @@ signal.setitimer(self.itimer, 0.3, 0.2) for i in range(100000000): + # use up some virtual time by doing real work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sun Oct 4 20:47:48 2009 @@ -73,6 +73,11 @@ - Issue #6848: Fix curses module build failure on OS X 10.6. +Tests +----- + +- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. + Build ----- From python-checkins at python.org Sun Oct 4 20:52:06 2009 From: python-checkins at python.org (kurt.kaiser) Date: Sun, 04 Oct 2009 18:52:06 -0000 Subject: [Python-checkins] r75240 - python/branches/release26-maint/Lib/idlelib/NEWS.txt Message-ID: Author: kurt.kaiser Date: Sun Oct 4 20:52:06 2009 New Revision: 75240 Log: Document backport of r72946, issue6110. r74976. Modified: python/branches/release26-maint/Lib/idlelib/NEWS.txt Modified: python/branches/release26-maint/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/release26-maint/Lib/idlelib/NEWS.txt (original) +++ python/branches/release26-maint/Lib/idlelib/NEWS.txt Sun Oct 4 20:52:06 2009 @@ -1,7 +1,19 @@ +What's New in Python 2.6.4rc1 +========================== + +*Release date: XX-Oct-2009* + +What's New in Python 2.6.3 +========================== + +*Release date: 02-Oct-2009* + +- On OS X IDLE 2.6 shows two Preference menu items. Issue6951. + What's New in IDLE 2.6.3rc1? ============================ -*Release date: XX-XXX-2009* +*Release date: 28-Sep-2009* - Windows: Version string for the .chm help file changed, file not being accessed Patch 5783 Guilherme Polo From python-checkins at python.org Sun Oct 4 22:07:35 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:07:35 -0000 Subject: [Python-checkins] r75241 - in python/branches/py3k: Doc/library/unittest.rst Doc/library/weakref.rst Lib/test/test_unittest.py Lib/unittest/case.py Modules/_threadmodule.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:07:34 2009 New Revision: 75241 Log: Merged revisions 74524,74556 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74524 | gregory.p.smith | 2009-08-20 04:39:38 -0500 (Thu, 20 Aug 2009) | 2 lines Add weakref support to the thread.lock type. ........ r74556 | kristjan.jonsson | 2009-08-27 17:20:21 -0500 (Thu, 27 Aug 2009) | 2 lines issue 6275 Add an "exc_value" attribute to the _AssertRaisesContext context manager in the unittest package. This allows further tests on the exception that was raised after the context manager exits. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/case.py python/branches/py3k/Modules/_threadmodule.c Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Sun Oct 4 22:07:34 2009 @@ -891,6 +891,10 @@ with self.failUnlessRaises(some_error_class): do_something() + The context manager will store the caught exception object in its + :attr:`exc_value` attribute. This can be useful if the intention + is to perform additional checks on the exception raised. + .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Sun Oct 4 22:07:34 2009 @@ -61,6 +61,9 @@ frozensets, file objects, :term:`generator`\s, type objects, sockets, arrays, deques, and regular expression pattern objects. +.. versionchanged:: 2.7 + Added support for thread.lock and threading.Lock. + Several built-in types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sun Oct 4 22:07:34 2009 @@ -2834,6 +2834,21 @@ self.assertRaisesRegexp, Exception, re.compile('^Expected$'), Stub) + def testAssertRaisesExcValue(self): + class ExceptionMock(Exception): + pass + + def Stub(foo): + raise ExceptionMock(foo) + v = "particular value" + + ctx = self.assertRaises(ExceptionMock) + with ctx: + Stub(v) + e = ctx.exc_value + self.assertTrue(isinstance(e, ExceptionMock)) + self.assertEqual(e.args[0], v) + def testSynonymAssertMethodNames(self): """Test undocumented method name synonyms. Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Sun Oct 4 22:07:34 2009 @@ -116,6 +116,7 @@ if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False + self.exc_value = exc_value #store for later retrieval if self.expected_regex is None: return True Modified: python/branches/py3k/Modules/_threadmodule.c ============================================================================== --- python/branches/py3k/Modules/_threadmodule.c (original) +++ python/branches/py3k/Modules/_threadmodule.c Sun Oct 4 22:07:34 2009 @@ -3,6 +3,7 @@ /* Interface to Sjoerd's portable C thread library */ #include "Python.h" +#include "structmember.h" /* offsetof */ #ifndef WITH_THREAD #error "Error! The rest of Python is not compiled with thread support." @@ -20,12 +21,15 @@ typedef struct { PyObject_HEAD PyThread_type_lock lock_lock; + PyObject *in_weakreflist; } lockobject; static void lock_dealloc(lockobject *self) { assert(self->lock_lock); + if (self->in_weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); /* Unlock the lock so it's safe to free it */ PyThread_acquire_lock(self->lock_lock, 0); PyThread_release_lock(self->lock_lock); @@ -140,12 +144,12 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ + offsetof(lockobject, in_weakreflist), /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ lock_methods, /*tp_methods*/ @@ -159,6 +163,7 @@ if (self == NULL) return NULL; self->lock_lock = PyThread_allocate_lock(); + self->in_weakreflist = NULL; if (self->lock_lock == NULL) { PyObject_Del(self); self = NULL; From python-checkins at python.org Sun Oct 4 22:13:06 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:13:06 -0000 Subject: [Python-checkins] r75242 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:13:06 2009 New Revision: 75242 Log: Blocked revisions 74845 via svnmerge ........ r74845 | georg.brandl | 2009-09-16 15:30:09 -0500 (Wed, 16 Sep 2009) | 5 lines #6844: do not emit DeprecationWarnings on access if Exception.message has been set by the user. This works by always setting it in __dict__, except when it's implicitly set in __init__. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 4 22:19:26 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:19:26 -0000 Subject: [Python-checkins] r75243 - in python/branches/py3k: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Tools/scripts/pindent.py Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:19:21 2009 New Revision: 75243 Log: Merged revisions 74865,75175,75180 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74865 | georg.brandl | 2009-09-17 02:49:37 -0500 (Thu, 17 Sep 2009) | 1 line #6912: add "with" block support to pindent. ........ r75175 | georg.brandl | 2009-10-01 15:11:14 -0500 (Thu, 01 Oct 2009) | 1 line Fix some weird whitespace and two other overlong lines. ........ r75180 | georg.brandl | 2009-10-01 15:59:31 -0500 (Thu, 01 Oct 2009) | 1 line #7031: Add TestCase.assertIsInstance and negated method. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/case.py python/branches/py3k/Tools/scripts/pindent.py Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Sun Oct 4 22:19:21 2009 @@ -952,6 +952,22 @@ .. versionadded:: 3.1 + .. method:: assertIsInstance(obj, cls[, msg]) + + This signals a test failure if *obj* is not an instance of *cls* (which + can be a class or a tuple of classes, as supported by :func:`isinstance`). + + .. versionadded:: 3.2 + + + .. method:: assertNotIsInstance(obj, cls[, msg]) + + The inverse of the :meth:`assertIsInstance` method. This signals a test + failure if *obj* is an instance of *cls*. + + .. versionadded:: 3.2 + + .. method:: assertFalse(expr, msg=None) failIf(expr, msg=None) Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sun Oct 4 22:19:21 2009 @@ -2510,6 +2510,18 @@ self.assertIsNot(thing, object()) self.assertRaises(self.failureException, self.assertIsNot, thing, thing) + def testAssertIsInstance(self): + thing = [] + self.assertIsInstance(thing, list) + self.assertRaises(self.failureException, self.assertIsInstance, + thing, dict) + + def testAssertNotIsInstance(self): + thing = [] + self.assertNotIsInstance(thing, dict) + self.assertRaises(self.failureException, self.assertNotIsInstance, + thing, list) + def testAssertIn(self): animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'} Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Sun Oct 4 22:19:21 2009 @@ -620,8 +620,9 @@ except (TypeError, IndexError, NotImplementedError): differing += ('Unable to index element %d ' 'of second %s\n' % (len1, seq_type_name)) - standardMsg = differing + '\n' + '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(), - pprint.pformat(seq2).splitlines())) + standardMsg = differing + '\n' + '\n'.join( + difflib.ndiff(pprint.pformat(seq1).splitlines(), + pprint.pformat(seq2).splitlines())) msg = self._formatMessage(msg, standardMsg) self.fail(msg) @@ -734,7 +735,8 @@ if key not in actual: missing.append(key) elif value != actual[key]: - mismatched.append('%s, expected: %s, actual: %s' % (key, value, actual[key])) + mismatched.append('%s, expected: %s, actual: %s' % + (key, value, actual[key])) if not (missing or mismatched): return @@ -793,7 +795,8 @@ 'Second argument is not a string')) if first != second: - standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), second.splitlines(True))) + standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True), + second.splitlines(True))) self.fail(self._formatMessage(msg, standardMsg)) def assertLess(self, a, b, msg=None): @@ -832,6 +835,19 @@ standardMsg = 'unexpectedly None' self.fail(self._formatMessage(msg, standardMsg)) + def assertIsInstance(self, obj, cls, msg=None): + """Same as self.assertTrue(isinstance(obj, cls)), with a nicer + default message.""" + if not isinstance(obj, cls): + standardMsg = '%r is not an instance of %r' % (obj, cls) + self.fail(self._formatMessage(msg, standardMsg)) + + def assertNotIsInstance(self, obj, cls, msg=None): + """Included for symmetry with assertIsInstance.""" + if isinstance(obj, cls): + standardMsg = '%r is an instance of %r' % (obj, cls) + self.fail(self._formatMessage(msg, standardMsg)) + def assertRaisesRegexp(self, expected_exception, expected_regexp, callable_obj=None, *args, **kwargs): """Asserts that the message in a raised exception matches a regexp. Modified: python/branches/py3k/Tools/scripts/pindent.py ============================================================================== --- python/branches/py3k/Tools/scripts/pindent.py (original) +++ python/branches/py3k/Tools/scripts/pindent.py Sun Oct 4 22:19:21 2009 @@ -88,10 +88,10 @@ next['if'] = next['elif'] = 'elif', 'else', 'end' next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' -next['except'] = 'except', 'else', 'end' +next['except'] = 'except', 'else', 'finally', 'end' next['else'] = next['finally'] = next['def'] = next['class'] = 'end' next['end'] = () -start = 'if', 'while', 'for', 'try', 'def', 'class' +start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' class PythonIndenter: From python-checkins at python.org Sun Oct 4 22:23:37 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:23:37 -0000 Subject: [Python-checkins] r75244 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:23:37 2009 New Revision: 75244 Log: Blocked revisions 74849,75143,75181 via svnmerge ........ r74849 | thomas.wouters | 2009-09-16 15:36:34 -0500 (Wed, 16 Sep 2009) | 4 lines Add news entry for r74841. ........ r75143 | philip.jenvey | 2009-09-29 14:10:15 -0500 (Tue, 29 Sep 2009) | 5 lines #5329: fix os.popen* regression from 2.5: don't execute commands as a sequence through the shell. also document the correct subprocess replacement for this case patch from Jean-Paul Calderone and Jani Hakala ........ r75181 | georg.brandl | 2009-10-01 16:02:39 -0500 (Thu, 01 Oct 2009) | 1 line Add NEWS entry for r75180. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 4 22:28:48 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:28:48 -0000 Subject: [Python-checkins] r75245 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:28:48 2009 New Revision: 75245 Log: Blocked revisions 75164-75166 via svnmerge ........ r75164 | senthil.kumaran | 2009-09-30 20:07:03 -0500 (Wed, 30 Sep 2009) | 3 lines Fix for issue7026 test_urllib: unsetting missing 'env' variable. ........ r75165 | senthil.kumaran | 2009-09-30 20:19:18 -0500 (Wed, 30 Sep 2009) | 3 lines using dict.unset(k) instead of del dict[k]. consistent with release26-maint ........ r75166 | senthil.kumaran | 2009-09-30 20:50:13 -0500 (Wed, 30 Sep 2009) | 3 lines That's self.env.unset(k) and not env.unset(k) I was heading back to the problem. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 4 22:32:25 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:32:25 -0000 Subject: [Python-checkins] r75246 - in python/branches/py3k: Doc/c-api/init.rst Include/import.h Lib/test/test_fork1.py Modules/posixmodule.c Python/import.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:32:25 2009 New Revision: 75246 Log: Merged revisions 74841 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74841 | thomas.wouters | 2009-09-16 14:55:54 -0500 (Wed, 16 Sep 2009) | 23 lines Fix issue #1590864, multiple threads and fork() can cause deadlocks, by acquiring the import lock around fork() calls. This prevents other threads from having that lock while the fork happens, and is the recommended way of dealing with such issues. There are two other locks we care about, the GIL and the Thread Local Storage lock. The GIL is obviously held when calling Python functions like os.fork(), and the TLS lock is explicitly reallocated instead, while also deleting now-orphaned TLS data. This only fixes calls to os.fork(), not extension modules or embedding programs calling C's fork() directly. Solving that requires a new set of API functions, and possibly a rewrite of the Python/thread_*.c mess. Add a warning explaining the problem to the documentation in the mean time. This also changes behaviour a little on AIX. Before, AIX (but only AIX) was getting the import lock reallocated, seemingly to avoid this very same problem. This is not the right approach, because the import lock is a re-entrant one, and reallocating would do the wrong thing when forking while holding the import lock. Will backport to 2.6, minus the tiny AIX behaviour change. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Include/import.h python/branches/py3k/Lib/test/test_fork1.py python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Python/import.c Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Sun Oct 4 22:32:25 2009 @@ -520,6 +520,22 @@ :cfunc:`Py_NewInterpreter`), but mixing multiple interpreters and the :cfunc:`PyGILState_\*` API is unsupported. +Another important thing to note about threads is their behaviour in the face +of the C :cfunc:`fork` call. On most systems with :cfunc:`fork`, after a +process forks only the thread that issued the fork will exist. That also +means any locks held by other threads will never be released. Python solves +this for :func:`os.fork` by acquiring the locks it uses internally before +the fork, and releasing them afterwards. In addition, it resets any +:ref:`lock-objects` in the child. When extending or embedding Python, there +is no way to inform Python of additional (non-Python) locks that need to be +acquired before or reset after a fork. OS facilities such as +:cfunc:`posix_atfork` would need to be used to accomplish the same thing. +Additionally, when extending or embedding Python, calling :cfunc:`fork` +directly rather than through :func:`os.fork` (and returning to or calling +into Python) may result in a deadlock by one of Python's internal locks +being held by a thread that is defunct after the fork. +:cfunc:`PyOS_AfterFork` tries to reset the necessary locks, but is not +always able to. .. ctype:: PyInterpreterState Modified: python/branches/py3k/Include/import.h ============================================================================== --- python/branches/py3k/Include/import.h (original) +++ python/branches/py3k/Include/import.h Sun Oct 4 22:32:25 2009 @@ -27,6 +27,14 @@ PyAPI_FUNC(void) PyImport_Cleanup(void); PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); +#ifdef WITH_THREAD +PyAPI_FUNC(void) _PyImport_AcquireLock(void); +PyAPI_FUNC(int) _PyImport_ReleaseLock(void); +#else +#define _PyImport_AcquireLock() +#define _PyImport_ReleaseLock() 1 +#endif + PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( const char *, PyObject *, char *, size_t, FILE **, PyObject **); PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); Modified: python/branches/py3k/Lib/test/test_fork1.py ============================================================================== --- python/branches/py3k/Lib/test/test_fork1.py (original) +++ python/branches/py3k/Lib/test/test_fork1.py Sun Oct 4 22:32:25 2009 @@ -1,8 +1,14 @@ """This test checks for correct fork() behavior. """ +import errno +import imp import os +import signal +import sys import time +import threading + from test.fork_wait import ForkWait from test.support import run_unittest, reap_children, get_attribute @@ -23,6 +29,41 @@ self.assertEqual(spid, cpid) self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8)) + def test_import_lock_fork(self): + import_started = threading.Event() + fake_module_name = "fake test module" + partial_module = "partial" + complete_module = "complete" + def importer(): + imp.acquire_lock() + sys.modules[fake_module_name] = partial_module + import_started.set() + time.sleep(0.01) # Give the other thread time to try and acquire. + sys.modules[fake_module_name] = complete_module + imp.release_lock() + t = threading.Thread(target=importer) + t.start() + import_started.wait() + pid = os.fork() + try: + if not pid: + m = __import__(fake_module_name) + if m == complete_module: + os._exit(0) + else: + os._exit(1) + else: + t.join() + # Exitcode 1 means the child got a partial module (bad.) No + # exitcode (but a hang, which manifests as 'got pid 0') + # means the child deadlocked (also bad.) + self.wait_impl(pid) + finally: + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + def test_main(): run_unittest(ForkTest) reap_children() Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Sun Oct 4 22:32:25 2009 @@ -3721,11 +3721,21 @@ static PyObject * posix_fork1(PyObject *self, PyObject *noargs) { - pid_t pid = fork1(); + pid_t pid; + int result; + _PyImport_AcquireLock(); + pid = fork1(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return PyLong_FromPid(pid); } #endif @@ -3740,11 +3750,21 @@ static PyObject * posix_fork(PyObject *self, PyObject *noargs) { - pid_t pid = fork(); + pid_t pid; + int result; + _PyImport_AcquireLock(); + pid = fork(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return PyLong_FromPid(pid); } #endif @@ -3847,14 +3867,22 @@ static PyObject * posix_forkpty(PyObject *self, PyObject *noargs) { - int master_fd = -1; + int master_fd = -1, result; pid_t pid; + _PyImport_AcquireLock(); pid = forkpty(&master_fd, NULL, NULL, NULL); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return Py_BuildValue("(Ni)", PyLong_FromPid(pid), master_fd); } #endif Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Sun Oct 4 22:32:25 2009 @@ -262,8 +262,8 @@ static long import_lock_thread = -1; static int import_lock_level = 0; -static void -lock_import(void) +void +_PyImport_AcquireLock(void) { long me = PyThread_get_thread_ident(); if (me == -1) @@ -287,8 +287,8 @@ import_lock_level = 1; } -static int -unlock_import(void) +int +_PyImport_ReleaseLock(void) { long me = PyThread_get_thread_ident(); if (me == -1 || import_lock == NULL) @@ -303,23 +303,16 @@ return 1; } -/* This function is called from PyOS_AfterFork to ensure that newly - created child processes do not share locks with the parent. */ +/* This function used to be called from PyOS_AfterFork to ensure that newly + created child processes do not share locks with the parent, but for some + reason only on AIX systems. Instead of re-initializing the lock, we now + acquire the import lock around fork() calls. */ void _PyImport_ReInitLock(void) { -#ifdef _AIX - if (import_lock != NULL) - import_lock = PyThread_allocate_lock(); -#endif } -#else - -#define lock_import() -#define unlock_import() 0 - #endif static PyObject * @@ -336,7 +329,7 @@ imp_acquire_lock(PyObject *self, PyObject *noargs) { #ifdef WITH_THREAD - lock_import(); + _PyImport_AcquireLock(); #endif Py_INCREF(Py_None); return Py_None; @@ -346,7 +339,7 @@ imp_release_lock(PyObject *self, PyObject *noargs) { #ifdef WITH_THREAD - if (unlock_import() < 0) { + if (_PyImport_ReleaseLock() < 0) { PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); return NULL; @@ -2201,9 +2194,9 @@ PyObject *fromlist, int level) { PyObject *result; - lock_import(); + _PyImport_AcquireLock(); result = import_module_level(name, globals, locals, fromlist, level); - if (unlock_import() < 0) { + if (_PyImport_ReleaseLock() < 0) { Py_XDECREF(result); PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); From python-checkins at python.org Sun Oct 4 22:35:31 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:35:31 -0000 Subject: [Python-checkins] r75247 - in python/branches/release31-maint: Doc/c-api/init.rst Include/import.h Lib/test/test_fork1.py Modules/posixmodule.c Python/import.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:35:30 2009 New Revision: 75247 Log: Merged revisions 75246 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75246 | benjamin.peterson | 2009-10-04 15:32:25 -0500 (Sun, 04 Oct 2009) | 29 lines Merged revisions 74841 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74841 | thomas.wouters | 2009-09-16 14:55:54 -0500 (Wed, 16 Sep 2009) | 23 lines Fix issue #1590864, multiple threads and fork() can cause deadlocks, by acquiring the import lock around fork() calls. This prevents other threads from having that lock while the fork happens, and is the recommended way of dealing with such issues. There are two other locks we care about, the GIL and the Thread Local Storage lock. The GIL is obviously held when calling Python functions like os.fork(), and the TLS lock is explicitly reallocated instead, while also deleting now-orphaned TLS data. This only fixes calls to os.fork(), not extension modules or embedding programs calling C's fork() directly. Solving that requires a new set of API functions, and possibly a rewrite of the Python/thread_*.c mess. Add a warning explaining the problem to the documentation in the mean time. This also changes behaviour a little on AIX. Before, AIX (but only AIX) was getting the import lock reallocated, seemingly to avoid this very same problem. This is not the right approach, because the import lock is a re-entrant one, and reallocating would do the wrong thing when forking while holding the import lock. Will backport to 2.6, minus the tiny AIX behaviour change. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/c-api/init.rst python/branches/release31-maint/Include/import.h python/branches/release31-maint/Lib/test/test_fork1.py python/branches/release31-maint/Modules/posixmodule.c python/branches/release31-maint/Python/import.c Modified: python/branches/release31-maint/Doc/c-api/init.rst ============================================================================== --- python/branches/release31-maint/Doc/c-api/init.rst (original) +++ python/branches/release31-maint/Doc/c-api/init.rst Sun Oct 4 22:35:30 2009 @@ -520,6 +520,22 @@ :cfunc:`Py_NewInterpreter`), but mixing multiple interpreters and the :cfunc:`PyGILState_\*` API is unsupported. +Another important thing to note about threads is their behaviour in the face +of the C :cfunc:`fork` call. On most systems with :cfunc:`fork`, after a +process forks only the thread that issued the fork will exist. That also +means any locks held by other threads will never be released. Python solves +this for :func:`os.fork` by acquiring the locks it uses internally before +the fork, and releasing them afterwards. In addition, it resets any +:ref:`lock-objects` in the child. When extending or embedding Python, there +is no way to inform Python of additional (non-Python) locks that need to be +acquired before or reset after a fork. OS facilities such as +:cfunc:`posix_atfork` would need to be used to accomplish the same thing. +Additionally, when extending or embedding Python, calling :cfunc:`fork` +directly rather than through :func:`os.fork` (and returning to or calling +into Python) may result in a deadlock by one of Python's internal locks +being held by a thread that is defunct after the fork. +:cfunc:`PyOS_AfterFork` tries to reset the necessary locks, but is not +always able to. .. ctype:: PyInterpreterState Modified: python/branches/release31-maint/Include/import.h ============================================================================== --- python/branches/release31-maint/Include/import.h (original) +++ python/branches/release31-maint/Include/import.h Sun Oct 4 22:35:30 2009 @@ -27,6 +27,14 @@ PyAPI_FUNC(void) PyImport_Cleanup(void); PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); +#ifdef WITH_THREAD +PyAPI_FUNC(void) _PyImport_AcquireLock(void); +PyAPI_FUNC(int) _PyImport_ReleaseLock(void); +#else +#define _PyImport_AcquireLock() +#define _PyImport_ReleaseLock() 1 +#endif + PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( const char *, PyObject *, char *, size_t, FILE **, PyObject **); PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); Modified: python/branches/release31-maint/Lib/test/test_fork1.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_fork1.py (original) +++ python/branches/release31-maint/Lib/test/test_fork1.py Sun Oct 4 22:35:30 2009 @@ -1,8 +1,14 @@ """This test checks for correct fork() behavior. """ +import errno +import imp import os +import signal +import sys import time +import threading + from test.fork_wait import ForkWait from test.support import run_unittest, reap_children, get_attribute @@ -23,6 +29,41 @@ self.assertEqual(spid, cpid) self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8)) + def test_import_lock_fork(self): + import_started = threading.Event() + fake_module_name = "fake test module" + partial_module = "partial" + complete_module = "complete" + def importer(): + imp.acquire_lock() + sys.modules[fake_module_name] = partial_module + import_started.set() + time.sleep(0.01) # Give the other thread time to try and acquire. + sys.modules[fake_module_name] = complete_module + imp.release_lock() + t = threading.Thread(target=importer) + t.start() + import_started.wait() + pid = os.fork() + try: + if not pid: + m = __import__(fake_module_name) + if m == complete_module: + os._exit(0) + else: + os._exit(1) + else: + t.join() + # Exitcode 1 means the child got a partial module (bad.) No + # exitcode (but a hang, which manifests as 'got pid 0') + # means the child deadlocked (also bad.) + self.wait_impl(pid) + finally: + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + def test_main(): run_unittest(ForkTest) reap_children() Modified: python/branches/release31-maint/Modules/posixmodule.c ============================================================================== --- python/branches/release31-maint/Modules/posixmodule.c (original) +++ python/branches/release31-maint/Modules/posixmodule.c Sun Oct 4 22:35:30 2009 @@ -3831,11 +3831,21 @@ static PyObject * posix_fork1(PyObject *self, PyObject *noargs) { - pid_t pid = fork1(); + pid_t pid; + int result; + _PyImport_AcquireLock(); + pid = fork1(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return PyLong_FromPid(pid); } #endif @@ -3850,11 +3860,21 @@ static PyObject * posix_fork(PyObject *self, PyObject *noargs) { - pid_t pid = fork(); + pid_t pid; + int result; + _PyImport_AcquireLock(); + pid = fork(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return PyLong_FromPid(pid); } #endif @@ -3957,14 +3977,22 @@ static PyObject * posix_forkpty(PyObject *self, PyObject *noargs) { - int master_fd = -1; + int master_fd = -1, result; pid_t pid; + _PyImport_AcquireLock(); pid = forkpty(&master_fd, NULL, NULL, NULL); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); if (pid == 0) PyOS_AfterFork(); + if (result < 0) { + /* Don't clobber the OSError if the fork failed. */ + PyErr_SetString(PyExc_RuntimeError, + "not holding the import lock"); + return NULL; + } return Py_BuildValue("(Ni)", PyLong_FromPid(pid), master_fd); } #endif Modified: python/branches/release31-maint/Python/import.c ============================================================================== --- python/branches/release31-maint/Python/import.c (original) +++ python/branches/release31-maint/Python/import.c Sun Oct 4 22:35:30 2009 @@ -261,8 +261,8 @@ static long import_lock_thread = -1; static int import_lock_level = 0; -static void -lock_import(void) +void +_PyImport_AcquireLock(void) { long me = PyThread_get_thread_ident(); if (me == -1) @@ -286,8 +286,8 @@ import_lock_level = 1; } -static int -unlock_import(void) +int +_PyImport_ReleaseLock(void) { long me = PyThread_get_thread_ident(); if (me == -1 || import_lock == NULL) @@ -302,23 +302,16 @@ return 1; } -/* This function is called from PyOS_AfterFork to ensure that newly - created child processes do not share locks with the parent. */ +/* This function used to be called from PyOS_AfterFork to ensure that newly + created child processes do not share locks with the parent, but for some + reason only on AIX systems. Instead of re-initializing the lock, we now + acquire the import lock around fork() calls. */ void _PyImport_ReInitLock(void) { -#ifdef _AIX - if (import_lock != NULL) - import_lock = PyThread_allocate_lock(); -#endif } -#else - -#define lock_import() -#define unlock_import() 0 - #endif static PyObject * @@ -335,7 +328,7 @@ imp_acquire_lock(PyObject *self, PyObject *noargs) { #ifdef WITH_THREAD - lock_import(); + _PyImport_AcquireLock(); #endif Py_INCREF(Py_None); return Py_None; @@ -345,7 +338,7 @@ imp_release_lock(PyObject *self, PyObject *noargs) { #ifdef WITH_THREAD - if (unlock_import() < 0) { + if (_PyImport_ReleaseLock() < 0) { PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); return NULL; @@ -2200,9 +2193,9 @@ PyObject *fromlist, int level) { PyObject *result; - lock_import(); + _PyImport_AcquireLock(); result = import_module_level(name, globals, locals, fromlist, level); - if (unlock_import() < 0) { + if (_PyImport_ReleaseLock() < 0) { Py_XDECREF(result); PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); From python-checkins at python.org Sun Oct 4 22:40:17 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:40:17 -0000 Subject: [Python-checkins] r75248 - in python/branches/py3k: Lib/test/test_curses.py Modules/_cursesmodule.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:40:17 2009 New Revision: 75248 Log: Merged revisions 75066 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75066 | andrew.kuchling | 2009-09-25 17:23:54 -0500 (Fri, 25 Sep 2009) | 4 lines #6243: fix segfault when keyname() returns a NULL pointer. Bug noted by Trundle, patched by Trundle and Jerry Chen. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_curses.py python/branches/py3k/Modules/_cursesmodule.c Modified: python/branches/py3k/Lib/test/test_curses.py ============================================================================== --- python/branches/py3k/Lib/test/test_curses.py (original) +++ python/branches/py3k/Lib/test/test_curses.py Sun Oct 4 22:40:17 2009 @@ -259,6 +259,10 @@ if curses.LINES != lines - 1 or curses.COLS != cols + 1: raise RuntimeError("Expected resizeterm to update LINES and COLS") +def test_issue6243(stdscr): + curses.ungetch(1025) + stdscr.getkey() + def main(stdscr): curses.savetty() try: @@ -266,6 +270,7 @@ window_funcs(stdscr) test_userptr_without_set(stdscr) test_resize_term(stdscr) + test_issue6243(stdscr) finally: curses.resetty() Modified: python/branches/py3k/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k/Modules/_cursesmodule.c (original) +++ python/branches/py3k/Modules/_cursesmodule.c Sun Oct 4 22:40:17 2009 @@ -890,14 +890,17 @@ /* getch() returns ERR in nodelay mode */ PyErr_SetString(PyCursesError, "no input"); return NULL; - } else if (rtn<=255) + } else if (rtn<=255) { return Py_BuildValue("C", rtn); - else + } else { + const char *knp; #if defined(__NetBSD__) - return PyUnicode_FromString(unctrl(rtn)); + knp = unctrl(rtn); #else - return PyUnicode_FromString((const char *)keyname(rtn)); + knp = keyname(rtn); #endif + return PyUnicode_FromString((knp == NULL) ? "" : knp); + } } static PyObject * From python-checkins at python.org Sun Oct 4 22:41:57 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 04 Oct 2009 20:41:57 -0000 Subject: [Python-checkins] r75249 - in python/branches/release31-maint: Lib/test/test_curses.py Modules/_cursesmodule.c Message-ID: Author: benjamin.peterson Date: Sun Oct 4 22:41:56 2009 New Revision: 75249 Log: Merged revisions 75248 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75248 | benjamin.peterson | 2009-10-04 15:40:17 -0500 (Sun, 04 Oct 2009) | 11 lines Merged revisions 75066 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75066 | andrew.kuchling | 2009-09-25 17:23:54 -0500 (Fri, 25 Sep 2009) | 4 lines #6243: fix segfault when keyname() returns a NULL pointer. Bug noted by Trundle, patched by Trundle and Jerry Chen. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_curses.py python/branches/release31-maint/Modules/_cursesmodule.c Modified: python/branches/release31-maint/Lib/test/test_curses.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_curses.py (original) +++ python/branches/release31-maint/Lib/test/test_curses.py Sun Oct 4 22:41:56 2009 @@ -259,6 +259,10 @@ if curses.LINES != lines - 1 or curses.COLS != cols + 1: raise RuntimeError("Expected resizeterm to update LINES and COLS") +def test_issue6243(stdscr): + curses.ungetch(1025) + stdscr.getkey() + def main(stdscr): curses.savetty() try: @@ -266,6 +270,7 @@ window_funcs(stdscr) test_userptr_without_set(stdscr) test_resize_term(stdscr) + test_issue6243(stdscr) finally: curses.resetty() Modified: python/branches/release31-maint/Modules/_cursesmodule.c ============================================================================== --- python/branches/release31-maint/Modules/_cursesmodule.c (original) +++ python/branches/release31-maint/Modules/_cursesmodule.c Sun Oct 4 22:41:56 2009 @@ -890,14 +890,17 @@ /* getch() returns ERR in nodelay mode */ PyErr_SetString(PyCursesError, "no input"); return NULL; - } else if (rtn<=255) + } else if (rtn<=255) { return Py_BuildValue("C", rtn); - else + } else { + const char *knp; #if defined(__NetBSD__) - return PyUnicode_FromString(unctrl(rtn)); + knp = unctrl(rtn); #else - return PyUnicode_FromString((const char *)keyname(rtn)); + knp = keyname(rtn); #endif + return PyUnicode_FromString((knp == NULL) ? "" : knp); + } } static PyObject * From python-checkins at python.org Mon Oct 5 00:35:31 2009 From: python-checkins at python.org (kurt.kaiser) Date: Sun, 04 Oct 2009 22:35:31 -0000 Subject: [Python-checkins] r75250 - python/branches/release26-maint/Lib/idlelib/NEWS.txt Message-ID: Author: kurt.kaiser Date: Mon Oct 5 00:35:30 2009 New Revision: 75250 Log: That fix was part of 2.5.3rc1.... Modified: python/branches/release26-maint/Lib/idlelib/NEWS.txt Modified: python/branches/release26-maint/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/release26-maint/Lib/idlelib/NEWS.txt (original) +++ python/branches/release26-maint/Lib/idlelib/NEWS.txt Mon Oct 5 00:35:30 2009 @@ -1,5 +1,5 @@ What's New in Python 2.6.4rc1 -========================== +============================= *Release date: XX-Oct-2009* @@ -8,13 +8,13 @@ *Release date: 02-Oct-2009* -- On OS X IDLE 2.6 shows two Preference menu items. Issue6951. - What's New in IDLE 2.6.3rc1? ============================ *Release date: 28-Sep-2009* +- On OS X IDLE 2.6 shows two Preference menu items. Issue6951. + - Windows: Version string for the .chm help file changed, file not being accessed Patch 5783 Guilherme Polo From python-checkins at python.org Mon Oct 5 00:48:26 2009 From: python-checkins at python.org (kurt.kaiser) Date: Sun, 04 Oct 2009 22:48:26 -0000 Subject: [Python-checkins] r75251 - python/branches/release26-maint Message-ID: Author: kurt.kaiser Date: Mon Oct 5 00:48:25 2009 New Revision: 75251 Log: Blocked revisions 72226 via svnmerge ........ r72226 | kurt.kaiser | 2009-05-02 21:03:44 -0400 (Sat, 02 May 2009) | 3 lines idle.py modified and simplified to better support developing experimental versions of IDLE which are not installed in the standard location. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 5 01:26:19 2009 From: python-checkins at python.org (kurt.kaiser) Date: Sun, 04 Oct 2009 23:26:19 -0000 Subject: [Python-checkins] r75252 - in python/branches/release26-maint: Lib/idlelib/NEWS.txt Lib/idlelib/OutputWindow.py Message-ID: Author: kurt.kaiser Date: Mon Oct 5 01:26:19 2009 New Revision: 75252 Log: Merged revisions 71995,72227 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r71995 | kurt.kaiser | 2009-04-26 19:22:11 -0400 (Sun, 26 Apr 2009) | 2 lines Right click 'go to file/line' not working if spaces in path. Bug 5559. ........ r72227 | kurt.kaiser | 2009-05-02 22:05:22 -0400 (Sat, 02 May 2009) | 2 lines Further development of issue5559, handle Windows files which not only have embedded spaces, but leading spaces. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/idlelib/NEWS.txt python/branches/release26-maint/Lib/idlelib/OutputWindow.py Modified: python/branches/release26-maint/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/release26-maint/Lib/idlelib/NEWS.txt (original) +++ python/branches/release26-maint/Lib/idlelib/NEWS.txt Mon Oct 5 01:26:19 2009 @@ -3,6 +3,9 @@ *Release date: XX-Oct-2009* +- OutputWindow/PyShell right click menu "Go to file/line" wasn't working with + file paths containing spaces. Bug 5559. + What's New in Python 2.6.3 ========================== Modified: python/branches/release26-maint/Lib/idlelib/OutputWindow.py ============================================================================== --- python/branches/release26-maint/Lib/idlelib/OutputWindow.py (original) +++ python/branches/release26-maint/Lib/idlelib/OutputWindow.py Mon Oct 5 01:26:19 2009 @@ -60,9 +60,12 @@ ] file_line_pats = [ + # order of patterns matters r'file "([^"]*)", line (\d+)', r'([^\s]+)\((\d+)\)', - r'([^\s]+):\s*(\d+):', + r'^(\s*\S.*?):\s*(\d+):', # Win filename, maybe starting with spaces + r'([^\s]+):\s*(\d+):', # filename or path, ltrim + r'^\s*(\S.*?):\s*(\d+):', # Win abs path with embedded spaces, ltrim ] file_line_progs = None @@ -96,17 +99,17 @@ def _file_line_helper(self, line): for prog in self.file_line_progs: - m = prog.search(line) - if m: - break + match = prog.search(line) + if match: + filename, lineno = match.group(1, 2) + try: + f = open(filename, "r") + f.close() + break + except IOError: + continue else: return None - filename, lineno = m.group(1, 2) - try: - f = open(filename, "r") - f.close() - except IOError: - return None try: return filename, int(lineno) except TypeError: @@ -139,19 +142,3 @@ text.tag_configure(tag, **cnf) text.tag_raise('sel') self.write = self.owin.write - -#class PseudoFile: -# -# def __init__(self, owin, tags, mark="end"): -# self.owin = owin -# self.tags = tags -# self.mark = mark - -# def write(self, s): -# self.owin.write(s, self.tags, self.mark) - -# def writelines(self, l): -# map(self.write, l) - -# def flush(self): -# pass From python-checkins at python.org Mon Oct 5 06:13:03 2009 From: python-checkins at python.org (senthil.kumaran) Date: Mon, 05 Oct 2009 04:13:03 -0000 Subject: [Python-checkins] r75253 - python/branches/release26-maint/Lib/nturl2path.py Message-ID: Author: senthil.kumaran Date: Mon Oct 5 06:13:01 2009 New Revision: 75253 Log: merge r72343. Fix for issue7043 Modified: python/branches/release26-maint/Lib/nturl2path.py Modified: python/branches/release26-maint/Lib/nturl2path.py ============================================================================== --- python/branches/release26-maint/Lib/nturl2path.py (original) +++ python/branches/release26-maint/Lib/nturl2path.py Mon Oct 5 06:13:01 2009 @@ -56,7 +56,7 @@ drive = urllib.quote(comp[0].upper()) components = comp[1].split('\\') - path = '///' + drive + '|' + path = '///' + drive + ':' for comp in components: if comp: path = path + '/' + urllib.quote(comp) From python-checkins at python.org Mon Oct 5 06:16:27 2009 From: python-checkins at python.org (senthil.kumaran) Date: Mon, 05 Oct 2009 04:16:27 -0000 Subject: [Python-checkins] r75254 - python/branches/release26-maint/Lib/test/test_urllib.py Message-ID: Author: senthil.kumaran Date: Mon Oct 5 06:16:26 2009 New Revision: 75254 Log: Fix for Issue7026. Making it self.env.unset Modified: python/branches/release26-maint/Lib/test/test_urllib.py Modified: python/branches/release26-maint/Lib/test/test_urllib.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_urllib.py (original) +++ python/branches/release26-maint/Lib/test/test_urllib.py Mon Oct 5 06:16:26 2009 @@ -103,7 +103,7 @@ # Delete all proxy related env vars for k, v in os.environ.iteritems(): if 'proxy' in k.lower(): - env.unset(k) + self.env.unset(k) def tearDown(self): # Restore all proxy related env vars From nnorwitz at gmail.com Mon Oct 5 11:44:46 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 5 Oct 2009 05:44:46 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091005094446.GA25903@python.psfb.org> More important issues: ---------------------- test_urllib2_localnet leaked [-291, 0, 0] references, sum=-291 Less important issues: ---------------------- test_smtplib leaked [-91, 88, 0] references, sum=-3 test_socketserver leaked [0, 70, -70] references, sum=0 test_ssl leaked [-339, 339, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Mon Oct 5 19:03:09 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 05 Oct 2009 17:03:09 -0000 Subject: [Python-checkins] r75255 - in python/trunk: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Mon Oct 5 19:03:09 2009 New Revision: 75255 Log: Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. Modified: python/trunk/Lib/test/regrtest.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Mon Oct 5 19:03:09 2009 @@ -641,6 +641,10 @@ refleak = False # True if the test leaked references. try: save_stdout = sys.stdout + # Save various things that tests may mess up so we can restore + # them afterward. + save_environ = dict(os.environ) + save_argv = sys.argv[:] try: if capture_stdout: sys.stdout = capture_stdout @@ -663,6 +667,17 @@ test_time = time.time() - start_time finally: sys.stdout = save_stdout + # Restore what we saved if needed, but also complain if the test + # changed it so that the test may eventually get fixed. + if not os.environ == save_environ: + if not quiet: + print "Warning: os.environ was modified by", test + os.environ.clear() + os.environ.update(save_environ) + if not sys.argv == save_argv: + if not quiet: + print "Warning: argv was modified by", test + sys.argv[:] = save_argv except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 5 19:03:09 2009 @@ -1436,6 +1436,9 @@ Tests ----- +- Issue #7058: Added save/restore for argv and os.environ to runtest_inner + in regrtest, with warnings if the called test modifies them. + - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. - Issue #6806: test_platform failed under OS X 10.6.0 because ``sw_ver`` leaves From python-checkins at python.org Mon Oct 5 19:35:51 2009 From: python-checkins at python.org (tarek.ziade) Date: Mon, 05 Oct 2009 17:35:51 -0000 Subject: [Python-checkins] r75256 - in python/branches/release26-maint: Lib/distutils/command/build_ext.py Lib/distutils/tests/setuptools_build_ext.py Lib/distutils/tests/setuptools_extension.py Lib/distutils/tests/test_build_ext.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Mon Oct 5 19:35:51 2009 New Revision: 75256 Log: Fixed #7064: making sure get_ext_filename is called as Setuptools is assuming so it doesn't break it Added: python/branches/release26-maint/Lib/distutils/tests/setuptools_build_ext.py python/branches/release26-maint/Lib/distutils/tests/setuptools_extension.py Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/command/build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/command/build_ext.py Mon Oct 5 19:35:51 2009 @@ -630,7 +630,8 @@ """ fullname = self.get_ext_fullname(ext_name) modpath = fullname.split('.') - filename = self.get_ext_filename(modpath[-1]) + filename = self.get_ext_filename(ext_name) + filename = os.path.split(filename)[-1] if not self.inplace: # no further work needed Added: python/branches/release26-maint/Lib/distutils/tests/setuptools_build_ext.py ============================================================================== --- (empty file) +++ python/branches/release26-maint/Lib/distutils/tests/setuptools_build_ext.py Mon Oct 5 19:35:51 2009 @@ -0,0 +1,287 @@ +from distutils.command.build_ext import build_ext as _du_build_ext +try: + # Attempt to use Pyrex for building extensions, if available + from Pyrex.Distutils.build_ext import build_ext as _build_ext +except ImportError: + _build_ext = _du_build_ext + +import os, sys +from distutils.file_util import copy_file + +from distutils.tests.setuptools_extension import Library + +from distutils.ccompiler import new_compiler +from distutils.sysconfig import customize_compiler, get_config_var +get_config_var("LDSHARED") # make sure _config_vars is initialized +from distutils.sysconfig import _config_vars +from distutils import log +from distutils.errors import * + +have_rtld = False +use_stubs = False +libtype = 'shared' + +if sys.platform == "darwin": + use_stubs = True +elif os.name != 'nt': + try: + from dl import RTLD_NOW + have_rtld = True + use_stubs = True + except ImportError: + pass + +def if_dl(s): + if have_rtld: + return s + return '' + + + + + + +class build_ext(_build_ext): + def run(self): + """Build extensions in build directory, then copy if --inplace""" + old_inplace, self.inplace = self.inplace, 0 + _build_ext.run(self) + self.inplace = old_inplace + if old_inplace: + self.copy_extensions_to_source() + + def copy_extensions_to_source(self): + build_py = self.get_finalized_command('build_py') + for ext in self.extensions: + fullname = self.get_ext_fullname(ext.name) + filename = self.get_ext_filename(fullname) + modpath = fullname.split('.') + package = '.'.join(modpath[:-1]) + package_dir = build_py.get_package_dir(package) + dest_filename = os.path.join(package_dir,os.path.basename(filename)) + src_filename = os.path.join(self.build_lib,filename) + + # Always copy, even if source is older than destination, to ensure + # that the right extensions for the current Python/platform are + # used. + copy_file( + src_filename, dest_filename, verbose=self.verbose, + dry_run=self.dry_run + ) + if ext._needs_stub: + self.write_stub(package_dir or os.curdir, ext, True) + + + if _build_ext is not _du_build_ext and not hasattr(_build_ext,'pyrex_sources'): + # Workaround for problems using some Pyrex versions w/SWIG and/or 2.4 + def swig_sources(self, sources, *otherargs): + # first do any Pyrex processing + sources = _build_ext.swig_sources(self, sources) or sources + # Then do any actual SWIG stuff on the remainder + return _du_build_ext.swig_sources(self, sources, *otherargs) + + + + def get_ext_filename(self, fullname): + filename = _build_ext.get_ext_filename(self,fullname) + ext = self.ext_map[fullname] + if isinstance(ext,Library): + fn, ext = os.path.splitext(filename) + return self.shlib_compiler.library_filename(fn,libtype) + elif use_stubs and ext._links_to_dynamic: + d,fn = os.path.split(filename) + return os.path.join(d,'dl-'+fn) + else: + return filename + + def initialize_options(self): + _build_ext.initialize_options(self) + self.shlib_compiler = None + self.shlibs = [] + self.ext_map = {} + + def finalize_options(self): + _build_ext.finalize_options(self) + self.extensions = self.extensions or [] + self.check_extensions_list(self.extensions) + self.shlibs = [ext for ext in self.extensions + if isinstance(ext,Library)] + if self.shlibs: + self.setup_shlib_compiler() + for ext in self.extensions: + ext._full_name = self.get_ext_fullname(ext.name) + for ext in self.extensions: + fullname = ext._full_name + self.ext_map[fullname] = ext + ltd = ext._links_to_dynamic = \ + self.shlibs and self.links_to_dynamic(ext) or False + ext._needs_stub = ltd and use_stubs and not isinstance(ext,Library) + filename = ext._file_name = self.get_ext_filename(fullname) + libdir = os.path.dirname(os.path.join(self.build_lib,filename)) + if ltd and libdir not in ext.library_dirs: + ext.library_dirs.append(libdir) + if ltd and use_stubs and os.curdir not in ext.runtime_library_dirs: + ext.runtime_library_dirs.append(os.curdir) + + def setup_shlib_compiler(self): + compiler = self.shlib_compiler = new_compiler( + compiler=self.compiler, dry_run=self.dry_run, force=self.force + ) + if sys.platform == "darwin": + tmp = _config_vars.copy() + try: + # XXX Help! I don't have any idea whether these are right... + _config_vars['LDSHARED'] = "gcc -Wl,-x -dynamiclib -undefined dynamic_lookup" + _config_vars['CCSHARED'] = " -dynamiclib" + _config_vars['SO'] = ".dylib" + customize_compiler(compiler) + finally: + _config_vars.clear() + _config_vars.update(tmp) + else: + customize_compiler(compiler) + + if self.include_dirs is not None: + compiler.set_include_dirs(self.include_dirs) + if self.define is not None: + # 'define' option is a list of (name,value) tuples + for (name,value) in self.define: + compiler.define_macro(name, value) + if self.undef is not None: + for macro in self.undef: + compiler.undefine_macro(macro) + if self.libraries is not None: + compiler.set_libraries(self.libraries) + if self.library_dirs is not None: + compiler.set_library_dirs(self.library_dirs) + if self.rpath is not None: + compiler.set_runtime_library_dirs(self.rpath) + if self.link_objects is not None: + compiler.set_link_objects(self.link_objects) + + # hack so distutils' build_extension() builds a library instead + compiler.link_shared_object = link_shared_object.__get__(compiler) + + + + def get_export_symbols(self, ext): + if isinstance(ext,Library): + return ext.export_symbols + return _build_ext.get_export_symbols(self,ext) + + def build_extension(self, ext): + _compiler = self.compiler + try: + if isinstance(ext,Library): + self.compiler = self.shlib_compiler + _build_ext.build_extension(self,ext) + if ext._needs_stub: + self.write_stub( + self.get_finalized_command('build_py').build_lib, ext + ) + finally: + self.compiler = _compiler + + def links_to_dynamic(self, ext): + """Return true if 'ext' links to a dynamic lib in the same package""" + # XXX this should check to ensure the lib is actually being built + # XXX as dynamic, and not just using a locally-found version or a + # XXX static-compiled version + libnames = dict.fromkeys([lib._full_name for lib in self.shlibs]) + pkg = '.'.join(ext._full_name.split('.')[:-1]+['']) + for libname in ext.libraries: + if pkg+libname in libnames: return True + return False + + def get_outputs(self): + outputs = _build_ext.get_outputs(self) + optimize = self.get_finalized_command('build_py').optimize + for ext in self.extensions: + if ext._needs_stub: + base = os.path.join(self.build_lib, *ext._full_name.split('.')) + outputs.append(base+'.py') + outputs.append(base+'.pyc') + if optimize: + outputs.append(base+'.pyo') + return outputs + + def write_stub(self, output_dir, ext, compile=False): + log.info("writing stub loader for %s to %s",ext._full_name, output_dir) + stub_file = os.path.join(output_dir, *ext._full_name.split('.'))+'.py' + if compile and os.path.exists(stub_file): + raise DistutilsError(stub_file+" already exists! Please delete.") + if not self.dry_run: + f = open(stub_file,'w') + f.write('\n'.join([ + "def __bootstrap__():", + " global __bootstrap__, __file__, __loader__", + " import sys, os, pkg_resources, imp"+if_dl(", dl"), + " __file__ = pkg_resources.resource_filename(__name__,%r)" + % os.path.basename(ext._file_name), + " del __bootstrap__", + " if '__loader__' in globals():", + " del __loader__", + if_dl(" old_flags = sys.getdlopenflags()"), + " old_dir = os.getcwd()", + " try:", + " os.chdir(os.path.dirname(__file__))", + if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"), + " imp.load_dynamic(__name__,__file__)", + " finally:", + if_dl(" sys.setdlopenflags(old_flags)"), + " os.chdir(old_dir)", + "__bootstrap__()", + "" # terminal \n + ])) + f.close() + if compile: + from distutils.util import byte_compile + byte_compile([stub_file], optimize=0, + force=True, dry_run=self.dry_run) + optimize = self.get_finalized_command('install_lib').optimize + if optimize > 0: + byte_compile([stub_file], optimize=optimize, + force=True, dry_run=self.dry_run) + if os.path.exists(stub_file) and not self.dry_run: + os.unlink(stub_file) + + +if use_stubs or os.name=='nt': + # Build shared libraries + # + def link_shared_object(self, objects, output_libname, output_dir=None, + libraries=None, library_dirs=None, runtime_library_dirs=None, + export_symbols=None, debug=0, extra_preargs=None, + extra_postargs=None, build_temp=None, target_lang=None + ): self.link( + self.SHARED_LIBRARY, objects, output_libname, + output_dir, libraries, library_dirs, runtime_library_dirs, + export_symbols, debug, extra_preargs, extra_postargs, + build_temp, target_lang + ) +else: + # Build static libraries everywhere else + libtype = 'static' + + def link_shared_object(self, objects, output_libname, output_dir=None, + libraries=None, library_dirs=None, runtime_library_dirs=None, + export_symbols=None, debug=0, extra_preargs=None, + extra_postargs=None, build_temp=None, target_lang=None + ): + # XXX we need to either disallow these attrs on Library instances, + # or warn/abort here if set, or something... + #libraries=None, library_dirs=None, runtime_library_dirs=None, + #export_symbols=None, extra_preargs=None, extra_postargs=None, + #build_temp=None + + assert output_dir is None # distutils build_ext doesn't pass this + output_dir,filename = os.path.split(output_libname) + basename, ext = os.path.splitext(filename) + if self.library_filename("x").startswith('lib'): + # strip 'lib' prefix; this is kludgy if some platform uses + # a different prefix + basename = basename[3:] + + self.create_static_lib( + objects, basename, output_dir, debug, target_lang + ) Added: python/branches/release26-maint/Lib/distutils/tests/setuptools_extension.py ============================================================================== --- (empty file) +++ python/branches/release26-maint/Lib/distutils/tests/setuptools_extension.py Mon Oct 5 19:35:51 2009 @@ -0,0 +1,51 @@ +from distutils.core import Extension as _Extension +from distutils.core import Distribution as _Distribution + +def _get_unpatched(cls): + """Protect against re-patching the distutils if reloaded + + Also ensures that no other distutils extension monkeypatched the distutils + first. + """ + while cls.__module__.startswith('setuptools'): + cls, = cls.__bases__ + if not cls.__module__.startswith('distutils'): + raise AssertionError( + "distutils has already been patched by %r" % cls + ) + return cls + +_Distribution = _get_unpatched(_Distribution) +_Extension = _get_unpatched(_Extension) + +try: + from Pyrex.Distutils.build_ext import build_ext +except ImportError: + have_pyrex = False +else: + have_pyrex = True + + +class Extension(_Extension): + """Extension that uses '.c' files in place of '.pyx' files""" + + if not have_pyrex: + # convert .pyx extensions to .c + def __init__(self,*args,**kw): + _Extension.__init__(self,*args,**kw) + sources = [] + for s in self.sources: + if s.endswith('.pyx'): + sources.append(s[:-3]+'c') + else: + sources.append(s) + self.sources = sources + +class Library(Extension): + """Just like a regular Extension, but built as a library instead""" + +import sys, distutils.core, distutils.extension +distutils.core.Extension = Extension +distutils.extension.Extension = Extension +if 'distutils.command.build_ext' in sys.modules: + sys.modules['distutils.command.build_ext'].Extension = Extension Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Mon Oct 5 19:35:51 2009 @@ -13,6 +13,7 @@ import unittest from test import test_support + # http://bugs.python.org/issue4373 # Don't load the xx module more than once. ALREADY_TESTED = False @@ -334,6 +335,25 @@ etree_ext = Extension('lxml.etree', [etree_c]) dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]}) cmd = build_ext(dist) + cmd.ensure_finalized() + cmd.inplace = 1 + cmd.distribution.package_dir = {'': 'src'} + cmd.distribution.packages = ['lxml', 'lxml.html'] + curdir = os.getcwd() + ext = sysconfig.get_config_var("SO") + wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext) + path = cmd.get_ext_fullpath('lxml.etree') + self.assertEquals(wanted, path) + + def test_setuptools_compat(self): + from setuptools_build_ext import build_ext as setuptools_build_ext + from setuptools_extension import Extension + + etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c') + etree_ext = Extension('lxml.etree', [etree_c]) + dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]}) + cmd = setuptools_build_ext(dist) + cmd.ensure_finalized() cmd.inplace = 1 cmd.distribution.package_dir = {'': 'src'} cmd.distribution.packages = ['lxml', 'lxml.html'] Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Mon Oct 5 19:35:51 2009 @@ -18,6 +18,9 @@ Library ------- +- Issue #7064: Fixed the incompatibility with Setuptools in distutils + when running the build_ext command. + - Issue #7052: Removed nonexisting NullHandler from logging.__all__. - Issue #7039: Fixed distutils.tests.test_sysconfig when running on From python-checkins at python.org Mon Oct 5 20:24:45 2009 From: python-checkins at python.org (georg.brandl) Date: Mon, 05 Oct 2009 18:24:45 -0000 Subject: [Python-checkins] r75257 - python/branches/pep370 sandbox/trunk/pep370 Message-ID: Author: georg.brandl Date: Mon Oct 5 20:24:44 2009 New Revision: 75257 Log: Move branch to where it belongs. Added: python/branches/pep370/ - copied from r75256, /sandbox/trunk/pep370/ Removed: sandbox/trunk/pep370/ From python-checkins at python.org Mon Oct 5 22:18:06 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Mon, 05 Oct 2009 20:18:06 -0000 Subject: [Python-checkins] r75258 - python/trunk/Modules/_io/bufferedio.c Message-ID: Author: amaury.forgeotdarc Date: Mon Oct 5 22:18:05 2009 New Revision: 75258 Log: Fix compilation warning on Windows, where size_t is 32bit but file offsets are 64bit. Modified: python/trunk/Modules/_io/bufferedio.c Modified: python/trunk/Modules/_io/bufferedio.c ============================================================================== --- python/trunk/Modules/_io/bufferedio.c (original) +++ python/trunk/Modules/_io/bufferedio.c Mon Oct 5 22:18:05 2009 @@ -1705,7 +1705,8 @@ { PyObject *res = NULL; Py_buffer buf; - Py_ssize_t written, avail, remaining, n; + Py_ssize_t written, avail, remaining; + Py_off_t offset; CHECK_INITIALIZED(self) if (!PyArg_ParseTuple(args, "s*:write", &buf)) { @@ -1780,18 +1781,18 @@ the raw stream by itself). Fixes issue #6629. */ - n = RAW_OFFSET(self); - if (n != 0) { - if (_buffered_raw_seek(self, -n, 1) < 0) + offset = RAW_OFFSET(self); + if (offset != 0) { + if (_buffered_raw_seek(self, -offset, 1) < 0) goto error; - self->raw_pos -= n; + self->raw_pos -= offset; } /* Then write buf itself. At this point the buffer has been emptied. */ remaining = buf.len; written = 0; while (remaining > self->buffer_size) { - n = _bufferedwriter_raw_write( + Py_ssize_t n = _bufferedwriter_raw_write( self, (char *) buf.buf + written, buf.len - written); if (n == -1) { Py_ssize_t *w = _buffered_check_blocking_error(); From python-checkins at python.org Mon Oct 5 23:09:05 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Mon, 05 Oct 2009 21:09:05 -0000 Subject: [Python-checkins] r75259 - in python/branches/py3k: Modules/_io/bufferedio.c Message-ID: Author: amaury.forgeotdarc Date: Mon Oct 5 23:09:00 2009 New Revision: 75259 Log: Merged revisions 75258 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75258 | amaury.forgeotdarc | 2009-10-05 22:18:05 +0200 (lun., 05 oct. 2009) | 2 lines Fix compilation warning on Windows, where size_t is 32bit but file offsets are 64bit. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/bufferedio.c Modified: python/branches/py3k/Modules/_io/bufferedio.c ============================================================================== --- python/branches/py3k/Modules/_io/bufferedio.c (original) +++ python/branches/py3k/Modules/_io/bufferedio.c Mon Oct 5 23:09:00 2009 @@ -1688,7 +1688,8 @@ { PyObject *res = NULL; Py_buffer buf; - Py_ssize_t written, avail, remaining, n; + Py_ssize_t written, avail, remaining; + Py_off_t offset; CHECK_INITIALIZED(self) if (!PyArg_ParseTuple(args, "y*:write", &buf)) { @@ -1763,18 +1764,18 @@ the raw stream by itself). Fixes issue #6629. */ - n = RAW_OFFSET(self); - if (n != 0) { - if (_buffered_raw_seek(self, -n, 1) < 0) + offset = RAW_OFFSET(self); + if (offset != 0) { + if (_buffered_raw_seek(self, -offset, 1) < 0) goto error; - self->raw_pos -= n; + self->raw_pos -= offset; } /* Then write buf itself. At this point the buffer has been emptied. */ remaining = buf.len; written = 0; while (remaining > self->buffer_size) { - n = _bufferedwriter_raw_write( + Py_ssize_t n = _bufferedwriter_raw_write( self, (char *) buf.buf + written, buf.len - written); if (n == -1) { Py_ssize_t *w = _buffered_check_blocking_error(); From python-checkins at python.org Mon Oct 5 23:24:20 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 21:24:20 -0000 Subject: [Python-checkins] r75260 - python/trunk/Doc/library/pdb.rst Message-ID: Author: andrew.kuchling Date: Mon Oct 5 23:24:20 2009 New Revision: 75260 Log: Wording fix Modified: python/trunk/Doc/library/pdb.rst Modified: python/trunk/Doc/library/pdb.rst ============================================================================== --- python/trunk/Doc/library/pdb.rst (original) +++ python/trunk/Doc/library/pdb.rst Mon Oct 5 23:24:20 2009 @@ -58,7 +58,7 @@ import pdb; pdb.set_trace() at the location you want to break into the debugger. You can then step through -the code following this statement, and continue running without debugger using +the code following this statement, and continue running without the debugger using the ``c`` command. The typical usage to inspect a crashed program is:: From python-checkins at python.org Mon Oct 5 23:24:35 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 21:24:35 -0000 Subject: [Python-checkins] r75261 - python/trunk/Doc/library/tarfile.rst Message-ID: Author: andrew.kuchling Date: Mon Oct 5 23:24:35 2009 New Revision: 75261 Log: Fix narkup Modified: python/trunk/Doc/library/tarfile.rst Modified: python/trunk/Doc/library/tarfile.rst ============================================================================== --- python/trunk/Doc/library/tarfile.rst (original) +++ python/trunk/Doc/library/tarfile.rst Mon Oct 5 23:24:35 2009 @@ -399,7 +399,7 @@ value. Depending on this value the respective file is either excluded (:const:`True`) or added (:const:`False`). If *filter* is specified it must be a function that takes a :class:`TarInfo` object argument and returns the - changed TarInfo object. If it instead returns :const:`None` the TarInfo + changed :class:`TarInfo` object. If it instead returns :const:`None` the :class:`TarInfo` object will be excluded from the archive. See :ref:`tar-examples` for an example. From python-checkins at python.org Mon Oct 5 23:25:03 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 21:25:03 -0000 Subject: [Python-checkins] r75262 - python/trunk/Doc/library/bdb.rst Message-ID: Author: andrew.kuchling Date: Mon Oct 5 23:25:03 2009 New Revision: 75262 Log: Document 'skip' parameter to constructor Modified: python/trunk/Doc/library/bdb.rst Modified: python/trunk/Doc/library/bdb.rst ============================================================================== --- python/trunk/Doc/library/bdb.rst (original) +++ python/trunk/Doc/library/bdb.rst Mon Oct 5 23:25:03 2009 @@ -62,14 +62,22 @@ * The breakpoint hit count. -.. class:: Bdb() +.. class:: Bdb(skip=None) - The :class:`Bdb` acts as a generic Python debugger base class. + The :class:`Bdb` class acts as a generic Python debugger base class. This class takes care of the details of the trace facility; a derived class should implement user interaction. The standard debugger class (:class:`pdb.Pdb`) is an example. + The *skip* argument, if given, must be an iterable of glob-style + module name patterns. The debugger will not step into frames that + originate in a module that matches one of these patterns. Whether a + frame is considered to originate in a certain module is determined + by the ``__name__`` in the frame globals. + + .. versionadded:: 2.7 + The *skip* argument. The following methods of :class:`Bdb` normally don't need to be overridden. From python-checkins at python.org Mon Oct 5 23:25:35 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 21:25:35 -0000 Subject: [Python-checkins] r75263 - python/trunk/Doc/whatsnew/2.6.rst Message-ID: Author: andrew.kuchling Date: Mon Oct 5 23:25:35 2009 New Revision: 75263 Log: Note side benefit of socket.create_connection() Modified: python/trunk/Doc/whatsnew/2.6.rst Modified: python/trunk/Doc/whatsnew/2.6.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.6.rst (original) +++ python/trunk/Doc/whatsnew/2.6.rst Mon Oct 5 23:25:35 2009 @@ -2412,9 +2412,13 @@ environments. TIPC addresses are 4- or 5-tuples. (Contributed by Alberto Bertogli; :issue:`1646`.) - A new function, :func:`create_connection`, takes an address - and connects to it using an optional timeout value, returning - the connected socket object. + A new function, :func:`create_connection`, takes an address and + connects to it using an optional timeout value, returning the + connected socket object. This function also looks up the address's + type and connects to it using IPv4 or IPv6 as appropriate. Changing + your code to use :func:`create_connection` instead of + ``socket(socket.AF_INET, ...)`` may be all that's required to make + your code work with IPv6. * The base classes in the :mod:`SocketServer` module now support calling a :meth:`handle_timeout` method after a span of inactivity From nnorwitz at gmail.com Tue Oct 6 00:12:06 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 5 Oct 2009 18:12:06 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091005221206.GA20940@python.psfb.org> More important issues: ---------------------- test_ctypes leaked [0, 0, 1] references, sum=1 Less important issues: ---------------------- test_asynchat leaked [126, -126, 0] references, sum=0 test_cmd_line leaked [0, 25, -25] references, sum=0 test_distutils leaked [-25, 25, 0] references, sum=0 test_file2k leaked [82, -82, 0] references, sum=0 test_smtplib leaked [-2, -88, 88] references, sum=-2 test_ssl leaked [0, -339, 339] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Tue Oct 6 00:30:22 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 22:30:22 -0000 Subject: [Python-checkins] r75264 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 6 00:30:22 2009 New Revision: 75264 Log: Add various items Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Tue Oct 6 00:30:22 2009 @@ -49,46 +49,191 @@ This saves the maintainer some effort going through the SVN logs when researching a change. -This article explains the new features in Python 2.7. -No release schedule has been decided yet for 2.7. +This article explains the new features in Python 2.7. No release +schedule has been decided yet for 2.7; the schedule will eventually be +described in :pep:`373`. .. Compare with previous release in 2 - 3 sentences here. add hyperlink when the documentation becomes available online. -Python 3.1 -================ +.. _whatsnew27-python31: -Much as Python 2.6 incorporated features from Python 3.0, -version 2.7 is influenced by features from 3.1. +Python 3.1 Features +======================= -XXX mention importlib; anything else? +Much as Python 2.6 incorporated features from Python 3.0, +version 2.7 incorporates some of the new features +in Python 3.1. The 2.x series continues to provide tools +for migrating to the 3.x series. + +A partial list of 3.1 features that were backported to 2.7: + +* A version of the :mod:`io` library, rewritten in C for performance. +* The ordered-dictionary type described in :ref:`pep-0372`. +* The new format specified described in :ref:`pep-0378`. +* The :class:`memoryview` object. +* A small subset of the :mod:`importlib` module `described below <#importlib-section>`__. One porting change: the :option:`-3` switch now automatically enables the :option:`-Qwarn` switch that causes warnings about using classic division with integers and long integers. +Other new Python3-mode warnings include: + +* :func:`operator.isCallable` and :func:`operator.sequenceIncludes`, + which are not supported in 3.x. + .. ======================================================================== .. Large, PEP-level features and changes should be described here. .. ======================================================================== +.. _pep-0372: + PEP 372: Adding an ordered dictionary to collections ==================================================== -XXX write this +Regular Python dictionaries iterate over key/value pairs in arbitrary order. +Over the years, a number of authors have written alternative implementations +that remember the order that the keys were originally inserted. Based on +the experiences from those implementations, a new +:class:`collections.OrderedDict` class has been introduced. + +The :class:`OrderedDict` API is substantially the same as regular dictionaries +but will iterate over keys and values in a guaranteed order depending on +when a key was first inserted:: + + >>> from collections import OrderedDict + >>> d = OrderedDict([('first', 1), ('second', 2), + ... ('third', 3)]) + >>> d.items() + [('first', 1), ('second', 2), ('third', 3)] + +If a new entry overwrites an existing entry, the original insertion +position is left unchanged:: + + >>> d['second'] = 4 + >>> d.items() + [('first', 1), ('second', 4), ('third', 3)] + +Deleting an entry and reinserting it will move it to the end:: + + >>> del d['second'] + >>> d['second'] = 5 + >>> d.items() + [('first', 1), ('third', 3), ('second', 5)] + +The :meth:`popitem` method has an optional *last* argument +that defaults to True. If *last* is True, the most recently +added key is returned and removed; if it's False, the +oldest key is selected:: + + >>> od = OrderedDict([(x,0) for x in range(20)]) + >>> od.popitem() + (19, 0) + >>> od.popitem() + (18, 0) + >>> od.popitem(False) + (0, 0) + >>> od.popitem(False) + (1, 0) + +Comparing two ordered dictionaries checks both the keys and values, +and requires that the insertion order was the same:: + + >>> od1 = OrderedDict([('first', 1), ('second', 2), + ... ('third', 3)]) + >>> od2 = OrderedDict([('third', 3), ('first', 1), + ... ('second', 2)]) + >>> od1==od2 + False + >>> # Move 'third' key to the end + >>> del od2['third'] ; od2['third'] = 3 + >>> od1==od2 + True + +Comparing an :class:`OrderedDict` with a regular dictionary +ignores the insertion order and just compares the keys and values. + +How does the :class:`OrderedDict` work? It maintains a doubly-linked +list of keys, appending new keys to the list as they're inserted. A +secondary dictionary maps keys to their corresponding list node, so +deletion doesn't have to traverse the entire linked list and therefore +remains O(1). + +.. XXX check O(1)-ness with Raymond + +The standard library now supports use of ordered dictionaries in several +modules. The :mod:`configparser` module uses them by default. This lets +configuration files be read, modified, and then written back in their original +order. The *_asdict()* method for :func:`collections.namedtuple` now +returns an ordered dictionary with the values appearing in the same order as +the underlying tuple indicies. The :mod:`json` module is being built-out with +an *object_pairs_hook* to allow OrderedDicts to be built by the decoder. +Support was also added for third-party tools like `PyYAML `_. -Several modules will now use :class:`OrderedDict` by default. The -:mod:`ConfigParser` module uses :class:`OrderedDict` for the list -of sections and the options within a section. -The :meth:`namedtuple._asdict` method returns an :class:`OrderedDict` -as well. +.. _pep-0378: + +PEP 378: Format Specifier for Thousands Separator +==================================================== + +To make program output more readable, it can be useful to add +separators to large numbers and render them as +18,446,744,073,709,551,616 instead of 18446744073709551616. + +The fully general solution for doing this is the :mod:`locale` module, +which can use different separators ("," in North America, "." in +Europe) and different grouping sizes, but :mod:`locale` is complicated +to use and unsuitable for multi-threaded applications where different +threads are producing output for different locales. + +Therefore, a simple comma-grouping mechanism has been added to the +mini-language used by the string :meth:`format` method. When +formatting a floating-point number, simply include a comma between the +width and the precision:: + + >>> '{:20,.2}'.format(f) + '18,446,744,073,709,551,616.00' + +This mechanism is not adaptable at all; commas are always used as the +separator and the grouping is always into three-digit groups. The +comma-formatting mechanism isn't as general as the :mod:`locale` +module, but it's easier to use. + +.. XXX "Format String Syntax" in string.rst doesn't describe ','; + could use many more examples. + +.. seealso:: + + :pep:`378` - Format Specifier for Thousands Separator + PEP written by Raymond Hettinger; implemented by Eric Smith. Other Language Changes ====================== Some smaller changes made to the core Python language are: -* :meth:`str.format` method now supports automatic numbering of the replacement +* The :keyword:`with` statement can now use multiple context managers + in one statement. Context managers are processed from left to right + and each one is treated as beginning a new :keyword:`with` statement. + This means that:: + + with A() as a, B() as b: + ... suite of statements ... + + is equivalent to:: + + with A() as a: + with B() as b: + ... suite of statements ... + + The :func:`contextlib.nested` function provides a very similar + function, so it's no longer necessary and has been deprecated. + + (Proposed in http://codereview.appspot.com/53094; implemented by + Georg Brandl.) + +* The :meth:`str.format` method now supports automatic numbering of the replacement fields. This makes using :meth:`str.format` more closely resemble using ``%s`` formatting:: @@ -102,7 +247,13 @@ specifier will use the next argument, and so on. You can't mix auto-numbering and explicit numbering -- either number all of your specifier fields or none of them -- but you can mix auto-numbering and named fields, as in the second - example above. (Contributed by Eric Smith; :issue`5237`.) + example above. (Contributed by Eric Smith; :issue:`5237`.) + + Complex numbers now correctly support usage with :func:`format`. + Specifying a precision or comma-separation applies to both the real + and imaginary parts of the number, but a specified field width and + alignment is applied to the whole of the resulting ``1.5+3j`` + output. (Contributed by Eric Smith; :issue:`1588`.) * The :func:`int` and :func:`long` types gained a ``bit_length`` method that returns the number of bits necessary to represent @@ -125,7 +276,7 @@ point now round differently, returning the floating-point number closest to the number. This doesn't matter for small integers that can be converted exactly, but for large numbers that will - unavoidably lose precision, Python 2.7 will now approximate more + unavoidably lose precision, Python 2.7 now approximates more closely. For example, Python 2.6 computed the following:: >>> n = 295147905179352891391 @@ -146,10 +297,20 @@ (Implemented by Mark Dickinson; :issue:`3166`.) -* The :class:`bytearray` type's :meth:`translate` method will - now accept ``None`` as its first argument. (Fixed by Georg Brandl; +* The :class:`bytearray` type's :meth:`translate` method now accepts + ``None`` as its first argument. (Fixed by Georg Brandl; :issue:`4759`.) +* When using ``@classmethod`` and ``@staticmethod`` to wrap + methods as class or static methods, the wrapper object now + exposes the wrapped function as their :attr:`__func__` attribute. + (Contributed by Amaury Forgeot d'Arc, after a suggestion by + George Sakkis; :issue:`5982`.) + +* A new encoding named "cp720", used primarily for Arabic text, is now + supported. (Contributed by Alexander Belchenko and Amaury Forgeot + d'Arc; :issue:`1616979`.) + .. ====================================================================== @@ -164,6 +325,10 @@ and benchmark. The new mechanism is only supported on certain compilers, such as gcc, SunPro, and icc. +* A new opcode was added to perform the initial setup for + :keyword:`with` statements, looking up the :meth:`__enter__` and + :meth:`__exit__` methods. (Contributed by Benjamin Peterson.) + * The garbage collector now performs better when many objects are being allocated without deallocating any. A full garbage collection pass is only performed when the middle generation has been collected @@ -184,7 +349,7 @@ considered and traversed by the collector. (Contributed by Antoine Pitrou; :issue:`4688`.) -* Integers are now stored internally either in base 2**15 or in base +* Long integers are now stored internally either in base 2**15 or in base 2**30, the base being determined at build time. Previously, they were always stored in base 2**15. Using base 2**30 gives significant performance improvements on 64-bit machines, but @@ -227,6 +392,21 @@ faster bytecode. (Patch by Antoine Pitrou, back-ported to 2.7 by Jeffrey Yasskin; :issue:`4715`.) +* The :mod:`pickle` and :mod:`cPickle` modules now automatically + intern the strings used for attribute names, reducing memory usage + of the objects resulting from unpickling. (Contributed by Jake + McGuire; :issue:`5084`.) + +* The :mod:`cPickle` module now special-cases dictionaries, + nearly halving the time required to pickle them. + (Contributed by Collin Winter; :issue:`5670`.) + +* Converting an integer or long integer to a decimal string was made + faster by special-casing base 10 instead of using a generalized + conversion function that supports arbitrary bases. + (Patch by Gawain Bolton; :issue:`6713`.) + + .. ====================================================================== New, Improved, and Deprecated Modules @@ -238,6 +418,14 @@ :file:`Misc/NEWS` file in the source tree for a more complete list of changes, or look through the Subversion logs for all the details. +* The :mod:`bdb` module's base debugging class :class:`Bdb` + gained a feature for skipping modules. The constructor + now takes an iterable containing glob-style patterns such as + ``django.*``; the debugger will not step into stack frames + from a module that matches one of these patterns. + (Contributed by Maru Newby after a suggestion by + Senthil Kumaran; :issue:`5142`.) + * The :mod:`bz2` module's :class:`BZ2File` now supports the context management protocol, so you can write ``with bz2.BZ2File(...) as f: ...``. (Contributed by Hagen Fuerstenau; :issue:`3860`.) @@ -279,6 +467,9 @@ Contributed by Raymond Hettinger; :issue:`1696199`. + The new `OrderedDict` class is described in the earlier section + :ref:`pep-0372`. + The :class:`namedtuple` class now has an optional *rename* parameter. If *rename* is true, field names that are invalid because they've been repeated or that aren't legal Python identifiers will be @@ -295,10 +486,42 @@ The :class:`deque` data type now exposes its maximum length as the read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.) -* In Distutils, :func:`distutils.sdist.add_defaults` now uses +* The :mod:`ctypes` module now always converts ``None`` to a C NULL + pointer for arguments declared as pointers. (Changed by Thomas + Heller; :issue:`4606`.) + +* New method: the :class:`Decimal` class gained a + :meth:`from_float` class method that performs an exact conversion + of a floating-point number to a :class:`Decimal`. + Note that this is an **exact** conversion that strives for the + closest decimal approximation to the floating-point representation's value; + the resulting decimal value will therefore still include the inaccuracy, + if any. + For example, ``Decimal.from_float(0.1)`` returns + ``Decimal('0.1000000000000000055511151231257827021181583404541015625')``. + (Implemented by Raymond Hettinger; :issue:`4796`.) + + The constructor for :class:`Decimal` now accepts non-European + Unicode characters, such as Arabic-Indic digits. (Contributed by + Mark Dickinson; :issue:`6595`.) + + When using :class:`Decimal` instances with a string's + :meth:`format` method, the default alignment was previously + left-alignment. This has been changed to right-alignment, which seems + more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.) + +* Distutils is being more actively developed, thanks to Tarek Ziade + has taken over maintenance of the package. A new + :file:`setup.py` subcommand, ``check``, will + check that the arguments being passed to the :func:`setup` function + are complete and correct (:issue:`5732`). + + :func:`distutils.sdist.add_defaults` now uses *package_dir* and *data_files* to create the MANIFEST file. - :mod:`distutils.sysconfig` will now read the :envvar:`AR` - environment variable. + :mod:`distutils.sysconfig` now reads the :envvar:`AR` and + :envvar:`ARFLAGS` environment variables. + + .. ARFLAGS done in #5941 It is no longer mandatory to store clear-text passwords in the :file:`.pypirc` file when registering and uploading packages to PyPI. As long @@ -312,18 +535,7 @@ process, but instead simply not install the failing extension. (Contributed by Georg Brandl; :issue:`5583`.) -* New method: the :class:`Decimal` class gained a - :meth:`from_float` class method that performs an exact conversion - of a floating-point number to a :class:`Decimal`. - Note that this is an **exact** conversion that strives for the - closest decimal approximation to the floating-point representation's value; - the resulting decimal value will therefore still include the inaccuracy, - if any. - For example, ``Decimal.from_float(0.1)`` returns - ``Decimal('0.1000000000000000055511151231257827021181583404541015625')``. - (Implemented by Raymond Hettinger; :issue:`4796`.) - -* The :class:`Fraction` class will now accept two rational numbers +* The :class:`Fraction` class now accepts two rational numbers as arguments to its constructor. (Implemented by Mark Dickinson; :issue:`5812`.) @@ -338,7 +550,32 @@ recorded in a gzipped file by providing an optional timestamp to the constructor. (Contributed by Jacques Frechet; :issue:`4272`.) -* The :class:`io.FileIO` class now raises an :exc:`OSError` when passed +* The :mod:`hashlib` module was inconsistent about accepting + input as a Unicode object or an object that doesn't support + the buffer protocol. The behavior was different depending on + whether :mod:`hashlib` was using an external OpenSSL library + or its built-in implementations. Python 2.7 makes the + behavior consistent, always rejecting such objects by raising a + :exc:`TypeError`. (Fixed by Gregory P. Smith; :issue:`3745`.) + +* The default :class:`HTTPResponse` class used by the :mod:`httplib` module now + supports buffering, resulting in much faster reading of HTTP responses. + (Contributed by Kristjan Valur Jonsson; :issue:`4879`.) + +* The :mod:`imaplib` module now supports IPv6 addresses. + (Contributed by Derek Morr; :issue:`1655`.) + +* The :mod:`io` library has been upgraded to the version shipped with + Python 3.1. For 3.1, the I/O library was entirely rewritten in C + and is 2 to 20 times faster depending on the task at hand. The + original Python version was renamed to the :mod:`_pyio` module. + + One minor resulting change: the :class:`io.TextIOBase` class now + has an :attr:`errors` attribute giving the error setting + used for encoding and decoding errors (one of ``'strict'``, ``'replace'``, + ``'ignore'``). + + The :class:`io.FileIO` class now raises an :exc:`OSError` when passed an invalid file descriptor. (Implemented by Benjamin Peterson; :issue:`4991`.) @@ -382,12 +619,19 @@ with any object literal that decodes to a list of pairs. (Contributed by Raymond Hettinger; :issue:`5381`.) +* New functions: the :mod:`math` module now has + a :func:`gamma` function. + (Contributed by Mark Dickinson and nirinA raseliarison; :issue:`3366`.) + * The :mod:`multiprocessing` module's :class:`Manager*` classes can now be passed a callable that will be called whenever a subprocess is started, along with a set of arguments that will be passed to the callable. (Contributed by lekma; :issue:`5585`.) +* The :mod:`nntplib` module now supports IPv6 addresses. + (Contributed by Derek Morr; :issue:`1664`.) + * The :mod:`pydoc` module now has help for the various symbols that Python uses. You can now do ``help('<<')`` or ``help('@')``, for example. (Contributed by David Laban; :issue:`4739`.) @@ -396,6 +640,39 @@ now accept an optional *flags* argument, for consistency with the other functions in the module. (Added by Gregory P. Smith.) +* The :mod:`shutil` module's :func:`copyfile` and :func:`copytree` + functions now raises a :exc:`SpecialFileError` exception when + asked to copy a named pipe. Previously the code would treat + named pipes like a regular file by opening them for reading, and + this would block indefinitely. (Fixed by Antoine Pitrou; :issue:`3002`.) + +* New functions: in the :mod:`site` module, three new functions + return various site- and user-specific paths. + :func:`getsitepackages` returns a list containing all + global site-packages directories, and + :func:`getusersitepackages` returns the path of the user's + site-packages directory. + :func:`getuserbase` returns the value of the :envvar:``USER_BASE`` + environment variable, giving the path to a directory that can be used + to store data. + (Contributed by Tarek Ziade; :issue:`6693`.) + +* The :mod:`SocketServer` module's :class:`TCPServer` class now + has a :attr:`disable_nagle_algorithm` class attribute. + The default value is False; if overridden to be True, + new request connections will have the TCP_NODELAY option set to + prevent buffering many small sends into a single TCP packet. + (Contributed by Kristjan Valur Jonsson; :issue:`6192`.) + + .. XXX the documentation for this attr was silently dropped from + .. Doc/library/socketserver.rst. + +* The :mod:`struct` module will no longer silently ignore overflow + errors when a value is too large for a particular integer format + code (one of ``bBhHiIlLqQ``); it now always raises a + :exc:`struct.error` exception. (Changed by Mark Dickinson; + :issue:`1523`.) + * New function: the :mod:`subprocess` module's :func:`check_output` runs a command with a specified set of arguments and returns the command's output as a string when the command runs without @@ -422,114 +699,25 @@ named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``. (Contributed by Ross Light; :issue:`4285`.) +* The :mod:`tarfile` module now supports filtering the :class:`TarInfo` + objects being added to a tar file. When you call :meth:`TarFile.add`, + instance, you may supply an optional *filter* argument + that's a callable. The *filter* callable will be passed the + :class:`TarInfo` for every file being added, and can modify and return it. + If the callable returns ``None``, the file will be excluded from the + resulting archive. This is more powerful than the existing + *exclude* argument, which has therefore been deprecated. + (Added by Lars Gustaebel; :issue:`6856`.) + * The :mod:`threading` module's :meth:`Event.wait` method now returns the internal flag on exit. This means the method will usually return true because :meth:`wait` is supposed to block until the internal flag becomes true. The return value will only be false if a timeout was provided and the operation timed out. - (Contributed by XXX; :issue:`1674032`.) - -* The :mod:`unittest` module was enhanced in several ways. - The progress messages will now show 'x' for expected failures - and 'u' for unexpected successes when run in verbose mode. - (Contributed by Benjamin Peterson.) - Test cases can raise the :exc:`SkipTest` exception to skip a test. - (:issue:`1034053`.) - - The error messages for :meth:`assertEqual`, - :meth:`assertTrue`, and :meth:`assertFalse` - failures now provide more information. If you set the - :attr:`longMessage` attribute of your :class:`TestCase` classes to - true, both the standard error message and any additional message you - provide will be printed for failures. (Added by Michael Foord; :issue:`5663`.) - - The :meth:`assertRaises` and :meth:`failUnlessRaises` methods now - return a context handler when called without providing a callable - object to run. For example, you can write this:: - - with self.assertRaises(KeyError): - raise ValueError - - (Implemented by Antoine Pitrou; :issue:`4444`.) - - The methods :meth:`addCleanup` and :meth:`doCleanups` were added. - :meth:`addCleanup` allows you to add cleanup functions that - will be called unconditionally (after :meth:`setUp` if - :meth:`setUp` fails, otherwise after :meth:`tearDown`). This allows - for much simpler resource allocation and deallocation during tests. - :issue:`5679` - - A number of new methods were added that provide more specialized - tests. Many of these methods were written by Google engineers - for use in their test suites; Gregory P. Smith, Michael Foord, and - GvR worked on merging them into Python's version of :mod:`unittest`. - - * :meth:`assertIsNone` and :meth:`assertIsNotNone` take one - expression and verify that the result is or is not ``None``. - - * :meth:`assertIs` and :meth:`assertIsNot` take two values and check - whether the two values evaluate to the same object or not. - (Added by Michael Foord; :issue:`2578`.) - - * :meth:`assertGreater`, :meth:`assertGreaterEqual`, - :meth:`assertLess`, and :meth:`assertLessEqual` compare - two quantities. - - * :meth:`assertMultiLineEqual` compares two strings, and if they're - not equal, displays a helpful comparison that highlights the - differences in the two strings. - - * :meth:`assertRegexpMatches` checks whether its first argument is a - string matching a regular expression provided as its second argument. - - * :meth:`assertRaisesRegexp` checks whether a particular exception - is raised, and then also checks that the string representation of - the exception matches the provided regular expression. - - * :meth:`assertIn` and :meth:`assertNotIn` tests whether - *first* is or is not in *second*. - - * :meth:`assertSameElements` tests whether two provided sequences - contain the same elements. - - * :meth:`assertSetEqual` compares whether two sets are equal, and - only reports the differences between the sets in case of error. - - * Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual` - compare the specified types and explain the differences. - More generally, :meth:`assertSequenceEqual` compares two sequences - and can optionally check whether both sequences are of a - particular type. - - * :meth:`assertDictEqual` compares two dictionaries and reports the - differences. :meth:`assertDictContainsSubset` checks whether - all of the key/value pairs in *first* are found in *second*. - - * :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` short-circuit - (automatically pass or fail without checking decimal places) if the objects - are equal. - - * :meth:`loadTestsFromName` properly honors the ``suiteClass`` attribute of - the :class:`TestLoader`. (Fixed by Mark Roddy; :issue:`6866`.) - - * A new hook, :meth:`addTypeEqualityFunc` takes a type object and a - function. The :meth:`assertEqual` method will use the function - when both of the objects being compared are of the specified type. - This function should compare the two objects and raise an - exception if they don't match; it's a good idea for the function - to provide additional information about why the two objects are - matching, much as the new sequence comparison methods do. - - :func:`unittest.main` now takes an optional ``exit`` argument. - If False ``main`` doesn't call :func:`sys.exit` allowing it to - be used from the interactive interpreter. :issue:`3379`. - - :class:`TestResult` has new :meth:`startTestRun` and - :meth:`stopTestRun` methods; called immediately before - and after a test run. :issue:`5728` by Robert Collins. + (Contributed by Tim Lesher; :issue:`1674032`.) -* The :func:`is_zipfile` function in the :mod:`zipfile` module will now - accept a file object, in addition to the path names accepted in earlier +* The :func:`is_zipfile` function in the :mod:`zipfile` module now + accepts a file object, in addition to the path names accepted in earlier versions. (Contributed by Gabriel Genellina; :issue:`4756`.) :mod:`zipfile` now supports archiving empty directories and @@ -538,6 +726,118 @@ .. ====================================================================== .. whole new modules get described in subsections here +Unit Testing Enhancements +--------------------------------- + +The :mod:`unittest` module was enhanced in several ways. +The progress messages now shows 'x' for expected failures +and 'u' for unexpected successes when run in verbose mode. +(Contributed by Benjamin Peterson.) +Test cases can raise the :exc:`SkipTest` exception to skip a test. +(:issue:`1034053`.) + +.. XXX describe test discovery (Contributed by Michael Foord; :issue:`6001`.) + +The error messages for :meth:`assertEqual`, +:meth:`assertTrue`, and :meth:`assertFalse` +failures now provide more information. If you set the +:attr:`longMessage` attribute of your :class:`TestCase` classes to +true, both the standard error message and any additional message you +provide will be printed for failures. (Added by Michael Foord; :issue:`5663`.) + +The :meth:`assertRaises` and :meth:`failUnlessRaises` methods now +return a context handler when called without providing a callable +object to run. For example, you can write this:: + + with self.assertRaises(KeyError): + raise ValueError + +(Implemented by Antoine Pitrou; :issue:`4444`.) + +The methods :meth:`addCleanup` and :meth:`doCleanups` were added. +:meth:`addCleanup` allows you to add cleanup functions that +will be called unconditionally (after :meth:`setUp` if +:meth:`setUp` fails, otherwise after :meth:`tearDown`). This allows +for much simpler resource allocation and deallocation during tests. +:issue:`5679` + +A number of new methods were added that provide more specialized +tests. Many of these methods were written by Google engineers +for use in their test suites; Gregory P. Smith, Michael Foord, and +GvR worked on merging them into Python's version of :mod:`unittest`. + +* :meth:`assertIsNone` and :meth:`assertIsNotNone` take one + expression and verify that the result is or is not ``None``. + +* :meth:`assertIs` and :meth:`assertIsNot` take two values and check + whether the two values evaluate to the same object or not. + (Added by Michael Foord; :issue:`2578`.) + +* :meth:`assertGreater`, :meth:`assertGreaterEqual`, + :meth:`assertLess`, and :meth:`assertLessEqual` compare + two quantities. + +* :meth:`assertMultiLineEqual` compares two strings, and if they're + not equal, displays a helpful comparison that highlights the + differences in the two strings. + +* :meth:`assertRegexpMatches` checks whether its first argument is a + string matching a regular expression provided as its second argument. + +* :meth:`assertRaisesRegexp` checks whether a particular exception + is raised, and then also checks that the string representation of + the exception matches the provided regular expression. + +* :meth:`assertIn` and :meth:`assertNotIn` tests whether + *first* is or is not in *second*. + +* :meth:`assertSameElements` tests whether two provided sequences + contain the same elements. + +* :meth:`assertSetEqual` compares whether two sets are equal, and + only reports the differences between the sets in case of error. + +* Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual` + compare the specified types and explain the differences. + More generally, :meth:`assertSequenceEqual` compares two sequences + and can optionally check whether both sequences are of a + particular type. + +* :meth:`assertDictEqual` compares two dictionaries and reports the + differences. :meth:`assertDictContainsSubset` checks whether + all of the key/value pairs in *first* are found in *second*. + +* :meth:`assertAlmostEqual` and :meth:`assertNotAlmostEqual` short-circuit + (automatically pass or fail without checking decimal places) if the objects + are equal. + +* :meth:`loadTestsFromName` properly honors the ``suiteClass`` attribute of + the :class:`TestLoader`. (Fixed by Mark Roddy; :issue:`6866`.) + +* A new hook, :meth:`addTypeEqualityFunc` takes a type object and a + function. The :meth:`assertEqual` method will use the function + when both of the objects being compared are of the specified type. + This function should compare the two objects and raise an + exception if they don't match; it's a good idea for the function + to provide additional information about why the two objects are + matching, much as the new sequence comparison methods do. + +:func:`unittest.main` now takes an optional ``exit`` argument. +If False ``main`` doesn't call :func:`sys.exit` allowing it to +be used from the interactive interpreter. :issue:`3379`. + +:class:`TestResult` has new :meth:`startTestRun` and +:meth:`stopTestRun` methods; called immediately before +and after a test run. :issue:`5728` by Robert Collins. + +With all these changes, the :file:`unittest.py` was becoming awkwardly +large, so the module was turned into a package and the code split into +several files (by Benjamin Peterson). This doesn't affect how the +module is imported. + + +.. _importlib-section: + importlib: Importing Modules ------------------------------ @@ -549,7 +849,7 @@ :mod:`importlib` package, but instead has a tiny subset that contains a single function, :func:`import_module`. -``import_module(*name*, *package*=None)`` imports a module. *name* is +``import_module(name, package=None)`` imports a module. *name* is a string containing the module or package's name. It's possible to do relative imports by providing a string that begins with a ``.`` character, such as ``..utils.errors``. For relative imports, the @@ -599,8 +899,8 @@ Changes to Python's build process and to the C API include: * If you use the :file:`.gdbinit` file provided with Python, - the "pyo" macro in the 2.7 version will now work when the thread being - debugged doesn't hold the GIL; the macro will now acquire it before printing. + the "pyo" macro in the 2.7 version now works correctly when the thread being + debugged doesn't hold the GIL; the macro now acquires it before printing. (Contributed by Victor Stinner; :issue:`3632`.) * :cfunc:`Py_AddPendingCall` is now thread-safe, letting any @@ -608,8 +908,57 @@ is particularly useful for asynchronous IO operations. (Contributed by Kristjan Valur Jonsson; :issue:`4293`.) +* New function: :cfunc:`PyCode_NewEmpty` creates an empty code object; + only the filename, function name, and first line number are required. + This is useful to extension modules that are attempting to + construct a more useful traceback stack. Previously such + extensions needed to call :cfunc:`PyCode_New`, which had many + more arguments. (Added by Jeffrey Yasskin.) + +* New function: :cfunc:`PyFrame_GetLineNumber` takes a frame object + and returns the line number that the frame is currently executing. + Previously code would need to get the index of the bytecode + instruction currently executing, and then look up the line number + corresponding to that address. (Added by Jeffrey Yasskin.) + +* New macros: the Python header files now define the following macros: + :cmacro:`Py_ISALNUM`, + :cmacro:`Py_ISALPHA`, + :cmacro:`Py_ISDIGIT`, + :cmacro:`Py_ISLOWER`, + :cmacro:`Py_ISSPACE`, + :cmacro:`Py_ISUPPER`, + :cmacro:`Py_ISXDIGIT`, + and :cmacro:`Py_TOLOWER`, :cmacro:`Py_TOUPPER`. + All of these functions are analogous to the C + standard macros for classifying characters, but ignore the current + locale setting, because in + several places Python needs to analyze characters in a + locale-independent way. (Added by Eric Smith; + :issue:`5793`.) + + .. XXX these macros don't seem to be described in the c-api docs. + +* The complicated interaction between threads and process forking has + been changed. Previously, the child process created by + :func:`os.fork` might fail because the child is created with only a + single thread running, the thread performing the :func:`os.fork`. + If other threads were holding a lock, such as Python's import lock, + when the fork was performed, the lock would still be marked as + "held" in the new process. But in the child process nothing would + ever release the lock, since the other threads weren't replicated, + and the child process would no longer be able to perform imports. + + Python 2.7 now acquires the import lock before performing an + :func:`os.fork`, and will also clean up any locks created using the + :mod:`threading` module. C extension modules that have internal + locks, or that call :cfunc:`fork()` themselves, will not benefit + from this clean-up. + + (Fixed by Thomas Wouters; :issue:`1590864`.) + * Global symbols defined by the :mod:`ctypes` module are now prefixed - with ``Py`, or with ``_ctypes``. (Implemented by Thomas + with ``Py``, or with ``_ctypes``. (Implemented by Thomas Heller; :issue:`3102`.) * The :program:`configure` script now checks for floating-point rounding bugs @@ -618,6 +967,12 @@ but it's available if anyone wishes to use it. (Added by Mark Dickinson; :issue:`2937`.) +* The build process now creates the necessary files for pkg-config + support. (Contributed by Clinton Roy; :issue:`3585`.) + +* The build process now supports Subversion 1.7. (Contributed by + Arfrever Frehtes Taifersar Arahesis; :issue:`6094`.) + .. ====================================================================== Port-Specific Changes: Windows @@ -634,12 +989,15 @@ the native thread-local storage functions are now used. (Contributed by Kristjan Valur Jonsson; :issue:`3582`.) +* The :func:`os.listdir` function now correctly fails + for an empty path. (Fixed by Hirokazu Yamamoto; :issue:`5913`.) + .. ====================================================================== Port-Specific Changes: Mac OS X ----------------------------------- -* The ``/Library/Python/2.7/site-packages`` is now appended to +* The path ``/Library/Python/2.7/site-packages`` is now appended to ``sys.path``, in order to share added packages between the system installation and a user-installed copy of the same version. (Changed by Ronald Oussoren; :issue:`4865`.) @@ -658,12 +1016,12 @@ * The :file:`regrtest.py` script now takes a :option:`--randseed=` switch that takes an integer that will be used as the random seed for the :option:`-r` option that executes tests in random order. - The :option:`-r` option also now reports the seed that was used + The :option:`-r` option also reports the seed that was used (Added by Collin Winter.) * The :file:`regrtest.py` script now takes a :option:`-j` switch that takes an integer specifying how many tests run in parallel. This - allows to shorten the total runtime on multi-core machines. + allows reducing the total runtime on multi-core machines. This option is compatible with several other options, including the :option:`-R` switch which is known to produce long runtimes. (Added by Antoine Pitrou, :issue:`6152`.) @@ -676,6 +1034,17 @@ This section lists previously described changes and other bugfixes that may require changes to your code: +* When using :class:`Decimal` instances with a string's + :meth:`format` method, the default alignment was previously + left-alignment. This has been changed to right-alignment, which might + change the output of your programs. + (Changed by Mark Dickinson; :issue:`6857`.) + + Another :meth:`format`-related change: the default precision used + for floating-point and complex numbers was changed from 6 decimal + places to 12, which matches the precision used by :func:`str`. + (Changed by Eric Smith; :issue:`5920`.) + * Because of an optimization for the :keyword:`with` statement, the special methods :meth:`__enter__` and :meth:`__exit__` must belong to the object's type, and cannot be directly attached to the object's instance. This From python-checkins at python.org Tue Oct 6 00:31:11 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 22:31:11 -0000 Subject: [Python-checkins] r75265 - python/trunk/Doc/distutils/apiref.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 6 00:31:11 2009 New Revision: 75265 Log: Reword sentence Modified: python/trunk/Doc/distutils/apiref.rst Modified: python/trunk/Doc/distutils/apiref.rst ============================================================================== --- python/trunk/Doc/distutils/apiref.rst (original) +++ python/trunk/Doc/distutils/apiref.rst Tue Oct 6 00:31:11 2009 @@ -1934,7 +1934,7 @@ The ``check`` command performs some tests on the meta-data of a package. -It makes sure for example that all required meta-data are provided through +For example, it verifies that all required meta-data are provided as the arguments passed to the :func:`setup` function. .. % todo From python-checkins at python.org Tue Oct 6 00:32:48 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 22:32:48 -0000 Subject: [Python-checkins] r75266 - in python/trunk: Doc/distutils/examples.rst Lib/distutils/command/check.py Message-ID: Author: andrew.kuchling Date: Tue Oct 6 00:32:48 2009 New Revision: 75266 Log: Use standard comma punctuation; reword some sentences in the docs Modified: python/trunk/Doc/distutils/examples.rst python/trunk/Lib/distutils/command/check.py Modified: python/trunk/Doc/distutils/examples.rst ============================================================================== --- python/trunk/Doc/distutils/examples.rst (original) +++ python/trunk/Doc/distutils/examples.rst Tue Oct 6 00:32:48 2009 @@ -236,10 +236,10 @@ Checking a package ================== -The ``check`` command allows you to verify if your package meta-data are -meeting the minimum requirements to build a distribution. +The ``check`` command allows you to verify if your package meta-data +meet the minimum requirements to build a distribution. -To run it, just call it over your :file:`setup.py` script. If something is +To run it, just call it using your :file:`setup.py` script. If something is missing, ``check`` will display a warning. Let's take an example with a simple script:: @@ -252,7 +252,7 @@ $ python setup.py check running check - warning: check: missing required meta-data: version ,url + warning: check: missing required meta-data: version, url warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied Modified: python/trunk/Lib/distutils/command/check.py ============================================================================== --- python/trunk/Lib/distutils/command/check.py (original) +++ python/trunk/Lib/distutils/command/check.py Tue Oct 6 00:32:48 2009 @@ -91,7 +91,7 @@ missing.append(attr) if missing: - self.warn("missing required meta-data: %s" % ' ,'.join(missing)) + self.warn("missing required meta-data: %s" % ', '.join(missing)) if metadata.author: if not metadata.author_email: self.warn("missing meta-data: if 'author' supplied, " + From python-checkins at python.org Tue Oct 6 00:42:57 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 22:42:57 -0000 Subject: [Python-checkins] r75267 - python/trunk/Doc/library/string.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 6 00:42:56 2009 New Revision: 75267 Log: Backport r73983: Document the thousands separator. Modified: python/trunk/Doc/library/string.rst Modified: python/trunk/Doc/library/string.rst ============================================================================== --- python/trunk/Doc/library/string.rst (original) +++ python/trunk/Doc/library/string.rst Tue Oct 6 00:42:56 2009 @@ -325,7 +325,7 @@ The general form of a *standard format specifier* is: .. productionlist:: sf - format_spec: [[`fill`]`align`][`sign`][#][0][`width`][.`precision`][`type`] + format_spec: [[`fill`]`align`][`sign`][#][0][`width`][,][.`precision`][`type`] fill: align: "<" | ">" | "=" | "^" sign: "+" | "-" | " " @@ -383,6 +383,10 @@ hexadecimal output. If present, it specifies that the output will be prefixed by ``'0b'``, ``'0o'``, or ``'0x'``, respectively. +The ``','`` option signals the use of a comma for a thousands separator. +For a locale aware separator, use the ``'n'`` integer presentation type +instead. + *width* is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content. From python-checkins at python.org Tue Oct 6 00:45:39 2009 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 05 Oct 2009 22:45:39 -0000 Subject: [Python-checkins] r75268 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 6 00:45:39 2009 New Revision: 75268 Log: Remove two notes Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Tue Oct 6 00:45:39 2009 @@ -200,8 +200,7 @@ comma-formatting mechanism isn't as general as the :mod:`locale` module, but it's easier to use. -.. XXX "Format String Syntax" in string.rst doesn't describe ','; - could use many more examples. +.. XXX "Format String Syntax" in string.rst could use many more examples. .. seealso:: @@ -664,9 +663,6 @@ prevent buffering many small sends into a single TCP packet. (Contributed by Kristjan Valur Jonsson; :issue:`6192`.) - .. XXX the documentation for this attr was silently dropped from - .. Doc/library/socketserver.rst. - * The :mod:`struct` module will no longer silently ignore overflow errors when a value is too large for a particular integer format code (one of ``bBhHiIlLqQ``); it now always raises a From python-checkins at python.org Tue Oct 6 14:35:46 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 06 Oct 2009 12:35:46 -0000 Subject: [Python-checkins] r75269 - in python/branches/release26-maint: Lib/distutils/command/build_ext.py Lib/distutils/tests/test_build_ext.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Tue Oct 6 14:35:46 2009 New Revision: 75269 Log: #7068: Fixed the partial renaming that occured in r72594 Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/command/build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/command/build_ext.py Tue Oct 6 14:35:46 2009 @@ -303,7 +303,7 @@ # Setup the CCompiler object that we'll use to do all the # compiling and linking - self.compiler = new_compiler(compiler=None, + self.compiler = new_compiler(compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, force=self.force) Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Tue Oct 6 14:35:46 2009 @@ -264,7 +264,7 @@ sysconfig.get_config_var('SO')) so_dir = os.path.dirname(so_file) self.assertEquals(so_dir, other_tmp_dir) - + cmd.compiler = None cmd.inplace = 0 cmd.run() so_file = cmd.get_outputs()[0] Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 6 14:35:46 2009 @@ -18,6 +18,8 @@ Library ------- +- Issue #7068: Fixed the partial renaming that occured in r72594. + - Issue #7064: Fixed the incompatibility with Setuptools in distutils when running the build_ext command. From python-checkins at python.org Tue Oct 6 15:21:07 2009 From: python-checkins at python.org (barry.warsaw) Date: Tue, 06 Oct 2009 13:21:07 -0000 Subject: [Python-checkins] r75270 - in python/branches/release26-maint: Include/patchlevel.h Lib/distutils/__init__.py Lib/idlelib/idlever.py Lib/pydoc_topics.py Misc/NEWS Misc/RPM/python-2.6.spec README Message-ID: Author: barry.warsaw Date: Tue Oct 6 15:21:07 2009 New Revision: 75270 Log: Bumping to 2.6.4rc1 Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Lib/distutils/__init__.py python/branches/release26-maint/Lib/idlelib/idlever.py python/branches/release26-maint/Lib/pydoc_topics.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Misc/RPM/python-2.6.spec python/branches/release26-maint/README Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Tue Oct 6 15:21:07 2009 @@ -22,12 +22,12 @@ /*--start constants--*/ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 6 -#define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL -#define PY_RELEASE_SERIAL 0 +#define PY_MICRO_VERSION 4 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA +#define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "2.6.3+" +#define PY_VERSION "2.6.4rc1" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Lib/distutils/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/__init__.py (original) +++ python/branches/release26-maint/Lib/distutils/__init__.py Tue Oct 6 15:21:07 2009 @@ -22,5 +22,5 @@ # #--start constants-- -__version__ = "2.6.3" +__version__ = "2.6.4rc1" #--end constants-- Modified: python/branches/release26-maint/Lib/idlelib/idlever.py ============================================================================== --- python/branches/release26-maint/Lib/idlelib/idlever.py (original) +++ python/branches/release26-maint/Lib/idlelib/idlever.py Tue Oct 6 15:21:07 2009 @@ -1 +1 @@ -IDLE_VERSION = "2.6.3" +IDLE_VERSION = "2.6.4rc1" Modified: python/branches/release26-maint/Lib/pydoc_topics.py ============================================================================== --- python/branches/release26-maint/Lib/pydoc_topics.py (original) +++ python/branches/release26-maint/Lib/pydoc_topics.py Tue Oct 6 15:21:07 2009 @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Thu Oct 1 19:36:50 2009 +# Autogenerated by Sphinx on Tue Oct 6 09:18:05 2009 topics = {'assert': u'\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError, expression2\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list is recursively defined as\nfollows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` statement in the\n current code block: the name is bound to the object in the current\n local namespace.\n\n * Otherwise: the name is bound to the object in the current global\n namespace.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield a plain integer. If it is negative, the\n sequence\'s length is added to it. The resulting value must be a\n nonnegative integer less than the sequence\'s length, and the\n sequence is asked to assign the assigned object to its item with\n that index. If the index is out of range, ``IndexError`` is raised\n (assignment to a subscripted sequence cannot add new items to a\n list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to (small) integers. If either\n bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n(In the current implementation, the syntax for targets is taken to be\nthe same as for expressions, and invalid syntax is rejected during the\ncode generation phase, causing less detailed error messages.)\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print x\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n', Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 6 15:21:07 2009 @@ -4,10 +4,10 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.6.4a1? -============================= +What's New in Python 2.6.4rc1? +============================== -*Release date: XX-XXX-20XX* +*Release date: 07-Oct-2009* Core and Builtins ----------------- Modified: python/branches/release26-maint/Misc/RPM/python-2.6.spec ============================================================================== --- python/branches/release26-maint/Misc/RPM/python-2.6.spec (original) +++ python/branches/release26-maint/Misc/RPM/python-2.6.spec Tue Oct 6 15:21:07 2009 @@ -34,7 +34,7 @@ %define name python #--start constants-- -%define version 2.6.3 +%define version 2.6.4rc1 %define libver 2.6 #--end constants-- %define release 1pydotorg Modified: python/branches/release26-maint/README ============================================================================== --- python/branches/release26-maint/README (original) +++ python/branches/release26-maint/README Tue Oct 6 15:21:07 2009 @@ -1,5 +1,5 @@ -This is Python version 2.6.3 -============================ +This is Python version 2.6.4rc1 +=============================== Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Python Software Foundation. From python-checkins at python.org Tue Oct 6 15:21:35 2009 From: python-checkins at python.org (barry.warsaw) Date: Tue, 06 Oct 2009 13:21:35 -0000 Subject: [Python-checkins] r75271 - python/tags/r264rc1 Message-ID: Author: barry.warsaw Date: Tue Oct 6 15:21:35 2009 New Revision: 75271 Log: Tagging 2.6.4rc1 Added: python/tags/r264rc1/ - copied from r75270, /python/branches/release26-maint/ From python-checkins at python.org Tue Oct 6 21:56:33 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Tue, 06 Oct 2009 19:56:33 -0000 Subject: [Python-checkins] r75272 - in python/trunk: Lib/test/test_unicodedata.py Misc/NEWS Modules/unicodedata.c Modules/unicodedata_db.h Objects/unicodectype.c Objects/unicodetype_db.h Tools/unicode/makeunicodedata.py Message-ID: Author: amaury.forgeotdarc Date: Tue Oct 6 21:56:32 2009 New Revision: 75272 Log: #1571184: makeunicodedata.py now generates the functions _PyUnicode_ToNumeric, _PyUnicode_IsLinebreak and _PyUnicode_IsWhitespace. It now also parses the Unihan.txt for numeric values. Modified: python/trunk/Lib/test/test_unicodedata.py python/trunk/Misc/NEWS python/trunk/Modules/unicodedata.c python/trunk/Modules/unicodedata_db.h python/trunk/Objects/unicodectype.c python/trunk/Objects/unicodetype_db.h python/trunk/Tools/unicode/makeunicodedata.py Modified: python/trunk/Lib/test/test_unicodedata.py ============================================================================== --- python/trunk/Lib/test/test_unicodedata.py (original) +++ python/trunk/Lib/test/test_unicodedata.py Tue Oct 6 21:56:32 2009 @@ -20,7 +20,7 @@ class UnicodeMethodsTest(unittest.TestCase): # update this, if the database changes - expectedchecksum = '6ec65b65835614ec00634c674bba0e50cd32c189' + expectedchecksum = '0b915116051f3ed029a98542c2b7df63c9646272' def test_method_checksum(self): h = hashlib.sha1() @@ -79,7 +79,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest): # update this, if the database changes - expectedchecksum = '3136d5afd787dc2bcb1bdcac95e385349fbebbca' + expectedchecksum = 'd4169ccff998ebbd1ec007a0b3fbd66e5ccf0229' def test_function_checksum(self): data = [] @@ -118,6 +118,7 @@ self.assertEqual(self.db.numeric(u'9'), 9) self.assertEqual(self.db.numeric(u'\u215b'), 0.125) self.assertEqual(self.db.numeric(u'\u2468'), 9.0) + self.assertEqual(self.db.numeric(u'\ua627'), 7.0) self.assertEqual(self.db.numeric(u'\U00020000', None), None) self.assertRaises(TypeError, self.db.numeric) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Oct 6 21:56:32 2009 @@ -12,6 +12,11 @@ Core and Builtins ----------------- +- Issue #1571184: The Unicode database contains properties for more characters. + The tables for code points representing numeric values, white spaces or line + breaks are now generated from the official Unicode Character Database files, + and include information from the Unihan.txt file. + - Issue #7050: Fix a SystemError when trying to use unpacking and augmented assignment. Modified: python/trunk/Modules/unicodedata.c ============================================================================== --- python/trunk/Modules/unicodedata.c (original) +++ python/trunk/Modules/unicodedata.c Tue Oct 6 21:56:32 2009 @@ -36,7 +36,7 @@ const unsigned char category_changed; const unsigned char decimal_changed; const unsigned char mirrored_changed; - const int numeric_changed; + const double numeric_changed; } change_record; /* data file generated by Tools/unicode/makeunicodedata.py */ Modified: python/trunk/Modules/unicodedata_db.h ============================================================================== --- python/trunk/Modules/unicodedata_db.h (original) +++ python/trunk/Modules/unicodedata_db.h Tue Oct 6 21:56:32 2009 @@ -4729,8 +4729,10 @@ { 255, 23, 255, 255, 0 }, { 9, 255, 255, 255, 0 }, { 255, 20, 255, 255, 0 }, - { 255, 19, 255, 255, 0 }, { 255, 255, 255, 255, -1 }, + { 255, 255, 255, 255, 1e+16 }, + { 255, 255, 255, 255, 1e+20 }, + { 255, 19, 255, 255, 0 }, { 15, 255, 255, 255, 0 }, { 255, 19, 255, 255, -1 }, }; @@ -4740,34 +4742,27 @@ 2, 2, 2, 31, 2, 32, 33, 34, 35, 36, 37, 2, 38, 39, 40, 2, 41, 42, 2, 43, 2, 2, 44, 45, 46, 47, 48, 2, 2, 49, 50, 51, 2, 2, 52, 53, 2, 54, 55, 55, 2, 2, 2, 2, 56, 2, 57, 58, 59, 60, 61, 2, 2, 2, 2, 62, 63, 64, 65, 66, - 67, 68, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 69, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 70, 71, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 72, 73, 41, 74, 75, 76, 77, - 2, 78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 67, 68, 69, 70, 2, 2, 2, 2, 2, 2, 71, 2, 2, 2, 2, 2, 72, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79, 80, 81, 82, 83, 2, 2, 2, - 2, 84, 85, 2, 86, 87, 88, 89, 90, 91, 2, 92, 93, 94, 95, 96, 2, 2, 2, 2, - 2, 2, 97, 2, 98, 2, 99, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 73, 2, 74, 2, 2, 2, 2, 2, 2, 2, 2, 75, 76, 2, 2, 2, + 2, 2, 2, 2, 77, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 78, 79, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 41, 41, 41, 41, 41, 41, 100, 2, 101, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 80, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 81, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 82, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 83, 84, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 85, 86, 41, 87, + 88, 89, 90, 2, 91, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 92, 93, 94, 95, + 96, 2, 2, 2, 2, 97, 98, 2, 99, 100, 101, 102, 103, 104, 2, 105, 106, 107, + 108, 109, 2, 2, 2, 2, 2, 2, 110, 2, 111, 2, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 41, 41, 41, 41, 113, 2, 114, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -4775,19 +4770,26 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 102, 2, 103, 2, 104, 2, 2, 105, 2, 2, 2, 106, 107, 108, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 109, 110, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 115, 2, 116, 2, 117, 2, 2, 118, 2, 2, 2, 119, + 120, 121, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 122, 123, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 124, 125, 82, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 71, 126, 2, 127, 128, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 129, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 130, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 131, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 132, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -4799,8 +4801,8 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 111, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 129, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -5035,7 +5037,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 41, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 133, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -5099,7 +5101,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static unsigned char changes_3_2_0_data[] = { @@ -5473,84 +5475,154 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, - 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 41, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5558,157 +5630,199 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13, 13, 13, 13, - 13, 0, 0, 0, 1, 1, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 13, 13, 13, 13, 13, 13, 0, 0, 0, 1, 1, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 45, 45, 45, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, + 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 0, - 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 0, 0, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 0, 0, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 7, 0, 0, 7, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 7, + 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, + 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, - 0, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, + 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, + 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const change_record* get_change_3_2_0(Py_UCS4 n) Modified: python/trunk/Objects/unicodectype.c ============================================================================== --- python/trunk/Objects/unicodectype.c (original) +++ python/trunk/Objects/unicodectype.c Tue Oct 6 21:56:32 2009 @@ -20,6 +20,7 @@ #define TITLE_MASK 0x40 #define UPPER_MASK 0x80 #define NODELTA_MASK 0x100 +#define NUMERIC_MASK 0x200 typedef struct { const Py_UNICODE upper; @@ -50,26 +51,6 @@ return &_PyUnicode_TypeRecords[index]; } -/* Returns 1 for Unicode characters having the category 'Zl', 'Zp' or - type 'B', 0 otherwise. */ - -int _PyUnicode_IsLinebreak(register const Py_UNICODE ch) -{ - switch (ch) { - case 0x000A: /* LINE FEED */ - case 0x000D: /* CARRIAGE RETURN */ - case 0x001C: /* FILE SEPARATOR */ - case 0x001D: /* GROUP SEPARATOR */ - case 0x001E: /* RECORD SEPARATOR */ - case 0x0085: /* NEXT LINE */ - case 0x2028: /* LINE SEPARATOR */ - case 0x2029: /* PARAGRAPH SEPARATOR */ - return 1; - default: - return 0; - } -} - /* Returns the titlecase Unicode characters corresponding to ch or just ch if no titlecase mapping is known. */ @@ -134,568 +115,15 @@ /* Returns the numeric value as double for Unicode characters having this property, -1.0 otherwise. */ -/* TODO: replace with unicodetype_db.h table */ - -double _PyUnicode_ToNumeric(Py_UNICODE ch) -{ - switch (ch) { - case 0x0F33: - return (double) -1 / 2; - case 0x17F0: - case 0x3007: -#ifdef Py_UNICODE_WIDE - case 0x1018A: -#endif - return (double) 0; - case 0x09F4: - case 0x17F1: - case 0x215F: - case 0x2160: - case 0x2170: - case 0x3021: - case 0x3192: - case 0x3220: - case 0x3280: -#ifdef Py_UNICODE_WIDE - case 0x10107: - case 0x10142: - case 0x10158: - case 0x10159: - case 0x1015A: - case 0x10320: - case 0x103D1: -#endif - return (double) 1; - case 0x00BD: - case 0x0F2A: - case 0x2CFD: -#ifdef Py_UNICODE_WIDE - case 0x10141: - case 0x10175: - case 0x10176: -#endif - return (double) 1 / 2; - case 0x2153: - return (double) 1 / 3; - case 0x00BC: -#ifdef Py_UNICODE_WIDE - case 0x10140: -#endif - return (double) 1 / 4; - case 0x2155: - return (double) 1 / 5; - case 0x2159: - return (double) 1 / 6; - case 0x215B: - return (double) 1 / 8; - case 0x0BF0: - case 0x1372: - case 0x2169: - case 0x2179: - case 0x2469: - case 0x247D: - case 0x2491: - case 0x24FE: - case 0x277F: - case 0x2789: - case 0x2793: - case 0x3038: - case 0x3229: - case 0x3289: -#ifdef Py_UNICODE_WIDE - case 0x10110: - case 0x10149: - case 0x10150: - case 0x10157: - case 0x10160: - case 0x10161: - case 0x10162: - case 0x10163: - case 0x10164: - case 0x10322: - case 0x103D3: - case 0x10A44: -#endif - return (double) 10; - case 0x0BF1: - case 0x137B: - case 0x216D: - case 0x217D: -#ifdef Py_UNICODE_WIDE - case 0x10119: - case 0x1014B: - case 0x10152: - case 0x1016A: - case 0x103D5: - case 0x10A46: -#endif - return (double) 100; - case 0x0BF2: - case 0x216F: - case 0x217F: - case 0x2180: -#ifdef Py_UNICODE_WIDE - case 0x10122: - case 0x1014D: - case 0x10154: - case 0x10171: - case 0x10A47: -#endif - return (double) 1000; - case 0x137C: - case 0x2182: -#ifdef Py_UNICODE_WIDE - case 0x1012B: - case 0x10155: -#endif - return (double) 10000; - case 0x216A: - case 0x217A: - case 0x246A: - case 0x247E: - case 0x2492: - case 0x24EB: - return (double) 11; - case 0x0F2F: - return (double) 11 / 2; - case 0x216B: - case 0x217B: - case 0x246B: - case 0x247F: - case 0x2493: - case 0x24EC: - return (double) 12; - case 0x246C: - case 0x2480: - case 0x2494: - case 0x24ED: - return (double) 13; - case 0x0F30: - return (double) 13 / 2; - case 0x246D: - case 0x2481: - case 0x2495: - case 0x24EE: - return (double) 14; - case 0x246E: - case 0x2482: - case 0x2496: - case 0x24EF: - return (double) 15; - case 0x0F31: - return (double) 15 / 2; - case 0x09F9: - case 0x246F: - case 0x2483: - case 0x2497: - case 0x24F0: - return (double) 16; - case 0x16EE: - case 0x2470: - case 0x2484: - case 0x2498: - case 0x24F1: - return (double) 17; - case 0x0F32: - return (double) 17 / 2; - case 0x16EF: - case 0x2471: - case 0x2485: - case 0x2499: - case 0x24F2: - return (double) 18; - case 0x16F0: - case 0x2472: - case 0x2486: - case 0x249A: - case 0x24F3: - return (double) 19; - case 0x09F5: - case 0x17F2: - case 0x2161: - case 0x2171: - case 0x3022: - case 0x3193: - case 0x3221: - case 0x3281: -#ifdef Py_UNICODE_WIDE - case 0x10108: - case 0x1015B: - case 0x1015C: - case 0x1015D: - case 0x1015E: - case 0x103D2: -#endif - return (double) 2; - case 0x2154: -#ifdef Py_UNICODE_WIDE - case 0x10177: -#endif - return (double) 2 / 3; - case 0x2156: - return (double) 2 / 5; - case 0x1373: - case 0x2473: - case 0x2487: - case 0x249B: - case 0x24F4: - case 0x3039: -#ifdef Py_UNICODE_WIDE - case 0x10111: - case 0x103D4: - case 0x10A45: -#endif - return (double) 20; -#ifdef Py_UNICODE_WIDE - case 0x1011A: - return (double) 200; - case 0x10123: - return (double) 2000; - case 0x1012C: - return (double) 20000; -#endif - case 0x3251: - return (double) 21; - case 0x3252: - return (double) 22; - case 0x3253: - return (double) 23; - case 0x3254: - return (double) 24; - case 0x3255: - return (double) 25; - case 0x3256: - return (double) 26; - case 0x3257: - return (double) 27; - case 0x3258: - return (double) 28; - case 0x3259: - return (double) 29; - case 0x09F6: - case 0x17F3: - case 0x2162: - case 0x2172: - case 0x3023: - case 0x3194: - case 0x3222: - case 0x3282: -#ifdef Py_UNICODE_WIDE - case 0x10109: -#endif - return (double) 3; - case 0x0F2B: - return (double) 3 / 2; - case 0x00BE: -#ifdef Py_UNICODE_WIDE - case 0x10178: -#endif - return (double) 3 / 4; - case 0x2157: - return (double) 3 / 5; - case 0x215C: - return (double) 3 / 8; - case 0x1374: - case 0x303A: - case 0x325A: -#ifdef Py_UNICODE_WIDE - case 0x10112: - case 0x10165: -#endif - return (double) 30; -#ifdef Py_UNICODE_WIDE - case 0x1011B: - case 0x1016B: - return (double) 300; - case 0x10124: - return (double) 3000; - case 0x1012D: - return (double) 30000; -#endif - case 0x325B: - return (double) 31; - case 0x325C: - return (double) 32; - case 0x325D: - return (double) 33; - case 0x325E: - return (double) 34; - case 0x325F: - return (double) 35; - case 0x32B1: - return (double) 36; - case 0x32B2: - return (double) 37; - case 0x32B3: - return (double) 38; - case 0x32B4: - return (double) 39; - case 0x09F7: - case 0x17F4: - case 0x2163: - case 0x2173: - case 0x3024: - case 0x3195: - case 0x3223: - case 0x3283: -#ifdef Py_UNICODE_WIDE - case 0x1010A: -#endif - return (double) 4; - case 0x2158: - return (double) 4 / 5; - case 0x1375: - case 0x32B5: -#ifdef Py_UNICODE_WIDE - case 0x10113: -#endif - return (double) 40; -#ifdef Py_UNICODE_WIDE - case 0x1011C: - return (double) 400; - case 0x10125: - return (double) 4000; - case 0x1012E: - return (double) 40000; -#endif - case 0x32B6: - return (double) 41; - case 0x32B7: - return (double) 42; - case 0x32B8: - return (double) 43; - case 0x32B9: - return (double) 44; - case 0x32BA: - return (double) 45; - case 0x32BB: - return (double) 46; - case 0x32BC: - return (double) 47; - case 0x32BD: - return (double) 48; - case 0x32BE: - return (double) 49; - case 0x17F5: - case 0x2164: - case 0x2174: - case 0x3025: - case 0x3224: - case 0x3284: -#ifdef Py_UNICODE_WIDE - case 0x1010B: - case 0x10143: - case 0x10148: - case 0x1014F: - case 0x1015F: - case 0x10173: - case 0x10321: -#endif - return (double) 5; - case 0x0F2C: - return (double) 5 / 2; - case 0x215A: - return (double) 5 / 6; - case 0x215D: - return (double) 5 / 8; - case 0x1376: - case 0x216C: - case 0x217C: - case 0x32BF: -#ifdef Py_UNICODE_WIDE - case 0x10114: - case 0x10144: - case 0x1014A: - case 0x10151: - case 0x10166: - case 0x10167: - case 0x10168: - case 0x10169: - case 0x10174: - case 0x10323: -#endif - return (double) 50; - case 0x216E: - case 0x217E: -#ifdef Py_UNICODE_WIDE - case 0x1011D: - case 0x10145: - case 0x1014C: - case 0x10153: - case 0x1016C: - case 0x1016D: - case 0x1016E: - case 0x1016F: - case 0x10170: -#endif - return (double) 500; - case 0x2181: -#ifdef Py_UNICODE_WIDE - case 0x10126: - case 0x10146: - case 0x1014E: - case 0x10172: -#endif - return (double) 5000; -#ifdef Py_UNICODE_WIDE - case 0x1012F: - case 0x10147: - case 0x10156: - return (double) 50000; -#endif - case 0x17F6: - case 0x2165: - case 0x2175: - case 0x3026: - case 0x3225: - case 0x3285: -#ifdef Py_UNICODE_WIDE - case 0x1010C: -#endif - return (double) 6; - case 0x1377: -#ifdef Py_UNICODE_WIDE - case 0x10115: -#endif - return (double) 60; -#ifdef Py_UNICODE_WIDE - case 0x1011E: - return (double) 600; - case 0x10127: - return (double) 6000; - case 0x10130: - return (double) 60000; -#endif - case 0x17F7: - case 0x2166: - case 0x2176: - case 0x3027: - case 0x3226: - case 0x3286: -#ifdef Py_UNICODE_WIDE - case 0x1010D: -#endif - return (double) 7; - case 0x0F2D: - return (double) 7 / 2; - case 0x215E: - return (double) 7 / 8; - case 0x1378: -#ifdef Py_UNICODE_WIDE - case 0x10116: -#endif - return (double) 70; -#ifdef Py_UNICODE_WIDE - case 0x1011F: - return (double) 700; - case 0x10128: - return (double) 7000; - case 0x10131: - return (double) 70000; -#endif - case 0x17F8: - case 0x2167: - case 0x2177: - case 0x3028: - case 0x3227: - case 0x3287: -#ifdef Py_UNICODE_WIDE - case 0x1010E: -#endif - return (double) 8; - case 0x1379: -#ifdef Py_UNICODE_WIDE - case 0x10117: -#endif - return (double) 80; -#ifdef Py_UNICODE_WIDE - case 0x10120: - return (double) 800; - case 0x10129: - return (double) 8000; - case 0x10132: - return (double) 80000; -#endif - case 0x17F9: - case 0x2168: - case 0x2178: - case 0x3029: - case 0x3228: - case 0x3288: -#ifdef Py_UNICODE_WIDE - case 0x1010F: -#endif - return (double) 9; - case 0x0F2E: - return (double) 9 / 2; - case 0x137A: -#ifdef Py_UNICODE_WIDE - case 0x10118: -#endif - return (double) 90; -#ifdef Py_UNICODE_WIDE - case 0x10121: - case 0x1034A: - return (double) 900; - case 0x1012A: - return (double) 9000; - case 0x10133: - return (double) 90000; -#endif - default: - return (double) _PyUnicode_ToDigit(ch); - } -} - int _PyUnicode_IsNumeric(Py_UNICODE ch) { - return _PyUnicode_ToNumeric(ch) != -1.0; + const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); + + return (ctype->flags & NUMERIC_MASK) != 0; } #ifndef WANT_WCTYPE_FUNCTIONS -/* Returns 1 for Unicode characters having the bidirectional type - 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */ - -int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) -{ - switch (ch) { - case 0x0009: /* HORIZONTAL TABULATION */ - case 0x000A: /* LINE FEED */ - case 0x000B: /* VERTICAL TABULATION */ - case 0x000C: /* FORM FEED */ - case 0x000D: /* CARRIAGE RETURN */ - case 0x001C: /* FILE SEPARATOR */ - case 0x001D: /* GROUP SEPARATOR */ - case 0x001E: /* RECORD SEPARATOR */ - case 0x001F: /* UNIT SEPARATOR */ - case 0x0020: /* SPACE */ - case 0x0085: /* NEXT LINE */ - case 0x00A0: /* NO-BREAK SPACE */ - case 0x1680: /* OGHAM SPACE MARK */ - case 0x2000: /* EN QUAD */ - case 0x2001: /* EM QUAD */ - case 0x2002: /* EN SPACE */ - case 0x2003: /* EM SPACE */ - case 0x2004: /* THREE-PER-EM SPACE */ - case 0x2005: /* FOUR-PER-EM SPACE */ - case 0x2006: /* SIX-PER-EM SPACE */ - case 0x2007: /* FIGURE SPACE */ - case 0x2008: /* PUNCTUATION SPACE */ - case 0x2009: /* THIN SPACE */ - case 0x200A: /* HAIR SPACE */ - case 0x200B: /* ZERO WIDTH SPACE */ - case 0x2028: /* LINE SEPARATOR */ - case 0x2029: /* PARAGRAPH SEPARATOR */ - case 0x202F: /* NARROW NO-BREAK SPACE */ - case 0x205F: /* MEDIUM MATHEMATICAL SPACE */ - case 0x3000: /* IDEOGRAPHIC SPACE */ - return 1; - default: - return 0; - } -} - /* Returns 1 for Unicode characters having the category 'Ll', 0 otherwise. */ @@ -759,11 +187,6 @@ /* Export the interfaces using the wchar_t type for portability reasons: */ -int _PyUnicode_IsWhitespace(Py_UNICODE ch) -{ - return iswspace(ch); -} - int _PyUnicode_IsLowercase(Py_UNICODE ch) { return iswlower(ch); Modified: python/trunk/Objects/unicodetype_db.h ============================================================================== --- python/trunk/Objects/unicodetype_db.h (original) +++ python/trunk/Objects/unicodetype_db.h Tue Oct 6 21:56:32 2009 @@ -6,23 +6,24 @@ {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 32}, {0, 0, 0, 0, 0, 48}, - {0, 0, 0, 0, 0, 6}, - {0, 0, 0, 1, 1, 6}, - {0, 0, 0, 2, 2, 6}, - {0, 0, 0, 3, 3, 6}, - {0, 0, 0, 4, 4, 6}, - {0, 0, 0, 5, 5, 6}, - {0, 0, 0, 6, 6, 6}, - {0, 0, 0, 7, 7, 6}, - {0, 0, 0, 8, 8, 6}, - {0, 0, 0, 9, 9, 6}, + {0, 0, 0, 0, 0, 518}, + {0, 0, 0, 1, 1, 518}, + {0, 0, 0, 2, 2, 518}, + {0, 0, 0, 3, 3, 518}, + {0, 0, 0, 4, 4, 518}, + {0, 0, 0, 5, 5, 518}, + {0, 0, 0, 6, 6, 518}, + {0, 0, 0, 7, 7, 518}, + {0, 0, 0, 8, 8, 518}, + {0, 0, 0, 9, 9, 518}, {0, 32, 0, 0, 0, 129}, {65504, 0, 65504, 0, 0, 9}, {0, 0, 0, 0, 0, 9}, - {0, 0, 0, 0, 2, 4}, - {0, 0, 0, 0, 3, 4}, + {0, 0, 0, 0, 2, 516}, + {0, 0, 0, 0, 3, 516}, {743, 0, 743, 0, 0, 9}, - {0, 0, 0, 0, 1, 4}, + {0, 0, 0, 0, 1, 516}, + {0, 0, 0, 0, 0, 512}, {121, 0, 121, 0, 0, 9}, {0, 1, 0, 0, 0, 129}, {65535, 0, 65535, 0, 0, 9}, @@ -112,12 +113,12 @@ {0, 48, 0, 0, 0, 129}, {65488, 0, 65488, 0, 0, 9}, {0, 7264, 0, 0, 0, 129}, - {0, 0, 0, 0, 4, 4}, - {0, 0, 0, 0, 5, 4}, - {0, 0, 0, 0, 6, 4}, - {0, 0, 0, 0, 7, 4}, - {0, 0, 0, 0, 8, 4}, - {0, 0, 0, 0, 9, 4}, + {0, 0, 0, 0, 4, 516}, + {0, 0, 0, 0, 5, 516}, + {0, 0, 0, 0, 6, 516}, + {0, 0, 0, 0, 7, 516}, + {0, 0, 0, 0, 8, 516}, + {0, 0, 0, 0, 9, 516}, {42877, 7545, 42877, 0, 0, 265}, {3814, 0, 3814, 0, 0, 9}, {65477, 0, 65477, 0, 0, 9}, @@ -140,14 +141,14 @@ {0, 65424, 0, 0, 0, 129}, {0, 65408, 0, 0, 0, 129}, {0, 65410, 0, 0, 0, 129}, - {0, 0, 0, 0, 0, 4}, + {0, 0, 0, 0, 0, 516}, {0, 58019, 0, 0, 0, 129}, {0, 57153, 0, 0, 0, 129}, {0, 57274, 0, 0, 0, 129}, {0, 28, 0, 0, 0, 129}, {65508, 0, 65508, 0, 0, 9}, - {0, 16, 0, 0, 0, 0}, - {65520, 0, 65520, 0, 0, 0}, + {0, 16, 0, 0, 0, 512}, + {65520, 0, 65520, 0, 0, 512}, {0, 26, 0, 0, 0, 0}, {65510, 0, 65510, 0, 0, 0}, {0, 54793, 0, 0, 0, 129}, @@ -159,209 +160,500 @@ {0, 54787, 0, 0, 0, 129}, {0, 54753, 0, 0, 0, 129}, {58272, 0, 58272, 0, 0, 9}, + {0, 0, 0, 0, 0, 513}, {42877, 7545, 42877, 0, 0, 385}, {0, 40, 0, 0, 0, 129}, {65496, 0, 65496, 0, 0, 9}, }; /* type indexes */ -#define SHIFT 8 +#define SHIFT 7 static unsigned char index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 34, 37, - 38, 34, 34, 34, 39, 40, 41, 42, 43, 44, 45, 46, 34, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 47, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 48, 21, 21, 21, 21, 49, - 21, 50, 51, 52, 53, 54, 8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 55, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 21, 56, 57, 21, 58, 59, - 60, 61, 62, 63, 64, 65, 8, 8, 8, 66, 67, 68, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 21, 69, 70, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 71, 72, - 73, 74, 75, 76, 77, 78, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 79, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 80, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 81, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 82, 83, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 84, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 84, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 40, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 16, 50, 51, 52, + 16, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 63, 63, 64, 65, 66, 63, + 63, 63, 67, 68, 69, 63, 63, 63, 63, 63, 63, 70, 16, 71, 72, 73, 74, 75, + 76, 63, 77, 78, 79, 80, 81, 82, 83, 63, 63, 84, 85, 40, 40, 40, 40, 40, + 40, 86, 40, 40, 40, 40, 40, 87, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 88, 89, 90, 91, 40, 40, 40, 92, 40, 40, + 40, 93, 94, 40, 40, 40, 40, 40, 95, 40, 40, 40, 96, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 97, 98, 99, 40, 40, 40, 40, 40, 40, 100, 101, 40, 40, + 40, 40, 40, 40, 40, 40, 102, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 103, 40, 40, 40, 40, 40, 40, 40, 40, 104, 40, 40, 40, 40, + 100, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 103, 40, 40, 40, 40, 40, 40, 105, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 106, 107, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 108, 109, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 110, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 111, 40, 40, 112, 113, 114, 115, 116, 117, 118, 16, 119, 16, + 16, 16, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 120, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 121, 122, 123, 124, 125, + 126, 40, 40, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 16, 137, + 138, 139, 140, 141, 16, 16, 16, 16, 16, 16, 142, 16, 143, 16, 144, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 40, 40, 40, 40, 40, 40, 145, 16, 146, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 63, 147, + 148, 149, 150, 16, 151, 16, 152, 153, 154, 155, 156, 157, 158, 159, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 160, 161, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 162, 163, 164, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 86, 165, 40, 166, 167, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 168, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 169, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 170, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 171, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 172, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 40, 168, 40, 40, 173, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 174, 16, 63, + 175, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 176, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 176, }; static unsigned char index2[] = { @@ -373,431 +665,403 @@ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 1, - 1, 1, 1, 1, 17, 18, 1, 19, 1, 1, 1, 20, 16, 1, 1, 1, 1, 1, 14, 14, 14, + 1, 1, 1, 1, 17, 18, 1, 19, 1, 1, 1, 20, 16, 1, 21, 21, 21, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 14, 14, 14, 14, 14, 14, 14, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 15, - 15, 15, 15, 15, 15, 15, 21, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 24, 25, 22, 23, 22, 23, 22, 23, 16, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 16, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 26, 22, 23, 22, 23, 22, 23, 27, 28, 29, 22, 23, 22, 23, 30, 22, 23, - 31, 31, 22, 23, 16, 32, 33, 34, 22, 23, 31, 35, 36, 37, 38, 22, 23, 39, - 16, 37, 40, 41, 42, 22, 23, 22, 23, 22, 23, 43, 22, 23, 43, 16, 16, 22, - 23, 43, 22, 23, 44, 44, 22, 23, 22, 23, 45, 22, 23, 16, 46, 22, 23, 16, - 47, 46, 46, 46, 46, 48, 49, 50, 48, 49, 50, 48, 49, 50, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 51, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 16, 48, 49, 50, 22, - 23, 52, 53, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 54, 16, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 16, 16, 16, 16, 16, 16, 55, 22, 23, - 56, 57, 16, 16, 22, 23, 58, 59, 60, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 61, 62, 16, 63, 64, 16, 65, 65, 16, 66, 16, 67, 16, 16, 16, 16, 65, - 16, 16, 68, 16, 16, 16, 16, 69, 70, 16, 71, 16, 16, 16, 70, 16, 72, 73, - 16, 16, 74, 16, 16, 16, 16, 16, 16, 16, 75, 16, 16, 76, 16, 16, 76, 16, - 16, 16, 16, 76, 77, 78, 78, 79, 16, 16, 16, 16, 16, 80, 16, 46, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, - 46, 1, 1, 1, 1, 1, 1, 1, 46, 1, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 15, 15, 15, 15, 15, 15, 22, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 25, 26, 23, 24, 23, 24, 23, 24, 16, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 16, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 27, 23, 24, 23, 24, 23, 24, 28, 29, 30, 23, 24, 23, 24, 31, 23, 24, + 32, 32, 23, 24, 16, 33, 34, 35, 23, 24, 32, 36, 37, 38, 39, 23, 24, 40, + 16, 38, 41, 42, 43, 23, 24, 23, 24, 23, 24, 44, 23, 24, 44, 16, 16, 23, + 24, 44, 23, 24, 45, 45, 23, 24, 23, 24, 46, 23, 24, 16, 47, 23, 24, 16, + 48, 47, 47, 47, 47, 49, 50, 51, 49, 50, 51, 49, 50, 51, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 52, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 16, 49, 50, 51, 23, + 24, 53, 54, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 55, 16, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 16, 16, 16, 16, 16, 16, 56, 23, 24, + 57, 58, 16, 16, 23, 24, 59, 60, 61, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 62, 63, 16, 64, 65, 16, 66, 66, 16, 67, 16, 68, 16, 16, 16, 16, 66, + 16, 16, 69, 16, 16, 16, 16, 70, 71, 16, 72, 16, 16, 16, 71, 16, 73, 74, + 16, 16, 75, 16, 16, 16, 16, 16, 16, 16, 76, 16, 16, 77, 16, 16, 77, 16, + 16, 16, 16, 77, 78, 79, 79, 80, 16, 16, 16, 16, 16, 81, 16, 47, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 47, 47, 47, + 47, 1, 1, 1, 1, 1, 1, 1, 47, 1, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 81, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 22, 23, - 22, 23, 46, 1, 22, 23, 0, 0, 46, 41, 41, 41, 1, 0, 0, 0, 0, 0, 1, 1, 82, - 1, 83, 83, 83, 0, 84, 0, 85, 85, 16, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 1, 1, 82, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 24, + 23, 24, 47, 1, 23, 24, 0, 0, 47, 42, 42, 42, 1, 0, 0, 0, 0, 0, 1, 1, 83, + 1, 84, 84, 84, 0, 85, 0, 86, 86, 16, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 86, 87, 87, 87, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 88, 15, 15, 15, 15, 15, 15, 15, 15, 15, 89, 90, 90, 91, - 92, 93, 94, 94, 94, 95, 96, 97, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 98, 99, 100, 16, - 101, 102, 1, 22, 23, 103, 22, 23, 16, 54, 54, 54, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 14, 14, 14, + 87, 88, 88, 88, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 89, 15, 15, 15, 15, 15, 15, 15, 15, 15, 90, 91, 91, 92, + 93, 94, 95, 95, 95, 96, 97, 98, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 99, 100, 101, 16, + 102, 103, 1, 23, 24, 104, 23, 24, 16, 55, 55, 55, 105, 105, 105, 105, + 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 1, 1, 1, 1, 1, 1, 1, 1, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 105, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 106, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 0, 0, 46, 1, 1, 1, 1, 1, 1, 0, 108, 108, 108, 108, + 15, 15, 15, 15, 15, 15, 15, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 1, 1, 1, 1, 1, 1, 1, 1, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 106, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 107, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 16, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 108, 108, 108, 108, 108, 108, 108, 0, 0, 47, 1, 1, 1, 1, 1, 1, 0, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 16, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 0, 46, 46, 46, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, - 1, 46, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 1, 1, 1, 1, 1, 1, 1, 46, 46, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 46, 46, 46, 1, 1, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 1, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, - 46, 1, 1, 1, 1, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 0, 0, 0, 0, 0, 47, 47, 47, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 1, 1, 1, 1, 47, 47, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, + 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 47, 1, 1, 1, 1, 1, + 1, 1, 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 47, 47, 47, 1, 1, 47, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 47, 1, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 47, 47, 1, 1, 1, 1, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 0, 0, 1, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 46, 1, 1, 1, 1, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 46, 46, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 0, 1, 1, 1, 0, 46, 46, 46, 46, 46, 46, - 46, 46, 0, 0, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, - 46, 0, 46, 0, 0, 0, 46, 46, 46, 46, 0, 0, 1, 46, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 1, 1, 0, 0, 1, 1, 1, 46, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 46, - 46, 0, 46, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, 46, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 46, 46, 46, 46, - 46, 46, 0, 0, 0, 0, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, - 46, 46, 0, 46, 46, 0, 46, 46, 0, 46, 46, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, - 46, 0, 46, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, - 46, 46, 46, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, - 46, 46, 46, 46, 0, 46, 46, 0, 46, 46, 46, 46, 46, 0, 0, 1, 46, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 46, - 46, 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, - 46, 46, 46, 46, 46, 46, 0, 46, 46, 0, 46, 46, 46, 46, 46, 0, 0, 1, 46, 1, + 0, 0, 0, 0, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 0, 0, 1, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 47, 1, 1, 1, 1, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 47, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 0, 1, 1, 1, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, + 47, 0, 47, 0, 0, 0, 47, 47, 47, 47, 0, 0, 1, 47, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 47, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 47, + 47, 0, 47, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 47, 47, + 1, 1, 21, 21, 21, 21, 1, 21, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 47, 47, 47, + 47, 47, 47, 0, 0, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, + 47, 47, 47, 0, 47, 47, 0, 47, 47, 0, 47, 47, 0, 0, 1, 0, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 0, 47, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, + 1, 47, 47, 47, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, + 47, 47, 47, 47, 47, 0, 47, 47, 0, 47, 47, 47, 47, 47, 0, 0, 1, 47, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, + 47, 47, 47, 47, 47, 47, 0, 47, 47, 0, 47, 47, 47, 47, 47, 0, 0, 1, 47, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 0, 0, 0, 0, 46, 46, 0, 46, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 1, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 46, - 0, 46, 46, 46, 46, 46, 46, 0, 0, 0, 46, 46, 46, 0, 46, 46, 46, 46, 0, 0, - 0, 46, 46, 0, 46, 0, 46, 46, 0, 0, 0, 46, 46, 0, 0, 0, 46, 46, 46, 0, 0, - 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 46, 0, 0, 0, 0, 0, 0, 1, 0, + 1, 0, 0, 0, 0, 47, 47, 0, 47, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 1, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 47, + 0, 47, 47, 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, 0, 47, 47, 47, 47, 0, 0, + 0, 47, 47, 0, 47, 0, 47, 47, 0, 0, 0, 47, 47, 0, 0, 0, 47, 47, 47, 0, 0, + 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 47, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 0, 0, 0, 46, 1, 1, + 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 0, 0, 0, 47, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 46, 46, 0, 0, 0, 0, 0, 0, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, - 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 0, 0, 1, - 46, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 46, 0, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 0, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 0, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, - 0, 0, 46, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 1, 1, 0, 0, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 46, 46, 46, 46, 46, 46, - 0, 0, 1, 1, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 0, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, - 46, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 46, 46, 46, 46, 46, 46, 46, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 0, 46, 0, 0, 46, 46, 0, 46, 0, 0, 46, - 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, - 46, 46, 0, 46, 0, 46, 0, 0, 46, 46, 0, 46, 46, 46, 46, 1, 46, 46, 1, 1, - 1, 1, 1, 1, 0, 1, 1, 46, 0, 0, 46, 46, 46, 46, 46, 0, 46, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 46, 46, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, - 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, - 46, 46, 46, 46, 1, 1, 1, 46, 1, 1, 1, 46, 46, 1, 1, 1, 1, 1, 1, 1, 46, - 46, 46, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 0, 0, 0, 0, 1, 1, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, 0, 0, 0, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 0, 46, 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, 0, 46, - 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 0, 0, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 0, 0, - 46, 46, 46, 46, 46, 46, 46, 0, 46, 0, 46, 46, 46, 46, 0, 0, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, - 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 17, 18, 110, 111, 112, 113, 114, - 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 46, 46, - 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 1, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 0, 46, 46, 46, 46, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, - 1, 1, 1, 1, 46, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, - 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, - 46, 1, 1, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 0, 0, 1, + 47, 47, 0, 0, 0, 0, 0, 0, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 1, 0, 0, 1, + 1, 0, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 0, + 0, 1, 47, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 47, 0, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 0, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 0, 0, 0, 47, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 1, 1, 0, 0, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 21, 21, 21, 21, 21, 21, 0, 0, 0, 1, 47, 47, 47, + 47, 47, 47, 0, 0, 1, 1, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 0, + 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 1, 47, 47, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 47, 47, 47, 47, 47, + 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, - 46, 46, 46, 46, 46, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 0, 47, 0, 0, 47, 47, 0, + 47, 0, 0, 47, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, + 47, 47, 0, 47, 47, 47, 0, 47, 0, 47, 0, 0, 47, 47, 0, 47, 47, 47, 47, 1, + 47, 47, 1, 1, 1, 1, 1, 1, 0, 1, 1, 47, 0, 0, 47, 47, 47, 47, 47, 0, 47, + 0, 1, 1, 1, 1, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 47, + 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 47, + 47, 47, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 46, 46, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, - 46, 46, 46, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 47, 47, 47, + 47, 47, 47, 1, 1, 1, 1, 47, 47, 47, 47, 1, 1, 1, 47, 1, 1, 1, 47, 47, 1, + 1, 1, 1, 1, 1, 1, 47, 47, 47, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 1, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 1, 1, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 1, 47, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, + 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, + 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 0, 47, 0, 47, 47, 47, + 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 0, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 17, 18, + 111, 112, 113, 114, 115, 116, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 0, 0, 0, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, + 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 0, 47, 47, 47, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 47, 1, 1, 1, 1, 47, 1, 0, 0, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 1, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, + 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 1, 1, 0, 0, 0, 0, 0, 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 0, 0, 0, 47, 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 46, 116, 16, 16, 16, 117, + 16, 16, 16, 16, 16, 16, 16, 16, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 47, 117, 16, 16, 16, 118, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 16, 16, 16, 16, 16, 118, - 16, 16, 119, 16, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 120, 120, 120, 120, 120, 120, - 120, 120, 121, 121, 121, 121, 121, 121, 121, 121, 120, 120, 120, 120, - 120, 120, 0, 0, 121, 121, 121, 121, 121, 121, 0, 0, 120, 120, 120, 120, - 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 121, 121, 120, 120, - 120, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 121, 121, - 120, 120, 120, 120, 120, 120, 0, 0, 121, 121, 121, 121, 121, 121, 0, 0, - 16, 120, 16, 120, 16, 120, 16, 120, 0, 121, 0, 121, 0, 121, 0, 121, 120, - 120, 120, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 121, - 121, 122, 122, 123, 123, 123, 123, 124, 124, 125, 125, 126, 126, 127, - 127, 0, 0, 120, 120, 120, 120, 120, 120, 120, 120, 128, 128, 128, 128, - 128, 128, 128, 128, 120, 120, 120, 120, 120, 120, 120, 120, 128, 128, - 128, 128, 128, 128, 128, 128, 120, 120, 120, 120, 120, 120, 120, 120, - 128, 128, 128, 128, 128, 128, 128, 128, 120, 120, 16, 129, 16, 0, 16, 16, - 121, 121, 130, 130, 131, 1, 132, 1, 1, 1, 16, 129, 16, 0, 16, 16, 133, - 133, 133, 133, 131, 1, 1, 1, 120, 120, 16, 16, 0, 0, 16, 16, 121, 121, - 134, 134, 0, 1, 1, 1, 120, 120, 16, 16, 16, 100, 16, 16, 121, 121, 135, - 135, 103, 1, 1, 1, 0, 0, 16, 129, 16, 0, 16, 16, 136, 136, 137, 137, 131, + 0, 0, 0, 0, 0, 0, 1, 1, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 16, 16, 16, 16, 16, 119, + 16, 16, 120, 16, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 121, 121, 121, 121, 121, 121, + 121, 121, 122, 122, 122, 122, 122, 122, 122, 122, 121, 121, 121, 121, + 121, 121, 0, 0, 122, 122, 122, 122, 122, 122, 0, 0, 121, 121, 121, 121, + 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 122, 122, 121, 121, + 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 122, 122, + 121, 121, 121, 121, 121, 121, 0, 0, 122, 122, 122, 122, 122, 122, 0, 0, + 16, 121, 16, 121, 16, 121, 16, 121, 0, 122, 0, 122, 0, 122, 0, 122, 121, + 121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, 122, + 122, 123, 123, 124, 124, 124, 124, 125, 125, 126, 126, 127, 127, 128, + 128, 0, 0, 121, 121, 121, 121, 121, 121, 121, 121, 129, 129, 129, 129, + 129, 129, 129, 129, 121, 121, 121, 121, 121, 121, 121, 121, 129, 129, + 129, 129, 129, 129, 129, 129, 121, 121, 121, 121, 121, 121, 121, 121, + 129, 129, 129, 129, 129, 129, 129, 129, 121, 121, 16, 130, 16, 0, 16, 16, + 122, 122, 131, 131, 132, 1, 133, 1, 1, 1, 16, 130, 16, 0, 16, 16, 134, + 134, 134, 134, 132, 1, 1, 1, 121, 121, 16, 16, 0, 0, 16, 16, 122, 122, + 135, 135, 0, 1, 1, 1, 121, 121, 16, 16, 16, 101, 16, 16, 122, 122, 136, + 136, 104, 1, 1, 1, 0, 0, 16, 130, 16, 0, 16, 16, 137, 137, 138, 138, 132, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 138, 16, 0, 0, - 110, 111, 112, 113, 114, 115, 1, 1, 1, 1, 1, 16, 138, 20, 17, 18, 110, - 111, 112, 113, 114, 115, 1, 1, 1, 1, 1, 0, 46, 46, 46, 46, 46, 0, 0, 0, + 1, 1, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 139, 16, 0, 0, + 111, 112, 113, 114, 115, 116, 1, 1, 1, 1, 1, 16, 139, 20, 17, 18, 111, + 112, 113, 114, 115, 116, 1, 1, 1, 1, 1, 0, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 94, 1, 1, 1, 1, 94, 1, 1, 16, 94, 94, 94, - 16, 16, 94, 94, 94, 16, 1, 94, 1, 1, 1, 94, 94, 94, 94, 94, 1, 1, 1, 1, - 1, 1, 94, 1, 139, 1, 94, 1, 140, 141, 94, 94, 1, 16, 94, 94, 142, 94, 16, - 46, 46, 46, 46, 16, 1, 1, 16, 16, 94, 94, 1, 1, 1, 1, 1, 94, 16, 16, 16, - 16, 1, 1, 1, 1, 143, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 1, 1, 1, 22, 23, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 95, 1, 1, 1, 1, 95, 1, 1, 16, 95, 95, 95, + 16, 16, 95, 95, 95, 16, 1, 95, 1, 1, 1, 95, 95, 95, 95, 95, 1, 1, 1, 1, + 1, 1, 95, 1, 140, 1, 95, 1, 141, 142, 95, 95, 1, 16, 95, 95, 143, 95, 16, + 47, 47, 47, 47, 16, 1, 1, 16, 16, 95, 95, 1, 1, 1, 1, 1, 95, 16, 16, 16, + 16, 1, 1, 1, 1, 144, 1, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, + 146, 146, 146, 146, 146, 146, 21, 21, 21, 23, 24, 21, 21, 21, 21, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -811,595 +1075,725 @@ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, - 17, 18, 110, 111, 112, 113, 114, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 20, 17, 18, 110, 111, 112, 113, 114, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 20, 17, 18, 110, 111, 112, 113, 114, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, - 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 17, 18, 111, 112, 113, 114, + 115, 116, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 17, 18, 111, + 112, 113, 114, 115, 116, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, + 17, 18, 111, 112, 113, 114, 115, 116, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 138, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 20, 17, 18, 110, 111, 112, 113, 114, 115, 1, 138, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, - 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, - 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 17, 18, 110, 111, 112, 113, - 114, 115, 1, 20, 17, 18, 110, 111, 112, 113, 114, 115, 1, 20, 17, 18, - 110, 111, 112, 113, 114, 115, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 0, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 0, 22, 23, 148, 149, 150, 151, 152, 22, 23, 22, - 23, 22, 23, 153, 154, 155, 0, 16, 22, 23, 16, 22, 23, 16, 16, 16, 16, 16, - 16, 46, 0, 0, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 16, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, - 46, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, - 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, - 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 46, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 139, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 20, 17, 18, 111, 112, 113, 114, 115, 116, + 21, 139, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, + 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 17, 18, 111, 112, 113, 114, 115, 116, 21, + 20, 17, 18, 111, 112, 113, 114, 115, 116, 21, 20, 17, 18, 111, 112, 113, + 114, 115, 116, 21, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 1, 1, 1, 1, 46, 46, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, - 1, 1, 1, 1, 1, 46, 46, 1, 1, 1, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 0, 0, 1, 1, 1, 1, 46, 46, 46, 1, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, 46, 46, 46, 0, - 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, - 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 0, 0, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 46, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 46, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, - 22, 23, 22, 23, 22, 23, 22, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 1, 1, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 16, 16, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, - 23, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 46, 16, 16, 16, 16, 16, 16, - 16, 16, 22, 23, 22, 23, 157, 22, 23, 22, 23, 22, 23, 22, 23, 22, 23, 46, - 1, 1, 22, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, - 46, 46, 1, 46, 46, 46, 1, 46, 46, 46, 46, 1, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 46, 46, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 0, 0, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 0, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 0, 23, 24, 149, + 150, 151, 152, 153, 23, 24, 23, 24, 23, 24, 154, 155, 156, 0, 16, 23, 24, + 16, 23, 24, 16, 16, 16, 16, 16, 16, 47, 0, 0, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 16, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 21, 1, 1, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, + 0, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, + 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, + 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 1, + 1, 1, 1, 47, 47, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, + 1, 1, 1, 47, 47, 47, 47, 47, 1, 1, 21, 21, 21, 47, 47, 1, 1, 1, 0, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 1, 1, 1, 1, 47, + 47, 47, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 1, 47, 47, 47, 47, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 0, 1, 1, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 47, 47, + 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 158, 47, 47, 158, 47, 47, 47, 158, 47, 158, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 158, 47, 158, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 158, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, + 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 158, 47, 158, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 158, 158, 158, 47, + 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 158, 158, + 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 158, 158, 158, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 158, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, - 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, - 0, 0, 0, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 0, 46, 0, - 46, 46, 0, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, - 0, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 1, 1, 1, 1, 1, 1, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 1, 1, 1, - 1, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, - 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 0, 0, 46, 46, 46, - 46, 46, 46, 0, 0, 46, 46, 46, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 0, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 0, 0, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 47, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 47, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, + 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 1, 1, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 16, 16, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 23, 24, 47, 16, 16, 16, 16, + 16, 16, 16, 16, 23, 24, 23, 24, 159, 23, 24, 23, 24, 23, 24, 23, 24, 23, + 24, 47, 1, 1, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 1, 47, 47, 47, 1, 47, 47, 47, 47, 1, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, + 47, 47, 1, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 158, + 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 158, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 47, 1, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 0, 47, 47, 47, 47, 47, 0, 47, 0, 47, 47, 0, 47, 47, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 47, 47, 47, 47, 47, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, + 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 1, 1, 1, 1, 1, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, 47, 47, 47, + 0, 0, 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, + 47, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 47, 47, 0, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, + 0, 1, 1, 1, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 21, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 1, 46, 46, 46, 46, 46, 46, 46, 46, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 1, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 46, 46, 46, 46, - 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 0, 0, 46, 0, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 0, 46, 46, 0, 0, 0, 46, 0, 0, 46, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 46, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 46, 46, 46, 46, 0, 46, - 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 1, 20, 17, 18, 110, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 0, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 21, + 47, 47, 47, 47, 47, 47, 47, 47, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 1, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, + 47, 1, 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 0, 0, 47, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 0, 47, 47, 0, 0, 0, 47, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 21, 21, 21, 21, 0, 0, 0, 0, 0, 1, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 47, 47, 47, 47, 0, 47, 47, 47, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 20, 17, 18, 111, 21, 21, 21, 21, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 94, 0, 94, 94, 0, 0, 94, 0, 0, 94, 94, 0, 0, - 94, 94, 94, 94, 0, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, 16, 0, 16, - 0, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, - 94, 0, 94, 94, 94, 94, 0, 0, 94, 94, 94, 94, 94, 94, 94, 94, 0, 94, 94, - 94, 94, 94, 94, 94, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, 94, 0, 94, - 94, 94, 94, 0, 94, 94, 94, 94, 94, 0, 94, 0, 0, 0, 94, 94, 94, 94, 94, - 94, 94, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, 16, 16, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, + 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 95, 0, 95, 95, 0, 0, 95, 0, 0, 95, 95, 0, 0, 95, 95, 95, 95, + 0, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 0, 16, 0, 16, 16, 16, + 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, 95, 0, 95, + 95, 95, 95, 0, 0, 95, 95, 95, 95, 95, 95, 95, 95, 0, 95, 95, 95, 95, 95, + 95, 95, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, 95, 0, 95, 95, 95, 95, 0, + 95, 95, 95, 95, 95, 0, 95, 0, 0, 0, 95, 95, 95, 95, 95, 95, 95, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 0, 0, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 1, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, + 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, - 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 1, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 1, + 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 95, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, - 16, 16, 16, 16, 94, 16, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 95, 16, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, + 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 158, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1407,18 +1801,1313 @@ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, }; +/* Returns the numeric value as double for Unicode characters + * having this property, -1.0 otherwise. + */ +double _PyUnicode_ToNumeric(Py_UNICODE ch) +{ + switch (ch) { + case 0x0F33: + return (double) -1/2; + case 0x0030: + case 0x0660: + case 0x06F0: + case 0x07C0: + case 0x0966: + case 0x09E6: + case 0x0A66: + case 0x0AE6: + case 0x0B66: + case 0x0BE6: + case 0x0C66: + case 0x0C78: + case 0x0CE6: + case 0x0D66: + case 0x0E50: + case 0x0ED0: + case 0x0F20: + case 0x1040: + case 0x1090: + case 0x17E0: + case 0x17F0: + case 0x1810: + case 0x1946: + case 0x19D0: + case 0x1B50: + case 0x1BB0: + case 0x1C40: + case 0x1C50: + case 0x2070: + case 0x2080: + case 0x24EA: + case 0x24FF: + case 0x3007: + case 0x96F6: + case 0xA620: + case 0xA8D0: + case 0xA900: + case 0xAA50: + case 0xF9B2: + case 0xFF10: +#ifdef Py_UNICODE_WIDE + case 0x1018A: + case 0x104A0: + case 0x1D7CE: + case 0x1D7D8: + case 0x1D7E2: + case 0x1D7EC: + case 0x1D7F6: +#endif + return (double) 0; + case 0x0031: + case 0x00B9: + case 0x0661: + case 0x06F1: + case 0x07C1: + case 0x0967: + case 0x09E7: + case 0x09F4: + case 0x0A67: + case 0x0AE7: + case 0x0B67: + case 0x0BE7: + case 0x0C67: + case 0x0C79: + case 0x0C7C: + case 0x0CE7: + case 0x0D67: + case 0x0E51: + case 0x0ED1: + case 0x0F21: + case 0x1041: + case 0x1091: + case 0x1369: + case 0x17E1: + case 0x17F1: + case 0x1811: + case 0x1947: + case 0x19D1: + case 0x1B51: + case 0x1BB1: + case 0x1C41: + case 0x1C51: + case 0x2081: + case 0x215F: + case 0x2160: + case 0x2170: + case 0x2460: + case 0x2474: + case 0x2488: + case 0x24F5: + case 0x2776: + case 0x2780: + case 0x278A: + case 0x3021: + case 0x3192: + case 0x3220: + case 0x3280: + case 0x4E00: + case 0x58F1: + case 0x58F9: + case 0x5E7A: + case 0x5F0C: + case 0xA621: + case 0xA8D1: + case 0xA901: + case 0xAA51: + case 0xFF11: +#ifdef Py_UNICODE_WIDE + case 0x10107: + case 0x10142: + case 0x10158: + case 0x10159: + case 0x1015A: + case 0x10320: + case 0x103D1: + case 0x104A1: + case 0x10916: + case 0x10A40: + case 0x12415: + case 0x1241E: + case 0x1242C: + case 0x12434: + case 0x1244F: + case 0x12458: + case 0x1D360: + case 0x1D7CF: + case 0x1D7D9: + case 0x1D7E3: + case 0x1D7ED: + case 0x1D7F7: + case 0x2092A: +#endif + return (double) 1; + case 0x00BD: + case 0x0D74: + case 0x0F2A: + case 0x2CFD: +#ifdef Py_UNICODE_WIDE + case 0x10141: + case 0x10175: + case 0x10176: +#endif + return (double) 1/2; + case 0x2153: +#ifdef Py_UNICODE_WIDE + case 0x1245A: + case 0x1245D: +#endif + return (double) 1/3; + case 0x00BC: + case 0x0D73: +#ifdef Py_UNICODE_WIDE + case 0x10140: + case 0x12460: + case 0x12462: +#endif + return (double) 1/4; + case 0x2155: + return (double) 1/5; + case 0x2159: +#ifdef Py_UNICODE_WIDE + case 0x12461: +#endif + return (double) 1/6; + case 0x215B: +#ifdef Py_UNICODE_WIDE + case 0x1245F: +#endif + return (double) 1/8; + case 0x0BF0: + case 0x0D70: + case 0x1372: + case 0x2169: + case 0x2179: + case 0x2469: + case 0x247D: + case 0x2491: + case 0x24FE: + case 0x277F: + case 0x2789: + case 0x2793: + case 0x3038: + case 0x3229: + case 0x3289: + case 0x4EC0: + case 0x5341: + case 0x62FE: + case 0xF973: + case 0xF9FD: +#ifdef Py_UNICODE_WIDE + case 0x10110: + case 0x10149: + case 0x10150: + case 0x10157: + case 0x10160: + case 0x10161: + case 0x10162: + case 0x10163: + case 0x10164: + case 0x10322: + case 0x103D3: + case 0x10917: + case 0x10A44: + case 0x1D369: +#endif + return (double) 10; + case 0x0BF1: + case 0x0D71: + case 0x137B: + case 0x216D: + case 0x217D: + case 0x4F70: + case 0x767E: + case 0x964C: +#ifdef Py_UNICODE_WIDE + case 0x10119: + case 0x1014B: + case 0x10152: + case 0x1016A: + case 0x103D5: + case 0x10919: + case 0x10A46: +#endif + return (double) 100; + case 0x0BF2: + case 0x0D72: + case 0x216F: + case 0x217F: + case 0x2180: + case 0x4EDF: + case 0x5343: + case 0x9621: +#ifdef Py_UNICODE_WIDE + case 0x10122: + case 0x1014D: + case 0x10154: + case 0x10171: + case 0x10A47: +#endif + return (double) 1000; + case 0x137C: + case 0x2182: + case 0x4E07: + case 0x842C: +#ifdef Py_UNICODE_WIDE + case 0x1012B: + case 0x10155: +#endif + return (double) 10000; + case 0x2188: + return (double) 100000; + case 0x4EBF: + case 0x5104: + return (double) 100000000; + case 0x5146: + return (double) 1000000000000; + case 0x216A: + case 0x217A: + case 0x246A: + case 0x247E: + case 0x2492: + case 0x24EB: + return (double) 11; + case 0x0F2F: + return (double) 11/2; + case 0x216B: + case 0x217B: + case 0x246B: + case 0x247F: + case 0x2493: + case 0x24EC: + return (double) 12; + case 0x246C: + case 0x2480: + case 0x2494: + case 0x24ED: + return (double) 13; + case 0x0F30: + return (double) 13/2; + case 0x246D: + case 0x2481: + case 0x2495: + case 0x24EE: + return (double) 14; + case 0x246E: + case 0x2482: + case 0x2496: + case 0x24EF: + return (double) 15; + case 0x0F31: + return (double) 15/2; + case 0x09F9: + case 0x246F: + case 0x2483: + case 0x2497: + case 0x24F0: + return (double) 16; + case 0x16EE: + case 0x2470: + case 0x2484: + case 0x2498: + case 0x24F1: + return (double) 17; + case 0x0F32: + return (double) 17/2; + case 0x16EF: + case 0x2471: + case 0x2485: + case 0x2499: + case 0x24F2: + return (double) 18; + case 0x16F0: + case 0x2472: + case 0x2486: + case 0x249A: + case 0x24F3: + return (double) 19; + case 0x0032: + case 0x00B2: + case 0x0662: + case 0x06F2: + case 0x07C2: + case 0x0968: + case 0x09E8: + case 0x09F5: + case 0x0A68: + case 0x0AE8: + case 0x0B68: + case 0x0BE8: + case 0x0C68: + case 0x0C7A: + case 0x0C7D: + case 0x0CE8: + case 0x0D68: + case 0x0E52: + case 0x0ED2: + case 0x0F22: + case 0x1042: + case 0x1092: + case 0x136A: + case 0x17E2: + case 0x17F2: + case 0x1812: + case 0x1948: + case 0x19D2: + case 0x1B52: + case 0x1BB2: + case 0x1C42: + case 0x1C52: + case 0x2082: + case 0x2161: + case 0x2171: + case 0x2461: + case 0x2475: + case 0x2489: + case 0x24F6: + case 0x2777: + case 0x2781: + case 0x278B: + case 0x3022: + case 0x3193: + case 0x3221: + case 0x3281: + case 0x3483: + case 0x4E8C: + case 0x5169: + case 0x5F0D: + case 0x5F10: + case 0x8CAE: + case 0x8CB3: + case 0x8D30: + case 0xA622: + case 0xA8D2: + case 0xA902: + case 0xAA52: + case 0xF978: + case 0xFF12: +#ifdef Py_UNICODE_WIDE + case 0x10108: + case 0x1015B: + case 0x1015C: + case 0x1015D: + case 0x1015E: + case 0x103D2: + case 0x104A2: + case 0x10A41: + case 0x12400: + case 0x12416: + case 0x1241F: + case 0x12423: + case 0x1242D: + case 0x12435: + case 0x1244A: + case 0x12450: + case 0x12459: + case 0x1D361: + case 0x1D7D0: + case 0x1D7DA: + case 0x1D7E4: + case 0x1D7EE: + case 0x1D7F8: + case 0x22390: +#endif + return (double) 2; + case 0x2154: +#ifdef Py_UNICODE_WIDE + case 0x10177: + case 0x1245B: + case 0x1245E: +#endif + return (double) 2/3; + case 0x2156: + return (double) 2/5; + case 0x1373: + case 0x2473: + case 0x2487: + case 0x249B: + case 0x24F4: + case 0x3039: + case 0x5344: + case 0x5EFF: +#ifdef Py_UNICODE_WIDE + case 0x10111: + case 0x103D4: + case 0x10918: + case 0x10A45: + case 0x1D36A: +#endif + return (double) 20; +#ifdef Py_UNICODE_WIDE + case 0x1011A: + return (double) 200; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10123: + return (double) 2000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012C: + return (double) 20000; +#endif + case 0x3251: + return (double) 21; + case 0x3252: + return (double) 22; + case 0x3253: + return (double) 23; + case 0x3254: + return (double) 24; + case 0x3255: + return (double) 25; + case 0x3256: + return (double) 26; + case 0x3257: + return (double) 27; + case 0x3258: + return (double) 28; + case 0x3259: + return (double) 29; + case 0x0033: + case 0x00B3: + case 0x0663: + case 0x06F3: + case 0x07C3: + case 0x0969: + case 0x09E9: + case 0x09F6: + case 0x0A69: + case 0x0AE9: + case 0x0B69: + case 0x0BE9: + case 0x0C69: + case 0x0C7B: + case 0x0C7E: + case 0x0CE9: + case 0x0D69: + case 0x0E53: + case 0x0ED3: + case 0x0F23: + case 0x1043: + case 0x1093: + case 0x136B: + case 0x17E3: + case 0x17F3: + case 0x1813: + case 0x1949: + case 0x19D3: + case 0x1B53: + case 0x1BB3: + case 0x1C43: + case 0x1C53: + case 0x2083: + case 0x2162: + case 0x2172: + case 0x2462: + case 0x2476: + case 0x248A: + case 0x24F7: + case 0x2778: + case 0x2782: + case 0x278C: + case 0x3023: + case 0x3194: + case 0x3222: + case 0x3282: + case 0x4E09: + case 0x4EE8: + case 0x53C1: + case 0x53C2: + case 0x53C3: + case 0x53C4: + case 0x5F0E: + case 0xA623: + case 0xA8D3: + case 0xA903: + case 0xAA53: + case 0xF96B: + case 0xFF13: +#ifdef Py_UNICODE_WIDE + case 0x10109: + case 0x104A3: + case 0x10A42: + case 0x12401: + case 0x12408: + case 0x12417: + case 0x12420: + case 0x12424: + case 0x12425: + case 0x1242E: + case 0x1242F: + case 0x12436: + case 0x12437: + case 0x1243A: + case 0x1243B: + case 0x1244B: + case 0x12451: + case 0x1D362: + case 0x1D7D1: + case 0x1D7DB: + case 0x1D7E5: + case 0x1D7EF: + case 0x1D7F9: + case 0x20AFD: + case 0x20B19: + case 0x22998: + case 0x23B1B: +#endif + return (double) 3; + case 0x0F2B: + return (double) 3/2; + case 0x00BE: + case 0x0D75: +#ifdef Py_UNICODE_WIDE + case 0x10178: +#endif + return (double) 3/4; + case 0x2157: + return (double) 3/5; + case 0x215C: + return (double) 3/8; + case 0x1374: + case 0x303A: + case 0x325A: + case 0x5345: +#ifdef Py_UNICODE_WIDE + case 0x10112: + case 0x10165: + case 0x1D36B: + case 0x20983: +#endif + return (double) 30; +#ifdef Py_UNICODE_WIDE + case 0x1011B: + case 0x1016B: + return (double) 300; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10124: + return (double) 3000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012D: + return (double) 30000; +#endif + case 0x325B: + return (double) 31; + case 0x325C: + return (double) 32; + case 0x325D: + return (double) 33; + case 0x325E: + return (double) 34; + case 0x325F: + return (double) 35; + case 0x32B1: + return (double) 36; + case 0x32B2: + return (double) 37; + case 0x32B3: + return (double) 38; + case 0x32B4: + return (double) 39; + case 0x0034: + case 0x0664: + case 0x06F4: + case 0x07C4: + case 0x096A: + case 0x09EA: + case 0x09F7: + case 0x0A6A: + case 0x0AEA: + case 0x0B6A: + case 0x0BEA: + case 0x0C6A: + case 0x0CEA: + case 0x0D6A: + case 0x0E54: + case 0x0ED4: + case 0x0F24: + case 0x1044: + case 0x1094: + case 0x136C: + case 0x17E4: + case 0x17F4: + case 0x1814: + case 0x194A: + case 0x19D4: + case 0x1B54: + case 0x1BB4: + case 0x1C44: + case 0x1C54: + case 0x2074: + case 0x2084: + case 0x2163: + case 0x2173: + case 0x2463: + case 0x2477: + case 0x248B: + case 0x24F8: + case 0x2779: + case 0x2783: + case 0x278D: + case 0x3024: + case 0x3195: + case 0x3223: + case 0x3283: + case 0x4E96: + case 0x56DB: + case 0x8086: + case 0xA624: + case 0xA8D4: + case 0xA904: + case 0xAA54: + case 0xFF14: +#ifdef Py_UNICODE_WIDE + case 0x1010A: + case 0x104A4: + case 0x10A43: + case 0x12402: + case 0x12409: + case 0x1240F: + case 0x12418: + case 0x12421: + case 0x12426: + case 0x12430: + case 0x12438: + case 0x1243C: + case 0x1243D: + case 0x1243E: + case 0x1243F: + case 0x1244C: + case 0x12452: + case 0x12453: + case 0x1D363: + case 0x1D7D2: + case 0x1D7DC: + case 0x1D7E6: + case 0x1D7F0: + case 0x1D7FA: + case 0x20064: + case 0x200E2: + case 0x2626D: +#endif + return (double) 4; + case 0x2158: + return (double) 4/5; + case 0x1375: + case 0x32B5: + case 0x534C: +#ifdef Py_UNICODE_WIDE + case 0x10113: + case 0x1D36C: + case 0x2098C: + case 0x2099C: +#endif + return (double) 40; +#ifdef Py_UNICODE_WIDE + case 0x1011C: + return (double) 400; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10125: + return (double) 4000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012E: + return (double) 40000; +#endif + case 0x32B6: + return (double) 41; + case 0x32B7: + return (double) 42; + case 0x32B8: + return (double) 43; + case 0x32B9: + return (double) 44; + case 0x32BA: + return (double) 45; + case 0x32BB: + return (double) 46; + case 0x32BC: + return (double) 47; + case 0x32BD: + return (double) 48; + case 0x32BE: + return (double) 49; + case 0x0035: + case 0x0665: + case 0x06F5: + case 0x07C5: + case 0x096B: + case 0x09EB: + case 0x0A6B: + case 0x0AEB: + case 0x0B6B: + case 0x0BEB: + case 0x0C6B: + case 0x0CEB: + case 0x0D6B: + case 0x0E55: + case 0x0ED5: + case 0x0F25: + case 0x1045: + case 0x1095: + case 0x136D: + case 0x17E5: + case 0x17F5: + case 0x1815: + case 0x194B: + case 0x19D5: + case 0x1B55: + case 0x1BB5: + case 0x1C45: + case 0x1C55: + case 0x2075: + case 0x2085: + case 0x2164: + case 0x2174: + case 0x2464: + case 0x2478: + case 0x248C: + case 0x24F9: + case 0x277A: + case 0x2784: + case 0x278E: + case 0x3025: + case 0x3224: + case 0x3284: + case 0x3405: + case 0x382A: + case 0x4E94: + case 0x4F0D: + case 0xA625: + case 0xA8D5: + case 0xA905: + case 0xAA55: + case 0xFF15: +#ifdef Py_UNICODE_WIDE + case 0x1010B: + case 0x10143: + case 0x10148: + case 0x1014F: + case 0x1015F: + case 0x10173: + case 0x10321: + case 0x104A5: + case 0x12403: + case 0x1240A: + case 0x12410: + case 0x12419: + case 0x12422: + case 0x12427: + case 0x12431: + case 0x12439: + case 0x1244D: + case 0x12454: + case 0x12455: + case 0x1D364: + case 0x1D7D3: + case 0x1D7DD: + case 0x1D7E7: + case 0x1D7F1: + case 0x1D7FB: + case 0x20121: +#endif + return (double) 5; + case 0x0F2C: + return (double) 5/2; + case 0x215A: +#ifdef Py_UNICODE_WIDE + case 0x1245C: +#endif + return (double) 5/6; + case 0x215D: + return (double) 5/8; + case 0x1376: + case 0x216C: + case 0x217C: + case 0x2186: + case 0x32BF: +#ifdef Py_UNICODE_WIDE + case 0x10114: + case 0x10144: + case 0x1014A: + case 0x10151: + case 0x10166: + case 0x10167: + case 0x10168: + case 0x10169: + case 0x10174: + case 0x10323: + case 0x1D36D: +#endif + return (double) 50; + case 0x216E: + case 0x217E: +#ifdef Py_UNICODE_WIDE + case 0x1011D: + case 0x10145: + case 0x1014C: + case 0x10153: + case 0x1016C: + case 0x1016D: + case 0x1016E: + case 0x1016F: + case 0x10170: +#endif + return (double) 500; + case 0x2181: +#ifdef Py_UNICODE_WIDE + case 0x10126: + case 0x10146: + case 0x1014E: + case 0x10172: +#endif + return (double) 5000; + case 0x2187: +#ifdef Py_UNICODE_WIDE + case 0x1012F: + case 0x10147: + case 0x10156: +#endif + return (double) 50000; + case 0x0036: + case 0x0666: + case 0x06F6: + case 0x07C6: + case 0x096C: + case 0x09EC: + case 0x0A6C: + case 0x0AEC: + case 0x0B6C: + case 0x0BEC: + case 0x0C6C: + case 0x0CEC: + case 0x0D6C: + case 0x0E56: + case 0x0ED6: + case 0x0F26: + case 0x1046: + case 0x1096: + case 0x136E: + case 0x17E6: + case 0x17F6: + case 0x1816: + case 0x194C: + case 0x19D6: + case 0x1B56: + case 0x1BB6: + case 0x1C46: + case 0x1C56: + case 0x2076: + case 0x2086: + case 0x2165: + case 0x2175: + case 0x2185: + case 0x2465: + case 0x2479: + case 0x248D: + case 0x24FA: + case 0x277B: + case 0x2785: + case 0x278F: + case 0x3026: + case 0x3225: + case 0x3285: + case 0x516D: + case 0x9646: + case 0x9678: + case 0xA626: + case 0xA8D6: + case 0xA906: + case 0xAA56: + case 0xF9D1: + case 0xF9D3: + case 0xFF16: +#ifdef Py_UNICODE_WIDE + case 0x1010C: + case 0x104A6: + case 0x12404: + case 0x1240B: + case 0x12411: + case 0x1241A: + case 0x12428: + case 0x12440: + case 0x1244E: + case 0x1D365: + case 0x1D7D4: + case 0x1D7DE: + case 0x1D7E8: + case 0x1D7F2: + case 0x1D7FC: + case 0x20AEA: +#endif + return (double) 6; + case 0x1377: +#ifdef Py_UNICODE_WIDE + case 0x10115: + case 0x1D36E: +#endif + return (double) 60; +#ifdef Py_UNICODE_WIDE + case 0x1011E: + return (double) 600; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10127: + return (double) 6000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10130: + return (double) 60000; +#endif + case 0x0037: + case 0x0667: + case 0x06F7: + case 0x07C7: + case 0x096D: + case 0x09ED: + case 0x0A6D: + case 0x0AED: + case 0x0B6D: + case 0x0BED: + case 0x0C6D: + case 0x0CED: + case 0x0D6D: + case 0x0E57: + case 0x0ED7: + case 0x0F27: + case 0x1047: + case 0x1097: + case 0x136F: + case 0x17E7: + case 0x17F7: + case 0x1817: + case 0x194D: + case 0x19D7: + case 0x1B57: + case 0x1BB7: + case 0x1C47: + case 0x1C57: + case 0x2077: + case 0x2087: + case 0x2166: + case 0x2176: + case 0x2466: + case 0x247A: + case 0x248E: + case 0x24FB: + case 0x277C: + case 0x2786: + case 0x2790: + case 0x3027: + case 0x3226: + case 0x3286: + case 0x3B4D: + case 0x4E03: + case 0x67D2: + case 0x6F06: + case 0xA627: + case 0xA8D7: + case 0xA907: + case 0xAA57: + case 0xFF17: +#ifdef Py_UNICODE_WIDE + case 0x1010D: + case 0x104A7: + case 0x12405: + case 0x1240C: + case 0x12412: + case 0x1241B: + case 0x12429: + case 0x12441: + case 0x12442: + case 0x12443: + case 0x1D366: + case 0x1D7D5: + case 0x1D7DF: + case 0x1D7E9: + case 0x1D7F3: + case 0x1D7FD: + case 0x20001: +#endif + return (double) 7; + case 0x0F2D: + return (double) 7/2; + case 0x215E: + return (double) 7/8; + case 0x1378: +#ifdef Py_UNICODE_WIDE + case 0x10116: + case 0x1D36F: +#endif + return (double) 70; +#ifdef Py_UNICODE_WIDE + case 0x1011F: + return (double) 700; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10128: + return (double) 7000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10131: + return (double) 70000; +#endif + case 0x0038: + case 0x0668: + case 0x06F8: + case 0x07C8: + case 0x096E: + case 0x09EE: + case 0x0A6E: + case 0x0AEE: + case 0x0B6E: + case 0x0BEE: + case 0x0C6E: + case 0x0CEE: + case 0x0D6E: + case 0x0E58: + case 0x0ED8: + case 0x0F28: + case 0x1048: + case 0x1098: + case 0x1370: + case 0x17E8: + case 0x17F8: + case 0x1818: + case 0x194E: + case 0x19D8: + case 0x1B58: + case 0x1BB8: + case 0x1C48: + case 0x1C58: + case 0x2078: + case 0x2088: + case 0x2167: + case 0x2177: + case 0x2467: + case 0x247B: + case 0x248F: + case 0x24FC: + case 0x277D: + case 0x2787: + case 0x2791: + case 0x3028: + case 0x3227: + case 0x3287: + case 0x516B: + case 0x634C: + case 0xA628: + case 0xA8D8: + case 0xA908: + case 0xAA58: + case 0xFF18: +#ifdef Py_UNICODE_WIDE + case 0x1010E: + case 0x104A8: + case 0x12406: + case 0x1240D: + case 0x12413: + case 0x1241C: + case 0x1242A: + case 0x12444: + case 0x12445: + case 0x1D367: + case 0x1D7D6: + case 0x1D7E0: + case 0x1D7EA: + case 0x1D7F4: + case 0x1D7FE: +#endif + return (double) 8; + case 0x1379: +#ifdef Py_UNICODE_WIDE + case 0x10117: + case 0x1D370: +#endif + return (double) 80; +#ifdef Py_UNICODE_WIDE + case 0x10120: + return (double) 800; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10129: + return (double) 8000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10132: + return (double) 80000; +#endif + case 0x0039: + case 0x0669: + case 0x06F9: + case 0x07C9: + case 0x096F: + case 0x09EF: + case 0x0A6F: + case 0x0AEF: + case 0x0B6F: + case 0x0BEF: + case 0x0C6F: + case 0x0CEF: + case 0x0D6F: + case 0x0E59: + case 0x0ED9: + case 0x0F29: + case 0x1049: + case 0x1099: + case 0x1371: + case 0x17E9: + case 0x17F9: + case 0x1819: + case 0x194F: + case 0x19D9: + case 0x1B59: + case 0x1BB9: + case 0x1C49: + case 0x1C59: + case 0x2079: + case 0x2089: + case 0x2168: + case 0x2178: + case 0x2468: + case 0x247C: + case 0x2490: + case 0x24FD: + case 0x277E: + case 0x2788: + case 0x2792: + case 0x3029: + case 0x3228: + case 0x3288: + case 0x4E5D: + case 0x5EFE: + case 0x7396: + case 0xA629: + case 0xA8D9: + case 0xA909: + case 0xAA59: + case 0xFF19: +#ifdef Py_UNICODE_WIDE + case 0x1010F: + case 0x104A9: + case 0x12407: + case 0x1240E: + case 0x12414: + case 0x1241D: + case 0x1242B: + case 0x12446: + case 0x12447: + case 0x12448: + case 0x12449: + case 0x1D368: + case 0x1D7D7: + case 0x1D7E1: + case 0x1D7EB: + case 0x1D7F5: + case 0x1D7FF: + case 0x2F890: +#endif + return (double) 9; + case 0x0F2E: + return (double) 9/2; + case 0x137A: +#ifdef Py_UNICODE_WIDE + case 0x10118: + case 0x10341: + case 0x1D371: +#endif + return (double) 90; +#ifdef Py_UNICODE_WIDE + case 0x10121: + case 0x1034A: + return (double) 900; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012A: + return (double) 9000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10133: + return (double) 90000; +#endif + } + return -1.0; +} + +/* Returns 1 for Unicode characters having the bidirectional + * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. + */ +int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) +{ +#ifdef WANT_WCTYPE_FUNCTIONS + return iswspace(ch); +#else + switch (ch) { + case 0x0009: + case 0x000A: + case 0x000B: + case 0x000C: + case 0x000D: + case 0x001C: + case 0x001D: + case 0x001E: + case 0x001F: + case 0x0020: + case 0x0085: + case 0x00A0: + case 0x1680: + case 0x180E: + case 0x2000: + case 0x2001: + case 0x2002: + case 0x2003: + case 0x2004: + case 0x2005: + case 0x2006: + case 0x2007: + case 0x2008: + case 0x2009: + case 0x200A: + case 0x2028: + case 0x2029: + case 0x202F: + case 0x205F: + case 0x3000: + return 1; + } + return 0; +#endif +} + +/* Returns 1 for Unicode characters having the category 'Zl', + * 'Zp' or type 'B', 0 otherwise. + */ +int _PyUnicode_IsLinebreak(register const Py_UNICODE ch) +{ + switch (ch) { + case 0x000A: + case 0x000D: + case 0x001C: + case 0x001D: + case 0x001E: + case 0x0085: + case 0x2028: + case 0x2029: + return 1; + } + return 0; +} + Modified: python/trunk/Tools/unicode/makeunicodedata.py ============================================================================== --- python/trunk/Tools/unicode/makeunicodedata.py (original) +++ python/trunk/Tools/unicode/makeunicodedata.py Tue Oct 6 21:56:32 2009 @@ -34,6 +34,7 @@ UNICODE_DATA = "UnicodeData%s.txt" COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt" EASTASIAN_WIDTH = "EastAsianWidth%s.txt" +UNIHAN = "Unihan%s.txt" DERIVEDNORMALIZATION_PROPS = "DerivedNormalizationProps%s.txt" old_versions = ["3.2.0"] @@ -59,6 +60,7 @@ TITLE_MASK = 0x40 UPPER_MASK = 0x80 NODELTA_MASK = 0x100 +NUMERIC_MASK = 0x200 def maketables(trace=0): @@ -68,6 +70,7 @@ unicode = UnicodeData(UNICODE_DATA % version, COMPOSITION_EXCLUSIONS % version, EASTASIAN_WIDTH % version, + UNIHAN % version, DERIVEDNORMALIZATION_PROPS % version) print len(filter(None, unicode.table)), "characters" @@ -76,7 +79,8 @@ print "--- Reading", UNICODE_DATA % ("-"+version), "..." old_unicode = UnicodeData(UNICODE_DATA % ("-"+version), COMPOSITION_EXCLUSIONS % ("-"+version), - EASTASIAN_WIDTH % ("-"+version)) + EASTASIAN_WIDTH % ("-"+version), + UNIHAN % ("-"+version)) print len(filter(None, old_unicode.table)), "characters" merge_old_version(version, unicode, old_unicode) @@ -352,6 +356,9 @@ table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) + numeric = {} + spaces = [] + linebreaks = [] for char in unicode.chars: record = unicode.table[char] @@ -367,8 +374,10 @@ flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK + linebreaks.append(char) if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK + spaces.append(char) if category == "Lt": flags |= TITLE_MASK if category == "Lu": @@ -411,6 +420,9 @@ if record[7]: flags |= DIGIT_MASK digit = int(record[7]) + if record[8]: + flags |= NUMERIC_MASK + numeric.setdefault(record[8], []).append(char) item = ( upper, lower, title, decimal, digit, flags ) @@ -422,6 +434,9 @@ index[char] = i print len(table), "unique character type entries" + print sum(map(len, numeric.values())), "numeric code points" + print len(spaces), "whitespace code points" + print len(linebreaks), "linebreak code points" print "--- Writing", FILE, "..." @@ -443,6 +458,97 @@ Array("index1", index1).dump(fp, trace) Array("index2", index2).dump(fp, trace) + # Generate code for _PyUnicode_ToNumeric() + numeric_items = numeric.items() + numeric_items.sort() + print >>fp, '/* Returns the numeric value as double for Unicode characters' + print >>fp, ' * having this property, -1.0 otherwise.' + print >>fp, ' */' + print >>fp, 'double _PyUnicode_ToNumeric(Py_UNICODE ch)' + print >>fp, '{' + print >>fp, ' switch (ch) {' + for value, codepoints in numeric_items: + haswide = False + hasnonewide = False + codepoints.sort() + for codepoint in codepoints: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print >>fp, '#ifdef Py_UNICODE_WIDE' + haswide = True + print >>fp, ' case 0x%04X:' % (codepoint,) + if haswide and hasnonewide: + print >>fp, '#endif' + print >>fp, ' return (double) %s;' % (value,) + if haswide and not hasnonewide: + print >>fp, '#endif' + print >>fp,' }' + print >>fp,' return -1.0;' + print >>fp,'}' + print >>fp + + # Generate code for _PyUnicode_IsWhitespace() + print >>fp, "/* Returns 1 for Unicode characters having the bidirectional" + print >>fp, " * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise." + print >>fp, " */" + print >>fp, 'int _PyUnicode_IsWhitespace(register const Py_UNICODE ch)' + print >>fp, '{' + print >>fp, '#ifdef WANT_WCTYPE_FUNCTIONS' + print >>fp, ' return iswspace(ch);' + print >>fp, '#else' + print >>fp, ' switch (ch) {' + + haswide = False + hasnonewide = False + spaces.sort() + for codepoint in spaces: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print >>fp, '#ifdef Py_UNICODE_WIDE' + haswide = True + print >>fp, ' case 0x%04X:' % (codepoint,) + if haswide and hasnonewide: + print >>fp, '#endif' + print >>fp, ' return 1;' + if haswide and not hasnonewide: + print >>fp, '#endif' + + print >>fp,' }' + print >>fp,' return 0;' + print >>fp, '#endif' + print >>fp,'}' + print >>fp + + # Generate code for _PyUnicode_IsLinebreak() + print >>fp, "/* Returns 1 for Unicode characters having the category 'Zl'," + print >>fp, " * 'Zp' or type 'B', 0 otherwise." + print >>fp, " */" + print >>fp, 'int _PyUnicode_IsLinebreak(register const Py_UNICODE ch)' + print >>fp, '{' + print >>fp, ' switch (ch) {' + haswide = False + hasnonewide = False + linebreaks.sort() + for codepoint in linebreaks: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print >>fp, '#ifdef Py_UNICODE_WIDE' + haswide = True + print >>fp, ' case 0x%04X:' % (codepoint,) + if haswide and hasnonewide: + print >>fp, '#endif' + print >>fp, ' return 1;' + if haswide and not hasnonewide: + print >>fp, '#endif' + + print >>fp,' }' + print >>fp,' return 0;' + print >>fp,'}' + print >>fp + fp.close() # -------------------------------------------------------------------- @@ -660,12 +766,11 @@ elif k == 8: # print "NUMERIC",hex(i), `old.table[i][k]`, new.table[i][k] # Since 0 encodes "no change", the old value is better not 0 - assert value != "0" and value != "-1" if not value: numeric_changes[i] = -1 else: - assert re.match("^[0-9]+$", value) - numeric_changes[i] = int(value) + numeric_changes[i] = float(value) + assert numeric_changes[i] not in (0, -1) elif k == 9: if value == 'Y': mirrored_changes[i] = '1' @@ -698,11 +803,9 @@ # load a unicode-data file from disk -import sys - class UnicodeData: - def __init__(self, filename, exclusions, eastasianwidth, + def __init__(self, filename, exclusions, eastasianwidth, unihan, derivednormalizationprops=None, expand=1): self.changed = [] file = open(filename) @@ -789,6 +892,19 @@ if table[i] is not None: table[i].append(quickchecks[i]) + for line in open(unihan): + if not line.startswith('U+'): + continue + code, tag, value = line.split(None, 3)[:3] + if tag not in ('kAccountingNumeric', 'kPrimaryNumeric', + 'kOtherNumeric'): + continue + value = value.strip().replace(',', '') + i = int(code[2:], 16) + # Patch the numeric field + if table[i] is not None: + table[i][8] = value + def uselatin1(self): # restrict character range to ISO Latin 1 self.chars = range(256) @@ -938,7 +1054,6 @@ you'll get. """ - import sys if trace: def dump(t1, t2, shift, bytes): print >>sys.stderr, "%d+%d bins at shift %d; %d bytes" % ( From python-checkins at python.org Tue Oct 6 22:02:09 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Tue, 06 Oct 2009 20:02:09 -0000 Subject: [Python-checkins] r75273 - python/trunk/Misc/ACKS Message-ID: Author: amaury.forgeotdarc Date: Tue Oct 6 22:02:09 2009 New Revision: 75273 Log: Add Anders Chrigstrom to Misc/ACKS for his work on unicodedata. Modified: python/trunk/Misc/ACKS Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Tue Oct 6 22:02:09 2009 @@ -132,6 +132,7 @@ Albert Chin-A-Young Adal Chiriliuc Matt Chisholm +Anders Chrigstr?m Tom Christiansen Vadim Chugunov David Cinege From python-checkins at python.org Tue Oct 6 23:03:21 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Tue, 06 Oct 2009 21:03:21 -0000 Subject: [Python-checkins] r75274 - in python/branches/py3k: Lib/test/test_unicodedata.py Misc/ACKS Misc/NEWS Modules/unicodedata.c Modules/unicodedata_db.h Objects/unicodectype.c Objects/unicodetype_db.h Tools/unicode/makeunicodedata.py Message-ID: Author: amaury.forgeotdarc Date: Tue Oct 6 23:03:20 2009 New Revision: 75274 Log: Merged revisions 75272-75273 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75272 | amaury.forgeotdarc | 2009-10-06 21:56:32 +0200 (mar., 06 oct. 2009) | 5 lines #1571184: makeunicodedata.py now generates the functions _PyUnicode_ToNumeric, _PyUnicode_IsLinebreak and _PyUnicode_IsWhitespace. It now also parses the Unihan.txt for numeric values. ........ r75273 | amaury.forgeotdarc | 2009-10-06 22:02:09 +0200 (mar., 06 oct. 2009) | 2 lines Add Anders Chrigstrom to Misc/ACKS for his work on unicodedata. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_unicodedata.py python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/unicodedata.c python/branches/py3k/Modules/unicodedata_db.h python/branches/py3k/Objects/unicodectype.c python/branches/py3k/Objects/unicodetype_db.h python/branches/py3k/Tools/unicode/makeunicodedata.py Modified: python/branches/py3k/Lib/test/test_unicodedata.py ============================================================================== --- python/branches/py3k/Lib/test/test_unicodedata.py (original) +++ python/branches/py3k/Lib/test/test_unicodedata.py Tue Oct 6 23:03:20 2009 @@ -21,7 +21,7 @@ class UnicodeMethodsTest(unittest.TestCase): # update this, if the database changes - expectedchecksum = '6ec65b65835614ec00634c674bba0e50cd32c189' + expectedchecksum = '0b915116051f3ed029a98542c2b7df63c9646272' def test_method_checksum(self): h = hashlib.sha1() @@ -80,7 +80,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest): # update this, if the database changes - expectedchecksum = '3136d5afd787dc2bcb1bdcac95e385349fbebbca' + expectedchecksum = 'd4169ccff998ebbd1ec007a0b3fbd66e5ccf0229' def test_function_checksum(self): data = [] @@ -119,6 +119,7 @@ self.assertEqual(self.db.numeric('9'), 9) self.assertEqual(self.db.numeric('\u215b'), 0.125) self.assertEqual(self.db.numeric('\u2468'), 9.0) + self.assertEqual(self.db.numeric('\ua627'), 7.0) self.assertEqual(self.db.numeric('\U00020000', None), None) self.assertRaises(TypeError, self.db.numeric) Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Tue Oct 6 23:03:20 2009 @@ -131,6 +131,7 @@ Albert Chin-A-Young Adal Chiriliuc Matt Chisholm +Anders Chrigstr?m Tom Christiansen Vadim Chugunov David Cinege Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Oct 6 23:03:20 2009 @@ -12,6 +12,11 @@ Core and Builtins ----------------- +- Issue #1571184: The Unicode database contains properties for more characters. + The tables for code points representing numeric values, white spaces or line + breaks are now generated from the official Unicode Character Database files, + and include information from the Unihan.txt file. + - Issue #7019: Raise ValueError when unmarshalling bad long data, instead of producing internally inconsistent Python longs. Modified: python/branches/py3k/Modules/unicodedata.c ============================================================================== --- python/branches/py3k/Modules/unicodedata.c (original) +++ python/branches/py3k/Modules/unicodedata.c Tue Oct 6 23:03:20 2009 @@ -36,7 +36,7 @@ const unsigned char category_changed; const unsigned char decimal_changed; const unsigned char mirrored_changed; - const int numeric_changed; + const double numeric_changed; } change_record; /* data file generated by Tools/unicode/makeunicodedata.py */ Modified: python/branches/py3k/Modules/unicodedata_db.h ============================================================================== --- python/branches/py3k/Modules/unicodedata_db.h (original) +++ python/branches/py3k/Modules/unicodedata_db.h Tue Oct 6 23:03:20 2009 @@ -4729,8 +4729,10 @@ { 255, 23, 255, 255, 0 }, { 9, 255, 255, 255, 0 }, { 255, 20, 255, 255, 0 }, - { 255, 19, 255, 255, 0 }, { 255, 255, 255, 255, -1 }, + { 255, 255, 255, 255, 1e+16 }, + { 255, 255, 255, 255, 1e+20 }, + { 255, 19, 255, 255, 0 }, { 15, 255, 255, 255, 0 }, { 255, 19, 255, 255, -1 }, }; @@ -4740,34 +4742,27 @@ 2, 2, 2, 31, 2, 32, 33, 34, 35, 36, 37, 2, 38, 39, 40, 2, 41, 42, 2, 43, 2, 2, 44, 45, 46, 47, 48, 2, 2, 49, 50, 51, 2, 2, 52, 53, 2, 54, 55, 55, 2, 2, 2, 2, 56, 2, 57, 58, 59, 60, 61, 2, 2, 2, 2, 62, 63, 64, 65, 66, - 67, 68, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 69, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 70, 71, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 72, 73, 41, 74, 75, 76, 77, - 2, 78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 67, 68, 69, 70, 2, 2, 2, 2, 2, 2, 71, 2, 2, 2, 2, 2, 72, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79, 80, 81, 82, 83, 2, 2, 2, - 2, 84, 85, 2, 86, 87, 88, 89, 90, 91, 2, 92, 93, 94, 95, 96, 2, 2, 2, 2, - 2, 2, 97, 2, 98, 2, 99, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 73, 2, 74, 2, 2, 2, 2, 2, 2, 2, 2, 75, 76, 2, 2, 2, + 2, 2, 2, 2, 77, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 78, 79, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 41, 41, 41, 41, 41, 41, 100, 2, 101, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 80, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 81, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 82, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 83, 84, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 85, 86, 41, 87, + 88, 89, 90, 2, 91, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 92, 93, 94, 95, + 96, 2, 2, 2, 2, 97, 98, 2, 99, 100, 101, 102, 103, 104, 2, 105, 106, 107, + 108, 109, 2, 2, 2, 2, 2, 2, 110, 2, 111, 2, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 41, 41, 41, 41, 41, 113, 2, 114, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -4775,19 +4770,26 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 102, 2, 103, 2, 104, 2, 2, 105, 2, 2, 2, 106, 107, 108, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 109, 110, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 115, 2, 116, 2, 117, 2, 2, 118, 2, 2, 2, 119, + 120, 121, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 122, 123, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 124, 125, 82, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 71, 126, 2, 127, 128, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 129, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 130, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 131, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 132, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -4799,8 +4801,8 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 111, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 129, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -5035,7 +5037,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 41, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 133, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -5099,7 +5101,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static unsigned char changes_3_2_0_data[] = { @@ -5473,84 +5475,154 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, - 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 41, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5558,157 +5630,199 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13, 13, 13, 13, - 13, 0, 0, 0, 1, 1, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 13, 13, 13, 13, 13, 13, 0, 0, 0, 1, 1, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 45, 45, 45, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, + 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 0, - 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 0, 0, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 0, 0, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 7, 0, 0, 7, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 7, + 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, + 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, - 0, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, + 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, + 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const change_record* get_change_3_2_0(Py_UCS4 n) Modified: python/branches/py3k/Objects/unicodectype.c ============================================================================== --- python/branches/py3k/Objects/unicodectype.c (original) +++ python/branches/py3k/Objects/unicodectype.c Tue Oct 6 23:03:20 2009 @@ -23,6 +23,7 @@ #define XID_CONTINUE_MASK 0x200 #define PRINTABLE_MASK 0x400 #define NODELTA_MASK 0x800 +#define NUMERIC_MASK 0x1000 typedef struct { const Py_UNICODE upper; @@ -53,26 +54,6 @@ return &_PyUnicode_TypeRecords[index]; } -/* Returns 1 for Unicode characters having the category 'Zl', 'Zp' or - type 'B', 0 otherwise. */ - -int _PyUnicode_IsLinebreak(register const Py_UNICODE ch) -{ - switch (ch) { - case 0x000A: /* LINE FEED */ - case 0x000D: /* CARRIAGE RETURN */ - case 0x001C: /* FILE SEPARATOR */ - case 0x001D: /* GROUP SEPARATOR */ - case 0x001E: /* RECORD SEPARATOR */ - case 0x0085: /* NEXT LINE */ - case 0x2028: /* LINE SEPARATOR */ - case 0x2029: /* PARAGRAPH SEPARATOR */ - return 1; - default: - return 0; - } -} - /* Returns the titlecase Unicode characters corresponding to ch or just ch if no titlecase mapping is known. */ @@ -157,522 +138,11 @@ /* Returns the numeric value as double for Unicode characters having this property, -1.0 otherwise. */ -/* TODO: replace with unicodetype_db.h table */ - -double _PyUnicode_ToNumeric(Py_UNICODE ch) -{ - switch (ch) { - case 0x0F33: - return (double) -1 / 2; - case 0x17F0: - case 0x3007: -#ifdef Py_UNICODE_WIDE - case 0x1018A: -#endif - return (double) 0; - case 0x09F4: - case 0x17F1: - case 0x215F: - case 0x2160: - case 0x2170: - case 0x3021: - case 0x3192: - case 0x3220: - case 0x3280: -#ifdef Py_UNICODE_WIDE - case 0x10107: - case 0x10142: - case 0x10158: - case 0x10159: - case 0x1015A: - case 0x10320: - case 0x103D1: -#endif - return (double) 1; - case 0x00BD: - case 0x0F2A: - case 0x2CFD: -#ifdef Py_UNICODE_WIDE - case 0x10141: - case 0x10175: - case 0x10176: -#endif - return (double) 1 / 2; - case 0x2153: - return (double) 1 / 3; - case 0x00BC: -#ifdef Py_UNICODE_WIDE - case 0x10140: -#endif - return (double) 1 / 4; - case 0x2155: - return (double) 1 / 5; - case 0x2159: - return (double) 1 / 6; - case 0x215B: - return (double) 1 / 8; - case 0x0BF0: - case 0x1372: - case 0x2169: - case 0x2179: - case 0x2469: - case 0x247D: - case 0x2491: - case 0x24FE: - case 0x277F: - case 0x2789: - case 0x2793: - case 0x3038: - case 0x3229: - case 0x3289: -#ifdef Py_UNICODE_WIDE - case 0x10110: - case 0x10149: - case 0x10150: - case 0x10157: - case 0x10160: - case 0x10161: - case 0x10162: - case 0x10163: - case 0x10164: - case 0x10322: - case 0x103D3: - case 0x10A44: -#endif - return (double) 10; - case 0x0BF1: - case 0x137B: - case 0x216D: - case 0x217D: -#ifdef Py_UNICODE_WIDE - case 0x10119: - case 0x1014B: - case 0x10152: - case 0x1016A: - case 0x103D5: - case 0x10A46: -#endif - return (double) 100; - case 0x0BF2: - case 0x216F: - case 0x217F: - case 0x2180: -#ifdef Py_UNICODE_WIDE - case 0x10122: - case 0x1014D: - case 0x10154: - case 0x10171: - case 0x10A47: -#endif - return (double) 1000; - case 0x137C: - case 0x2182: -#ifdef Py_UNICODE_WIDE - case 0x1012B: - case 0x10155: -#endif - return (double) 10000; - case 0x216A: - case 0x217A: - case 0x246A: - case 0x247E: - case 0x2492: - case 0x24EB: - return (double) 11; - case 0x0F2F: - return (double) 11 / 2; - case 0x216B: - case 0x217B: - case 0x246B: - case 0x247F: - case 0x2493: - case 0x24EC: - return (double) 12; - case 0x246C: - case 0x2480: - case 0x2494: - case 0x24ED: - return (double) 13; - case 0x0F30: - return (double) 13 / 2; - case 0x246D: - case 0x2481: - case 0x2495: - case 0x24EE: - return (double) 14; - case 0x246E: - case 0x2482: - case 0x2496: - case 0x24EF: - return (double) 15; - case 0x0F31: - return (double) 15 / 2; - case 0x09F9: - case 0x246F: - case 0x2483: - case 0x2497: - case 0x24F0: - return (double) 16; - case 0x16EE: - case 0x2470: - case 0x2484: - case 0x2498: - case 0x24F1: - return (double) 17; - case 0x0F32: - return (double) 17 / 2; - case 0x16EF: - case 0x2471: - case 0x2485: - case 0x2499: - case 0x24F2: - return (double) 18; - case 0x16F0: - case 0x2472: - case 0x2486: - case 0x249A: - case 0x24F3: - return (double) 19; - case 0x09F5: - case 0x17F2: - case 0x2161: - case 0x2171: - case 0x3022: - case 0x3193: - case 0x3221: - case 0x3281: -#ifdef Py_UNICODE_WIDE - case 0x10108: - case 0x1015B: - case 0x1015C: - case 0x1015D: - case 0x1015E: - case 0x103D2: -#endif - return (double) 2; - case 0x2154: -#ifdef Py_UNICODE_WIDE - case 0x10177: -#endif - return (double) 2 / 3; - case 0x2156: - return (double) 2 / 5; - case 0x1373: - case 0x2473: - case 0x2487: - case 0x249B: - case 0x24F4: - case 0x3039: -#ifdef Py_UNICODE_WIDE - case 0x10111: - case 0x103D4: - case 0x10A45: -#endif - return (double) 20; -#ifdef Py_UNICODE_WIDE - case 0x1011A: - return (double) 200; - case 0x10123: - return (double) 2000; - case 0x1012C: - return (double) 20000; -#endif - case 0x3251: - return (double) 21; - case 0x3252: - return (double) 22; - case 0x3253: - return (double) 23; - case 0x3254: - return (double) 24; - case 0x3255: - return (double) 25; - case 0x3256: - return (double) 26; - case 0x3257: - return (double) 27; - case 0x3258: - return (double) 28; - case 0x3259: - return (double) 29; - case 0x09F6: - case 0x17F3: - case 0x2162: - case 0x2172: - case 0x3023: - case 0x3194: - case 0x3222: - case 0x3282: -#ifdef Py_UNICODE_WIDE - case 0x10109: -#endif - return (double) 3; - case 0x0F2B: - return (double) 3 / 2; - case 0x00BE: -#ifdef Py_UNICODE_WIDE - case 0x10178: -#endif - return (double) 3 / 4; - case 0x2157: - return (double) 3 / 5; - case 0x215C: - return (double) 3 / 8; - case 0x1374: - case 0x303A: - case 0x325A: -#ifdef Py_UNICODE_WIDE - case 0x10112: - case 0x10165: -#endif - return (double) 30; -#ifdef Py_UNICODE_WIDE - case 0x1011B: - case 0x1016B: - return (double) 300; - case 0x10124: - return (double) 3000; - case 0x1012D: - return (double) 30000; -#endif - case 0x325B: - return (double) 31; - case 0x325C: - return (double) 32; - case 0x325D: - return (double) 33; - case 0x325E: - return (double) 34; - case 0x325F: - return (double) 35; - case 0x32B1: - return (double) 36; - case 0x32B2: - return (double) 37; - case 0x32B3: - return (double) 38; - case 0x32B4: - return (double) 39; - case 0x09F7: - case 0x17F4: - case 0x2163: - case 0x2173: - case 0x3024: - case 0x3195: - case 0x3223: - case 0x3283: -#ifdef Py_UNICODE_WIDE - case 0x1010A: -#endif - return (double) 4; - case 0x2158: - return (double) 4 / 5; - case 0x1375: - case 0x32B5: -#ifdef Py_UNICODE_WIDE - case 0x10113: -#endif - return (double) 40; -#ifdef Py_UNICODE_WIDE - case 0x1011C: - return (double) 400; - case 0x10125: - return (double) 4000; - case 0x1012E: - return (double) 40000; -#endif - case 0x32B6: - return (double) 41; - case 0x32B7: - return (double) 42; - case 0x32B8: - return (double) 43; - case 0x32B9: - return (double) 44; - case 0x32BA: - return (double) 45; - case 0x32BB: - return (double) 46; - case 0x32BC: - return (double) 47; - case 0x32BD: - return (double) 48; - case 0x32BE: - return (double) 49; - case 0x17F5: - case 0x2164: - case 0x2174: - case 0x3025: - case 0x3224: - case 0x3284: -#ifdef Py_UNICODE_WIDE - case 0x1010B: - case 0x10143: - case 0x10148: - case 0x1014F: - case 0x1015F: - case 0x10173: - case 0x10321: -#endif - return (double) 5; - case 0x0F2C: - return (double) 5 / 2; - case 0x215A: - return (double) 5 / 6; - case 0x215D: - return (double) 5 / 8; - case 0x1376: - case 0x216C: - case 0x217C: - case 0x32BF: -#ifdef Py_UNICODE_WIDE - case 0x10114: - case 0x10144: - case 0x1014A: - case 0x10151: - case 0x10166: - case 0x10167: - case 0x10168: - case 0x10169: - case 0x10174: - case 0x10323: -#endif - return (double) 50; - case 0x216E: - case 0x217E: -#ifdef Py_UNICODE_WIDE - case 0x1011D: - case 0x10145: - case 0x1014C: - case 0x10153: - case 0x1016C: - case 0x1016D: - case 0x1016E: - case 0x1016F: - case 0x10170: -#endif - return (double) 500; - case 0x2181: -#ifdef Py_UNICODE_WIDE - case 0x10126: - case 0x10146: - case 0x1014E: - case 0x10172: -#endif - return (double) 5000; -#ifdef Py_UNICODE_WIDE - case 0x1012F: - case 0x10147: - case 0x10156: - return (double) 50000; -#endif - case 0x17F6: - case 0x2165: - case 0x2175: - case 0x3026: - case 0x3225: - case 0x3285: -#ifdef Py_UNICODE_WIDE - case 0x1010C: -#endif - return (double) 6; - case 0x1377: -#ifdef Py_UNICODE_WIDE - case 0x10115: -#endif - return (double) 60; -#ifdef Py_UNICODE_WIDE - case 0x1011E: - return (double) 600; - case 0x10127: - return (double) 6000; - case 0x10130: - return (double) 60000; -#endif - case 0x17F7: - case 0x2166: - case 0x2176: - case 0x3027: - case 0x3226: - case 0x3286: -#ifdef Py_UNICODE_WIDE - case 0x1010D: -#endif - return (double) 7; - case 0x0F2D: - return (double) 7 / 2; - case 0x215E: - return (double) 7 / 8; - case 0x1378: -#ifdef Py_UNICODE_WIDE - case 0x10116: -#endif - return (double) 70; -#ifdef Py_UNICODE_WIDE - case 0x1011F: - return (double) 700; - case 0x10128: - return (double) 7000; - case 0x10131: - return (double) 70000; -#endif - case 0x17F8: - case 0x2167: - case 0x2177: - case 0x3028: - case 0x3227: - case 0x3287: -#ifdef Py_UNICODE_WIDE - case 0x1010E: -#endif - return (double) 8; - case 0x1379: -#ifdef Py_UNICODE_WIDE - case 0x10117: -#endif - return (double) 80; -#ifdef Py_UNICODE_WIDE - case 0x10120: - return (double) 800; - case 0x10129: - return (double) 8000; - case 0x10132: - return (double) 80000; -#endif - case 0x17F9: - case 0x2168: - case 0x2178: - case 0x3029: - case 0x3228: - case 0x3288: -#ifdef Py_UNICODE_WIDE - case 0x1010F: -#endif - return (double) 9; - case 0x0F2E: - return (double) 9 / 2; - case 0x137A: -#ifdef Py_UNICODE_WIDE - case 0x10118: -#endif - return (double) 90; -#ifdef Py_UNICODE_WIDE - case 0x10121: - case 0x1034A: - return (double) 900; - case 0x1012A: - return (double) 9000; - case 0x10133: - return (double) 90000; -#endif - default: - return (double) _PyUnicode_ToDigit(ch); - } -} - int _PyUnicode_IsNumeric(Py_UNICODE ch) { - return _PyUnicode_ToNumeric(ch) != -1.0; + const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); + + return (ctype->flags & NUMERIC_MASK) != 0; } /* Returns 1 for Unicode characters to be hex-escaped when repr()ed, @@ -697,48 +167,6 @@ #ifndef WANT_WCTYPE_FUNCTIONS -/* Returns 1 for Unicode characters having the bidirectional type - 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */ - -int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) -{ - switch (ch) { - case 0x0009: /* HORIZONTAL TABULATION */ - case 0x000A: /* LINE FEED */ - case 0x000B: /* VERTICAL TABULATION */ - case 0x000C: /* FORM FEED */ - case 0x000D: /* CARRIAGE RETURN */ - case 0x001C: /* FILE SEPARATOR */ - case 0x001D: /* GROUP SEPARATOR */ - case 0x001E: /* RECORD SEPARATOR */ - case 0x001F: /* UNIT SEPARATOR */ - case 0x0020: /* SPACE */ - case 0x0085: /* NEXT LINE */ - case 0x00A0: /* NO-BREAK SPACE */ - case 0x1680: /* OGHAM SPACE MARK */ - case 0x2000: /* EN QUAD */ - case 0x2001: /* EM QUAD */ - case 0x2002: /* EN SPACE */ - case 0x2003: /* EM SPACE */ - case 0x2004: /* THREE-PER-EM SPACE */ - case 0x2005: /* FOUR-PER-EM SPACE */ - case 0x2006: /* SIX-PER-EM SPACE */ - case 0x2007: /* FIGURE SPACE */ - case 0x2008: /* PUNCTUATION SPACE */ - case 0x2009: /* THIN SPACE */ - case 0x200A: /* HAIR SPACE */ - case 0x200B: /* ZERO WIDTH SPACE */ - case 0x2028: /* LINE SEPARATOR */ - case 0x2029: /* PARAGRAPH SEPARATOR */ - case 0x202F: /* NARROW NO-BREAK SPACE */ - case 0x205F: /* MEDIUM MATHEMATICAL SPACE */ - case 0x3000: /* IDEOGRAPHIC SPACE */ - return 1; - default: - return 0; - } -} - /* Returns 1 for Unicode characters having the category 'Ll', 0 otherwise. */ @@ -802,11 +230,6 @@ /* Export the interfaces using the wchar_t type for portability reasons: */ -int _PyUnicode_IsWhitespace(Py_UNICODE ch) -{ - return iswspace(ch); -} - int _PyUnicode_IsLowercase(Py_UNICODE ch) { return iswlower(ch); Modified: python/branches/py3k/Objects/unicodetype_db.h ============================================================================== --- python/branches/py3k/Objects/unicodetype_db.h (original) +++ python/branches/py3k/Objects/unicodetype_db.h Tue Oct 6 23:03:20 2009 @@ -8,24 +8,25 @@ {0, 0, 0, 0, 0, 48}, {0, 0, 0, 0, 0, 1056}, {0, 0, 0, 0, 0, 1024}, - {0, 0, 0, 0, 0, 1542}, - {0, 0, 0, 1, 1, 1542}, - {0, 0, 0, 2, 2, 1542}, - {0, 0, 0, 3, 3, 1542}, - {0, 0, 0, 4, 4, 1542}, - {0, 0, 0, 5, 5, 1542}, - {0, 0, 0, 6, 6, 1542}, - {0, 0, 0, 7, 7, 1542}, - {0, 0, 0, 8, 8, 1542}, - {0, 0, 0, 9, 9, 1542}, + {0, 0, 0, 0, 0, 5638}, + {0, 0, 0, 1, 1, 5638}, + {0, 0, 0, 2, 2, 5638}, + {0, 0, 0, 3, 3, 5638}, + {0, 0, 0, 4, 4, 5638}, + {0, 0, 0, 5, 5, 5638}, + {0, 0, 0, 6, 6, 5638}, + {0, 0, 0, 7, 7, 5638}, + {0, 0, 0, 8, 8, 5638}, + {0, 0, 0, 9, 9, 5638}, {0, 32, 0, 0, 0, 1921}, {0, 0, 0, 0, 0, 1536}, {65504, 0, 65504, 0, 0, 1801}, {0, 0, 0, 0, 0, 1801}, - {0, 0, 0, 0, 2, 1028}, - {0, 0, 0, 0, 3, 1028}, + {0, 0, 0, 0, 2, 5124}, + {0, 0, 0, 0, 3, 5124}, {743, 0, 743, 0, 0, 1801}, - {0, 0, 0, 0, 1, 1028}, + {0, 0, 0, 0, 1, 5124}, + {0, 0, 0, 0, 0, 5120}, {121, 0, 121, 0, 0, 1801}, {0, 1, 0, 0, 0, 1921}, {65535, 0, 65535, 0, 0, 1801}, @@ -117,16 +118,16 @@ {65488, 0, 65488, 0, 0, 1801}, {0, 0, 0, 0, 0, 1537}, {0, 7264, 0, 0, 0, 1921}, - {0, 0, 0, 0, 1, 1540}, - {0, 0, 0, 0, 2, 1540}, - {0, 0, 0, 0, 3, 1540}, - {0, 0, 0, 0, 4, 1540}, - {0, 0, 0, 0, 5, 1540}, - {0, 0, 0, 0, 6, 1540}, - {0, 0, 0, 0, 7, 1540}, - {0, 0, 0, 0, 8, 1540}, - {0, 0, 0, 0, 9, 1540}, - {0, 0, 0, 0, 0, 1792}, + {0, 0, 0, 0, 1, 5636}, + {0, 0, 0, 0, 2, 5636}, + {0, 0, 0, 0, 3, 5636}, + {0, 0, 0, 0, 4, 5636}, + {0, 0, 0, 0, 5, 5636}, + {0, 0, 0, 0, 6, 5636}, + {0, 0, 0, 0, 7, 5636}, + {0, 0, 0, 0, 8, 5636}, + {0, 0, 0, 0, 9, 5636}, + {0, 0, 0, 0, 0, 5888}, {42877, 7545, 42877, 0, 0, 3849}, {3814, 0, 3814, 0, 0, 1801}, {65477, 0, 65477, 0, 0, 1801}, @@ -149,20 +150,21 @@ {0, 65424, 0, 0, 0, 1921}, {0, 65408, 0, 0, 0, 1921}, {0, 65410, 0, 0, 0, 1921}, - {0, 0, 0, 0, 0, 1028}, - {0, 0, 0, 0, 4, 1028}, - {0, 0, 0, 0, 5, 1028}, - {0, 0, 0, 0, 6, 1028}, - {0, 0, 0, 0, 7, 1028}, - {0, 0, 0, 0, 8, 1028}, - {0, 0, 0, 0, 9, 1028}, + {0, 0, 0, 0, 0, 5124}, + {0, 0, 0, 0, 4, 5124}, + {0, 0, 0, 0, 5, 5124}, + {0, 0, 0, 0, 6, 5124}, + {0, 0, 0, 0, 7, 5124}, + {0, 0, 0, 0, 8, 5124}, + {0, 0, 0, 0, 9, 5124}, + {0, 0, 0, 0, 0, 1792}, {0, 58019, 0, 0, 0, 1921}, {0, 57153, 0, 0, 0, 1921}, {0, 57274, 0, 0, 0, 1921}, {0, 28, 0, 0, 0, 1921}, {65508, 0, 65508, 0, 0, 1801}, - {0, 16, 0, 0, 0, 1792}, - {65520, 0, 65520, 0, 0, 1792}, + {0, 16, 0, 0, 0, 5888}, + {65520, 0, 65520, 0, 0, 5888}, {0, 26, 0, 0, 0, 1024}, {65510, 0, 65510, 0, 0, 1024}, {0, 54793, 0, 0, 0, 1921}, @@ -174,209 +176,517 @@ {0, 54787, 0, 0, 0, 1921}, {0, 54753, 0, 0, 0, 1921}, {58272, 0, 58272, 0, 0, 1801}, + {0, 0, 0, 0, 0, 5889}, {42877, 7545, 42877, 0, 0, 3969}, {0, 40, 0, 0, 0, 1921}, {65496, 0, 65496, 0, 0, 1801}, }; /* type indexes */ -#define SHIFT 8 +#define SHIFT 7 static unsigned char index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 34, 37, - 38, 34, 34, 34, 39, 40, 41, 42, 43, 44, 45, 46, 34, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 47, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 48, 21, 21, 21, 21, 49, - 21, 50, 51, 52, 53, 54, 8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 55, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 21, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 8, 8, 8, 68, 69, 70, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 21, 71, 72, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 73, 74, - 75, 76, 77, 78, 79, 80, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 81, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 82, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 83, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 84, 85, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 86, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 86, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 40, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 16, 50, 51, 52, + 16, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 63, 63, 64, 65, 66, 63, + 63, 63, 67, 68, 69, 63, 63, 63, 63, 63, 63, 70, 16, 71, 72, 73, 74, 75, + 76, 63, 77, 78, 79, 80, 81, 82, 83, 63, 63, 84, 85, 40, 40, 40, 40, 40, + 40, 86, 40, 40, 40, 40, 40, 87, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 88, 89, 90, 91, 40, 40, 40, 92, 40, 40, + 40, 93, 94, 40, 40, 40, 40, 40, 95, 40, 40, 40, 96, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 97, 98, 99, 40, 40, 40, 40, 40, 40, 100, 101, 40, 40, + 40, 40, 40, 40, 40, 40, 102, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 103, 40, 40, 40, 40, 40, 40, 40, 40, 104, 40, 40, 40, 40, + 100, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 103, 40, 40, 40, 40, 40, 40, 105, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 106, 107, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 108, 109, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 110, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 111, 40, 40, 112, 113, 114, 115, 116, 117, 118, 16, 119, 16, + 16, 16, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 120, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 122, 123, 124, 125, + 126, 127, 128, 40, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 16, + 139, 140, 141, 142, 143, 16, 16, 16, 16, 16, 16, 144, 16, 145, 16, 146, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 40, 40, 40, 40, 40, 40, 147, 16, 148, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 63, + 149, 150, 151, 152, 16, 153, 16, 154, 155, 156, 157, 158, 159, 160, 161, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 162, 163, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 164, 165, 166, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 86, 167, 40, 168, 169, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 170, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 171, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 172, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 173, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 174, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 40, 170, 40, 40, 175, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 176, 16, + 177, 178, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 179, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 179, }; static unsigned char index2[] = { @@ -388,455 +698,415 @@ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 19, 5, 5, - 1, 5, 5, 5, 5, 20, 21, 5, 22, 5, 17, 5, 23, 19, 5, 5, 5, 5, 5, 16, 16, + 1, 5, 5, 5, 5, 20, 21, 5, 22, 5, 17, 5, 23, 19, 5, 24, 24, 24, 5, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 5, 16, 16, 16, 16, 16, 16, 16, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 5, - 18, 18, 18, 18, 18, 18, 18, 24, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 27, 28, 25, 26, 25, 26, 25, 26, 19, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 19, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 29, 25, 26, 25, 26, 25, 26, 30, 31, 32, 25, 26, 25, 26, 33, 25, - 26, 34, 34, 25, 26, 19, 35, 36, 37, 25, 26, 34, 38, 39, 40, 41, 25, 26, - 42, 19, 40, 43, 44, 45, 25, 26, 25, 26, 25, 26, 46, 25, 26, 46, 19, 19, - 25, 26, 46, 25, 26, 47, 47, 25, 26, 25, 26, 48, 25, 26, 19, 49, 25, 26, - 19, 50, 49, 49, 49, 49, 51, 52, 53, 51, 52, 53, 51, 52, 53, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 54, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 19, 51, 52, 53, - 25, 26, 55, 56, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 57, 19, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 19, 19, 19, 19, 19, 19, 58, 25, - 26, 59, 60, 19, 19, 25, 26, 61, 62, 63, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 64, 65, 19, 66, 67, 19, 68, 68, 19, 69, 19, 70, 19, 19, 19, 19, - 68, 19, 19, 71, 19, 19, 19, 19, 72, 73, 19, 74, 19, 19, 19, 73, 19, 75, - 76, 19, 19, 77, 19, 19, 19, 19, 19, 19, 19, 78, 19, 19, 79, 19, 19, 79, - 19, 19, 19, 19, 79, 80, 81, 81, 82, 19, 19, 19, 19, 19, 83, 19, 49, 19, + 18, 18, 18, 18, 18, 18, 18, 25, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 28, 29, 26, 27, 26, 27, 26, 27, 19, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 19, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 30, 26, 27, 26, 27, 26, 27, 31, 32, 33, 26, 27, 26, 27, 34, 26, + 27, 35, 35, 26, 27, 19, 36, 37, 38, 26, 27, 35, 39, 40, 41, 42, 26, 27, + 43, 19, 41, 44, 45, 46, 26, 27, 26, 27, 26, 27, 47, 26, 27, 47, 19, 19, + 26, 27, 47, 26, 27, 48, 48, 26, 27, 26, 27, 49, 26, 27, 19, 50, 26, 27, + 19, 51, 50, 50, 50, 50, 52, 53, 54, 52, 53, 54, 52, 53, 54, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 55, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 19, 52, 53, 54, + 26, 27, 56, 57, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 58, 19, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 19, 19, 19, 19, 19, 19, 59, 26, + 27, 60, 61, 19, 19, 26, 27, 62, 63, 64, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 65, 66, 19, 67, 68, 19, 69, 69, 19, 70, 19, 71, 19, 19, 19, 19, + 69, 19, 19, 72, 19, 19, 19, 19, 73, 74, 19, 75, 19, 19, 19, 74, 19, 76, + 77, 19, 19, 78, 19, 19, 19, 19, 19, 19, 19, 79, 19, 19, 80, 19, 19, 80, + 19, 19, 19, 19, 80, 81, 82, 82, 83, 19, 19, 19, 19, 19, 84, 19, 50, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 5, 5, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 49, 49, 49, - 49, 49, 5, 5, 5, 5, 5, 5, 5, 49, 5, 49, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 19, 19, 19, 19, 19, 19, 19, 19, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 5, 5, 5, 5, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 50, 50, 50, + 50, 50, 5, 5, 5, 5, 5, 5, 5, 50, 5, 50, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 84, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 85, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 25, 26, 25, 26, 49, 5, 25, 26, 0, 0, 85, - 44, 44, 44, 5, 0, 0, 0, 0, 0, 5, 5, 86, 17, 87, 87, 87, 0, 88, 0, 89, 89, + 17, 17, 17, 17, 17, 17, 17, 17, 26, 27, 26, 27, 50, 5, 26, 27, 0, 0, 86, + 45, 45, 45, 5, 0, 0, 0, 0, 0, 5, 5, 87, 17, 88, 88, 88, 0, 89, 0, 90, 90, 19, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 90, 91, 91, 91, 19, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 92, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 93, 94, 94, 95, 96, 97, 98, 98, 98, 99, 100, 101, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 102, 103, 104, 19, 105, 106, 5, 25, 26, 107, 25, - 26, 19, 57, 57, 57, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 91, 92, 92, 92, 19, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 93, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 94, 95, 95, 96, 97, 98, 99, 99, 99, 100, 101, + 102, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 103, 104, 105, 19, 106, 107, 5, 26, 27, 108, + 26, 27, 19, 58, 58, 58, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 5, - 17, 17, 17, 17, 17, 5, 5, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 109, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 110, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 0, 0, 49, 5, 5, 5, 5, 5, 5, 0, 112, 112, 112, 112, 112, 112, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 5, + 17, 17, 17, 17, 17, 5, 5, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 110, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 111, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 19, 0, 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, + 112, 112, 0, 0, 50, 5, 5, 5, 5, 5, 5, 0, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 19, 0, 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 17, 5, 17, 17, 5, 17, 17, 5, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 49, 49, 49, 5, 5, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 50, 50, 50, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 0, 0, 5, 5, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, - 5, 5, 5, 49, 49, 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 49, 17, 17, - 17, 17, 17, 17, 17, 1, 5, 17, 17, 17, 17, 17, 17, 49, 49, 17, 17, 5, 17, - 17, 17, 17, 49, 49, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 49, 5, 5, - 49, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 1, 49, 17, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 49, 49, 5, 5, 5, 5, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 17, 49, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 49, 17, 17, 17, 17, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 5, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 5, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 0, - 17, 17, 17, 0, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 49, 49, 0, 0, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 0, 0, 0, 49, 49, 49, - 49, 0, 0, 17, 49, 17, 17, 17, 17, 17, 17, 17, 0, 0, 17, 17, 0, 0, 17, 17, - 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 49, 49, 0, 49, 49, 49, - 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 49, 49, 49, 49, 49, 49, 0, - 0, 0, 0, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, - 49, 49, 0, 49, 49, 0, 49, 49, 0, 0, 17, 0, 17, 17, 17, 17, 17, 0, 0, 0, - 0, 17, 17, 0, 0, 17, 17, 17, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 49, 49, - 49, 49, 0, 49, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 17, 17, 49, 49, 49, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 0, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, - 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 0, 49, 49, 49, 49, 49, 0, 0, 17, - 49, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 0, 17, 17, 17, 0, 0, - 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 17, 17, 0, 0, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 17, 17, 17, 0, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 49, 49, - 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 0, 49, 49, - 49, 49, 49, 0, 0, 17, 49, 17, 17, 17, 17, 17, 17, 17, 0, 0, 17, 17, 0, 0, - 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 0, 0, 0, 49, 49, 0, 49, - 49, 49, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 49, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 49, 0, 49, 49, 49, 49, 49, 49, - 0, 0, 0, 49, 49, 49, 0, 49, 49, 49, 49, 0, 0, 0, 49, 49, 0, 49, 0, 49, - 49, 0, 0, 0, 49, 49, 0, 0, 0, 49, 49, 49, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 17, 17, 17, 17, 17, 0, 0, 0, 17, - 17, 17, 0, 17, 17, 17, 17, 0, 0, 49, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 0, 0, 0, 49, 17, 17, 17, - 17, 17, 17, 17, 0, 17, 17, 17, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, - 17, 17, 0, 49, 49, 0, 0, 0, 0, 0, 0, 49, 49, 17, 17, 0, 0, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, - 0, 0, 17, 17, 0, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 0, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, - 49, 49, 0, 0, 17, 49, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 0, 17, - 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 0, 0, 0, 0, 0, 0, 49, 0, 49, - 49, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 5, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 49, 17, 17, 17, 17, 17, - 17, 17, 0, 17, 17, 17, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, - 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 49, 49, 49, 49, 49, 49, 0, 0, 17, - 17, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 17, 0, 0, 0, 0, - 17, 17, 17, 17, 17, 17, 0, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 5, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, - 49, 113, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 5, 49, 49, 49, 49, 49, - 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 0, 49, 0, 0, - 49, 49, 0, 49, 0, 0, 49, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 0, 49, 49, 49, - 49, 49, 49, 49, 0, 49, 49, 49, 0, 49, 0, 49, 0, 0, 49, 49, 0, 49, 49, 49, - 49, 17, 49, 113, 17, 17, 17, 17, 17, 17, 0, 17, 17, 49, 0, 0, 49, 49, 49, - 49, 49, 0, 49, 0, 17, 17, 17, 17, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 0, 0, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 5, 5, 5, 5, - 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 17, 5, 17, 5, 17, 5, 5, 5, 5, 17, 17, 49, 49, 49, 49, 49, 49, 49, 49, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 5, 17, 17, 49, 49, 49, 49, 0, 0, 0, 0, 17, 17, - 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 0, 5, 5, 5, 5, 5, 5, 5, 5, 17, 5, 5, 5, 5, 5, - 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 49, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, - 49, 49, 49, 49, 17, 17, 17, 49, 17, 17, 17, 49, 49, 17, 17, 17, 17, 17, - 17, 17, 49, 49, 49, 17, 17, 17, 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 49, 17, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 5, 5, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 5, 49, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 0, 0, 49, 49, 49, - 49, 49, 49, 49, 0, 49, 0, 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, - 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 0, - 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 49, 49, 49, 49, 49, 49, 49, 49, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 2, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 0, 0, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 5, 5, 5, 124, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, - 49, 49, 49, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, 5, 5, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 0, 17, - 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 5, 5, 5, 49, 5, 5, 5, 5, 49, 17, 0, 0, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, - 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 2, 0, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 17, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, - 0, 0, 5, 0, 0, 0, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 49, 49, 49, 49, - 49, 49, 49, 17, 17, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, - 17, 17, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 0, 0, 0, 17, 17, 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 49, 49, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 0, 0, 0, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 0, 0, 0, 49, 49, 49, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 5, 5, 5, 50, 50, 17, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 50, 17, 17, + 17, 17, 17, 17, 17, 1, 5, 17, 17, 17, 17, 17, 17, 50, 50, 17, 17, 5, 17, + 17, 17, 17, 50, 50, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 50, 50, 5, 5, + 50, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 1, 50, 17, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 50, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 50, 50, 5, 5, 5, 5, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, + 17, 17, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 0, 0, 17, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 0, 0, 50, 17, 17, 17, 17, 0, 0, 0, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 17, 17, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 50, + 50, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 0, 17, 17, 17, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, + 50, 50, 50, 50, 50, 0, 50, 0, 0, 0, 50, 50, 50, 50, 0, 0, 17, 50, 17, 17, + 17, 17, 17, 17, 17, 0, 0, 17, 17, 0, 0, 17, 17, 17, 50, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 0, 0, 50, 50, 0, 50, 50, 50, 17, 17, 0, 0, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 50, 50, 5, 5, 24, 24, 24, 24, 5, 24, 5, 0, 0, 0, + 0, 0, 0, 17, 17, 17, 0, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 0, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 0, 50, 50, 0, + 50, 50, 0, 0, 17, 0, 17, 17, 17, 17, 17, 0, 0, 0, 0, 17, 17, 0, 0, 17, + 17, 17, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 0, 50, 0, 0, 0, + 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 17, 50, 50, 50, 17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 0, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, + 50, 0, 50, 50, 0, 50, 50, 50, 50, 50, 0, 0, 17, 50, 17, 17, 17, 17, 17, + 17, 17, 17, 0, 17, 17, 17, 0, 17, 17, 17, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, + 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 0, 50, 50, 50, 50, 50, 0, 0, 17, + 50, 17, 17, 17, 17, 17, 17, 17, 0, 0, 17, 17, 0, 0, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 17, 0, 0, 0, 0, 50, 50, 0, 50, 50, 50, 17, 17, 0, 0, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 50, 0, 50, 50, 50, 50, 50, 50, 0, 0, 0, 50, 50, 50, + 0, 50, 50, 50, 50, 0, 0, 0, 50, 50, 0, 50, 0, 50, 50, 0, 0, 0, 50, 50, 0, + 0, 0, 50, 50, 50, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 0, 0, 0, 0, 17, 17, 17, 17, 17, 0, 0, 0, 17, 17, 17, 0, 17, 17, 17, + 17, 0, 0, 50, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 24, 24, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 50, 50, 50, 50, 50, 50, 50, 50, 0, + 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 0, 50, 50, 50, 50, 50, 0, 0, 0, 50, 17, 17, 17, 17, 17, 17, 17, + 0, 17, 17, 17, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 50, 50, + 0, 0, 0, 0, 0, 0, 50, 50, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 5, 0, 0, 17, 17, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 0, 0, + 17, 50, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 0, 17, 17, 17, 17, 0, + 0, 0, 0, 0, 0, 0, 17, 17, 0, 0, 0, 0, 0, 0, 0, 50, 0, 50, 50, 17, 17, 0, + 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, + 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 50, 17, 17, 17, 17, 17, 17, 17, 0, + 17, 17, 17, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 50, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, + 24, 24, 24, 24, 24, 0, 0, 0, 5, 50, 50, 50, 50, 50, 50, 0, 0, 17, 17, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, + 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 17, 0, 0, 0, 0, 17, 17, + 17, 17, 17, 17, 0, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 50, 114, + 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 5, 50, 50, 50, 50, 50, 50, 50, + 17, 17, 17, 17, 17, 17, 17, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, + 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 0, 50, 0, 0, 50, 50, 0, + 50, 0, 0, 50, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, + 50, 50, 0, 50, 50, 50, 0, 50, 0, 50, 0, 0, 50, 50, 0, 50, 50, 50, 50, 17, + 50, 114, 17, 17, 17, 17, 17, 17, 0, 17, 17, 50, 0, 0, 50, 50, 50, 50, 50, + 0, 50, 0, 17, 17, 17, 17, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 0, 0, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 5, 5, 5, 5, 5, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 5, 17, 5, 17, 5, 17, 5, 5, 5, 5, 17, 17, 50, 50, 50, 50, 50, 50, 50, + 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 5, 17, 17, 50, 50, 50, 50, 0, 0, 0, 0, 17, + 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 0, 5, 5, 5, 5, 5, 5, 5, 5, 17, 5, 5, 5, + 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 50, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 50, 50, 50, 50, 50, 50, 17, 17, 17, + 17, 50, 50, 50, 50, 17, 17, 17, 50, 17, 17, 17, 50, 50, 17, 17, 17, 17, + 17, 17, 17, 50, 50, 50, 17, 17, 17, 17, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 50, + 17, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 5, 5, 115, 115, 115, + 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, + 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, + 115, 115, 115, 115, 115, 115, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 5, 50, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 0, 50, 0, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 0, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 0, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, + 0, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 17, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 116, 117, 118, 119, 120, 121, 122, 123, 124, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 5, 5, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 5, 0, 0, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 5, 5, 5, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, + 50, 50, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 5, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 0, 17, 17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 5, 5, 5, 50, 5, 5, 5, 5, 50, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, + 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 2, 0, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 17, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 0, 0, 5, 0, 0, 0, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 50, 50, + 50, 50, 50, 50, 50, 17, 17, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, + 17, 17, 17, 17, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, + 17, 17, 17, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 50, 50, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 0, 0, 0, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, + 0, 50, 50, 50, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 49, 125, - 19, 19, 19, 126, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 17, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 19, 19, 19, 19, 19, 127, 19, 19, 128, 19, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 129, 129, 129, 129, 129, 129, 129, 129, 130, 130, - 130, 130, 130, 130, 130, 130, 129, 129, 129, 129, 129, 129, 0, 0, 130, - 130, 130, 130, 130, 130, 0, 0, 129, 129, 129, 129, 129, 129, 129, 129, - 130, 130, 130, 130, 130, 130, 130, 130, 129, 129, 129, 129, 129, 129, - 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 129, 129, 129, 129, - 129, 129, 0, 0, 130, 130, 130, 130, 130, 130, 0, 0, 19, 129, 19, 129, 19, - 129, 19, 129, 0, 130, 0, 130, 0, 130, 0, 130, 129, 129, 129, 129, 129, - 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, 132, - 132, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136, 0, 0, 129, 129, - 129, 129, 129, 129, 129, 129, 137, 137, 137, 137, 137, 137, 137, 137, - 129, 129, 129, 129, 129, 129, 129, 129, 137, 137, 137, 137, 137, 137, - 137, 137, 129, 129, 129, 129, 129, 129, 129, 129, 137, 137, 137, 137, - 137, 137, 137, 137, 129, 129, 19, 138, 19, 0, 19, 19, 130, 130, 139, 139, - 140, 5, 141, 5, 5, 5, 19, 138, 19, 0, 19, 19, 142, 142, 142, 142, 140, 5, - 5, 5, 129, 129, 19, 19, 0, 0, 19, 19, 130, 130, 143, 143, 0, 5, 5, 5, - 129, 129, 19, 19, 19, 104, 19, 19, 130, 130, 144, 144, 107, 5, 5, 5, 0, - 0, 19, 138, 19, 0, 19, 19, 145, 145, 146, 146, 140, 5, 5, 0, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 147, 19, 0, 0, 148, 149, 150, 151, - 152, 153, 5, 5, 5, 5, 5, 19, 147, 23, 20, 21, 148, 149, 150, 151, 152, - 153, 5, 5, 5, 5, 5, 0, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 17, 5, - 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 98, 5, 5, 5, 5, 98, 5, 5, 19, 98, 98, - 98, 19, 19, 98, 98, 98, 19, 5, 98, 5, 5, 124, 98, 98, 98, 98, 98, 5, 5, - 5, 5, 5, 5, 98, 5, 154, 5, 98, 5, 155, 156, 98, 98, 124, 19, 98, 98, 157, - 98, 19, 49, 49, 49, 49, 19, 5, 5, 19, 19, 98, 98, 5, 5, 5, 5, 5, 98, 19, - 19, 19, 19, 5, 5, 5, 5, 158, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 124, 124, 124, 25, 26, 124, 124, 124, 124, 0, 0, - 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 50, 126, 19, 19, 19, 127, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 19, 19, 19, 19, 19, 128, 19, 19, 129, 19, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 130, 130, + 130, 130, 130, 130, 130, 130, 131, 131, 131, 131, 131, 131, 131, 131, + 130, 130, 130, 130, 130, 130, 0, 0, 131, 131, 131, 131, 131, 131, 0, 0, + 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, 131, 131, 131, 131, + 131, 131, 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, 131, 131, + 131, 131, 131, 131, 130, 130, 130, 130, 130, 130, 0, 0, 131, 131, 131, + 131, 131, 131, 0, 0, 19, 130, 19, 130, 19, 130, 19, 130, 0, 131, 0, 131, + 0, 131, 0, 131, 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, 131, + 131, 131, 131, 131, 131, 132, 132, 133, 133, 133, 133, 134, 134, 135, + 135, 136, 136, 137, 137, 0, 0, 130, 130, 130, 130, 130, 130, 130, 130, + 138, 138, 138, 138, 138, 138, 138, 138, 130, 130, 130, 130, 130, 130, + 130, 130, 138, 138, 138, 138, 138, 138, 138, 138, 130, 130, 130, 130, + 130, 130, 130, 130, 138, 138, 138, 138, 138, 138, 138, 138, 130, 130, 19, + 139, 19, 0, 19, 19, 131, 131, 140, 140, 141, 5, 142, 5, 5, 5, 19, 139, + 19, 0, 19, 19, 143, 143, 143, 143, 141, 5, 5, 5, 130, 130, 19, 19, 0, 0, + 19, 19, 131, 131, 144, 144, 0, 5, 5, 5, 130, 130, 19, 19, 19, 105, 19, + 19, 131, 131, 145, 145, 108, 5, 5, 5, 0, 0, 19, 139, 19, 0, 19, 19, 146, + 146, 147, 147, 141, 5, 5, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 3, 3, 1, 1, 1, 1, 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 148, 19, 0, 0, 149, 150, 151, 152, 153, 154, 5, 5, 5, 5, 5, 19, + 148, 23, 20, 21, 149, 150, 151, 152, 153, 154, 5, 5, 5, 5, 5, 0, 50, 50, + 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 17, 5, 5, 5, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 5, 99, 5, 5, 5, 5, 99, 5, 5, 19, 99, 99, 99, 19, 19, 99, 99, 99, 19, 5, + 99, 5, 5, 155, 99, 99, 99, 99, 99, 5, 5, 5, 5, 5, 5, 99, 5, 156, 5, 99, + 5, 157, 158, 99, 99, 155, 19, 99, 99, 159, 99, 19, 50, 50, 50, 50, 19, 5, + 5, 19, 19, 99, 99, 5, 5, 5, 5, 5, 99, 19, 19, 19, 19, 5, 5, 5, 5, 160, 5, + 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 125, 125, 125, 26, 27, 125, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -851,614 +1121,747 @@ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 23, 20, 21, 148, 149, 150, 151, 152, 153, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 23, 20, 21, 148, 149, 150, 151, 152, 153, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 23, 20, 21, 148, 149, 150, 151, 152, 153, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 161, 161, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, - 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, - 162, 162, 147, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 20, 21, 148, 149, 150, - 151, 152, 153, 5, 147, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 5, 5, 5, 0, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 23, 20, 21, 149, 150, 151, 152, 153, 154, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 20, 21, 149, 150, 151, 152, 153, + 154, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 20, 21, 149, 150, + 151, 152, 153, 154, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 148, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 23, 20, 21, 149, 150, 151, 152, 153, 154, 24, 148, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 0, 5, 5, 5, 5, 0, 0, 0, 5, 0, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 23, 20, 21, 149, 150, 151, 152, 153, 154, 24, 23, 20, 21, + 149, 150, 151, 152, 153, 154, 24, 23, 20, 21, 149, 150, 151, 152, 153, + 154, 24, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 0, 5, 0, 5, 5, 5, 5, 0, 0, 0, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 20, - 21, 148, 149, 150, 151, 152, 153, 5, 23, 20, 21, 148, 149, 150, 151, 152, - 153, 5, 23, 20, 21, 148, 149, 150, 151, 152, 153, 5, 5, 0, 0, 0, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 0, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 0, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, + 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 0, 25, 26, 163, 164, 165, 166, - 167, 25, 26, 25, 26, 25, 26, 168, 169, 170, 0, 19, 25, 26, 19, 25, 26, - 19, 19, 19, 19, 19, 19, 49, 0, 0, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 19, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, - 5, 5, 5, 5, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, - 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, - 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, - 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, - 49, 49, 49, 49, 49, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 112, 112, 112, 112, 0, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 0, 26, 27, 165, 166, 167, + 168, 169, 26, 27, 26, 27, 26, 27, 170, 171, 172, 0, 19, 26, 27, 19, 26, + 27, 19, 19, 19, 19, 19, 19, 50, 0, 0, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 19, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, + 5, 5, 24, 5, 5, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, + 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, + 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, + 50, 50, 50, 50, 50, 50, 50, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 85, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 86, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 2, 5, 5, 5, 5, 49, 49, 124, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 17, 17, 17, 17, 17, 17, 5, 49, 49, 49, - 49, 49, 5, 5, 124, 124, 124, 49, 49, 5, 5, 5, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 17, 17, 5, 5, 49, 49, 49, 5, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, - 49, 49, 49, 49, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 5, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 0, 0, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 49, 17, 5, 5, 5, 5, 0, 0, - 0, 0, 0, 0, 0, 0, 17, 17, 5, 49, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, - 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 19, 19, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 25, 26, 49, - 19, 19, 19, 19, 19, 19, 19, 19, 25, 26, 25, 26, 172, 25, 26, 25, 26, 25, - 26, 25, 26, 25, 26, 49, 5, 5, 25, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 49, 49, 49, 49, 49, 49, 49, 17, 49, 49, 49, 17, 49, 49, 49, 49, 17, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 17, - 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 17, 49, 49, 49, 49, 49, 49, - 49, 49, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 5, 5, 5, - 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 19, - 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 19, 19, 19, - 19, 0, 0, 0, 0, 0, 49, 17, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 0, - 49, 0, 49, 49, 0, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 85, 85, 85, 85, 85, 85, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 5, 5, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 85, 85, 5, 5, 0, 0, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 5, 5, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 17, 17, 17, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 0, 0, 0, 0, 85, 49, 85, 49, 85, 0, - 85, 49, 85, 49, 85, 49, 85, 49, 85, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 1, 0, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, - 5, 5, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 5, 5, 5, 5, 17, 5, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 113, 113, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 0, 0, 49, 49, 49, 49, 49, 49, 0, 0, 49, 49, 49, 49, 49, 49, 0, 0, 49, - 49, 49, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 5, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, - 0, 0, 5, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 2, 5, 5, 5, 5, 50, 50, 125, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 17, 17, 17, 17, 17, 17, 5, 50, 50, 50, 50, 50, 5, 5, + 125, 125, 125, 50, 50, 5, 5, 5, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 0, 0, 17, 17, 5, 5, 50, 50, 50, 5, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 50, 50, 50, + 50, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 5, 5, + 24, 24, 24, 24, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, + 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 0, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 5, 5, 5, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 124, 49, 49, 49, 49, 49, 49, 49, 49, 124, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 5, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, - 49, 49, 49, 49, 49, 49, 49, 49, 5, 124, 124, 124, 124, 124, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, - 174, 174, 174, 174, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 6, 7, 8, 9, 10, 11, 12, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 174, + 50, 50, 174, 50, 50, 50, 174, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, + 50, 50, 50, 50, 174, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 174, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 50, 174, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 174, 50, 174, 174, 174, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 174, 174, 174, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 174, 174, 174, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, + 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 5, 5, 5, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 50, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 26, 27, 0, 0, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 50, 17, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 5, 50, 26, 27, + 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, + 26, 27, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 5, 5, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 19, 19, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, + 27, 26, 27, 26, 27, 26, 27, 50, 19, 19, 19, 19, 19, 19, 19, 19, 26, 27, + 26, 27, 175, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 50, 5, 5, 26, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 17, + 50, 50, 50, 17, 50, 50, 50, 50, 17, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, + 17, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, - 49, 0, 0, 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 49, 49, 0, 0, 0, 49, - 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 5, 5, 5, 5, 0, 0, 0, 0, 0, 5, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 17, 17, 17, 0, 17, 17, 0, 0, 0, 0, 0, - 17, 17, 17, 17, 49, 49, 49, 49, 0, 49, 49, 49, 0, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 17, 23, 20, 21, 148, 5, - 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, + 17, 17, 17, 17, 5, 5, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 17, 50, 50, 50, 50, 50, + 50, 50, 50, 17, 17, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 174, + 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 174, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 50, 17, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 5, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 0, 50, 50, 50, 50, 50, 0, 50, 0, 50, 50, 0, 50, 50, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 86, + 86, 86, 86, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 86, 86, 5, 5, + 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 5, 5, 5, 0, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 0, 0, + 0, 0, 86, 50, 86, 50, 86, 0, 86, 50, 86, 50, 86, 50, 86, 50, 86, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 1, + 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 5, 5, 5, + 5, 17, 5, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 114, 114, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, + 0, 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 0, 0, 50, 50, + 50, 50, 50, 50, 0, 0, 50, 50, 50, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, + 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 5, 0, 0, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 0, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 24, 24, 24, 24, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 17, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 125, 50, 50, 50, 50, 50, 50, 50, 50, 125, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 5, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, + 50, 50, 50, 50, 50, 5, 125, 125, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, 177, + 177, 177, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 0, 0, + 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 0, 0, 0, 50, 0, 0, 50, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 24, 24, + 24, 24, 0, 0, 0, 0, 0, 5, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 17, 17, 17, 0, 17, + 17, 0, 0, 0, 0, 0, 17, 17, 17, 17, 50, 50, 50, 50, 0, 50, 50, 50, 0, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 17, + 23, 20, 21, 149, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 155, 155, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 155, 155, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 5, 5, 5, 17, 17, 17, 17, - 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, 17, - 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 5, 5, 5, 17, 17, 17, + 17, 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 5, 5, + 17, 17, 17, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, - 17, 17, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 17, 17, 17, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, - 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, + 19, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 0, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 0, 99, + 99, 0, 0, 99, 0, 0, 99, 99, 0, 0, 99, 99, 99, 99, 0, 99, 99, 99, 99, 99, + 99, 99, 99, 19, 19, 19, 19, 0, 19, 0, 19, 19, 19, 19, 19, 19, 19, 0, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 98, 0, 98, 98, 0, 0, 98, 0, 0, 98, 98, 0, 0, 98, 98, 98, - 98, 0, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 0, 19, 0, 19, 19, - 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 98, 98, 0, - 98, 98, 98, 98, 0, 0, 98, 98, 98, 98, 98, 98, 98, 98, 0, 98, 98, 98, 98, - 98, 98, 98, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 98, 98, 0, 98, 98, 98, - 98, 0, 98, 98, 98, 98, 98, 0, 98, 0, 0, 0, 98, 98, 98, 98, 98, 98, 98, 0, + 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 0, 99, 99, 99, 99, 0, 0, 99, 99, + 99, 99, 99, 99, 99, 99, 0, 99, 99, 99, 99, 99, 99, 99, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, + 19, 19, 19, 19, 99, 99, 0, 99, 99, 99, 99, 0, 99, 99, 99, 99, 99, 0, 99, + 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, - 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 5, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 5, 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 5, 19, 19, 19, + 5, 19, 19, 19, 19, 19, 19, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 5, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, - 19, 98, 19, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, + 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 99, 19, 0, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, + 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 174, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 174, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, @@ -1471,18 +1874,1312 @@ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, }; +/* Returns the numeric value as double for Unicode characters + * having this property, -1.0 otherwise. + */ +double _PyUnicode_ToNumeric(Py_UNICODE ch) +{ + switch (ch) { + case 0x0F33: + return (double) -1/2; + case 0x0030: + case 0x0660: + case 0x06F0: + case 0x07C0: + case 0x0966: + case 0x09E6: + case 0x0A66: + case 0x0AE6: + case 0x0B66: + case 0x0BE6: + case 0x0C66: + case 0x0C78: + case 0x0CE6: + case 0x0D66: + case 0x0E50: + case 0x0ED0: + case 0x0F20: + case 0x1040: + case 0x1090: + case 0x17E0: + case 0x17F0: + case 0x1810: + case 0x1946: + case 0x19D0: + case 0x1B50: + case 0x1BB0: + case 0x1C40: + case 0x1C50: + case 0x2070: + case 0x2080: + case 0x24EA: + case 0x24FF: + case 0x3007: + case 0x96F6: + case 0xA620: + case 0xA8D0: + case 0xA900: + case 0xAA50: + case 0xF9B2: + case 0xFF10: +#ifdef Py_UNICODE_WIDE + case 0x1018A: + case 0x104A0: + case 0x1D7CE: + case 0x1D7D8: + case 0x1D7E2: + case 0x1D7EC: + case 0x1D7F6: +#endif + return (double) 0; + case 0x0031: + case 0x00B9: + case 0x0661: + case 0x06F1: + case 0x07C1: + case 0x0967: + case 0x09E7: + case 0x09F4: + case 0x0A67: + case 0x0AE7: + case 0x0B67: + case 0x0BE7: + case 0x0C67: + case 0x0C79: + case 0x0C7C: + case 0x0CE7: + case 0x0D67: + case 0x0E51: + case 0x0ED1: + case 0x0F21: + case 0x1041: + case 0x1091: + case 0x1369: + case 0x17E1: + case 0x17F1: + case 0x1811: + case 0x1947: + case 0x19D1: + case 0x1B51: + case 0x1BB1: + case 0x1C41: + case 0x1C51: + case 0x2081: + case 0x215F: + case 0x2160: + case 0x2170: + case 0x2460: + case 0x2474: + case 0x2488: + case 0x24F5: + case 0x2776: + case 0x2780: + case 0x278A: + case 0x3021: + case 0x3192: + case 0x3220: + case 0x3280: + case 0x4E00: + case 0x58F1: + case 0x58F9: + case 0x5E7A: + case 0x5F0C: + case 0xA621: + case 0xA8D1: + case 0xA901: + case 0xAA51: + case 0xFF11: +#ifdef Py_UNICODE_WIDE + case 0x10107: + case 0x10142: + case 0x10158: + case 0x10159: + case 0x1015A: + case 0x10320: + case 0x103D1: + case 0x104A1: + case 0x10916: + case 0x10A40: + case 0x12415: + case 0x1241E: + case 0x1242C: + case 0x12434: + case 0x1244F: + case 0x12458: + case 0x1D360: + case 0x1D7CF: + case 0x1D7D9: + case 0x1D7E3: + case 0x1D7ED: + case 0x1D7F7: + case 0x2092A: +#endif + return (double) 1; + case 0x00BD: + case 0x0D74: + case 0x0F2A: + case 0x2CFD: +#ifdef Py_UNICODE_WIDE + case 0x10141: + case 0x10175: + case 0x10176: +#endif + return (double) 1/2; + case 0x2153: +#ifdef Py_UNICODE_WIDE + case 0x1245A: + case 0x1245D: +#endif + return (double) 1/3; + case 0x00BC: + case 0x0D73: +#ifdef Py_UNICODE_WIDE + case 0x10140: + case 0x12460: + case 0x12462: +#endif + return (double) 1/4; + case 0x2155: + return (double) 1/5; + case 0x2159: +#ifdef Py_UNICODE_WIDE + case 0x12461: +#endif + return (double) 1/6; + case 0x215B: +#ifdef Py_UNICODE_WIDE + case 0x1245F: +#endif + return (double) 1/8; + case 0x0BF0: + case 0x0D70: + case 0x1372: + case 0x2169: + case 0x2179: + case 0x2469: + case 0x247D: + case 0x2491: + case 0x24FE: + case 0x277F: + case 0x2789: + case 0x2793: + case 0x3038: + case 0x3229: + case 0x3289: + case 0x4EC0: + case 0x5341: + case 0x62FE: + case 0xF973: + case 0xF9FD: +#ifdef Py_UNICODE_WIDE + case 0x10110: + case 0x10149: + case 0x10150: + case 0x10157: + case 0x10160: + case 0x10161: + case 0x10162: + case 0x10163: + case 0x10164: + case 0x10322: + case 0x103D3: + case 0x10917: + case 0x10A44: + case 0x1D369: +#endif + return (double) 10; + case 0x0BF1: + case 0x0D71: + case 0x137B: + case 0x216D: + case 0x217D: + case 0x4F70: + case 0x767E: + case 0x964C: +#ifdef Py_UNICODE_WIDE + case 0x10119: + case 0x1014B: + case 0x10152: + case 0x1016A: + case 0x103D5: + case 0x10919: + case 0x10A46: +#endif + return (double) 100; + case 0x0BF2: + case 0x0D72: + case 0x216F: + case 0x217F: + case 0x2180: + case 0x4EDF: + case 0x5343: + case 0x9621: +#ifdef Py_UNICODE_WIDE + case 0x10122: + case 0x1014D: + case 0x10154: + case 0x10171: + case 0x10A47: +#endif + return (double) 1000; + case 0x137C: + case 0x2182: + case 0x4E07: + case 0x842C: +#ifdef Py_UNICODE_WIDE + case 0x1012B: + case 0x10155: +#endif + return (double) 10000; + case 0x2188: + return (double) 100000; + case 0x4EBF: + case 0x5104: + return (double) 100000000; + case 0x5146: + return (double) 1000000000000; + case 0x216A: + case 0x217A: + case 0x246A: + case 0x247E: + case 0x2492: + case 0x24EB: + return (double) 11; + case 0x0F2F: + return (double) 11/2; + case 0x216B: + case 0x217B: + case 0x246B: + case 0x247F: + case 0x2493: + case 0x24EC: + return (double) 12; + case 0x246C: + case 0x2480: + case 0x2494: + case 0x24ED: + return (double) 13; + case 0x0F30: + return (double) 13/2; + case 0x246D: + case 0x2481: + case 0x2495: + case 0x24EE: + return (double) 14; + case 0x246E: + case 0x2482: + case 0x2496: + case 0x24EF: + return (double) 15; + case 0x0F31: + return (double) 15/2; + case 0x09F9: + case 0x246F: + case 0x2483: + case 0x2497: + case 0x24F0: + return (double) 16; + case 0x16EE: + case 0x2470: + case 0x2484: + case 0x2498: + case 0x24F1: + return (double) 17; + case 0x0F32: + return (double) 17/2; + case 0x16EF: + case 0x2471: + case 0x2485: + case 0x2499: + case 0x24F2: + return (double) 18; + case 0x16F0: + case 0x2472: + case 0x2486: + case 0x249A: + case 0x24F3: + return (double) 19; + case 0x0032: + case 0x00B2: + case 0x0662: + case 0x06F2: + case 0x07C2: + case 0x0968: + case 0x09E8: + case 0x09F5: + case 0x0A68: + case 0x0AE8: + case 0x0B68: + case 0x0BE8: + case 0x0C68: + case 0x0C7A: + case 0x0C7D: + case 0x0CE8: + case 0x0D68: + case 0x0E52: + case 0x0ED2: + case 0x0F22: + case 0x1042: + case 0x1092: + case 0x136A: + case 0x17E2: + case 0x17F2: + case 0x1812: + case 0x1948: + case 0x19D2: + case 0x1B52: + case 0x1BB2: + case 0x1C42: + case 0x1C52: + case 0x2082: + case 0x2161: + case 0x2171: + case 0x2461: + case 0x2475: + case 0x2489: + case 0x24F6: + case 0x2777: + case 0x2781: + case 0x278B: + case 0x3022: + case 0x3193: + case 0x3221: + case 0x3281: + case 0x3483: + case 0x4E8C: + case 0x5169: + case 0x5F0D: + case 0x5F10: + case 0x8CAE: + case 0x8CB3: + case 0x8D30: + case 0xA622: + case 0xA8D2: + case 0xA902: + case 0xAA52: + case 0xF978: + case 0xFF12: +#ifdef Py_UNICODE_WIDE + case 0x10108: + case 0x1015B: + case 0x1015C: + case 0x1015D: + case 0x1015E: + case 0x103D2: + case 0x104A2: + case 0x10A41: + case 0x12400: + case 0x12416: + case 0x1241F: + case 0x12423: + case 0x1242D: + case 0x12435: + case 0x1244A: + case 0x12450: + case 0x12459: + case 0x1D361: + case 0x1D7D0: + case 0x1D7DA: + case 0x1D7E4: + case 0x1D7EE: + case 0x1D7F8: + case 0x22390: +#endif + return (double) 2; + case 0x2154: +#ifdef Py_UNICODE_WIDE + case 0x10177: + case 0x1245B: + case 0x1245E: +#endif + return (double) 2/3; + case 0x2156: + return (double) 2/5; + case 0x1373: + case 0x2473: + case 0x2487: + case 0x249B: + case 0x24F4: + case 0x3039: + case 0x5344: + case 0x5EFF: +#ifdef Py_UNICODE_WIDE + case 0x10111: + case 0x103D4: + case 0x10918: + case 0x10A45: + case 0x1D36A: +#endif + return (double) 20; +#ifdef Py_UNICODE_WIDE + case 0x1011A: + return (double) 200; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10123: + return (double) 2000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012C: + return (double) 20000; +#endif + case 0x3251: + return (double) 21; + case 0x3252: + return (double) 22; + case 0x3253: + return (double) 23; + case 0x3254: + return (double) 24; + case 0x3255: + return (double) 25; + case 0x3256: + return (double) 26; + case 0x3257: + return (double) 27; + case 0x3258: + return (double) 28; + case 0x3259: + return (double) 29; + case 0x0033: + case 0x00B3: + case 0x0663: + case 0x06F3: + case 0x07C3: + case 0x0969: + case 0x09E9: + case 0x09F6: + case 0x0A69: + case 0x0AE9: + case 0x0B69: + case 0x0BE9: + case 0x0C69: + case 0x0C7B: + case 0x0C7E: + case 0x0CE9: + case 0x0D69: + case 0x0E53: + case 0x0ED3: + case 0x0F23: + case 0x1043: + case 0x1093: + case 0x136B: + case 0x17E3: + case 0x17F3: + case 0x1813: + case 0x1949: + case 0x19D3: + case 0x1B53: + case 0x1BB3: + case 0x1C43: + case 0x1C53: + case 0x2083: + case 0x2162: + case 0x2172: + case 0x2462: + case 0x2476: + case 0x248A: + case 0x24F7: + case 0x2778: + case 0x2782: + case 0x278C: + case 0x3023: + case 0x3194: + case 0x3222: + case 0x3282: + case 0x4E09: + case 0x4EE8: + case 0x53C1: + case 0x53C2: + case 0x53C3: + case 0x53C4: + case 0x5F0E: + case 0xA623: + case 0xA8D3: + case 0xA903: + case 0xAA53: + case 0xF96B: + case 0xFF13: +#ifdef Py_UNICODE_WIDE + case 0x10109: + case 0x104A3: + case 0x10A42: + case 0x12401: + case 0x12408: + case 0x12417: + case 0x12420: + case 0x12424: + case 0x12425: + case 0x1242E: + case 0x1242F: + case 0x12436: + case 0x12437: + case 0x1243A: + case 0x1243B: + case 0x1244B: + case 0x12451: + case 0x1D362: + case 0x1D7D1: + case 0x1D7DB: + case 0x1D7E5: + case 0x1D7EF: + case 0x1D7F9: + case 0x20AFD: + case 0x20B19: + case 0x22998: + case 0x23B1B: +#endif + return (double) 3; + case 0x0F2B: + return (double) 3/2; + case 0x00BE: + case 0x0D75: +#ifdef Py_UNICODE_WIDE + case 0x10178: +#endif + return (double) 3/4; + case 0x2157: + return (double) 3/5; + case 0x215C: + return (double) 3/8; + case 0x1374: + case 0x303A: + case 0x325A: + case 0x5345: +#ifdef Py_UNICODE_WIDE + case 0x10112: + case 0x10165: + case 0x1D36B: + case 0x20983: +#endif + return (double) 30; +#ifdef Py_UNICODE_WIDE + case 0x1011B: + case 0x1016B: + return (double) 300; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10124: + return (double) 3000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012D: + return (double) 30000; +#endif + case 0x325B: + return (double) 31; + case 0x325C: + return (double) 32; + case 0x325D: + return (double) 33; + case 0x325E: + return (double) 34; + case 0x325F: + return (double) 35; + case 0x32B1: + return (double) 36; + case 0x32B2: + return (double) 37; + case 0x32B3: + return (double) 38; + case 0x32B4: + return (double) 39; + case 0x0034: + case 0x0664: + case 0x06F4: + case 0x07C4: + case 0x096A: + case 0x09EA: + case 0x09F7: + case 0x0A6A: + case 0x0AEA: + case 0x0B6A: + case 0x0BEA: + case 0x0C6A: + case 0x0CEA: + case 0x0D6A: + case 0x0E54: + case 0x0ED4: + case 0x0F24: + case 0x1044: + case 0x1094: + case 0x136C: + case 0x17E4: + case 0x17F4: + case 0x1814: + case 0x194A: + case 0x19D4: + case 0x1B54: + case 0x1BB4: + case 0x1C44: + case 0x1C54: + case 0x2074: + case 0x2084: + case 0x2163: + case 0x2173: + case 0x2463: + case 0x2477: + case 0x248B: + case 0x24F8: + case 0x2779: + case 0x2783: + case 0x278D: + case 0x3024: + case 0x3195: + case 0x3223: + case 0x3283: + case 0x4E96: + case 0x56DB: + case 0x8086: + case 0xA624: + case 0xA8D4: + case 0xA904: + case 0xAA54: + case 0xFF14: +#ifdef Py_UNICODE_WIDE + case 0x1010A: + case 0x104A4: + case 0x10A43: + case 0x12402: + case 0x12409: + case 0x1240F: + case 0x12418: + case 0x12421: + case 0x12426: + case 0x12430: + case 0x12438: + case 0x1243C: + case 0x1243D: + case 0x1243E: + case 0x1243F: + case 0x1244C: + case 0x12452: + case 0x12453: + case 0x1D363: + case 0x1D7D2: + case 0x1D7DC: + case 0x1D7E6: + case 0x1D7F0: + case 0x1D7FA: + case 0x20064: + case 0x200E2: + case 0x2626D: +#endif + return (double) 4; + case 0x2158: + return (double) 4/5; + case 0x1375: + case 0x32B5: + case 0x534C: +#ifdef Py_UNICODE_WIDE + case 0x10113: + case 0x1D36C: + case 0x2098C: + case 0x2099C: +#endif + return (double) 40; +#ifdef Py_UNICODE_WIDE + case 0x1011C: + return (double) 400; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10125: + return (double) 4000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012E: + return (double) 40000; +#endif + case 0x32B6: + return (double) 41; + case 0x32B7: + return (double) 42; + case 0x32B8: + return (double) 43; + case 0x32B9: + return (double) 44; + case 0x32BA: + return (double) 45; + case 0x32BB: + return (double) 46; + case 0x32BC: + return (double) 47; + case 0x32BD: + return (double) 48; + case 0x32BE: + return (double) 49; + case 0x0035: + case 0x0665: + case 0x06F5: + case 0x07C5: + case 0x096B: + case 0x09EB: + case 0x0A6B: + case 0x0AEB: + case 0x0B6B: + case 0x0BEB: + case 0x0C6B: + case 0x0CEB: + case 0x0D6B: + case 0x0E55: + case 0x0ED5: + case 0x0F25: + case 0x1045: + case 0x1095: + case 0x136D: + case 0x17E5: + case 0x17F5: + case 0x1815: + case 0x194B: + case 0x19D5: + case 0x1B55: + case 0x1BB5: + case 0x1C45: + case 0x1C55: + case 0x2075: + case 0x2085: + case 0x2164: + case 0x2174: + case 0x2464: + case 0x2478: + case 0x248C: + case 0x24F9: + case 0x277A: + case 0x2784: + case 0x278E: + case 0x3025: + case 0x3224: + case 0x3284: + case 0x3405: + case 0x382A: + case 0x4E94: + case 0x4F0D: + case 0xA625: + case 0xA8D5: + case 0xA905: + case 0xAA55: + case 0xFF15: +#ifdef Py_UNICODE_WIDE + case 0x1010B: + case 0x10143: + case 0x10148: + case 0x1014F: + case 0x1015F: + case 0x10173: + case 0x10321: + case 0x104A5: + case 0x12403: + case 0x1240A: + case 0x12410: + case 0x12419: + case 0x12422: + case 0x12427: + case 0x12431: + case 0x12439: + case 0x1244D: + case 0x12454: + case 0x12455: + case 0x1D364: + case 0x1D7D3: + case 0x1D7DD: + case 0x1D7E7: + case 0x1D7F1: + case 0x1D7FB: + case 0x20121: +#endif + return (double) 5; + case 0x0F2C: + return (double) 5/2; + case 0x215A: +#ifdef Py_UNICODE_WIDE + case 0x1245C: +#endif + return (double) 5/6; + case 0x215D: + return (double) 5/8; + case 0x1376: + case 0x216C: + case 0x217C: + case 0x2186: + case 0x32BF: +#ifdef Py_UNICODE_WIDE + case 0x10114: + case 0x10144: + case 0x1014A: + case 0x10151: + case 0x10166: + case 0x10167: + case 0x10168: + case 0x10169: + case 0x10174: + case 0x10323: + case 0x1D36D: +#endif + return (double) 50; + case 0x216E: + case 0x217E: +#ifdef Py_UNICODE_WIDE + case 0x1011D: + case 0x10145: + case 0x1014C: + case 0x10153: + case 0x1016C: + case 0x1016D: + case 0x1016E: + case 0x1016F: + case 0x10170: +#endif + return (double) 500; + case 0x2181: +#ifdef Py_UNICODE_WIDE + case 0x10126: + case 0x10146: + case 0x1014E: + case 0x10172: +#endif + return (double) 5000; + case 0x2187: +#ifdef Py_UNICODE_WIDE + case 0x1012F: + case 0x10147: + case 0x10156: +#endif + return (double) 50000; + case 0x0036: + case 0x0666: + case 0x06F6: + case 0x07C6: + case 0x096C: + case 0x09EC: + case 0x0A6C: + case 0x0AEC: + case 0x0B6C: + case 0x0BEC: + case 0x0C6C: + case 0x0CEC: + case 0x0D6C: + case 0x0E56: + case 0x0ED6: + case 0x0F26: + case 0x1046: + case 0x1096: + case 0x136E: + case 0x17E6: + case 0x17F6: + case 0x1816: + case 0x194C: + case 0x19D6: + case 0x1B56: + case 0x1BB6: + case 0x1C46: + case 0x1C56: + case 0x2076: + case 0x2086: + case 0x2165: + case 0x2175: + case 0x2185: + case 0x2465: + case 0x2479: + case 0x248D: + case 0x24FA: + case 0x277B: + case 0x2785: + case 0x278F: + case 0x3026: + case 0x3225: + case 0x3285: + case 0x516D: + case 0x9646: + case 0x9678: + case 0xA626: + case 0xA8D6: + case 0xA906: + case 0xAA56: + case 0xF9D1: + case 0xF9D3: + case 0xFF16: +#ifdef Py_UNICODE_WIDE + case 0x1010C: + case 0x104A6: + case 0x12404: + case 0x1240B: + case 0x12411: + case 0x1241A: + case 0x12428: + case 0x12440: + case 0x1244E: + case 0x1D365: + case 0x1D7D4: + case 0x1D7DE: + case 0x1D7E8: + case 0x1D7F2: + case 0x1D7FC: + case 0x20AEA: +#endif + return (double) 6; + case 0x1377: +#ifdef Py_UNICODE_WIDE + case 0x10115: + case 0x1D36E: +#endif + return (double) 60; +#ifdef Py_UNICODE_WIDE + case 0x1011E: + return (double) 600; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10127: + return (double) 6000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10130: + return (double) 60000; +#endif + case 0x0037: + case 0x0667: + case 0x06F7: + case 0x07C7: + case 0x096D: + case 0x09ED: + case 0x0A6D: + case 0x0AED: + case 0x0B6D: + case 0x0BED: + case 0x0C6D: + case 0x0CED: + case 0x0D6D: + case 0x0E57: + case 0x0ED7: + case 0x0F27: + case 0x1047: + case 0x1097: + case 0x136F: + case 0x17E7: + case 0x17F7: + case 0x1817: + case 0x194D: + case 0x19D7: + case 0x1B57: + case 0x1BB7: + case 0x1C47: + case 0x1C57: + case 0x2077: + case 0x2087: + case 0x2166: + case 0x2176: + case 0x2466: + case 0x247A: + case 0x248E: + case 0x24FB: + case 0x277C: + case 0x2786: + case 0x2790: + case 0x3027: + case 0x3226: + case 0x3286: + case 0x3B4D: + case 0x4E03: + case 0x67D2: + case 0x6F06: + case 0xA627: + case 0xA8D7: + case 0xA907: + case 0xAA57: + case 0xFF17: +#ifdef Py_UNICODE_WIDE + case 0x1010D: + case 0x104A7: + case 0x12405: + case 0x1240C: + case 0x12412: + case 0x1241B: + case 0x12429: + case 0x12441: + case 0x12442: + case 0x12443: + case 0x1D366: + case 0x1D7D5: + case 0x1D7DF: + case 0x1D7E9: + case 0x1D7F3: + case 0x1D7FD: + case 0x20001: +#endif + return (double) 7; + case 0x0F2D: + return (double) 7/2; + case 0x215E: + return (double) 7/8; + case 0x1378: +#ifdef Py_UNICODE_WIDE + case 0x10116: + case 0x1D36F: +#endif + return (double) 70; +#ifdef Py_UNICODE_WIDE + case 0x1011F: + return (double) 700; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10128: + return (double) 7000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10131: + return (double) 70000; +#endif + case 0x0038: + case 0x0668: + case 0x06F8: + case 0x07C8: + case 0x096E: + case 0x09EE: + case 0x0A6E: + case 0x0AEE: + case 0x0B6E: + case 0x0BEE: + case 0x0C6E: + case 0x0CEE: + case 0x0D6E: + case 0x0E58: + case 0x0ED8: + case 0x0F28: + case 0x1048: + case 0x1098: + case 0x1370: + case 0x17E8: + case 0x17F8: + case 0x1818: + case 0x194E: + case 0x19D8: + case 0x1B58: + case 0x1BB8: + case 0x1C48: + case 0x1C58: + case 0x2078: + case 0x2088: + case 0x2167: + case 0x2177: + case 0x2467: + case 0x247B: + case 0x248F: + case 0x24FC: + case 0x277D: + case 0x2787: + case 0x2791: + case 0x3028: + case 0x3227: + case 0x3287: + case 0x516B: + case 0x634C: + case 0xA628: + case 0xA8D8: + case 0xA908: + case 0xAA58: + case 0xFF18: +#ifdef Py_UNICODE_WIDE + case 0x1010E: + case 0x104A8: + case 0x12406: + case 0x1240D: + case 0x12413: + case 0x1241C: + case 0x1242A: + case 0x12444: + case 0x12445: + case 0x1D367: + case 0x1D7D6: + case 0x1D7E0: + case 0x1D7EA: + case 0x1D7F4: + case 0x1D7FE: +#endif + return (double) 8; + case 0x1379: +#ifdef Py_UNICODE_WIDE + case 0x10117: + case 0x1D370: +#endif + return (double) 80; +#ifdef Py_UNICODE_WIDE + case 0x10120: + return (double) 800; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10129: + return (double) 8000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10132: + return (double) 80000; +#endif + case 0x0039: + case 0x0669: + case 0x06F9: + case 0x07C9: + case 0x096F: + case 0x09EF: + case 0x0A6F: + case 0x0AEF: + case 0x0B6F: + case 0x0BEF: + case 0x0C6F: + case 0x0CEF: + case 0x0D6F: + case 0x0E59: + case 0x0ED9: + case 0x0F29: + case 0x1049: + case 0x1099: + case 0x1371: + case 0x17E9: + case 0x17F9: + case 0x1819: + case 0x194F: + case 0x19D9: + case 0x1B59: + case 0x1BB9: + case 0x1C49: + case 0x1C59: + case 0x2079: + case 0x2089: + case 0x2168: + case 0x2178: + case 0x2468: + case 0x247C: + case 0x2490: + case 0x24FD: + case 0x277E: + case 0x2788: + case 0x2792: + case 0x3029: + case 0x3228: + case 0x3288: + case 0x4E5D: + case 0x5EFE: + case 0x7396: + case 0xA629: + case 0xA8D9: + case 0xA909: + case 0xAA59: + case 0xFF19: +#ifdef Py_UNICODE_WIDE + case 0x1010F: + case 0x104A9: + case 0x12407: + case 0x1240E: + case 0x12414: + case 0x1241D: + case 0x1242B: + case 0x12446: + case 0x12447: + case 0x12448: + case 0x12449: + case 0x1D368: + case 0x1D7D7: + case 0x1D7E1: + case 0x1D7EB: + case 0x1D7F5: + case 0x1D7FF: + case 0x2F890: +#endif + return (double) 9; + case 0x0F2E: + return (double) 9/2; + case 0x137A: +#ifdef Py_UNICODE_WIDE + case 0x10118: + case 0x10341: + case 0x1D371: +#endif + return (double) 90; +#ifdef Py_UNICODE_WIDE + case 0x10121: + case 0x1034A: + return (double) 900; +#endif +#ifdef Py_UNICODE_WIDE + case 0x1012A: + return (double) 9000; +#endif +#ifdef Py_UNICODE_WIDE + case 0x10133: + return (double) 90000; +#endif + } + return -1.0; +} + +/* Returns 1 for Unicode characters having the bidirectional + * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. + */ +int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) +{ +#ifdef WANT_WCTYPE_FUNCTIONS + return iswspace(ch); +#else + switch (ch) { + case 0x0009: + case 0x000A: + case 0x000B: + case 0x000C: + case 0x000D: + case 0x001C: + case 0x001D: + case 0x001E: + case 0x001F: + case 0x0020: + case 0x0085: + case 0x00A0: + case 0x1680: + case 0x180E: + case 0x2000: + case 0x2001: + case 0x2002: + case 0x2003: + case 0x2004: + case 0x2005: + case 0x2006: + case 0x2007: + case 0x2008: + case 0x2009: + case 0x200A: + case 0x2028: + case 0x2029: + case 0x202F: + case 0x205F: + case 0x3000: + return 1; + } + return 0; +#endif +} + +/* Returns 1 for Unicode characters having the category 'Zl', + * 'Zp' or type 'B', 0 otherwise. + */ +int _PyUnicode_IsLinebreak(register const Py_UNICODE ch) +{ + switch (ch) { + case 0x000A: + case 0x000D: + case 0x001C: + case 0x001D: + case 0x001E: + case 0x0085: + case 0x2028: + case 0x2029: + return 1; + } + return 0; +} + Modified: python/branches/py3k/Tools/unicode/makeunicodedata.py ============================================================================== --- python/branches/py3k/Tools/unicode/makeunicodedata.py (original) +++ python/branches/py3k/Tools/unicode/makeunicodedata.py Tue Oct 6 23:03:20 2009 @@ -35,6 +35,7 @@ UNICODE_DATA = "UnicodeData%s.txt" COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt" EASTASIAN_WIDTH = "EastAsianWidth%s.txt" +UNIHAN = "Unihan%s.txt" DERIVED_CORE_PROPERTIES = "DerivedCoreProperties%s.txt" DERIVEDNORMALIZATION_PROPS = "DerivedNormalizationProps%s.txt" @@ -64,6 +65,7 @@ XID_CONTINUE_MASK = 0x200 PRINTABLE_MASK = 0x400 NODELTA_MASK = 0x800 +NUMERIC_MASK = 0x1000 def maketables(trace=0): @@ -73,6 +75,7 @@ unicode = UnicodeData(UNICODE_DATA % version, COMPOSITION_EXCLUSIONS % version, EASTASIAN_WIDTH % version, + UNIHAN % version, DERIVED_CORE_PROPERTIES % version, DERIVEDNORMALIZATION_PROPS % version) @@ -83,6 +86,7 @@ old_unicode = UnicodeData(UNICODE_DATA % ("-"+version), COMPOSITION_EXCLUSIONS % ("-"+version), EASTASIAN_WIDTH % ("-"+version), + UNIHAN % ("-"+version), DERIVED_CORE_PROPERTIES % ("-"+version)) print(len(list(filter(None, old_unicode.table))), "characters") merge_old_version(version, unicode, old_unicode) @@ -357,6 +361,9 @@ table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) + numeric = {} + spaces = [] + linebreaks = [] for char in unicode.chars: record = unicode.table[char] @@ -373,8 +380,10 @@ flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK + linebreaks.append(char) if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK + spaces.append(char) if category == "Lt": flags |= TITLE_MASK if category == "Lu": @@ -423,6 +432,9 @@ if record[7]: flags |= DIGIT_MASK digit = int(record[7]) + if record[8]: + flags |= NUMERIC_MASK + numeric.setdefault(record[8], []).append(char) item = ( upper, lower, title, decimal, digit, flags ) @@ -434,6 +446,9 @@ index[char] = i print(len(table), "unique character type entries") + print(sum(map(len, numeric.values())), "numeric code points") + print(len(spaces), "whitespace code points") + print(len(linebreaks), "linebreak code points") print("--- Writing", FILE, "...") @@ -455,6 +470,96 @@ Array("index1", index1).dump(fp, trace) Array("index2", index2).dump(fp, trace) + # Generate code for _PyUnicode_ToNumeric() + numeric_items = sorted(numeric.items()) + print('/* Returns the numeric value as double for Unicode characters', file=fp) + print(' * having this property, -1.0 otherwise.', file=fp) + print(' */', file=fp) + print('double _PyUnicode_ToNumeric(Py_UNICODE ch)', file=fp) + print('{', file=fp) + print(' switch (ch) {', file=fp) + for value, codepoints in numeric_items: + haswide = False + hasnonewide = False + codepoints.sort() + for codepoint in codepoints: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print('#ifdef Py_UNICODE_WIDE', file=fp) + haswide = True + print(' case 0x%04X:' % (codepoint,), file=fp) + if haswide and hasnonewide: + print('#endif', file=fp) + print(' return (double) %s;' % (value,), file=fp) + if haswide and not hasnonewide: + print('#endif', file=fp) + print(' }', file=fp) + print(' return -1.0;', file=fp) + print('}', file=fp) + print(file=fp) + + # Generate code for _PyUnicode_IsWhitespace() + print("/* Returns 1 for Unicode characters having the bidirectional", file=fp) + print(" * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise.", file=fp) + print(" */", file=fp) + print('int _PyUnicode_IsWhitespace(register const Py_UNICODE ch)', file=fp) + print('{', file=fp) + print('#ifdef WANT_WCTYPE_FUNCTIONS', file=fp) + print(' return iswspace(ch);', file=fp) + print('#else', file=fp) + print(' switch (ch) {', file=fp) + + haswide = False + hasnonewide = False + spaces.sort() + for codepoint in spaces: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print('#ifdef Py_UNICODE_WIDE', file=fp) + haswide = True + print(' case 0x%04X:' % (codepoint,), file=fp) + if haswide and hasnonewide: + print('#endif', file=fp) + print(' return 1;', file=fp) + if haswide and not hasnonewide: + print('#endif', file=fp) + + print(' }', file=fp) + print(' return 0;', file=fp) + print('#endif', file=fp) + print('}', file=fp) + print(file=fp) + + # Generate code for _PyUnicode_IsLinebreak() + print("/* Returns 1 for Unicode characters having the category 'Zl',", file=fp) + print(" * 'Zp' or type 'B', 0 otherwise.", file=fp) + print(" */", file=fp) + print('int _PyUnicode_IsLinebreak(register const Py_UNICODE ch)', file=fp) + print('{', file=fp) + print(' switch (ch) {', file=fp) + haswide = False + hasnonewide = False + linebreaks.sort() + for codepoint in linebreaks: + if codepoint < 0x10000: + hasnonewide = True + if codepoint >= 0x10000 and not haswide: + print('#ifdef Py_UNICODE_WIDE', file=fp) + haswide = True + print(' case 0x%04X:' % (codepoint,), file=fp) + if haswide and hasnonewide: + print('#endif', file=fp) + print(' return 1;', file=fp) + if haswide and not hasnonewide: + print('#endif', file=fp) + + print(' }', file=fp) + print(' return 0;', file=fp) + print('}', file=fp) + print(file=fp) + fp.close() # -------------------------------------------------------------------- @@ -670,12 +775,11 @@ elif k == 8: # print "NUMERIC",hex(i), `old.table[i][k]`, new.table[i][k] # Since 0 encodes "no change", the old value is better not 0 - assert value != "0" and value != "-1" if not value: numeric_changes[i] = -1 else: - assert re.match("^[0-9]+$", value) - numeric_changes[i] = int(value) + numeric_changes[i] = float(value) + assert numeric_changes[i] not in (0, -1) elif k == 9: if value == 'Y': mirrored_changes[i] = '1' @@ -711,8 +815,6 @@ # load a unicode-data file from disk -import sys - class UnicodeData: # Record structure: # [ID, name, category, combining, bidi, decomp, (6) @@ -720,7 +822,7 @@ # ISO-comment, uppercase, lowercase, titlecase, ea-width, (16) # derived-props] (17) - def __init__(self, filename, exclusions, eastasianwidth, + def __init__(self, filename, exclusions, eastasianwidth, unihan, derivedprops, derivednormalizationprops=None, expand=1): self.changed = [] file = open(filename) @@ -830,6 +932,19 @@ if table[i] is not None: table[i].append(quickchecks[i]) + for line in open(unihan, encoding='utf-8'): + if not line.startswith('U+'): + continue + code, tag, value = line.split(None, 3)[:3] + if tag not in ('kAccountingNumeric', 'kPrimaryNumeric', + 'kOtherNumeric'): + continue + value = value.strip().replace(',', '') + i = int(code[2:], 16) + # Patch the numeric field + if table[i] is not None: + table[i][8] = value + def uselatin1(self): # restrict character range to ISO Latin 1 self.chars = list(range(256)) @@ -979,7 +1094,6 @@ you'll get. """ - import sys if trace: def dump(t1, t2, shift, bytes): print("%d+%d bins at shift %d; %d bytes" % ( From python-checkins at python.org Wed Oct 7 21:22:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 07 Oct 2009 19:22:05 -0000 Subject: [Python-checkins] r75275 - in python/trunk: Lib/decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Wed Oct 7 21:22:05 2009 New Revision: 75275 Log: Issue #7048: logb should round its result when that result doesn't fit into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.) Modified: python/trunk/Lib/decimal.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Wed Oct 7 21:22:05 2009 @@ -3126,7 +3126,8 @@ # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. - return Decimal(self.adjusted()) + ans = Decimal(self.adjusted()) + return ans._fix(context) def _islogical(self): """Return True if self is a logical operand. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 7 21:22:05 2009 @@ -398,6 +398,9 @@ Library ------- +- Issue #7048: Force Decimal.logb to round its result when that result + is too large to fit in the current precision. + - Issue #6516: Added owner/group support when creating tar archives in Distutils. From python-checkins at python.org Wed Oct 7 21:23:50 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 07 Oct 2009 19:23:50 -0000 Subject: [Python-checkins] r75276 - in python/branches/py3k: Lib/decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Wed Oct 7 21:23:50 2009 New Revision: 75276 Log: Merged revisions 75275 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75275 | mark.dickinson | 2009-10-07 20:22:05 +0100 (Wed, 07 Oct 2009) | 6 lines Issue #7048: logb should round its result when that result doesn't fit into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.) ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/decimal.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Wed Oct 7 21:23:50 2009 @@ -3209,7 +3209,8 @@ # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. - return Decimal(self.adjusted()) + ans = Decimal(self.adjusted()) + return ans._fix(context) def _islogical(self): """Return True if self is a logical operand. Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 7 21:23:50 2009 @@ -87,6 +87,9 @@ Library ------- +- Issue #7048: Force Decimal.logb to round its result when that result + is too large to fit in the current precision. + - Issue #6236, #6348: Fix various failures in the I/O library under AIX and other platforms, when using a non-gcc compiler. Patch by egreen. From python-checkins at python.org Wed Oct 7 21:24:44 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 07 Oct 2009 19:24:44 -0000 Subject: [Python-checkins] r75277 - in python/branches/release31-maint: Lib/decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Wed Oct 7 21:24:43 2009 New Revision: 75277 Log: Merged revisions 75276 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75276 | mark.dickinson | 2009-10-07 20:23:50 +0100 (Wed, 07 Oct 2009) | 12 lines Merged revisions 75275 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75275 | mark.dickinson | 2009-10-07 20:22:05 +0100 (Wed, 07 Oct 2009) | 6 lines Issue #7048: logb should round its result when that result doesn't fit into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.) ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/decimal.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/decimal.py ============================================================================== --- python/branches/release31-maint/Lib/decimal.py (original) +++ python/branches/release31-maint/Lib/decimal.py Wed Oct 7 21:24:43 2009 @@ -3209,7 +3209,8 @@ # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. - return Decimal(self.adjusted()) + ans = Decimal(self.adjusted()) + return ans._fix(context) def _islogical(self): """Return True if self is a logical operand. Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Wed Oct 7 21:24:43 2009 @@ -27,6 +27,9 @@ Library ------- +- Issue #7048: Force Decimal.logb to round its result when that result + is too large to fit in the current precision. + - Issue #6236, #6348: Fix various failures in the I/O library under AIX and other platforms, when using a non-gcc compiler. Patch by egreen. From python-checkins at python.org Wed Oct 7 23:25:56 2009 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 07 Oct 2009 21:25:56 -0000 Subject: [Python-checkins] r75278 - in sandbox/trunk/2to3/lib2to3: fixes/fix_idioms.py tests/test_fixers.py Message-ID: Author: benjamin.peterson Date: Wed Oct 7 23:25:56 2009 New Revision: 75278 Log: fix whitespace problems with fix_idioms #3563 Patch by Joe Amenta. Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_idioms.py sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_idioms.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_idioms.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_idioms.py Wed Oct 7 23:25:56 2009 @@ -29,7 +29,7 @@ # Local imports from .. import fixer_base -from ..fixer_util import Call, Comma, Name, Node, syms +from ..fixer_util import Call, Comma, Name, Node, BlankLine, syms CMP = "(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)" TYPE = "power< 'type' trailer< '(' x=any ')' > >" @@ -130,5 +130,24 @@ else: raise RuntimeError("should not have reached here") sort_stmt.remove() - if next_stmt: - next_stmt[0].prefix = sort_stmt.prefix + + btwn = sort_stmt.prefix + # Keep any prefix lines between the sort_stmt and the list_call and + # shove them right after the sorted() call. + if u"\n" in btwn: + if next_stmt: + # The new prefix should be everything from the sort_stmt's + # prefix up to the last newline, then the old prefix after a new + # line. + prefix_lines = (btwn.rpartition(u"\n")[0], next_stmt[0].prefix) + next_stmt[0].prefix = u"\n".join(prefix_lines) + else: + assert list_call.parent + assert list_call.next_sibling is None + # Put a blank line after list_call and set its prefix. + end_line = BlankLine() + list_call.parent.append_child(end_line) + assert list_call.next_sibling is end_line + # The new prefix should be everything up to the first new line + # of sort_stmt's prefix. + end_line.prefix = btwn.rpartition(u"\n")[0] Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py (original) +++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Wed Oct 7 23:25:56 2009 @@ -3238,6 +3238,46 @@ """ self.check(b, a) + b = r""" + try: + m = list(s) + m.sort() + except: pass + """ + + a = r""" + try: + m = sorted(s) + except: pass + """ + self.check(b, a) + + b = r""" + try: + m = list(s) + # foo + m.sort() + except: pass + """ + + a = r""" + try: + m = sorted(s) + # foo + except: pass + """ + self.check(b, a) + + b = r""" + m = list(s) + # more comments + m.sort()""" + + a = r""" + m = sorted(s) + # more comments""" + self.check(b, a) + def test_sort_simple_expr(self): b = """ v = t From nnorwitz at gmail.com Wed Oct 7 23:56:10 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 7 Oct 2009 17:56:10 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091007215610.GA9197@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 0, -420] references, sum=-420 Less important issues: ---------------------- test_asynchat leaked [117, -117, 0] references, sum=0 test_cmd_line leaked [50, -25, 0] references, sum=25 test_smtplib leaked [-91, 119, -119] references, sum=-91 test_socketserver leaked [0, 80, -80] references, sum=0 test_sys leaked [21, 0, -21] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 test_xmlrpc leaked [6, -6, 0] references, sum=0 From python-checkins at python.org Thu Oct 8 01:39:00 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 07 Oct 2009 23:39:00 -0000 Subject: [Python-checkins] r75279 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Thu Oct 8 01:38:55 2009 New Revision: 75279 Log: Merged revisions 75255 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75255 | r.david.murray | 2009-10-05 13:03:09 -0400 (Mon, 05 Oct 2009) | 3 lines Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Thu Oct 8 01:38:55 2009 @@ -682,6 +682,10 @@ refleak = False # True if the test leaked references. try: save_stdout = sys.stdout + # Save various things that tests may mess up so we can restore + # them afterward. + save_environ = dict(os.environ) + save_argv = sys.argv[:] try: if test.startswith('test.'): abstest = test @@ -702,6 +706,17 @@ test_time = time.time() - start_time finally: sys.stdout = save_stdout + # Restore what we saved if needed, but also complain if the test + # changed it so that the test may eventually get fixed. + if not os.environ == save_environ: + if not quiet: + print("Warning: os.environ was modified by", test) + os.environ.clear() + os.environ.update(save_environ) + if not sys.argv == save_argv: + if not quiet: + print("Warning: argv was modified by", test) + sys.argv[:] = save_argv except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Oct 8 01:38:55 2009 @@ -260,6 +260,9 @@ Tests ----- +- Issue #7058: Added save/restore for argv and os.environ to runtest_inner + in regrtest, with warnings if the called test modifies them. + - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. - Fixed tests in importlib.test.source.test_abc_loader that were masking From python-checkins at python.org Thu Oct 8 01:54:54 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 07 Oct 2009 23:54:54 -0000 Subject: [Python-checkins] r75280 - in python/branches/release31-maint: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Thu Oct 8 01:54:53 2009 New Revision: 75280 Log: Merged revisions 75279 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75279 | r.david.murray | 2009-10-07 19:38:55 -0400 (Wed, 07 Oct 2009) | 10 lines Merged revisions 75255 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75255 | r.david.murray | 2009-10-05 13:03:09 -0400 (Mon, 05 Oct 2009) | 3 lines Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/regrtest.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/regrtest.py ============================================================================== --- python/branches/release31-maint/Lib/test/regrtest.py (original) +++ python/branches/release31-maint/Lib/test/regrtest.py Thu Oct 8 01:54:53 2009 @@ -598,6 +598,10 @@ refleak = False # True if the test leaked references. try: save_stdout = sys.stdout + # Save various things that tests may mess up so we can restore + # them afterward. + save_environ = dict(os.environ) + save_argv = sys.argv[:] try: if cfp: sys.stdout = cfp @@ -622,6 +626,17 @@ test_times.append((test_time, test)) finally: sys.stdout = save_stdout + # Restore what we saved if needed, but also complain if the test + # changed it so that the test may eventually get fixed. + if not os.environ == save_environ: + if not quiet: + print("Warning: os.environ was modified by", test) + os.environ.clear() + os.environ.update(save_environ) + if not sys.argv == save_argv: + if not quiet: + print("Warning: argv was modified by", test) + sys.argv[:] = save_argv except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Thu Oct 8 01:54:53 2009 @@ -79,6 +79,9 @@ Tests ----- +- Issue #7058: Added save/restore for argv and os.environ to runtest_inner + in regrtest, with warnings if the called test modifies them. + - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. Build From python-checkins at python.org Thu Oct 8 10:04:16 2009 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 08 Oct 2009 08:04:16 -0000 Subject: [Python-checkins] r75281 - python/trunk/setup.py Message-ID: Author: ronald.oussoren Date: Thu Oct 8 10:04:15 2009 New Revision: 75281 Log: Ensure that _scproxy gets build even when --disable-toolbox-glue is specified on OSX. Fixes a regression in 2.6.3. Modified: python/trunk/setup.py Modified: python/trunk/setup.py ============================================================================== --- python/trunk/setup.py (original) +++ python/trunk/setup.py Thu Oct 8 10:04:15 2009 @@ -1347,6 +1347,15 @@ else: missing.append('sunaudiodev') + if platform == 'darwin': + # _scproxy + exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")], + extra_link_args= [ + '-framework', 'SystemConfiguration', + '-framework', 'CoreFoundation' + ])) + + if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): @@ -1400,15 +1409,6 @@ addMacExtension('_CF', core_kwds, ['cf/pycfbridge.c']) addMacExtension('autoGIL', core_kwds) - # _scproxy - sc_kwds = { - 'extra_compile_args': carbon_extra_compile_args, - 'extra_link_args': [ - '-framework', 'SystemConfiguration', - '-framework', 'CoreFoundation' - ], - } - addMacExtension("_scproxy", sc_kwds) # Carbon From python-checkins at python.org Thu Oct 8 11:48:32 2009 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 08 Oct 2009 09:48:32 -0000 Subject: [Python-checkins] r75282 - in python/branches/release26-maint: setup.py Message-ID: Author: ronald.oussoren Date: Thu Oct 8 11:48:32 2009 New Revision: 75282 Log: Merged revisions 75281 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75281 | ronald.oussoren | 2009-10-08 10:04:15 +0200 (Thu, 08 Oct 2009) | 3 lines Ensure that _scproxy gets build even when --disable-toolbox-glue is specified on OSX. Fixes a regression in 2.6.3. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/setup.py Modified: python/branches/release26-maint/setup.py ============================================================================== --- python/branches/release26-maint/setup.py (original) +++ python/branches/release26-maint/setup.py Thu Oct 8 11:48:32 2009 @@ -1349,6 +1349,15 @@ else: missing.append('sunaudiodev') + if platform == 'darwin': + # _scproxy + exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")], + extra_link_args= [ + '-framework', 'SystemConfiguration', + '-framework', 'CoreFoundation' + ])) + + if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): @@ -1402,15 +1411,6 @@ addMacExtension('_CF', core_kwds, ['cf/pycfbridge.c']) addMacExtension('autoGIL', core_kwds) - # _scproxy - sc_kwds = { - 'extra_compile_args': carbon_extra_compile_args, - 'extra_link_args': [ - '-framework', 'SystemConfiguration', - '-framework', 'CoreFoundation' - ], - } - addMacExtension("_scproxy", sc_kwds) # Carbon From nnorwitz at gmail.com Thu Oct 8 12:06:54 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 8 Oct 2009 06:06:54 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091008100654.GA28368@python.psfb.org> More important issues: ---------------------- test_ctypes leaked [1, 0, 0] references, sum=1 Less important issues: ---------------------- test_asynchat leaked [-117, 0, 0] references, sum=-117 test_cmd_line leaked [0, -25, 50] references, sum=25 test_smtplib leaked [75, 6, -6] references, sum=75 test_socketserver leaked [80, -80, 0] references, sum=0 test_sys leaked [21, -21, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [284, -284, 0] references, sum=0 test_xmlrpc leaked [-1, 1, 0] references, sum=0 From python-checkins at python.org Thu Oct 8 17:54:10 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 15:54:10 -0000 Subject: [Python-checkins] r75283 - in python/trunk: Lib/struct.py Misc/NEWS Modules/_struct.c Message-ID: Author: mark.dickinson Date: Thu Oct 8 17:54:10 2009 New Revision: 75283 Log: Issue #7078: _struct.__doc__ was being ignored. Import it into struct. Also add description of '?' struct format character. Thanks Gabriel Genellina for the patch. Modified: python/trunk/Lib/struct.py python/trunk/Misc/NEWS python/trunk/Modules/_struct.c Modified: python/trunk/Lib/struct.py ============================================================================== --- python/trunk/Lib/struct.py (original) +++ python/trunk/Lib/struct.py Thu Oct 8 17:54:10 2009 @@ -1,2 +1,3 @@ from _struct import * from _struct import _clearcache +from _struct import __doc__ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 8 17:54:10 2009 @@ -1370,6 +1370,8 @@ Extension Modules ----------------- +- Issue #7078: Set struct.__doc__ from _struct.__doc__. + - Issue #3366: Add gamma function to math module. - Issue #6823: Allow time.strftime() to accept a tuple with a isdst field Modified: python/trunk/Modules/_struct.c ============================================================================== --- python/trunk/Modules/_struct.c (original) +++ python/trunk/Modules/_struct.c Thu Oct 8 17:54:10 2009 @@ -1868,20 +1868,22 @@ /* Module initialization */ PyDoc_STRVAR(module_doc, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ +"Functions to convert between Python values and C structs represented\n\ +as Python strings. It uses format strings (explained below) as compact\n\ +descriptions of the lay-out of the C structs and the intended conversion\n\ +to/from Python values.\n\ \n\ The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ + @: native order, size & alignment (default)\n\ + =: native order, std. size & alignment\n\ + <: little-endian, std. size & alignment\n\ + >: big-endian, std. size & alignment\n\ + !: same as >\n\ \n\ The remaining chars indicate types of args and must match exactly;\n\ these can be preceded by a decimal repeat count:\n\ x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ + ?: _Bool (requires C99; if not available, char is used instead)\n\ h:short; H:unsigned short; i:int; I:unsigned int;\n\ l:long; L:unsigned long; f:float; d:double.\n\ Special cases (preceding decimal count indicates length):\n\ From python-checkins at python.org Thu Oct 8 17:59:20 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 15:59:20 -0000 Subject: [Python-checkins] r75284 - in python/branches/py3k: Lib/struct.py Misc/NEWS Modules/_struct.c Message-ID: Author: mark.dickinson Date: Thu Oct 8 17:59:20 2009 New Revision: 75284 Log: Merged revisions 75283 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75283 | mark.dickinson | 2009-10-08 16:54:10 +0100 (Thu, 08 Oct 2009) | 4 lines Issue #7078: _struct.__doc__ was being ignored. Import it into struct. Also add description of '?' struct format character. Thanks Gabriel Genellina for the patch. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/struct.py python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/_struct.c Modified: python/branches/py3k/Lib/struct.py ============================================================================== --- python/branches/py3k/Lib/struct.py (original) +++ python/branches/py3k/Lib/struct.py Thu Oct 8 17:59:20 2009 @@ -1,2 +1,3 @@ from _struct import * from _struct import _clearcache +from _struct import __doc__ Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Oct 8 17:59:20 2009 @@ -216,6 +216,8 @@ Extension Modules ----------------- +- Issue #7078: Set struct.__doc__ from _struct.__doc__. + - Issue #3366: Add gamma function to math module. - Issue #6877: It is now possible to link the readline extension to the Modified: python/branches/py3k/Modules/_struct.c ============================================================================== --- python/branches/py3k/Modules/_struct.c (original) +++ python/branches/py3k/Modules/_struct.c Thu Oct 8 17:59:20 2009 @@ -1900,18 +1900,20 @@ PyDoc_STRVAR(module_doc, "Functions to convert between Python values and C structs.\n\ Python bytes objects are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ +and also as format strings (explained below) to describe the layout of data\n\ +in the C struct.\n\ \n\ The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ + @: native order, size & alignment (default)\n\ + =: native order, std. size & alignment\n\ + <: little-endian, std. size & alignment\n\ + >: big-endian, std. size & alignment\n\ + !: same as >\n\ \n\ The remaining chars indicate types of args and must match exactly;\n\ these can be preceded by a decimal repeat count:\n\ x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ + ?: _Bool (requires C99; if not available, char is used instead)\n\ h:short; H:unsigned short; i:int; I:unsigned int;\n\ l:long; L:unsigned long; f:float; d:double.\n\ Special cases (preceding decimal count indicates length):\n\ From python-checkins at python.org Thu Oct 8 18:02:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 16:02:51 -0000 Subject: [Python-checkins] r75285 - in python/branches/release31-maint: Lib/struct.py Misc/NEWS Modules/_struct.c Message-ID: Author: mark.dickinson Date: Thu Oct 8 18:02:50 2009 New Revision: 75285 Log: Merged revisions 75284 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75284 | mark.dickinson | 2009-10-08 16:59:20 +0100 (Thu, 08 Oct 2009) | 11 lines Merged revisions 75283 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75283 | mark.dickinson | 2009-10-08 16:54:10 +0100 (Thu, 08 Oct 2009) | 4 lines Issue #7078: _struct.__doc__ was being ignored. Import it into struct. Also add description of '?' struct format character. Thanks Gabriel Genellina for the patch. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/struct.py python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/_struct.c Modified: python/branches/release31-maint/Lib/struct.py ============================================================================== --- python/branches/release31-maint/Lib/struct.py (original) +++ python/branches/release31-maint/Lib/struct.py Thu Oct 8 18:02:50 2009 @@ -1,2 +1,3 @@ from _struct import * from _struct import _clearcache +from _struct import __doc__ Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Thu Oct 8 18:02:50 2009 @@ -74,6 +74,8 @@ Extension Modules ----------------- +- Issue #7078: Set struct.__doc__ from _struct.__doc__. + - Issue #6848: Fix curses module build failure on OS X 10.6. Tests Modified: python/branches/release31-maint/Modules/_struct.c ============================================================================== --- python/branches/release31-maint/Modules/_struct.c (original) +++ python/branches/release31-maint/Modules/_struct.c Thu Oct 8 18:02:50 2009 @@ -1900,18 +1900,20 @@ PyDoc_STRVAR(module_doc, "Functions to convert between Python values and C structs.\n\ Python bytes objects are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ +and also as format strings (explained below) to describe the layout of data\n\ +in the C struct.\n\ \n\ The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ + @: native order, size & alignment (default)\n\ + =: native order, std. size & alignment\n\ + <: little-endian, std. size & alignment\n\ + >: big-endian, std. size & alignment\n\ + !: same as >\n\ \n\ The remaining chars indicate types of args and must match exactly;\n\ these can be preceded by a decimal repeat count:\n\ x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ + ?: _Bool (requires C99; if not available, char is used instead)\n\ h:short; H:unsigned short; i:int; I:unsigned int;\n\ l:long; L:unsigned long; f:float; d:double.\n\ Special cases (preceding decimal count indicates length):\n\ From python-checkins at python.org Thu Oct 8 18:28:41 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 16:28:41 -0000 Subject: [Python-checkins] r75286 - in python/trunk/Lib/test: decimaltestdata/abs.decTest decimaltestdata/add.decTest decimaltestdata/and.decTest decimaltestdata/base.decTest decimaltestdata/clamp.decTest decimaltestdata/class.decTest decimaltestdata/compare.decTest decimaltestdata/comparetotal.decTest decimaltestdata/comparetotmag.decTest decimaltestdata/copy.decTest decimaltestdata/copyabs.decTest decimaltestdata/copynegate.decTest decimaltestdata/copysign.decTest decimaltestdata/ddAbs.decTest decimaltestdata/ddAdd.decTest decimaltestdata/ddAnd.decTest decimaltestdata/ddBase.decTest decimaltestdata/ddCanonical.decTest decimaltestdata/ddClass.decTest decimaltestdata/ddCompare.decTest decimaltestdata/ddCompareSig.decTest decimaltestdata/ddCompareTotal.decTest decimaltestdata/ddCompareTotalMag.decTest decimaltestdata/ddCopy.decTest decimaltestdata/ddCopyAbs.decTest decimaltestdata/ddCopyNegate.decTest decimaltestdata/ddCopySign.decTest decimaltestdata/ddDivide.decTest decimaltestdata/ddDivideInt.decTest decimaltestdata/ddEncode.decTest decimaltestdata/ddFMA.decTest decimaltestdata/ddInvert.decTest decimaltestdata/ddLogB.decTest decimaltestdata/ddMax.decTest decimaltestdata/ddMaxMag.decTest decimaltestdata/ddMin.decTest decimaltestdata/ddMinMag.decTest decimaltestdata/ddMinus.decTest decimaltestdata/ddMultiply.decTest decimaltestdata/ddNextMinus.decTest decimaltestdata/ddNextPlus.decTest decimaltestdata/ddNextToward.decTest decimaltestdata/ddOr.decTest decimaltestdata/ddPlus.decTest decimaltestdata/ddQuantize.decTest decimaltestdata/ddReduce.decTest decimaltestdata/ddRemainder.decTest decimaltestdata/ddRemainderNear.decTest decimaltestdata/ddRotate.decTest decimaltestdata/ddSameQuantum.decTest decimaltestdata/ddScaleB.decTest decimaltestdata/ddShift.decTest decimaltestdata/ddSubtract.decTest decimaltestdata/ddToIntegral.decTest decimaltestdata/ddXor.decTest decimaltestdata/decDouble.decTest decimaltestdata/decQuad.decTest decimaltestdata/decSingle.decTest decimaltestdata/divide.decTest decimaltestdata/divideint.decTest decimaltestdata/dqAbs.decTest decimaltestdata/dqAdd.decTest decimaltestdata/dqAnd.decTest decimaltestdata/dqBase.decTest decimaltestdata/dqCanonical.decTest decimaltestdata/dqClass.decTest decimaltestdata/dqCompare.decTest decimaltestdata/dqCompareSig.decTest decimaltestdata/dqCompareTotal.decTest decimaltestdata/dqCompareTotalMag.decTest decimaltestdata/dqCopy.decTest decimaltestdata/dqCopyAbs.decTest decimaltestdata/dqCopyNegate.decTest decimaltestdata/dqCopySign.decTest decimaltestdata/dqDivide.decTest decimaltestdata/dqDivideInt.decTest decimaltestdata/dqEncode.decTest decimaltestdata/dqFMA.decTest decimaltestdata/dqInvert.decTest decimaltestdata/dqLogB.decTest decimaltestdata/dqMax.decTest decimaltestdata/dqMaxMag.decTest decimaltestdata/dqMin.decTest decimaltestdata/dqMinMag.decTest decimaltestdata/dqMinus.decTest decimaltestdata/dqMultiply.decTest decimaltestdata/dqNextMinus.decTest decimaltestdata/dqNextPlus.decTest decimaltestdata/dqNextToward.decTest decimaltestdata/dqOr.decTest decimaltestdata/dqPlus.decTest decimaltestdata/dqQuantize.decTest decimaltestdata/dqReduce.decTest decimaltestdata/dqRemainder.decTest decimaltestdata/dqRemainderNear.decTest decimaltestdata/dqRotate.decTest decimaltestdata/dqSameQuantum.decTest decimaltestdata/dqScaleB.decTest decimaltestdata/dqShift.decTest decimaltestdata/dqSubtract.decTest decimaltestdata/dqToIntegral.decTest decimaltestdata/dqXor.decTest decimaltestdata/dsBase.decTest decimaltestdata/dsEncode.decTest decimaltestdata/exp.decTest decimaltestdata/fma.decTest decimaltestdata/inexact.decTest decimaltestdata/invert.decTest decimaltestdata/ln.decTest decimaltestdata/log10.decTest decimaltestdata/logb.decTest decimaltestdata/max.decTest decimaltestdata/maxmag.decTest decimaltestdata/min.decTest decimaltestdata/minmag.decTest decimaltestdata/minus.decTest decimaltestdata/multiply.decTest decimaltestdata/nextminus.decTest decimaltestdata/nextplus.decTest decimaltestdata/nexttoward.decTest decimaltestdata/or.decTest decimaltestdata/plus.decTest decimaltestdata/power.decTest decimaltestdata/powersqrt.decTest decimaltestdata/quantize.decTest decimaltestdata/randomBound32.decTest decimaltestdata/randoms.decTest decimaltestdata/reduce.decTest decimaltestdata/remainder.decTest decimaltestdata/remainderNear.decTest decimaltestdata/rescale.decTest decimaltestdata/rotate.decTest decimaltestdata/rounding.decTest decimaltestdata/samequantum.decTest decimaltestdata/scaleb.decTest decimaltestdata/shift.decTest decimaltestdata/squareroot.decTest decimaltestdata/subtract.decTest decimaltestdata/testall.decTest decimaltestdata/tointegral.decTest decimaltestdata/tointegralx.decTest decimaltestdata/xor.decTest test_decimal.py Message-ID: Author: mark.dickinson Date: Thu Oct 8 18:28:39 2009 New Revision: 75286 Log: Update decimal test data to the most recent set from Mike Cowlishaw. Modified: python/trunk/Lib/test/decimaltestdata/abs.decTest python/trunk/Lib/test/decimaltestdata/add.decTest python/trunk/Lib/test/decimaltestdata/and.decTest python/trunk/Lib/test/decimaltestdata/base.decTest python/trunk/Lib/test/decimaltestdata/clamp.decTest python/trunk/Lib/test/decimaltestdata/class.decTest python/trunk/Lib/test/decimaltestdata/compare.decTest python/trunk/Lib/test/decimaltestdata/comparetotal.decTest python/trunk/Lib/test/decimaltestdata/comparetotmag.decTest python/trunk/Lib/test/decimaltestdata/copy.decTest python/trunk/Lib/test/decimaltestdata/copyabs.decTest python/trunk/Lib/test/decimaltestdata/copynegate.decTest python/trunk/Lib/test/decimaltestdata/copysign.decTest python/trunk/Lib/test/decimaltestdata/ddAbs.decTest python/trunk/Lib/test/decimaltestdata/ddAdd.decTest python/trunk/Lib/test/decimaltestdata/ddAnd.decTest python/trunk/Lib/test/decimaltestdata/ddBase.decTest python/trunk/Lib/test/decimaltestdata/ddCanonical.decTest python/trunk/Lib/test/decimaltestdata/ddClass.decTest python/trunk/Lib/test/decimaltestdata/ddCompare.decTest python/trunk/Lib/test/decimaltestdata/ddCompareSig.decTest python/trunk/Lib/test/decimaltestdata/ddCompareTotal.decTest python/trunk/Lib/test/decimaltestdata/ddCompareTotalMag.decTest python/trunk/Lib/test/decimaltestdata/ddCopy.decTest python/trunk/Lib/test/decimaltestdata/ddCopyAbs.decTest python/trunk/Lib/test/decimaltestdata/ddCopyNegate.decTest python/trunk/Lib/test/decimaltestdata/ddCopySign.decTest python/trunk/Lib/test/decimaltestdata/ddDivide.decTest python/trunk/Lib/test/decimaltestdata/ddDivideInt.decTest python/trunk/Lib/test/decimaltestdata/ddEncode.decTest python/trunk/Lib/test/decimaltestdata/ddFMA.decTest python/trunk/Lib/test/decimaltestdata/ddInvert.decTest python/trunk/Lib/test/decimaltestdata/ddLogB.decTest python/trunk/Lib/test/decimaltestdata/ddMax.decTest python/trunk/Lib/test/decimaltestdata/ddMaxMag.decTest python/trunk/Lib/test/decimaltestdata/ddMin.decTest python/trunk/Lib/test/decimaltestdata/ddMinMag.decTest python/trunk/Lib/test/decimaltestdata/ddMinus.decTest python/trunk/Lib/test/decimaltestdata/ddMultiply.decTest python/trunk/Lib/test/decimaltestdata/ddNextMinus.decTest python/trunk/Lib/test/decimaltestdata/ddNextPlus.decTest python/trunk/Lib/test/decimaltestdata/ddNextToward.decTest python/trunk/Lib/test/decimaltestdata/ddOr.decTest python/trunk/Lib/test/decimaltestdata/ddPlus.decTest python/trunk/Lib/test/decimaltestdata/ddQuantize.decTest python/trunk/Lib/test/decimaltestdata/ddReduce.decTest python/trunk/Lib/test/decimaltestdata/ddRemainder.decTest python/trunk/Lib/test/decimaltestdata/ddRemainderNear.decTest python/trunk/Lib/test/decimaltestdata/ddRotate.decTest python/trunk/Lib/test/decimaltestdata/ddSameQuantum.decTest python/trunk/Lib/test/decimaltestdata/ddScaleB.decTest python/trunk/Lib/test/decimaltestdata/ddShift.decTest python/trunk/Lib/test/decimaltestdata/ddSubtract.decTest python/trunk/Lib/test/decimaltestdata/ddToIntegral.decTest python/trunk/Lib/test/decimaltestdata/ddXor.decTest python/trunk/Lib/test/decimaltestdata/decDouble.decTest python/trunk/Lib/test/decimaltestdata/decQuad.decTest python/trunk/Lib/test/decimaltestdata/decSingle.decTest python/trunk/Lib/test/decimaltestdata/divide.decTest python/trunk/Lib/test/decimaltestdata/divideint.decTest python/trunk/Lib/test/decimaltestdata/dqAbs.decTest python/trunk/Lib/test/decimaltestdata/dqAdd.decTest python/trunk/Lib/test/decimaltestdata/dqAnd.decTest python/trunk/Lib/test/decimaltestdata/dqBase.decTest python/trunk/Lib/test/decimaltestdata/dqCanonical.decTest python/trunk/Lib/test/decimaltestdata/dqClass.decTest python/trunk/Lib/test/decimaltestdata/dqCompare.decTest python/trunk/Lib/test/decimaltestdata/dqCompareSig.decTest python/trunk/Lib/test/decimaltestdata/dqCompareTotal.decTest python/trunk/Lib/test/decimaltestdata/dqCompareTotalMag.decTest python/trunk/Lib/test/decimaltestdata/dqCopy.decTest python/trunk/Lib/test/decimaltestdata/dqCopyAbs.decTest python/trunk/Lib/test/decimaltestdata/dqCopyNegate.decTest python/trunk/Lib/test/decimaltestdata/dqCopySign.decTest python/trunk/Lib/test/decimaltestdata/dqDivide.decTest python/trunk/Lib/test/decimaltestdata/dqDivideInt.decTest python/trunk/Lib/test/decimaltestdata/dqEncode.decTest python/trunk/Lib/test/decimaltestdata/dqFMA.decTest python/trunk/Lib/test/decimaltestdata/dqInvert.decTest python/trunk/Lib/test/decimaltestdata/dqLogB.decTest python/trunk/Lib/test/decimaltestdata/dqMax.decTest python/trunk/Lib/test/decimaltestdata/dqMaxMag.decTest python/trunk/Lib/test/decimaltestdata/dqMin.decTest python/trunk/Lib/test/decimaltestdata/dqMinMag.decTest python/trunk/Lib/test/decimaltestdata/dqMinus.decTest python/trunk/Lib/test/decimaltestdata/dqMultiply.decTest python/trunk/Lib/test/decimaltestdata/dqNextMinus.decTest python/trunk/Lib/test/decimaltestdata/dqNextPlus.decTest python/trunk/Lib/test/decimaltestdata/dqNextToward.decTest python/trunk/Lib/test/decimaltestdata/dqOr.decTest python/trunk/Lib/test/decimaltestdata/dqPlus.decTest python/trunk/Lib/test/decimaltestdata/dqQuantize.decTest python/trunk/Lib/test/decimaltestdata/dqReduce.decTest python/trunk/Lib/test/decimaltestdata/dqRemainder.decTest python/trunk/Lib/test/decimaltestdata/dqRemainderNear.decTest python/trunk/Lib/test/decimaltestdata/dqRotate.decTest python/trunk/Lib/test/decimaltestdata/dqSameQuantum.decTest python/trunk/Lib/test/decimaltestdata/dqScaleB.decTest python/trunk/Lib/test/decimaltestdata/dqShift.decTest python/trunk/Lib/test/decimaltestdata/dqSubtract.decTest python/trunk/Lib/test/decimaltestdata/dqToIntegral.decTest python/trunk/Lib/test/decimaltestdata/dqXor.decTest python/trunk/Lib/test/decimaltestdata/dsBase.decTest python/trunk/Lib/test/decimaltestdata/dsEncode.decTest python/trunk/Lib/test/decimaltestdata/exp.decTest python/trunk/Lib/test/decimaltestdata/fma.decTest python/trunk/Lib/test/decimaltestdata/inexact.decTest python/trunk/Lib/test/decimaltestdata/invert.decTest python/trunk/Lib/test/decimaltestdata/ln.decTest python/trunk/Lib/test/decimaltestdata/log10.decTest python/trunk/Lib/test/decimaltestdata/logb.decTest python/trunk/Lib/test/decimaltestdata/max.decTest python/trunk/Lib/test/decimaltestdata/maxmag.decTest python/trunk/Lib/test/decimaltestdata/min.decTest python/trunk/Lib/test/decimaltestdata/minmag.decTest python/trunk/Lib/test/decimaltestdata/minus.decTest python/trunk/Lib/test/decimaltestdata/multiply.decTest python/trunk/Lib/test/decimaltestdata/nextminus.decTest python/trunk/Lib/test/decimaltestdata/nextplus.decTest python/trunk/Lib/test/decimaltestdata/nexttoward.decTest python/trunk/Lib/test/decimaltestdata/or.decTest python/trunk/Lib/test/decimaltestdata/plus.decTest python/trunk/Lib/test/decimaltestdata/power.decTest python/trunk/Lib/test/decimaltestdata/powersqrt.decTest python/trunk/Lib/test/decimaltestdata/quantize.decTest python/trunk/Lib/test/decimaltestdata/randomBound32.decTest python/trunk/Lib/test/decimaltestdata/randoms.decTest python/trunk/Lib/test/decimaltestdata/reduce.decTest python/trunk/Lib/test/decimaltestdata/remainder.decTest python/trunk/Lib/test/decimaltestdata/remainderNear.decTest python/trunk/Lib/test/decimaltestdata/rescale.decTest python/trunk/Lib/test/decimaltestdata/rotate.decTest python/trunk/Lib/test/decimaltestdata/rounding.decTest python/trunk/Lib/test/decimaltestdata/samequantum.decTest python/trunk/Lib/test/decimaltestdata/scaleb.decTest python/trunk/Lib/test/decimaltestdata/shift.decTest python/trunk/Lib/test/decimaltestdata/squareroot.decTest python/trunk/Lib/test/decimaltestdata/subtract.decTest python/trunk/Lib/test/decimaltestdata/testall.decTest python/trunk/Lib/test/decimaltestdata/tointegral.decTest python/trunk/Lib/test/decimaltestdata/tointegralx.decTest python/trunk/Lib/test/decimaltestdata/xor.decTest python/trunk/Lib/test/test_decimal.py Modified: python/trunk/Lib/test/decimaltestdata/abs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/abs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/abs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested Modified: python/trunk/Lib/test/decimaltestdata/add.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/add.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/add.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 9 rounding: half_up Modified: python/trunk/Lib/test/decimaltestdata/and.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/and.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/and.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/base.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/base.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/base.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 -- This file tests base conversions from string to a decimal number Modified: python/trunk/Lib/test/decimaltestdata/clamp.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/clamp.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/clamp.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific Modified: python/trunk/Lib/test/decimaltestdata/class.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/class.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/class.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/trunk/Lib/test/decimaltestdata/compare.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/compare.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/compare.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/comparetotal.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/comparetotal.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/comparetotal.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/comparetotmag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/comparetotmag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/comparetotmag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that it cannot be assumed that add/subtract tests cover paths -- for this operation adequately, here, because the code might be Modified: python/trunk/Lib/test/decimaltestdata/copy.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/copy.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/copy.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/copyabs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/copyabs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/copyabs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/copynegate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/copynegate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/copynegate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/copysign.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/copysign.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/copysign.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/ddAbs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddAbs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddAbs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddAdd.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddAdd.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddAdd.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/trunk/Lib/test/decimaltestdata/ddAnd.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddAnd.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddAnd.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddBase.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddBase.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddBase.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/trunk/Lib/test/decimaltestdata/ddCanonical.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCanonical.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCanonical.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/trunk/Lib/test/decimaltestdata/ddClass.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddClass.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddClass.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddCompare.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCompare.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCompare.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/ddCompareSig.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCompareSig.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCompareSig.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/ddCompareTotal.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCompareTotal.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCompareTotal.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/ddCompareTotalMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCompareTotalMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/ddCopy.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCopy.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCopy.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddCopyAbs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCopyAbs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCopyAbs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddCopyNegate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCopyNegate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCopyNegate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddCopySign.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddCopySign.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddCopySign.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddDivide.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddDivide.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddDivide.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 @@ -160,7 +160,7 @@ dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded --- test some cases that are close to exponent overflow +-- test some cases that are close to exponent overflow, some with coefficient padding dddiv270 divide 1 1e384 -> 1E-384 Subnormal dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow @@ -168,7 +168,16 @@ dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped -dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 +dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped +dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped +dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 + +dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped +dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded +dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped +dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded +dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped + -- Divide into 0 tests dddiv301 divide 0 7 -> 0 Modified: python/trunk/Lib/test/decimaltestdata/ddDivideInt.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddDivideInt.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddDivideInt.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddEncode.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddEncode.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddEncode.decTest Thu Oct 8 18:28:39 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal64.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: Modified: python/trunk/Lib/test/decimaltestdata/ddFMA.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddFMA.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddFMA.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddInvert.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddInvert.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddInvert.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddLogB.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddLogB.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddLogB.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddMax.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMax.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMax.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/ddMaxMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMaxMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMaxMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/ddMin.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMin.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMin.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/ddMinMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMinMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMinMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/ddMinus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMinus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMinus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddMultiply.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddMultiply.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddMultiply.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/trunk/Lib/test/decimaltestdata/ddNextMinus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddNextMinus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddNextMinus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddNextPlus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddNextPlus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddNextPlus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddNextToward.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddNextToward.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddNextToward.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddOr.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddOr.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddOr.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddPlus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddPlus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddPlus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddQuantize.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddQuantize.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddQuantize.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/trunk/Lib/test/decimaltestdata/ddReduce.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddReduce.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddReduce.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddRemainder.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddRemainder.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddRemainder.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddRemainderNear.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddRemainderNear.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddRemainderNear.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddRotate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddRotate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddRotate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddSameQuantum.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddSameQuantum.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddSameQuantum.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/ddScaleB.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddScaleB.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddScaleB.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddShift.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddShift.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddShift.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/ddSubtract.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddSubtract.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddSubtract.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/trunk/Lib/test/decimaltestdata/ddToIntegral.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddToIntegral.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddToIntegral.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/trunk/Lib/test/decimaltestdata/ddXor.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ddXor.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ddXor.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/trunk/Lib/test/decimaltestdata/decDouble.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/decDouble.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/decDouble.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decDouble tests dectest: ddAbs Modified: python/trunk/Lib/test/decimaltestdata/decQuad.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/decQuad.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/decQuad.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decQuad tests dectest: dqAbs Modified: python/trunk/Lib/test/decimaltestdata/decSingle.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/decSingle.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/decSingle.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decSingle tests dectest: dsBase Modified: python/trunk/Lib/test/decimaltestdata/divide.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/divide.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/divide.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/divideint.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/divideint.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/divideint.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/dqAbs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqAbs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqAbs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqAdd.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqAdd.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqAdd.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad @@ -637,7 +637,7 @@ dqadd7732 add 0 0 -> 0 dqadd7733 add 0 -0 -> 0 dqadd7734 add -0 0 -> 0 -dqadd7735 add -0 -0 -> -0 -- IEEE 854 special case +dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case dqadd7736 add 1 -1 -> 0 dqadd7737 add -1 -1 -> -2 Modified: python/trunk/Lib/test/decimaltestdata/dqAnd.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqAnd.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqAnd.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqBase.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqBase.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqBase.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/trunk/Lib/test/decimaltestdata/dqCanonical.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCanonical.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCanonical.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/trunk/Lib/test/decimaltestdata/dqClass.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqClass.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqClass.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/trunk/Lib/test/decimaltestdata/dqCompare.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCompare.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCompare.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/dqCompareSig.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCompareSig.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCompareSig.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/dqCompareTotal.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCompareTotal.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCompareTotal.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/dqCompareTotalMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCompareTotalMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/trunk/Lib/test/decimaltestdata/dqCopy.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCopy.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCopy.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqCopyAbs.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCopyAbs.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCopyAbs.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqCopyNegate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCopyNegate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCopyNegate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqCopySign.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqCopySign.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqCopySign.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqDivide.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqDivide.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqDivide.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqDivideInt.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqDivideInt.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqDivideInt.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqEncode.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqEncode.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqEncode.decTest Thu Oct 8 18:28:39 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal128.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: Modified: python/trunk/Lib/test/decimaltestdata/dqFMA.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqFMA.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqFMA.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqInvert.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqInvert.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqInvert.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqLogB.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqLogB.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqLogB.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqMax.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMax.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMax.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/dqMaxMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMaxMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMaxMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/dqMin.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMin.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMin.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/dqMinMag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMinMag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMinMag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/dqMinus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMinus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMinus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqMultiply.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqMultiply.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqMultiply.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/trunk/Lib/test/decimaltestdata/dqNextMinus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqNextMinus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqNextMinus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqNextPlus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqNextPlus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqNextPlus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqNextToward.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqNextToward.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqNextToward.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqOr.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqOr.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqOr.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqPlus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqPlus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqPlus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqQuantize.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqQuantize.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqQuantize.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. @@ -357,8 +357,6 @@ rounding: down dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation --- ? should that one instead have been: --- dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions Modified: python/trunk/Lib/test/decimaltestdata/dqReduce.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqReduce.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqReduce.decTest Thu Oct 8 18:28:39 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqRemainder.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqRemainder.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqRemainder.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqRemainderNear.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqRemainderNear.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqRemainderNear.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqRotate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqRotate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqRotate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqSameQuantum.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqSameQuantum.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqSameQuantum.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqScaleB.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqScaleB.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqScaleB.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqShift.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqShift.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqShift.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dqSubtract.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqSubtract.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqSubtract.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/trunk/Lib/test/decimaltestdata/dqToIntegral.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqToIntegral.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqToIntegral.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/trunk/Lib/test/decimaltestdata/dqXor.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dqXor.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dqXor.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/trunk/Lib/test/decimaltestdata/dsBase.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dsBase.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dsBase.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/trunk/Lib/test/decimaltestdata/dsEncode.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/dsEncode.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/dsEncode.decTest Thu Oct 8 18:28:39 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal32.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: Modified: python/trunk/Lib/test/decimaltestdata/exp.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/exp.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/exp.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Tests of the exponential funtion. Currently all testcases here -- show results which are correctly rounded (within <= 0.5 ulp). Modified: python/trunk/Lib/test/decimaltestdata/fma.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/fma.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/fma.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/inexact.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/inexact.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/inexact.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/invert.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/invert.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/invert.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/ln.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/ln.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/ln.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 16 Modified: python/trunk/Lib/test/decimaltestdata/log10.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/log10.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/log10.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). Modified: python/trunk/Lib/test/decimaltestdata/logb.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/logb.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/logb.decTest Thu Oct 8 18:28:39 2009 @@ -1,6 +1,6 @@ ------------------------------------------------------------------------ -- logb.decTest -- return integral adjusted exponent as per 754r -- --- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. -- +-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). @@ -143,7 +143,33 @@ logbx1419 logb 1000E2 -> 5 logbx1420 logb 10000E2 -> 6 +-- inexacts +precision: 2 +logbx1500 logb 10000E2 -> 6 +logbx1501 logb 1E+99 -> 99 +logbx1502 logb 1E-99 -> -99 +logbx1503 logb 1E+100 -> 1.0E+2 Rounded +logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded +logbx1505 logb 1E-100 -> -1.0E+2 Rounded +logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded +logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded +logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded +logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded +logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded +logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded +precision: 1 +logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded +logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded +logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded +precision: 8 +logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded +logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded +precision: 9 +logbx1523 logb 1E+999999999 -> 999999999 +logbx1524 logb 1E-999999999 -> -999999999 + -- special values +precision: 9 logbx820 logb Infinity -> Infinity logbx821 logb -Infinity -> Infinity logbx822 logb 0 -> -Infinity Division_by_zero Modified: python/trunk/Lib/test/decimaltestdata/max.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/max.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/max.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/maxmag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/maxmag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/maxmag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/min.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/min.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/min.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/minmag.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/minmag.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/minmag.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/trunk/Lib/test/decimaltestdata/minus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/minus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/minus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. Modified: python/trunk/Lib/test/decimaltestdata/multiply.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/multiply.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/multiply.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/nextminus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/nextminus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/nextminus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/nextplus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/nextplus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/nextplus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/nexttoward.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/nexttoward.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/nexttoward.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/or.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/or.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/or.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/plus.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/plus.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/plus.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. Modified: python/trunk/Lib/test/decimaltestdata/power.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/power.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/power.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- In addition to the power operator testcases here, see also the file -- powersqrt.decTest which includes all the tests from Modified: python/trunk/Lib/test/decimaltestdata/powersqrt.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/powersqrt.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/powersqrt.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases are taken from squareroot.decTest but are -- evaluated using the power operator. The differences in results Modified: python/trunk/Lib/test/decimaltestdata/quantize.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/quantize.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/quantize.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/trunk/Lib/test/decimaltestdata/randomBound32.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/randomBound32.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/randomBound32.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases test calculations at precisions 31, 32, and 33, to -- exercise the boundaries around 2**5 Modified: python/trunk/Lib/test/decimaltestdata/randoms.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/randoms.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/randoms.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 maxexponent: 999999999 Modified: python/trunk/Lib/test/decimaltestdata/reduce.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/reduce.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/reduce.decTest Thu Oct 8 18:28:39 2009 @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ -- [This used to be called normalize.] -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/remainder.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/remainder.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/remainder.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/remainderNear.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/remainderNear.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/remainderNear.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/rescale.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/rescale.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/rescale.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [obsolete] Quantize.decTest has the improved version Modified: python/trunk/Lib/test/decimaltestdata/rotate.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/rotate.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/rotate.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/rounding.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/rounding.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/rounding.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These tests require that implementations take account of residues in -- order to get correct results for some rounding modes. Rather than Modified: python/trunk/Lib/test/decimaltestdata/samequantum.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/samequantum.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/samequantum.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/scaleb.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/scaleb.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/scaleb.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -198,3 +198,12 @@ scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998 scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded + +-- Krah examples +precision: 34 +maxExponent: 999999999 +minExponent: -999999999 +-- integer overflow in 3.61 or earlier +scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation +-- out of range +scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation Modified: python/trunk/Lib/test/decimaltestdata/shift.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/shift.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/shift.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/squareroot.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/squareroot.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/squareroot.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -3812,6 +3812,16 @@ clamp: 1 sqtx9045 squareroot 1 -> 1.00000 Clamped +-- other +maxexponent: 999 +minexponent: -999 +precision: 16 +sqtx9046 squareroot 10 -> 3.162277660168379 inexact rounded +sqtx9047 squareroot 10E-1 -> 1.0 +sqtx9048 squareroot 10E-2 -> 0.3162277660168379 inexact rounded +sqtx9049 squareroot 10E-3 -> 0.10 + + -- High-precision exact and inexact maxexponent: 999 minexponent: -999 Modified: python/trunk/Lib/test/decimaltestdata/subtract.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/subtract.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/subtract.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/decimaltestdata/testall.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/testall.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/testall.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- core tests (using Extended: 1) -------------------------------------- dectest: base Modified: python/trunk/Lib/test/decimaltestdata/tointegral.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/tointegral.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/tointegral.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/trunk/Lib/test/decimaltestdata/tointegralx.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/tointegralx.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/tointegralx.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/trunk/Lib/test/decimaltestdata/xor.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/xor.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/xor.decTest Thu Oct 8 18:28:39 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/trunk/Lib/test/test_decimal.py ============================================================================== --- python/trunk/Lib/test/test_decimal.py (original) +++ python/trunk/Lib/test/test_decimal.py Thu Oct 8 18:28:39 2009 @@ -63,6 +63,13 @@ skip_expected = not os.path.isdir(directory) +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False @@ -262,6 +269,10 @@ val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val + + if id in skipped_test_ids: + return + fname = nameAdapter.get(funct, funct) if fname == 'rescale': return From python-checkins at python.org Thu Oct 8 18:30:39 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 16:30:39 -0000 Subject: [Python-checkins] r75287 - in python/branches/py3k: Lib/test/decimaltestdata/abs.decTest Lib/test/decimaltestdata/add.decTest Lib/test/decimaltestdata/and.decTest Lib/test/decimaltestdata/base.decTest Lib/test/decimaltestdata/clamp.decTest Lib/test/decimaltestdata/class.decTest Lib/test/decimaltestdata/compare.decTest Lib/test/decimaltestdata/comparetotal.decTest Lib/test/decimaltestdata/comparetotmag.decTest Lib/test/decimaltestdata/copy.decTest Lib/test/decimaltestdata/copyabs.decTest Lib/test/decimaltestdata/copynegate.decTest Lib/test/decimaltestdata/copysign.decTest Lib/test/decimaltestdata/ddAbs.decTest Lib/test/decimaltestdata/ddAdd.decTest Lib/test/decimaltestdata/ddAnd.decTest Lib/test/decimaltestdata/ddBase.decTest Lib/test/decimaltestdata/ddCanonical.decTest Lib/test/decimaltestdata/ddClass.decTest Lib/test/decimaltestdata/ddCompare.decTest Lib/test/decimaltestdata/ddCompareSig.decTest Lib/test/decimaltestdata/ddCompareTotal.decTest Lib/test/decimaltestdata/ddCompareTotalMag.decTest Lib/test/decimaltestdata/ddCopy.decTest Lib/test/decimaltestdata/ddCopyAbs.decTest Lib/test/decimaltestdata/ddCopyNegate.decTest Lib/test/decimaltestdata/ddCopySign.decTest Lib/test/decimaltestdata/ddDivide.decTest Lib/test/decimaltestdata/ddDivideInt.decTest Lib/test/decimaltestdata/ddEncode.decTest Lib/test/decimaltestdata/ddFMA.decTest Lib/test/decimaltestdata/ddInvert.decTest Lib/test/decimaltestdata/ddLogB.decTest Lib/test/decimaltestdata/ddMax.decTest Lib/test/decimaltestdata/ddMaxMag.decTest Lib/test/decimaltestdata/ddMin.decTest Lib/test/decimaltestdata/ddMinMag.decTest Lib/test/decimaltestdata/ddMinus.decTest Lib/test/decimaltestdata/ddMultiply.decTest Lib/test/decimaltestdata/ddNextMinus.decTest Lib/test/decimaltestdata/ddNextPlus.decTest Lib/test/decimaltestdata/ddNextToward.decTest Lib/test/decimaltestdata/ddOr.decTest Lib/test/decimaltestdata/ddPlus.decTest Lib/test/decimaltestdata/ddQuantize.decTest Lib/test/decimaltestdata/ddReduce.decTest Lib/test/decimaltestdata/ddRemainder.decTest Lib/test/decimaltestdata/ddRemainderNear.decTest Lib/test/decimaltestdata/ddRotate.decTest Lib/test/decimaltestdata/ddSameQuantum.decTest Lib/test/decimaltestdata/ddScaleB.decTest Lib/test/decimaltestdata/ddShift.decTest Lib/test/decimaltestdata/ddSubtract.decTest Lib/test/decimaltestdata/ddToIntegral.decTest Lib/test/decimaltestdata/ddXor.decTest Lib/test/decimaltestdata/decDouble.decTest Lib/test/decimaltestdata/decQuad.decTest Lib/test/decimaltestdata/decSingle.decTest Lib/test/decimaltestdata/divide.decTest Lib/test/decimaltestdata/divideint.decTest Lib/test/decimaltestdata/dqAbs.decTest Lib/test/decimaltestdata/dqAdd.decTest Lib/test/decimaltestdata/dqAnd.decTest Lib/test/decimaltestdata/dqBase.decTest Lib/test/decimaltestdata/dqCanonical.decTest Lib/test/decimaltestdata/dqClass.decTest Lib/test/decimaltestdata/dqCompare.decTest Lib/test/decimaltestdata/dqCompareSig.decTest Lib/test/decimaltestdata/dqCompareTotal.decTest Lib/test/decimaltestdata/dqCompareTotalMag.decTest Lib/test/decimaltestdata/dqCopy.decTest Lib/test/decimaltestdata/dqCopyAbs.decTest Lib/test/decimaltestdata/dqCopyNegate.decTest Lib/test/decimaltestdata/dqCopySign.decTest Lib/test/decimaltestdata/dqDivide.decTest Lib/test/decimaltestdata/dqDivideInt.decTest Lib/test/decimaltestdata/dqEncode.decTest Lib/test/decimaltestdata/dqFMA.decTest Lib/test/decimaltestdata/dqInvert.decTest Lib/test/decimaltestdata/dqLogB.decTest Lib/test/decimaltestdata/dqMax.decTest Lib/test/decimaltestdata/dqMaxMag.decTest Lib/test/decimaltestdata/dqMin.decTest Lib/test/decimaltestdata/dqMinMag.decTest Lib/test/decimaltestdata/dqMinus.decTest Lib/test/decimaltestdata/dqMultiply.decTest Lib/test/decimaltestdata/dqNextMinus.decTest Lib/test/decimaltestdata/dqNextPlus.decTest Lib/test/decimaltestdata/dqNextToward.decTest Lib/test/decimaltestdata/dqOr.decTest Lib/test/decimaltestdata/dqPlus.decTest Lib/test/decimaltestdata/dqQuantize.decTest Lib/test/decimaltestdata/dqReduce.decTest Lib/test/decimaltestdata/dqRemainder.decTest Lib/test/decimaltestdata/dqRemainderNear.decTest Lib/test/decimaltestdata/dqRotate.decTest Lib/test/decimaltestdata/dqSameQuantum.decTest Lib/test/decimaltestdata/dqScaleB.decTest Lib/test/decimaltestdata/dqShift.decTest Lib/test/decimaltestdata/dqSubtract.decTest Lib/test/decimaltestdata/dqToIntegral.decTest Lib/test/decimaltestdata/dqXor.decTest Lib/test/decimaltestdata/dsBase.decTest Lib/test/decimaltestdata/dsEncode.decTest Lib/test/decimaltestdata/exp.decTest Lib/test/decimaltestdata/fma.decTest Lib/test/decimaltestdata/inexact.decTest Lib/test/decimaltestdata/invert.decTest Lib/test/decimaltestdata/ln.decTest Lib/test/decimaltestdata/log10.decTest Lib/test/decimaltestdata/logb.decTest Lib/test/decimaltestdata/max.decTest Lib/test/decimaltestdata/maxmag.decTest Lib/test/decimaltestdata/min.decTest Lib/test/decimaltestdata/minmag.decTest Lib/test/decimaltestdata/minus.decTest Lib/test/decimaltestdata/multiply.decTest Lib/test/decimaltestdata/nextminus.decTest Lib/test/decimaltestdata/nextplus.decTest Lib/test/decimaltestdata/nexttoward.decTest Lib/test/decimaltestdata/or.decTest Lib/test/decimaltestdata/plus.decTest Lib/test/decimaltestdata/power.decTest Lib/test/decimaltestdata/powersqrt.decTest Lib/test/decimaltestdata/quantize.decTest Lib/test/decimaltestdata/randomBound32.decTest Lib/test/decimaltestdata/randoms.decTest Lib/test/decimaltestdata/reduce.decTest Lib/test/decimaltestdata/remainder.decTest Lib/test/decimaltestdata/remainderNear.decTest Lib/test/decimaltestdata/rescale.decTest Lib/test/decimaltestdata/rotate.decTest Lib/test/decimaltestdata/rounding.decTest Lib/test/decimaltestdata/samequantum.decTest Lib/test/decimaltestdata/scaleb.decTest Lib/test/decimaltestdata/shift.decTest Lib/test/decimaltestdata/squareroot.decTest Lib/test/decimaltestdata/subtract.decTest Lib/test/decimaltestdata/testall.decTest Lib/test/decimaltestdata/tointegral.decTest Lib/test/decimaltestdata/tointegralx.decTest Lib/test/decimaltestdata/xor.decTest Lib/test/test_decimal.py Message-ID: Author: mark.dickinson Date: Thu Oct 8 18:30:38 2009 New Revision: 75287 Log: Merged revisions 75286 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75286 | mark.dickinson | 2009-10-08 17:28:39 +0100 (Thu, 08 Oct 2009) | 2 lines Update decimal test data to the most recent set from Mike Cowlishaw. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/decimaltestdata/abs.decTest python/branches/py3k/Lib/test/decimaltestdata/add.decTest python/branches/py3k/Lib/test/decimaltestdata/and.decTest python/branches/py3k/Lib/test/decimaltestdata/base.decTest python/branches/py3k/Lib/test/decimaltestdata/clamp.decTest python/branches/py3k/Lib/test/decimaltestdata/class.decTest python/branches/py3k/Lib/test/decimaltestdata/compare.decTest python/branches/py3k/Lib/test/decimaltestdata/comparetotal.decTest python/branches/py3k/Lib/test/decimaltestdata/comparetotmag.decTest python/branches/py3k/Lib/test/decimaltestdata/copy.decTest python/branches/py3k/Lib/test/decimaltestdata/copyabs.decTest python/branches/py3k/Lib/test/decimaltestdata/copynegate.decTest python/branches/py3k/Lib/test/decimaltestdata/copysign.decTest python/branches/py3k/Lib/test/decimaltestdata/ddAbs.decTest python/branches/py3k/Lib/test/decimaltestdata/ddAdd.decTest python/branches/py3k/Lib/test/decimaltestdata/ddAnd.decTest python/branches/py3k/Lib/test/decimaltestdata/ddBase.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCanonical.decTest python/branches/py3k/Lib/test/decimaltestdata/ddClass.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCompare.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCompareSig.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotal.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotalMag.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCopy.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCopyAbs.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCopyNegate.decTest python/branches/py3k/Lib/test/decimaltestdata/ddCopySign.decTest python/branches/py3k/Lib/test/decimaltestdata/ddDivide.decTest python/branches/py3k/Lib/test/decimaltestdata/ddDivideInt.decTest python/branches/py3k/Lib/test/decimaltestdata/ddEncode.decTest python/branches/py3k/Lib/test/decimaltestdata/ddFMA.decTest python/branches/py3k/Lib/test/decimaltestdata/ddInvert.decTest python/branches/py3k/Lib/test/decimaltestdata/ddLogB.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMax.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMaxMag.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMin.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMinMag.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMinus.decTest python/branches/py3k/Lib/test/decimaltestdata/ddMultiply.decTest python/branches/py3k/Lib/test/decimaltestdata/ddNextMinus.decTest python/branches/py3k/Lib/test/decimaltestdata/ddNextPlus.decTest python/branches/py3k/Lib/test/decimaltestdata/ddNextToward.decTest python/branches/py3k/Lib/test/decimaltestdata/ddOr.decTest python/branches/py3k/Lib/test/decimaltestdata/ddPlus.decTest python/branches/py3k/Lib/test/decimaltestdata/ddQuantize.decTest python/branches/py3k/Lib/test/decimaltestdata/ddReduce.decTest python/branches/py3k/Lib/test/decimaltestdata/ddRemainder.decTest python/branches/py3k/Lib/test/decimaltestdata/ddRemainderNear.decTest python/branches/py3k/Lib/test/decimaltestdata/ddRotate.decTest python/branches/py3k/Lib/test/decimaltestdata/ddSameQuantum.decTest python/branches/py3k/Lib/test/decimaltestdata/ddScaleB.decTest python/branches/py3k/Lib/test/decimaltestdata/ddShift.decTest python/branches/py3k/Lib/test/decimaltestdata/ddSubtract.decTest python/branches/py3k/Lib/test/decimaltestdata/ddToIntegral.decTest python/branches/py3k/Lib/test/decimaltestdata/ddXor.decTest python/branches/py3k/Lib/test/decimaltestdata/decDouble.decTest python/branches/py3k/Lib/test/decimaltestdata/decQuad.decTest python/branches/py3k/Lib/test/decimaltestdata/decSingle.decTest python/branches/py3k/Lib/test/decimaltestdata/divide.decTest python/branches/py3k/Lib/test/decimaltestdata/divideint.decTest python/branches/py3k/Lib/test/decimaltestdata/dqAbs.decTest python/branches/py3k/Lib/test/decimaltestdata/dqAdd.decTest python/branches/py3k/Lib/test/decimaltestdata/dqAnd.decTest python/branches/py3k/Lib/test/decimaltestdata/dqBase.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCanonical.decTest python/branches/py3k/Lib/test/decimaltestdata/dqClass.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCompare.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCompareSig.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotal.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotalMag.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCopy.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCopyAbs.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCopyNegate.decTest python/branches/py3k/Lib/test/decimaltestdata/dqCopySign.decTest python/branches/py3k/Lib/test/decimaltestdata/dqDivide.decTest python/branches/py3k/Lib/test/decimaltestdata/dqDivideInt.decTest python/branches/py3k/Lib/test/decimaltestdata/dqEncode.decTest python/branches/py3k/Lib/test/decimaltestdata/dqFMA.decTest python/branches/py3k/Lib/test/decimaltestdata/dqInvert.decTest python/branches/py3k/Lib/test/decimaltestdata/dqLogB.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMax.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMaxMag.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMin.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMinMag.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMinus.decTest python/branches/py3k/Lib/test/decimaltestdata/dqMultiply.decTest python/branches/py3k/Lib/test/decimaltestdata/dqNextMinus.decTest python/branches/py3k/Lib/test/decimaltestdata/dqNextPlus.decTest python/branches/py3k/Lib/test/decimaltestdata/dqNextToward.decTest python/branches/py3k/Lib/test/decimaltestdata/dqOr.decTest python/branches/py3k/Lib/test/decimaltestdata/dqPlus.decTest python/branches/py3k/Lib/test/decimaltestdata/dqQuantize.decTest python/branches/py3k/Lib/test/decimaltestdata/dqReduce.decTest python/branches/py3k/Lib/test/decimaltestdata/dqRemainder.decTest python/branches/py3k/Lib/test/decimaltestdata/dqRemainderNear.decTest python/branches/py3k/Lib/test/decimaltestdata/dqRotate.decTest python/branches/py3k/Lib/test/decimaltestdata/dqSameQuantum.decTest python/branches/py3k/Lib/test/decimaltestdata/dqScaleB.decTest python/branches/py3k/Lib/test/decimaltestdata/dqShift.decTest python/branches/py3k/Lib/test/decimaltestdata/dqSubtract.decTest python/branches/py3k/Lib/test/decimaltestdata/dqToIntegral.decTest python/branches/py3k/Lib/test/decimaltestdata/dqXor.decTest python/branches/py3k/Lib/test/decimaltestdata/dsBase.decTest python/branches/py3k/Lib/test/decimaltestdata/dsEncode.decTest python/branches/py3k/Lib/test/decimaltestdata/exp.decTest python/branches/py3k/Lib/test/decimaltestdata/fma.decTest python/branches/py3k/Lib/test/decimaltestdata/inexact.decTest python/branches/py3k/Lib/test/decimaltestdata/invert.decTest python/branches/py3k/Lib/test/decimaltestdata/ln.decTest python/branches/py3k/Lib/test/decimaltestdata/log10.decTest python/branches/py3k/Lib/test/decimaltestdata/logb.decTest python/branches/py3k/Lib/test/decimaltestdata/max.decTest python/branches/py3k/Lib/test/decimaltestdata/maxmag.decTest python/branches/py3k/Lib/test/decimaltestdata/min.decTest python/branches/py3k/Lib/test/decimaltestdata/minmag.decTest python/branches/py3k/Lib/test/decimaltestdata/minus.decTest python/branches/py3k/Lib/test/decimaltestdata/multiply.decTest python/branches/py3k/Lib/test/decimaltestdata/nextminus.decTest python/branches/py3k/Lib/test/decimaltestdata/nextplus.decTest python/branches/py3k/Lib/test/decimaltestdata/nexttoward.decTest python/branches/py3k/Lib/test/decimaltestdata/or.decTest python/branches/py3k/Lib/test/decimaltestdata/plus.decTest python/branches/py3k/Lib/test/decimaltestdata/power.decTest python/branches/py3k/Lib/test/decimaltestdata/powersqrt.decTest python/branches/py3k/Lib/test/decimaltestdata/quantize.decTest python/branches/py3k/Lib/test/decimaltestdata/randomBound32.decTest python/branches/py3k/Lib/test/decimaltestdata/randoms.decTest python/branches/py3k/Lib/test/decimaltestdata/reduce.decTest python/branches/py3k/Lib/test/decimaltestdata/remainder.decTest python/branches/py3k/Lib/test/decimaltestdata/remainderNear.decTest python/branches/py3k/Lib/test/decimaltestdata/rescale.decTest python/branches/py3k/Lib/test/decimaltestdata/rotate.decTest python/branches/py3k/Lib/test/decimaltestdata/rounding.decTest python/branches/py3k/Lib/test/decimaltestdata/samequantum.decTest python/branches/py3k/Lib/test/decimaltestdata/scaleb.decTest python/branches/py3k/Lib/test/decimaltestdata/shift.decTest python/branches/py3k/Lib/test/decimaltestdata/squareroot.decTest python/branches/py3k/Lib/test/decimaltestdata/subtract.decTest python/branches/py3k/Lib/test/decimaltestdata/testall.decTest python/branches/py3k/Lib/test/decimaltestdata/tointegral.decTest python/branches/py3k/Lib/test/decimaltestdata/tointegralx.decTest python/branches/py3k/Lib/test/decimaltestdata/xor.decTest python/branches/py3k/Lib/test/test_decimal.py Modified: python/branches/py3k/Lib/test/decimaltestdata/abs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/abs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/abs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested Modified: python/branches/py3k/Lib/test/decimaltestdata/add.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/add.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/add.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 9 rounding: half_up Modified: python/branches/py3k/Lib/test/decimaltestdata/and.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/and.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/and.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/base.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/base.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/base.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 -- This file tests base conversions from string to a decimal number Modified: python/branches/py3k/Lib/test/decimaltestdata/clamp.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/clamp.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/clamp.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific Modified: python/branches/py3k/Lib/test/decimaltestdata/class.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/class.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/class.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/py3k/Lib/test/decimaltestdata/compare.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/compare.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/compare.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/comparetotal.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/comparetotal.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/comparetotal.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/comparetotmag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/comparetotmag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/comparetotmag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that it cannot be assumed that add/subtract tests cover paths -- for this operation adequately, here, because the code might be Modified: python/branches/py3k/Lib/test/decimaltestdata/copy.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/copy.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/copy.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/copyabs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/copyabs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/copyabs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/copynegate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/copynegate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/copynegate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/copysign.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/copysign.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/copysign.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddAbs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddAbs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddAbs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddAdd.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddAdd.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddAdd.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/py3k/Lib/test/decimaltestdata/ddAnd.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddAnd.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddAnd.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddBase.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddBase.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddBase.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCanonical.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCanonical.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCanonical.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/py3k/Lib/test/decimaltestdata/ddClass.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddClass.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddClass.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCompare.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCompare.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCompare.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCompareSig.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCompareSig.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCompareSig.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotal.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotal.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotal.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotalMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCompareTotalMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCopy.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCopy.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCopy.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCopyAbs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCopyAbs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCopyAbs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCopyNegate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCopyNegate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCopyNegate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddCopySign.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddCopySign.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddCopySign.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddDivide.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddDivide.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddDivide.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 @@ -160,7 +160,7 @@ dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded --- test some cases that are close to exponent overflow +-- test some cases that are close to exponent overflow, some with coefficient padding dddiv270 divide 1 1e384 -> 1E-384 Subnormal dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow @@ -168,7 +168,16 @@ dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped -dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 +dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped +dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped +dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 + +dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped +dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded +dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped +dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded +dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped + -- Divide into 0 tests dddiv301 divide 0 7 -> 0 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddDivideInt.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddDivideInt.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddDivideInt.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddEncode.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddEncode.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddEncode.decTest Thu Oct 8 18:30:38 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal64.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: Modified: python/branches/py3k/Lib/test/decimaltestdata/ddFMA.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddFMA.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddFMA.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddInvert.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddInvert.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddInvert.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddLogB.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddLogB.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddLogB.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMax.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMax.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMax.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMaxMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMaxMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMaxMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMin.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMin.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMin.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMinMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMinMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMinMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMinus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMinus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMinus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddMultiply.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddMultiply.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddMultiply.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/py3k/Lib/test/decimaltestdata/ddNextMinus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddNextMinus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddNextMinus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddNextPlus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddNextPlus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddNextPlus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddNextToward.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddNextToward.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddNextToward.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddOr.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddOr.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddOr.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddPlus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddPlus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddPlus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddQuantize.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddQuantize.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddQuantize.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/py3k/Lib/test/decimaltestdata/ddReduce.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddReduce.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddReduce.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddRemainder.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddRemainder.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddRemainder.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddRemainderNear.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddRemainderNear.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddRemainderNear.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddRotate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddRotate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddRotate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddSameQuantum.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddSameQuantum.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddSameQuantum.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddScaleB.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddScaleB.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddScaleB.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddShift.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddShift.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddShift.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/ddSubtract.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddSubtract.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddSubtract.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/py3k/Lib/test/decimaltestdata/ddToIntegral.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddToIntegral.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddToIntegral.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/py3k/Lib/test/decimaltestdata/ddXor.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ddXor.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ddXor.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/py3k/Lib/test/decimaltestdata/decDouble.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/decDouble.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/decDouble.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decDouble tests dectest: ddAbs Modified: python/branches/py3k/Lib/test/decimaltestdata/decQuad.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/decQuad.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/decQuad.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decQuad tests dectest: dqAbs Modified: python/branches/py3k/Lib/test/decimaltestdata/decSingle.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/decSingle.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/decSingle.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decSingle tests dectest: dsBase Modified: python/branches/py3k/Lib/test/decimaltestdata/divide.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/divide.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/divide.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/divideint.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/divideint.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/divideint.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqAbs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqAbs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqAbs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqAdd.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqAdd.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqAdd.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad @@ -637,7 +637,7 @@ dqadd7732 add 0 0 -> 0 dqadd7733 add 0 -0 -> 0 dqadd7734 add -0 0 -> 0 -dqadd7735 add -0 -0 -> -0 -- IEEE 854 special case +dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case dqadd7736 add 1 -1 -> 0 dqadd7737 add -1 -1 -> -2 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqAnd.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqAnd.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqAnd.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqBase.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqBase.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqBase.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCanonical.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCanonical.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCanonical.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/py3k/Lib/test/decimaltestdata/dqClass.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqClass.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqClass.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCompare.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCompare.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCompare.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCompareSig.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCompareSig.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCompareSig.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotal.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotal.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotal.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotalMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCompareTotalMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCopy.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCopy.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCopy.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCopyAbs.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCopyAbs.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCopyAbs.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCopyNegate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCopyNegate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCopyNegate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqCopySign.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqCopySign.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqCopySign.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqDivide.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqDivide.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqDivide.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqDivideInt.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqDivideInt.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqDivideInt.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqEncode.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqEncode.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqEncode.decTest Thu Oct 8 18:30:38 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal128.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: Modified: python/branches/py3k/Lib/test/decimaltestdata/dqFMA.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqFMA.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqFMA.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqInvert.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqInvert.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqInvert.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqLogB.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqLogB.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqLogB.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMax.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMax.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMax.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMaxMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMaxMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMaxMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMin.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMin.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMin.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMinMag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMinMag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMinMag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMinus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMinus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMinus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqMultiply.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqMultiply.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqMultiply.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/py3k/Lib/test/decimaltestdata/dqNextMinus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqNextMinus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqNextMinus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqNextPlus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqNextPlus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqNextPlus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqNextToward.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqNextToward.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqNextToward.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqOr.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqOr.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqOr.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqPlus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqPlus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqPlus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqQuantize.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqQuantize.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqQuantize.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. @@ -357,8 +357,6 @@ rounding: down dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation --- ? should that one instead have been: --- dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions Modified: python/branches/py3k/Lib/test/decimaltestdata/dqReduce.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqReduce.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqReduce.decTest Thu Oct 8 18:30:38 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqRemainder.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqRemainder.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqRemainder.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqRemainderNear.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqRemainderNear.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqRemainderNear.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqRotate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqRotate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqRotate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqSameQuantum.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqSameQuantum.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqSameQuantum.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqScaleB.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqScaleB.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqScaleB.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqShift.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqShift.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqShift.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dqSubtract.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqSubtract.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqSubtract.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/py3k/Lib/test/decimaltestdata/dqToIntegral.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqToIntegral.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqToIntegral.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/py3k/Lib/test/decimaltestdata/dqXor.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dqXor.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dqXor.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/py3k/Lib/test/decimaltestdata/dsBase.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dsBase.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dsBase.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/py3k/Lib/test/decimaltestdata/dsEncode.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/dsEncode.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/dsEncode.decTest Thu Oct 8 18:30:38 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal32.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: Modified: python/branches/py3k/Lib/test/decimaltestdata/exp.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/exp.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/exp.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Tests of the exponential funtion. Currently all testcases here -- show results which are correctly rounded (within <= 0.5 ulp). Modified: python/branches/py3k/Lib/test/decimaltestdata/fma.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/fma.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/fma.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/inexact.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/inexact.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/inexact.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/invert.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/invert.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/invert.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/ln.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/ln.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/ln.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 16 Modified: python/branches/py3k/Lib/test/decimaltestdata/log10.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/log10.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/log10.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). Modified: python/branches/py3k/Lib/test/decimaltestdata/logb.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/logb.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/logb.decTest Thu Oct 8 18:30:38 2009 @@ -1,6 +1,6 @@ ------------------------------------------------------------------------ -- logb.decTest -- return integral adjusted exponent as per 754r -- --- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. -- +-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). @@ -143,7 +143,33 @@ logbx1419 logb 1000E2 -> 5 logbx1420 logb 10000E2 -> 6 +-- inexacts +precision: 2 +logbx1500 logb 10000E2 -> 6 +logbx1501 logb 1E+99 -> 99 +logbx1502 logb 1E-99 -> -99 +logbx1503 logb 1E+100 -> 1.0E+2 Rounded +logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded +logbx1505 logb 1E-100 -> -1.0E+2 Rounded +logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded +logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded +logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded +logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded +logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded +logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded +precision: 1 +logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded +logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded +logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded +precision: 8 +logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded +logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded +precision: 9 +logbx1523 logb 1E+999999999 -> 999999999 +logbx1524 logb 1E-999999999 -> -999999999 + -- special values +precision: 9 logbx820 logb Infinity -> Infinity logbx821 logb -Infinity -> Infinity logbx822 logb 0 -> -Infinity Division_by_zero Modified: python/branches/py3k/Lib/test/decimaltestdata/max.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/max.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/max.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/maxmag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/maxmag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/maxmag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/min.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/min.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/min.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/minmag.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/minmag.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/minmag.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/py3k/Lib/test/decimaltestdata/minus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/minus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/minus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. Modified: python/branches/py3k/Lib/test/decimaltestdata/multiply.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/multiply.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/multiply.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/nextminus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/nextminus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/nextminus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/nextplus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/nextplus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/nextplus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/nexttoward.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/nexttoward.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/nexttoward.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/or.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/or.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/or.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/plus.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/plus.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/plus.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. Modified: python/branches/py3k/Lib/test/decimaltestdata/power.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/power.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/power.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- In addition to the power operator testcases here, see also the file -- powersqrt.decTest which includes all the tests from Modified: python/branches/py3k/Lib/test/decimaltestdata/powersqrt.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/powersqrt.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/powersqrt.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases are taken from squareroot.decTest but are -- evaluated using the power operator. The differences in results Modified: python/branches/py3k/Lib/test/decimaltestdata/quantize.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/quantize.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/quantize.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/py3k/Lib/test/decimaltestdata/randomBound32.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/randomBound32.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/randomBound32.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases test calculations at precisions 31, 32, and 33, to -- exercise the boundaries around 2**5 Modified: python/branches/py3k/Lib/test/decimaltestdata/randoms.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/randoms.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/randoms.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 maxexponent: 999999999 Modified: python/branches/py3k/Lib/test/decimaltestdata/reduce.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/reduce.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/reduce.decTest Thu Oct 8 18:30:38 2009 @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ -- [This used to be called normalize.] -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/remainder.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/remainder.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/remainder.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/remainderNear.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/remainderNear.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/remainderNear.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/rescale.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/rescale.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/rescale.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [obsolete] Quantize.decTest has the improved version Modified: python/branches/py3k/Lib/test/decimaltestdata/rotate.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/rotate.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/rotate.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/rounding.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/rounding.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/rounding.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These tests require that implementations take account of residues in -- order to get correct results for some rounding modes. Rather than Modified: python/branches/py3k/Lib/test/decimaltestdata/samequantum.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/samequantum.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/samequantum.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/scaleb.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/scaleb.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/scaleb.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -198,3 +198,12 @@ scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998 scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded + +-- Krah examples +precision: 34 +maxExponent: 999999999 +minExponent: -999999999 +-- integer overflow in 3.61 or earlier +scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation +-- out of range +scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation Modified: python/branches/py3k/Lib/test/decimaltestdata/shift.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/shift.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/shift.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/squareroot.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/squareroot.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/squareroot.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -3812,6 +3812,16 @@ clamp: 1 sqtx9045 squareroot 1 -> 1.00000 Clamped +-- other +maxexponent: 999 +minexponent: -999 +precision: 16 +sqtx9046 squareroot 10 -> 3.162277660168379 inexact rounded +sqtx9047 squareroot 10E-1 -> 1.0 +sqtx9048 squareroot 10E-2 -> 0.3162277660168379 inexact rounded +sqtx9049 squareroot 10E-3 -> 0.10 + + -- High-precision exact and inexact maxexponent: 999 minexponent: -999 Modified: python/branches/py3k/Lib/test/decimaltestdata/subtract.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/subtract.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/subtract.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/decimaltestdata/testall.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/testall.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/testall.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- core tests (using Extended: 1) -------------------------------------- dectest: base Modified: python/branches/py3k/Lib/test/decimaltestdata/tointegral.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/tointegral.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/tointegral.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/py3k/Lib/test/decimaltestdata/tointegralx.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/tointegralx.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/tointegralx.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/py3k/Lib/test/decimaltestdata/xor.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/xor.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/xor.decTest Thu Oct 8 18:30:38 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Thu Oct 8 18:30:38 2009 @@ -63,6 +63,13 @@ skip_expected = not os.path.isdir(directory) +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False @@ -262,6 +269,10 @@ val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val + + if id in skipped_test_ids: + return + fname = nameAdapter.get(funct, funct) if fname == 'rescale': return From python-checkins at python.org Thu Oct 8 18:33:07 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 16:33:07 -0000 Subject: [Python-checkins] r75288 - in python/branches/release31-maint: Lib/test/decimaltestdata/abs.decTest Lib/test/decimaltestdata/add.decTest Lib/test/decimaltestdata/and.decTest Lib/test/decimaltestdata/base.decTest Lib/test/decimaltestdata/clamp.decTest Lib/test/decimaltestdata/class.decTest Lib/test/decimaltestdata/compare.decTest Lib/test/decimaltestdata/comparetotal.decTest Lib/test/decimaltestdata/comparetotmag.decTest Lib/test/decimaltestdata/copy.decTest Lib/test/decimaltestdata/copyabs.decTest Lib/test/decimaltestdata/copynegate.decTest Lib/test/decimaltestdata/copysign.decTest Lib/test/decimaltestdata/ddAbs.decTest Lib/test/decimaltestdata/ddAdd.decTest Lib/test/decimaltestdata/ddAnd.decTest Lib/test/decimaltestdata/ddBase.decTest Lib/test/decimaltestdata/ddCanonical.decTest Lib/test/decimaltestdata/ddClass.decTest Lib/test/decimaltestdata/ddCompare.decTest Lib/test/decimaltestdata/ddCompareSig.decTest Lib/test/decimaltestdata/ddCompareTotal.decTest Lib/test/decimaltestdata/ddCompareTotalMag.decTest Lib/test/decimaltestdata/ddCopy.decTest Lib/test/decimaltestdata/ddCopyAbs.decTest Lib/test/decimaltestdata/ddCopyNegate.decTest Lib/test/decimaltestdata/ddCopySign.decTest Lib/test/decimaltestdata/ddDivide.decTest Lib/test/decimaltestdata/ddDivideInt.decTest Lib/test/decimaltestdata/ddEncode.decTest Lib/test/decimaltestdata/ddFMA.decTest Lib/test/decimaltestdata/ddInvert.decTest Lib/test/decimaltestdata/ddLogB.decTest Lib/test/decimaltestdata/ddMax.decTest Lib/test/decimaltestdata/ddMaxMag.decTest Lib/test/decimaltestdata/ddMin.decTest Lib/test/decimaltestdata/ddMinMag.decTest Lib/test/decimaltestdata/ddMinus.decTest Lib/test/decimaltestdata/ddMultiply.decTest Lib/test/decimaltestdata/ddNextMinus.decTest Lib/test/decimaltestdata/ddNextPlus.decTest Lib/test/decimaltestdata/ddNextToward.decTest Lib/test/decimaltestdata/ddOr.decTest Lib/test/decimaltestdata/ddPlus.decTest Lib/test/decimaltestdata/ddQuantize.decTest Lib/test/decimaltestdata/ddReduce.decTest Lib/test/decimaltestdata/ddRemainder.decTest Lib/test/decimaltestdata/ddRemainderNear.decTest Lib/test/decimaltestdata/ddRotate.decTest Lib/test/decimaltestdata/ddSameQuantum.decTest Lib/test/decimaltestdata/ddScaleB.decTest Lib/test/decimaltestdata/ddShift.decTest Lib/test/decimaltestdata/ddSubtract.decTest Lib/test/decimaltestdata/ddToIntegral.decTest Lib/test/decimaltestdata/ddXor.decTest Lib/test/decimaltestdata/decDouble.decTest Lib/test/decimaltestdata/decQuad.decTest Lib/test/decimaltestdata/decSingle.decTest Lib/test/decimaltestdata/divide.decTest Lib/test/decimaltestdata/divideint.decTest Lib/test/decimaltestdata/dqAbs.decTest Lib/test/decimaltestdata/dqAdd.decTest Lib/test/decimaltestdata/dqAnd.decTest Lib/test/decimaltestdata/dqBase.decTest Lib/test/decimaltestdata/dqCanonical.decTest Lib/test/decimaltestdata/dqClass.decTest Lib/test/decimaltestdata/dqCompare.decTest Lib/test/decimaltestdata/dqCompareSig.decTest Lib/test/decimaltestdata/dqCompareTotal.decTest Lib/test/decimaltestdata/dqCompareTotalMag.decTest Lib/test/decimaltestdata/dqCopy.decTest Lib/test/decimaltestdata/dqCopyAbs.decTest Lib/test/decimaltestdata/dqCopyNegate.decTest Lib/test/decimaltestdata/dqCopySign.decTest Lib/test/decimaltestdata/dqDivide.decTest Lib/test/decimaltestdata/dqDivideInt.decTest Lib/test/decimaltestdata/dqEncode.decTest Lib/test/decimaltestdata/dqFMA.decTest Lib/test/decimaltestdata/dqInvert.decTest Lib/test/decimaltestdata/dqLogB.decTest Lib/test/decimaltestdata/dqMax.decTest Lib/test/decimaltestdata/dqMaxMag.decTest Lib/test/decimaltestdata/dqMin.decTest Lib/test/decimaltestdata/dqMinMag.decTest Lib/test/decimaltestdata/dqMinus.decTest Lib/test/decimaltestdata/dqMultiply.decTest Lib/test/decimaltestdata/dqNextMinus.decTest Lib/test/decimaltestdata/dqNextPlus.decTest Lib/test/decimaltestdata/dqNextToward.decTest Lib/test/decimaltestdata/dqOr.decTest Lib/test/decimaltestdata/dqPlus.decTest Lib/test/decimaltestdata/dqQuantize.decTest Lib/test/decimaltestdata/dqReduce.decTest Lib/test/decimaltestdata/dqRemainder.decTest Lib/test/decimaltestdata/dqRemainderNear.decTest Lib/test/decimaltestdata/dqRotate.decTest Lib/test/decimaltestdata/dqSameQuantum.decTest Lib/test/decimaltestdata/dqScaleB.decTest Lib/test/decimaltestdata/dqShift.decTest Lib/test/decimaltestdata/dqSubtract.decTest Lib/test/decimaltestdata/dqToIntegral.decTest Lib/test/decimaltestdata/dqXor.decTest Lib/test/decimaltestdata/dsBase.decTest Lib/test/decimaltestdata/dsEncode.decTest Lib/test/decimaltestdata/exp.decTest Lib/test/decimaltestdata/fma.decTest Lib/test/decimaltestdata/inexact.decTest Lib/test/decimaltestdata/invert.decTest Lib/test/decimaltestdata/ln.decTest Lib/test/decimaltestdata/log10.decTest Lib/test/decimaltestdata/logb.decTest Lib/test/decimaltestdata/max.decTest Lib/test/decimaltestdata/maxmag.decTest Lib/test/decimaltestdata/min.decTest Lib/test/decimaltestdata/minmag.decTest Lib/test/decimaltestdata/minus.decTest Lib/test/decimaltestdata/multiply.decTest Lib/test/decimaltestdata/nextminus.decTest Lib/test/decimaltestdata/nextplus.decTest Lib/test/decimaltestdata/nexttoward.decTest Lib/test/decimaltestdata/or.decTest Lib/test/decimaltestdata/plus.decTest Lib/test/decimaltestdata/power.decTest Lib/test/decimaltestdata/powersqrt.decTest Lib/test/decimaltestdata/quantize.decTest Lib/test/decimaltestdata/randomBound32.decTest Lib/test/decimaltestdata/randoms.decTest Lib/test/decimaltestdata/reduce.decTest Lib/test/decimaltestdata/remainder.decTest Lib/test/decimaltestdata/remainderNear.decTest Lib/test/decimaltestdata/rescale.decTest Lib/test/decimaltestdata/rotate.decTest Lib/test/decimaltestdata/rounding.decTest Lib/test/decimaltestdata/samequantum.decTest Lib/test/decimaltestdata/scaleb.decTest Lib/test/decimaltestdata/shift.decTest Lib/test/decimaltestdata/squareroot.decTest Lib/test/decimaltestdata/subtract.decTest Lib/test/decimaltestdata/testall.decTest Lib/test/decimaltestdata/tointegral.decTest Lib/test/decimaltestdata/tointegralx.decTest Lib/test/decimaltestdata/xor.decTest Lib/test/test_decimal.py Message-ID: Author: mark.dickinson Date: Thu Oct 8 18:33:06 2009 New Revision: 75288 Log: Merged revisions 75287 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75287 | mark.dickinson | 2009-10-08 17:30:38 +0100 (Thu, 08 Oct 2009) | 9 lines Merged revisions 75286 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75286 | mark.dickinson | 2009-10-08 17:28:39 +0100 (Thu, 08 Oct 2009) | 2 lines Update decimal test data to the most recent set from Mike Cowlishaw. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/decimaltestdata/abs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/add.decTest python/branches/release31-maint/Lib/test/decimaltestdata/and.decTest python/branches/release31-maint/Lib/test/decimaltestdata/base.decTest python/branches/release31-maint/Lib/test/decimaltestdata/clamp.decTest python/branches/release31-maint/Lib/test/decimaltestdata/class.decTest python/branches/release31-maint/Lib/test/decimaltestdata/compare.decTest python/branches/release31-maint/Lib/test/decimaltestdata/comparetotal.decTest python/branches/release31-maint/Lib/test/decimaltestdata/comparetotmag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/copy.decTest python/branches/release31-maint/Lib/test/decimaltestdata/copyabs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/copynegate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/copysign.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddAbs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddAdd.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddAnd.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddBase.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCanonical.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddClass.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCompare.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareSig.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCopy.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddCopySign.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddDivide.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddDivideInt.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddEncode.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddFMA.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddInvert.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddLogB.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMax.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMaxMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMin.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMinMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMinus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddMultiply.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddNextMinus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddNextPlus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddNextToward.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddOr.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddPlus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddQuantize.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddReduce.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainder.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddRotate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddScaleB.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddShift.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddSubtract.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddToIntegral.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ddXor.decTest python/branches/release31-maint/Lib/test/decimaltestdata/decDouble.decTest python/branches/release31-maint/Lib/test/decimaltestdata/decQuad.decTest python/branches/release31-maint/Lib/test/decimaltestdata/decSingle.decTest python/branches/release31-maint/Lib/test/decimaltestdata/divide.decTest python/branches/release31-maint/Lib/test/decimaltestdata/divideint.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqAbs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqAdd.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqAnd.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqBase.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCanonical.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqClass.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCompare.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareSig.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCopy.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqCopySign.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqDivide.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqDivideInt.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqEncode.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqFMA.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqInvert.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqLogB.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMax.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMaxMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMin.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMinMag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMinus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqMultiply.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqNextMinus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqNextPlus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqNextToward.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqOr.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqPlus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqQuantize.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqReduce.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainder.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqRotate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqScaleB.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqShift.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqSubtract.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqToIntegral.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dqXor.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dsBase.decTest python/branches/release31-maint/Lib/test/decimaltestdata/dsEncode.decTest python/branches/release31-maint/Lib/test/decimaltestdata/exp.decTest python/branches/release31-maint/Lib/test/decimaltestdata/fma.decTest python/branches/release31-maint/Lib/test/decimaltestdata/inexact.decTest python/branches/release31-maint/Lib/test/decimaltestdata/invert.decTest python/branches/release31-maint/Lib/test/decimaltestdata/ln.decTest python/branches/release31-maint/Lib/test/decimaltestdata/log10.decTest python/branches/release31-maint/Lib/test/decimaltestdata/logb.decTest python/branches/release31-maint/Lib/test/decimaltestdata/max.decTest python/branches/release31-maint/Lib/test/decimaltestdata/maxmag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/min.decTest python/branches/release31-maint/Lib/test/decimaltestdata/minmag.decTest python/branches/release31-maint/Lib/test/decimaltestdata/minus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/multiply.decTest python/branches/release31-maint/Lib/test/decimaltestdata/nextminus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/nextplus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/nexttoward.decTest python/branches/release31-maint/Lib/test/decimaltestdata/or.decTest python/branches/release31-maint/Lib/test/decimaltestdata/plus.decTest python/branches/release31-maint/Lib/test/decimaltestdata/power.decTest python/branches/release31-maint/Lib/test/decimaltestdata/powersqrt.decTest python/branches/release31-maint/Lib/test/decimaltestdata/quantize.decTest python/branches/release31-maint/Lib/test/decimaltestdata/randomBound32.decTest python/branches/release31-maint/Lib/test/decimaltestdata/randoms.decTest python/branches/release31-maint/Lib/test/decimaltestdata/reduce.decTest python/branches/release31-maint/Lib/test/decimaltestdata/remainder.decTest python/branches/release31-maint/Lib/test/decimaltestdata/remainderNear.decTest python/branches/release31-maint/Lib/test/decimaltestdata/rescale.decTest python/branches/release31-maint/Lib/test/decimaltestdata/rotate.decTest python/branches/release31-maint/Lib/test/decimaltestdata/rounding.decTest python/branches/release31-maint/Lib/test/decimaltestdata/samequantum.decTest python/branches/release31-maint/Lib/test/decimaltestdata/scaleb.decTest python/branches/release31-maint/Lib/test/decimaltestdata/shift.decTest python/branches/release31-maint/Lib/test/decimaltestdata/squareroot.decTest python/branches/release31-maint/Lib/test/decimaltestdata/subtract.decTest python/branches/release31-maint/Lib/test/decimaltestdata/testall.decTest python/branches/release31-maint/Lib/test/decimaltestdata/tointegral.decTest python/branches/release31-maint/Lib/test/decimaltestdata/tointegralx.decTest python/branches/release31-maint/Lib/test/decimaltestdata/xor.decTest python/branches/release31-maint/Lib/test/test_decimal.py Modified: python/branches/release31-maint/Lib/test/decimaltestdata/abs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/abs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/abs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested Modified: python/branches/release31-maint/Lib/test/decimaltestdata/add.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/add.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/add.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 9 rounding: half_up Modified: python/branches/release31-maint/Lib/test/decimaltestdata/and.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/and.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/and.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/base.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/base.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/base.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 -- This file tests base conversions from string to a decimal number Modified: python/branches/release31-maint/Lib/test/decimaltestdata/clamp.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/clamp.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/clamp.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific Modified: python/branches/release31-maint/Lib/test/decimaltestdata/class.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/class.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/class.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/release31-maint/Lib/test/decimaltestdata/compare.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/compare.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/compare.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/comparetotal.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/comparetotal.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/comparetotal.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/comparetotmag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/comparetotmag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/comparetotmag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that it cannot be assumed that add/subtract tests cover paths -- for this operation adequately, here, because the code might be Modified: python/branches/release31-maint/Lib/test/decimaltestdata/copy.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/copy.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/copy.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/copyabs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/copyabs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/copyabs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/copynegate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/copynegate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/copynegate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/copysign.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/copysign.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/copysign.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddAbs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddAbs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddAbs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddAdd.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddAdd.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddAdd.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddAnd.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddAnd.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddAnd.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddBase.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddBase.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddBase.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCanonical.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCanonical.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCanonical.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddClass.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddClass.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddClass.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCompare.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCompare.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCompare.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareSig.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareSig.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareSig.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCopy.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCopy.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCopy.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddCopySign.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddCopySign.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddCopySign.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddDivide.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddDivide.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddDivide.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 @@ -160,7 +160,7 @@ dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded --- test some cases that are close to exponent overflow +-- test some cases that are close to exponent overflow, some with coefficient padding dddiv270 divide 1 1e384 -> 1E-384 Subnormal dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow @@ -168,7 +168,16 @@ dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped -dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 +dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped +dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped +dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 + +dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped +dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded +dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped +dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded +dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped + -- Divide into 0 tests dddiv301 divide 0 7 -> 0 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddDivideInt.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddDivideInt.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddDivideInt.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddEncode.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddEncode.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddEncode.decTest Thu Oct 8 18:33:06 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal64.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddFMA.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddFMA.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddFMA.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddInvert.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddInvert.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddInvert.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddLogB.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddLogB.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddLogB.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMax.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMax.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMax.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMaxMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMaxMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMaxMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMin.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMin.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMin.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMinMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMinMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMinMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMinus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMinus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMinus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddMultiply.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddMultiply.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddMultiply.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddNextMinus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddNextMinus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddNextMinus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddNextPlus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddNextPlus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddNextPlus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddNextToward.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddNextToward.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddNextToward.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddOr.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddOr.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddOr.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddPlus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddPlus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddPlus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddQuantize.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddQuantize.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddQuantize.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddReduce.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddReduce.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddReduce.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainder.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainder.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainder.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddRotate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddRotate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddRotate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddScaleB.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddScaleB.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddScaleB.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddShift.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddShift.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddShift.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddSubtract.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddSubtract.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddSubtract.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddToIntegral.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddToIntegral.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddToIntegral.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ddXor.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ddXor.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ddXor.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/decDouble.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/decDouble.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/decDouble.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decDouble tests dectest: ddAbs Modified: python/branches/release31-maint/Lib/test/decimaltestdata/decQuad.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/decQuad.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/decQuad.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decQuad tests dectest: dqAbs Modified: python/branches/release31-maint/Lib/test/decimaltestdata/decSingle.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/decSingle.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/decSingle.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decSingle tests dectest: dsBase Modified: python/branches/release31-maint/Lib/test/decimaltestdata/divide.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/divide.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/divide.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/divideint.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/divideint.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/divideint.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqAbs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqAbs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqAbs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqAdd.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqAdd.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqAdd.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad @@ -637,7 +637,7 @@ dqadd7732 add 0 0 -> 0 dqadd7733 add 0 -0 -> 0 dqadd7734 add -0 0 -> 0 -dqadd7735 add -0 -0 -> -0 -- IEEE 854 special case +dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case dqadd7736 add 1 -1 -> 0 dqadd7737 add -1 -1 -> -2 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqAnd.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqAnd.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqAnd.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqBase.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqBase.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqBase.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCanonical.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCanonical.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCanonical.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqClass.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqClass.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqClass.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCompare.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCompare.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCompare.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareSig.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareSig.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareSig.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCopy.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCopy.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCopy.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqCopySign.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqCopySign.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqCopySign.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqDivide.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqDivide.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqDivide.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqDivideInt.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqDivideInt.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqDivideInt.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqEncode.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqEncode.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqEncode.decTest Thu Oct 8 18:33:06 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal128.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqFMA.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqFMA.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqFMA.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqInvert.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqInvert.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqInvert.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqLogB.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqLogB.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqLogB.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMax.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMax.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMax.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMaxMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMaxMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMaxMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMin.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMin.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMin.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMinMag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMinMag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMinMag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMinus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMinus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMinus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqMultiply.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqMultiply.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqMultiply.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqNextMinus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqNextMinus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqNextMinus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqNextPlus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqNextPlus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqNextPlus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqNextToward.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqNextToward.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqNextToward.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqOr.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqOr.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqOr.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqPlus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqPlus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqPlus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqQuantize.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqQuantize.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqQuantize.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. @@ -357,8 +357,6 @@ rounding: down dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation --- ? should that one instead have been: --- dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqReduce.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqReduce.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqReduce.decTest Thu Oct 8 18:33:06 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainder.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainder.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainder.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqRotate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqRotate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqRotate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqScaleB.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqScaleB.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqScaleB.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqShift.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqShift.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqShift.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqSubtract.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqSubtract.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqSubtract.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqToIntegral.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqToIntegral.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqToIntegral.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dqXor.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dqXor.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dqXor.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dsBase.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dsBase.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dsBase.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release31-maint/Lib/test/decimaltestdata/dsEncode.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/dsEncode.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/dsEncode.decTest Thu Oct 8 18:33:06 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal32.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: Modified: python/branches/release31-maint/Lib/test/decimaltestdata/exp.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/exp.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/exp.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Tests of the exponential funtion. Currently all testcases here -- show results which are correctly rounded (within <= 0.5 ulp). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/fma.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/fma.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/fma.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/inexact.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/inexact.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/inexact.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/invert.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/invert.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/invert.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/ln.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/ln.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/ln.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 16 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/log10.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/log10.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/log10.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/logb.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/logb.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/logb.decTest Thu Oct 8 18:33:06 2009 @@ -1,6 +1,6 @@ ------------------------------------------------------------------------ -- logb.decTest -- return integral adjusted exponent as per 754r -- --- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. -- +-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). @@ -143,7 +143,33 @@ logbx1419 logb 1000E2 -> 5 logbx1420 logb 10000E2 -> 6 +-- inexacts +precision: 2 +logbx1500 logb 10000E2 -> 6 +logbx1501 logb 1E+99 -> 99 +logbx1502 logb 1E-99 -> -99 +logbx1503 logb 1E+100 -> 1.0E+2 Rounded +logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded +logbx1505 logb 1E-100 -> -1.0E+2 Rounded +logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded +logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded +logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded +logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded +logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded +logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded +precision: 1 +logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded +logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded +logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded +precision: 8 +logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded +logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded +precision: 9 +logbx1523 logb 1E+999999999 -> 999999999 +logbx1524 logb 1E-999999999 -> -999999999 + -- special values +precision: 9 logbx820 logb Infinity -> Infinity logbx821 logb -Infinity -> Infinity logbx822 logb 0 -> -Infinity Division_by_zero Modified: python/branches/release31-maint/Lib/test/decimaltestdata/max.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/max.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/max.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/maxmag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/maxmag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/maxmag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/min.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/min.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/min.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/minmag.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/minmag.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/minmag.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release31-maint/Lib/test/decimaltestdata/minus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/minus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/minus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. Modified: python/branches/release31-maint/Lib/test/decimaltestdata/multiply.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/multiply.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/multiply.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/nextminus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/nextminus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/nextminus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/nextplus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/nextplus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/nextplus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/nexttoward.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/nexttoward.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/nexttoward.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/or.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/or.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/or.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/plus.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/plus.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/plus.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. Modified: python/branches/release31-maint/Lib/test/decimaltestdata/power.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/power.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/power.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- In addition to the power operator testcases here, see also the file -- powersqrt.decTest which includes all the tests from Modified: python/branches/release31-maint/Lib/test/decimaltestdata/powersqrt.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/powersqrt.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/powersqrt.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases are taken from squareroot.decTest but are -- evaluated using the power operator. The differences in results Modified: python/branches/release31-maint/Lib/test/decimaltestdata/quantize.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/quantize.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/quantize.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/release31-maint/Lib/test/decimaltestdata/randomBound32.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/randomBound32.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/randomBound32.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases test calculations at precisions 31, 32, and 33, to -- exercise the boundaries around 2**5 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/randoms.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/randoms.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/randoms.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 maxexponent: 999999999 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/reduce.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/reduce.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/reduce.decTest Thu Oct 8 18:33:06 2009 @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ -- [This used to be called normalize.] -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/remainder.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/remainder.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/remainder.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/remainderNear.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/remainderNear.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/remainderNear.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/rescale.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/rescale.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/rescale.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [obsolete] Quantize.decTest has the improved version Modified: python/branches/release31-maint/Lib/test/decimaltestdata/rotate.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/rotate.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/rotate.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/rounding.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/rounding.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/rounding.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These tests require that implementations take account of residues in -- order to get correct results for some rounding modes. Rather than Modified: python/branches/release31-maint/Lib/test/decimaltestdata/samequantum.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/samequantum.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/samequantum.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/scaleb.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/scaleb.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/scaleb.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -198,3 +198,12 @@ scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998 scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded + +-- Krah examples +precision: 34 +maxExponent: 999999999 +minExponent: -999999999 +-- integer overflow in 3.61 or earlier +scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation +-- out of range +scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation Modified: python/branches/release31-maint/Lib/test/decimaltestdata/shift.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/shift.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/shift.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/squareroot.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/squareroot.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/squareroot.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -3812,6 +3812,16 @@ clamp: 1 sqtx9045 squareroot 1 -> 1.00000 Clamped +-- other +maxexponent: 999 +minexponent: -999 +precision: 16 +sqtx9046 squareroot 10 -> 3.162277660168379 inexact rounded +sqtx9047 squareroot 10E-1 -> 1.0 +sqtx9048 squareroot 10E-2 -> 0.3162277660168379 inexact rounded +sqtx9049 squareroot 10E-3 -> 0.10 + + -- High-precision exact and inexact maxexponent: 999 minexponent: -999 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/subtract.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/subtract.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/subtract.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/decimaltestdata/testall.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/testall.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/testall.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- core tests (using Extended: 1) -------------------------------------- dectest: base Modified: python/branches/release31-maint/Lib/test/decimaltestdata/tointegral.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/tointegral.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/tointegral.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/tointegralx.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/tointegralx.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/tointegralx.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/release31-maint/Lib/test/decimaltestdata/xor.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/xor.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/xor.decTest Thu Oct 8 18:33:06 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release31-maint/Lib/test/test_decimal.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_decimal.py (original) +++ python/branches/release31-maint/Lib/test/test_decimal.py Thu Oct 8 18:33:06 2009 @@ -63,6 +63,13 @@ skip_expected = not os.path.isdir(directory) +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False @@ -262,6 +269,10 @@ val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val + + if id in skipped_test_ids: + return + fname = nameAdapter.get(funct, funct) if fname == 'rescale': return From python-checkins at python.org Thu Oct 8 22:02:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 20:02:26 -0000 Subject: [Python-checkins] r75289 - python/trunk/Doc/library/string.rst Message-ID: Author: mark.dickinson Date: Thu Oct 8 22:02:25 2009 New Revision: 75289 Log: Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting. Modified: python/trunk/Doc/library/string.rst Modified: python/trunk/Doc/library/string.rst ============================================================================== --- python/trunk/Doc/library/string.rst (original) +++ python/trunk/Doc/library/string.rst Thu Oct 8 22:02:25 2009 @@ -446,15 +446,33 @@ +---------+----------------------------------------------------------+ | ``'F'`` | Fixed point. Same as ``'f'``. | +---------+----------------------------------------------------------+ - | ``'g'`` | General format. This prints the number as a fixed-point | - | | number, unless the number is too large, in which case | - | | it switches to ``'e'`` exponent notation. Infinity and | - | | NaN values are formatted as ``inf``, ``-inf`` and | - | | ``nan``, respectively. | + | ``'g'`` | General format. For a given precision ``p >= 1``, | + | | this rounds the number to ``p`` significant digits and | + | | then formats the result in either fixed-point format | + | | or in scientific notation, depending on its magnitude. | + | | | + | | The precise rules are as follows: suppose that the | + | | result formatted with presentation type ``'e'`` and | + | | precision ``p-1`` would have exponent ``exp``. Then | + | | if ``-4 <= exp < p``, the number is formatted | + | | with presentation type ``'f'`` and precision | + | | ``p-1-exp``. Otherwise, the number is formatted | + | | with presentation type ``'e'`` and precision ``p-1``. | + | | In both cases insignificant trailing zeros are removed | + | | from the significand, and the decimal point is also | + | | removed if there are no remaining digits following it. | + | | | + | | Postive and negative infinity, positive and negative | + | | zero, and nans, are formatted as ``inf``, ``-inf``, | + | | ``0``, ``-0`` and ``nan`` respectively, regardless of | + | | the precision. | + | | | + | | A precision of ``0`` is treated as equivalent to a | + | | precision of ``1``. | +---------+----------------------------------------------------------+ | ``'G'`` | General format. Same as ``'g'`` except switches to | - | | ``'E'`` if the number gets to large. The representations | - | | of infinity and NaN are uppercased, too. | + | | ``'E'`` if the number gets too large. The | + | | representations of infinity and NaN are uppercased, too. | +---------+----------------------------------------------------------+ | ``'n'`` | Number. This is the same as ``'g'``, except that it uses | | | the current locale setting to insert the appropriate | From python-checkins at python.org Thu Oct 8 22:05:49 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 20:05:49 -0000 Subject: [Python-checkins] r75290 - in python/branches/py3k: Doc/library/string.rst Message-ID: Author: mark.dickinson Date: Thu Oct 8 22:05:48 2009 New Revision: 75290 Log: Merged revisions 75289 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75289 | mark.dickinson | 2009-10-08 21:02:25 +0100 (Thu, 08 Oct 2009) | 2 lines Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/string.rst Modified: python/branches/py3k/Doc/library/string.rst ============================================================================== --- python/branches/py3k/Doc/library/string.rst (original) +++ python/branches/py3k/Doc/library/string.rst Thu Oct 8 22:05:48 2009 @@ -423,15 +423,33 @@ | ``'F'`` | Fixed point. Same as ``'f'``, but converts ``nan`` to | | | ``NAN`` and ``inf`` to ``INF``. | +---------+----------------------------------------------------------+ - | ``'g'`` | General format. This prints the number as a fixed-point | - | | number, unless the number is too large, in which case | - | | it switches to ``'e'`` exponent notation. Infinity and | - | | NaN values are formatted as ``inf``, ``-inf`` and | - | | ``nan``, respectively. | + | ``'g'`` | General format. For a given precision ``p >= 1``, | + | | this rounds the number to ``p`` significant digits and | + | | then formats the result in either fixed-point format | + | | or in scientific notation, depending on its magnitude. | + | | | + | | The precise rules are as follows: suppose that the | + | | result formatted with presentation type ``'e'`` and | + | | precision ``p-1`` would have exponent ``exp``. Then | + | | if ``-4 <= exp < p``, the number is formatted | + | | with presentation type ``'f'`` and precision | + | | ``p-1-exp``. Otherwise, the number is formatted | + | | with presentation type ``'e'`` and precision ``p-1``. | + | | In both cases insignificant trailing zeros are removed | + | | from the significand, and the decimal point is also | + | | removed if there are no remaining digits following it. | + | | | + | | Postive and negative infinity, positive and negative | + | | zero, and nans, are formatted as ``inf``, ``-inf``, | + | | ``0``, ``-0`` and ``nan`` respectively, regardless of | + | | the precision. | + | | | + | | A precision of ``0`` is treated as equivalent to a | + | | precision of ``1``. | +---------+----------------------------------------------------------+ | ``'G'`` | General format. Same as ``'g'`` except switches to | - | | ``'E'`` if the number gets to large. The representations | - | | of infinity and NaN are uppercased, too. | + | | ``'E'`` if the number gets too large. The | + | | representations of infinity and NaN are uppercased, too. | +---------+----------------------------------------------------------+ | ``'n'`` | Number. This is the same as ``'g'``, except that it uses | | | the current locale setting to insert the appropriate | From python-checkins at python.org Thu Oct 8 22:06:27 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 08 Oct 2009 20:06:27 -0000 Subject: [Python-checkins] r75291 - in python/branches/release31-maint: Doc/library/string.rst Message-ID: Author: mark.dickinson Date: Thu Oct 8 22:06:27 2009 New Revision: 75291 Log: Merged revisions 75290 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75290 | mark.dickinson | 2009-10-08 21:05:48 +0100 (Thu, 08 Oct 2009) | 9 lines Merged revisions 75289 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75289 | mark.dickinson | 2009-10-08 21:02:25 +0100 (Thu, 08 Oct 2009) | 2 lines Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/library/string.rst Modified: python/branches/release31-maint/Doc/library/string.rst ============================================================================== --- python/branches/release31-maint/Doc/library/string.rst (original) +++ python/branches/release31-maint/Doc/library/string.rst Thu Oct 8 22:06:27 2009 @@ -423,15 +423,33 @@ | ``'F'`` | Fixed point. Same as ``'f'``, but converts ``nan`` to | | | ``NAN`` and ``inf`` to ``INF``. | +---------+----------------------------------------------------------+ - | ``'g'`` | General format. This prints the number as a fixed-point | - | | number, unless the number is too large, in which case | - | | it switches to ``'e'`` exponent notation. Infinity and | - | | NaN values are formatted as ``inf``, ``-inf`` and | - | | ``nan``, respectively. | + | ``'g'`` | General format. For a given precision ``p >= 1``, | + | | this rounds the number to ``p`` significant digits and | + | | then formats the result in either fixed-point format | + | | or in scientific notation, depending on its magnitude. | + | | | + | | The precise rules are as follows: suppose that the | + | | result formatted with presentation type ``'e'`` and | + | | precision ``p-1`` would have exponent ``exp``. Then | + | | if ``-4 <= exp < p``, the number is formatted | + | | with presentation type ``'f'`` and precision | + | | ``p-1-exp``. Otherwise, the number is formatted | + | | with presentation type ``'e'`` and precision ``p-1``. | + | | In both cases insignificant trailing zeros are removed | + | | from the significand, and the decimal point is also | + | | removed if there are no remaining digits following it. | + | | | + | | Postive and negative infinity, positive and negative | + | | zero, and nans, are formatted as ``inf``, ``-inf``, | + | | ``0``, ``-0`` and ``nan`` respectively, regardless of | + | | the precision. | + | | | + | | A precision of ``0`` is treated as equivalent to a | + | | precision of ``1``. | +---------+----------------------------------------------------------+ | ``'G'`` | General format. Same as ``'g'`` except switches to | - | | ``'E'`` if the number gets to large. The representations | - | | of infinity and NaN are uppercased, too. | + | | ``'E'`` if the number gets too large. The | + | | representations of infinity and NaN are uppercased, too. | +---------+----------------------------------------------------------+ | ``'n'`` | Number. This is the same as ``'g'``, except that it uses | | | the current locale setting to insert the appropriate | From nnorwitz at gmail.com Fri Oct 9 00:09:43 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 8 Oct 2009 18:09:43 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091008220943.GA940@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 0, 339] references, sum=339 test_urllib2_localnet leaked [0, 0, 270] references, sum=270 Less important issues: ---------------------- test_asynchat leaked [126, -126, 0] references, sum=0 test_cmd_line leaked [50, 0, -50] references, sum=0 test_file2k leaked [0, 91, -7] references, sum=84 test_smtplib leaked [-88, 88, -85] references, sum=-85 test_sys leaked [21, -21, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Fri Oct 9 05:11:42 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 03:11:42 -0000 Subject: [Python-checkins] r75292 - python/trunk/Lib/xml/__init__.py Message-ID: Author: benjamin.peterson Date: Fri Oct 9 05:11:36 2009 New Revision: 75292 Log: death to old CVS keyword Modified: python/trunk/Lib/xml/__init__.py Modified: python/trunk/Lib/xml/__init__.py ============================================================================== --- python/trunk/Lib/xml/__init__.py (original) +++ python/trunk/Lib/xml/__init__.py Fri Oct 9 05:11:36 2009 @@ -19,12 +19,6 @@ __all__ = ["dom", "parsers", "sax", "etree"] -# When being checked-out without options, this has the form -# "Revision: x.y " -# When exported using -kv, it is "x.y". -__version__ = "$Revision$".split()[-2:][0] - - _MINIMUM_XMLPLUS_VERSION = (0, 8, 4) From nnorwitz at gmail.com Fri Oct 9 11:45:49 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 9 Oct 2009 05:45:49 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091009094549.GA14635@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 0, -420] references, sum=-420 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_smtplib leaked [0, 0, 88] references, sum=88 test_sys leaked [42, -21, -21] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [0, 284, -284] references, sum=0 From python-checkins at python.org Fri Oct 9 16:32:19 2009 From: python-checkins at python.org (kristjan.jonsson) Date: Fri, 09 Oct 2009 14:32:19 -0000 Subject: [Python-checkins] r75293 - python/trunk/Tools/pybench/pybench.py Message-ID: Author: kristjan.jonsson Date: Fri Oct 9 16:32:19 2009 New Revision: 75293 Log: http://bugs.python.org/issue7029 a non-default timer wasn't actually used by the individual Tests. Modified: python/trunk/Tools/pybench/pybench.py Modified: python/trunk/Tools/pybench/pybench.py ============================================================================== --- python/trunk/Tools/pybench/pybench.py (original) +++ python/trunk/Tools/pybench/pybench.py Fri Oct 9 16:32:19 2009 @@ -230,7 +230,7 @@ raise ValueError('at least one calibration run is required') self.calibration_runs = calibration_runs if timer is not None: - timer = timer + self.timer = timer # Init variables self.times = [] From python-checkins at python.org Fri Oct 9 22:25:24 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:25:24 -0000 Subject: [Python-checkins] r75294 - python/branches/release31-maint/Include/patchlevel.h Message-ID: Author: benjamin.peterson Date: Fri Oct 9 22:25:23 2009 New Revision: 75294 Log: we are in 3.1.1+ Modified: python/branches/release31-maint/Include/patchlevel.h Modified: python/branches/release31-maint/Include/patchlevel.h ============================================================================== --- python/branches/release31-maint/Include/patchlevel.h (original) +++ python/branches/release31-maint/Include/patchlevel.h Fri Oct 9 22:25:23 2009 @@ -23,7 +23,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.1.1" +#define PY_VERSION "3.1.1+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ From python-checkins at python.org Fri Oct 9 22:28:14 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:28:14 -0000 Subject: [Python-checkins] r75295 - sandbox/trunk/release/release.py Message-ID: Author: benjamin.peterson Date: Fri Oct 9 22:28:14 2009 New Revision: 75295 Log: use an explicit encoding for everything Modified: sandbox/trunk/release/release.py Modified: sandbox/trunk/release/release.py ============================================================================== --- sandbox/trunk/release/release.py (original) +++ sandbox/trunk/release/release.py Fri Oct 9 22:28:14 2009 @@ -84,7 +84,8 @@ """ start_tag = comment_start + '--start constants--' + comment_end end_tag = comment_start + '--end constants--' + comment_end - with open(fn) as infile, open(fn + '.new', 'w') as outfile: + with open(fn, encoding="ascii") as infile, \ + open(fn + '.new', 'w', encoding="ascii") as outfile: found_constants = False waiting_for_end = False for line in infile: @@ -155,7 +156,7 @@ tweak_patchlevel(tag) print('Updating Lib/idlelib/idlever.py...', end=' ') - with open('Lib/idlelib/idlever.py', 'w') as fp: + with open('Lib/idlelib/idlever.py', 'w', encoding="ascii") as fp: new = 'IDLE_VERSION = "%s"\n' % tag.next_text fp.write(new) print('done') @@ -232,9 +233,9 @@ checksum_tgz.hexdigest(), int(os.path.getsize(tgz)), tgz)) print(' %s %8s %s' % ( checksum_bz2.hexdigest(), int(os.path.getsize(bz)), bz)) - with open(tgz + '.md5', 'w') as fp: + with open(tgz + '.md5', 'w', encoding="ascii") as fp: fp.write(checksum_tgz.hexdigest()) - with open(bz + '.md5', 'w') as fp: + with open(bz + '.md5', 'w', encoding="ascii") as fp: fp.write(checksum_bz2.hexdigest()) print('Signing tarballs') @@ -393,7 +394,7 @@ def update_news(): print("Updating Misc/NEWS") - with open('Misc/NEWS') as fp: + with open('Misc/NEWS', encoding="utf-8") as fp: lines = fp.readlines() for i, line in enumerate(lines): if line.startswith("(editors"): @@ -403,7 +404,7 @@ break release_date = time.strftime("%d-%b-%Y") insert = NEWS_TEMPLATE % release_date - with open('Misc/NEWS', 'w') as fp: + with open('Misc/NEWS', 'w', encoding="utf-8") as fp: fp.writelines(lines[:start+1]) fp.write(insert) fp.writelines(lines[end-1:]) From python-checkins at python.org Fri Oct 9 22:36:25 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:36:25 -0000 Subject: [Python-checkins] r75296 - in python/branches/py3k: Doc/library/weakref.rst Modules/_threadmodule.c Message-ID: Author: benjamin.peterson Date: Fri Oct 9 22:36:25 2009 New Revision: 75296 Log: rollback the merge of r75241 because it causes failures in test_multiprocessing Modified: python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Modules/_threadmodule.c Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Fri Oct 9 22:36:25 2009 @@ -61,9 +61,6 @@ frozensets, file objects, :term:`generator`\s, type objects, sockets, arrays, deques, and regular expression pattern objects. -.. versionchanged:: 2.7 - Added support for thread.lock and threading.Lock. - Several built-in types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: Modified: python/branches/py3k/Modules/_threadmodule.c ============================================================================== --- python/branches/py3k/Modules/_threadmodule.c (original) +++ python/branches/py3k/Modules/_threadmodule.c Fri Oct 9 22:36:25 2009 @@ -3,7 +3,6 @@ /* Interface to Sjoerd's portable C thread library */ #include "Python.h" -#include "structmember.h" /* offsetof */ #ifndef WITH_THREAD #error "Error! The rest of Python is not compiled with thread support." @@ -21,15 +20,12 @@ typedef struct { PyObject_HEAD PyThread_type_lock lock_lock; - PyObject *in_weakreflist; } lockobject; static void lock_dealloc(lockobject *self) { assert(self->lock_lock); - if (self->in_weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *) self); /* Unlock the lock so it's safe to free it */ PyThread_acquire_lock(self->lock_lock, 0); PyThread_release_lock(self->lock_lock); @@ -144,12 +140,12 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ - offsetof(lockobject, in_weakreflist), /*tp_weaklistoffset*/ + 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ lock_methods, /*tp_methods*/ @@ -163,7 +159,6 @@ if (self == NULL) return NULL; self->lock_lock = PyThread_allocate_lock(); - self->in_weakreflist = NULL; if (self->lock_lock == NULL) { PyObject_Del(self); self = NULL; From python-checkins at python.org Fri Oct 9 22:39:55 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:39:55 -0000 Subject: [Python-checkins] r75297 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Fri Oct 9 22:39:55 2009 New Revision: 75297 Log: Recorded rollback of revisions 72524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Fri Oct 9 22:41:54 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:41:54 -0000 Subject: [Python-checkins] r75296 - svn:log Message-ID: Author: benjamin.peterson Revision: 75296 Property Name: svn:log Action: modified Property diff: --- old property value +++ new property value @@ -1 +1 @@ -rollback the merge of r75241 because it causes failures in test_multiprocessing \ No newline at end of file +rollback the merge of r74524 because it causes failures in test_multiprocessing From python-checkins at python.org Fri Oct 9 22:47:22 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 20:47:22 -0000 Subject: [Python-checkins] r75298 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Fri Oct 9 22:47:22 2009 New Revision: 75298 Log: Recorded rollback of revisions 74524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Fri Oct 9 23:43:09 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 21:43:09 -0000 Subject: [Python-checkins] r75299 - in python/branches/py3k: Lib/test/test_tokenize.py Lib/tokenize.py Misc/NEWS Message-ID: Author: benjamin.peterson Date: Fri Oct 9 23:43:09 2009 New Revision: 75299 Log: normalize latin-1 and utf-8 variant encodings like the builtin tokenizer does Modified: python/branches/py3k/Lib/test/test_tokenize.py python/branches/py3k/Lib/tokenize.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_tokenize.py ============================================================================== --- python/branches/py3k/Lib/test/test_tokenize.py (original) +++ python/branches/py3k/Lib/test/test_tokenize.py Fri Oct 9 23:43:09 2009 @@ -719,7 +719,7 @@ b'do_something(else)\n' ) encoding, consumed_lines = detect_encoding(self.get_readline(lines)) - self.assertEquals(encoding, 'latin-1') + self.assertEquals(encoding, 'iso-8859-1') self.assertEquals(consumed_lines, [b'# -*- coding: latin-1 -*-\n']) def test_matched_bom_and_cookie_first_line(self): @@ -775,6 +775,34 @@ readline = self.get_readline(lines) self.assertRaises(SyntaxError, detect_encoding, readline) + def test_latin1_normalization(self): + # See get_normal_name() in tokenizer.c. + encodings = ("latin-1", "iso-8859-1", "iso-latin-1", "latin-1-unix", + "iso-8859-1-unix", "iso-latin-1-mac") + for encoding in encodings: + for rep in ("-", "_"): + enc = encoding.replace("-", rep) + lines = (b"#!/usr/bin/python\n", + b"# coding: " + enc.encode("ascii") + b"\n", + b"print(things)\n", + b"do_something += 4\n") + rl = self.get_readline(lines) + found, consumed_lines = detect_encoding(rl) + self.assertEquals(found, "iso-8859-1") + + def test_utf8_normalization(self): + # See get_normal_name() in tokenizer.c. + encodings = ("utf-8", "utf-8-mac", "utf-8-unix") + for encoding in encodings: + for rep in ("-", "_"): + enc = encoding.replace("-", rep) + lines = (b"#!/usr/bin/python\n", + b"# coding: " + enc.encode("ascii") + b"\n", + b"1 + 3\n") + rl = self.get_readline(lines) + found, consumed_lines = detect_encoding(rl) + self.assertEquals(found, "utf-8") + def test_short_files(self): readline = self.get_readline((b'print(something)\n',)) encoding, consumed_lines = detect_encoding(readline) Modified: python/branches/py3k/Lib/tokenize.py ============================================================================== --- python/branches/py3k/Lib/tokenize.py (original) +++ python/branches/py3k/Lib/tokenize.py Fri Oct 9 23:43:09 2009 @@ -279,6 +279,17 @@ return out +def _get_normal_name(orig_enc): + """Imitates get_normal_name in tokenizer.c.""" + # Only care about the first 12 characters. + enc = orig_enc[:12].lower().replace("_", "-") + if enc == "utf-8" or enc.startswith("utf-8-"): + return "utf-8" + if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \ + enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")): + return "iso-8859-1" + return orig_enc + def detect_encoding(readline): """ The detect_encoding() function is used to detect the encoding that should @@ -313,7 +324,7 @@ matches = cookie_re.findall(line_string) if not matches: return None - encoding = matches[0] + encoding = _get_normal_name(matches[0]) try: codec = lookup(encoding) except LookupError: Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Fri Oct 9 23:43:09 2009 @@ -87,6 +87,9 @@ Library ------- +- Make tokenize.detect_coding() normalize utf-8 and iso-8859-1 variants like the + builtin tokenizer. + - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. From python-checkins at python.org Fri Oct 9 23:48:15 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 21:48:15 -0000 Subject: [Python-checkins] r75300 - python/trunk/Parser/tokenizer.c Message-ID: Author: benjamin.peterson Date: Fri Oct 9 23:48:14 2009 New Revision: 75300 Log: fix some coding style Modified: python/trunk/Parser/tokenizer.c Modified: python/trunk/Parser/tokenizer.c ============================================================================== --- python/trunk/Parser/tokenizer.c (original) +++ python/trunk/Parser/tokenizer.c Fri Oct 9 23:48:14 2009 @@ -180,20 +180,26 @@ int i; for (i = 0; i < 12; i++) { int c = s[i]; - if (c == '\0') break; - else if (c == '_') buf[i] = '-'; - else buf[i] = tolower(c); + if (c == '\0') + break; + else if (c == '_') + buf[i] = '-'; + else + buf[i] = tolower(c); } buf[i] = '\0'; if (strcmp(buf, "utf-8") == 0 || - strncmp(buf, "utf-8-", 6) == 0) return "utf-8"; + strncmp(buf, "utf-8-", 6) == 0) + return "utf-8"; else if (strcmp(buf, "latin-1") == 0 || strcmp(buf, "iso-8859-1") == 0 || strcmp(buf, "iso-latin-1") == 0 || strncmp(buf, "latin-1-", 8) == 0 || strncmp(buf, "iso-8859-1-", 11) == 0 || - strncmp(buf, "iso-latin-1-", 12) == 0) return "iso-8859-1"; - else return s; + strncmp(buf, "iso-latin-1-", 12) == 0) + return "iso-8859-1"; + else + return s; } /* Return the coding spec in S, or NULL if none is found. */ @@ -309,18 +315,28 @@ if (ch == EOF) { return 1; } else if (ch == 0xEF) { - ch = get_char(tok); if (ch != 0xBB) goto NON_BOM; - ch = get_char(tok); if (ch != 0xBF) goto NON_BOM; + ch = get_char(tok); + if (ch != 0xBB) + goto NON_BOM; + ch = get_char(tok); + if (ch != 0xBF) + goto NON_BOM; #if 0 /* Disable support for UTF-16 BOMs until a decision is made whether this needs to be supported. */ } else if (ch == 0xFE) { - ch = get_char(tok); if (ch != 0xFF) goto NON_BOM; - if (!set_readline(tok, "utf-16-be")) return 0; + ch = get_char(tok); + if (ch != 0xFF) + goto NON_BOM; + if (!set_readline(tok, "utf-16-be")) + return 0; tok->decoding_state = -1; } else if (ch == 0xFF) { - ch = get_char(tok); if (ch != 0xFE) goto NON_BOM; - if (!set_readline(tok, "utf-16-le")) return 0; + ch = get_char(tok); + if (ch != 0xFE) + goto NON_BOM; + if (!set_readline(tok, "utf-16-le")) + return 0; tok->decoding_state = -1; #endif } else { @@ -397,7 +413,8 @@ memcpy(s, str, utf8len); s[utf8len] = '\0'; Py_DECREF(utf8); - if (utf8len == 0) return NULL; /* EOF */ + if (utf8len == 0) + return NULL; /* EOF */ return s; #endif } From python-checkins at python.org Fri Oct 9 23:50:54 2009 From: python-checkins at python.org (r.david.murray) Date: Fri, 09 Oct 2009 21:50:54 -0000 Subject: [Python-checkins] r75301 - in python/trunk: Lib/email/message.py Lib/email/test/data/msg_44.txt Misc/ACKS Misc/NEWS Message-ID: Author: r.david.murray Date: Fri Oct 9 23:50:54 2009 New Revision: 75301 Log: Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. Patch by Darren Worrall. Modified: python/trunk/Lib/email/message.py python/trunk/Lib/email/test/data/msg_44.txt python/trunk/Misc/ACKS python/trunk/Misc/NEWS Modified: python/trunk/Lib/email/message.py ============================================================================== --- python/trunk/Lib/email/message.py (original) +++ python/trunk/Lib/email/message.py Fri Oct 9 23:50:54 2009 @@ -674,7 +674,7 @@ missing = object() filename = self.get_param('filename', missing, 'content-disposition') if filename is missing: - filename = self.get_param('name', missing, 'content-disposition') + filename = self.get_param('name', missing, 'content-type') if filename is missing: return failobj return utils.collapse_rfc2231_value(filename).strip() Modified: python/trunk/Lib/email/test/data/msg_44.txt ============================================================================== --- python/trunk/Lib/email/test/data/msg_44.txt (original) +++ python/trunk/Lib/email/test/data/msg_44.txt Fri Oct 9 23:50:54 2009 @@ -16,16 +16,14 @@ --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror to reflect upon our own --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Fri Oct 9 23:50:54 2009 @@ -807,6 +807,7 @@ Klaus-Juergen Wolf Dan Wolfe Richard Wolff +Darren Worrall Gordon Worley Thomas Wouters Heiko Wundram Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Oct 9 23:50:54 2009 @@ -398,6 +398,9 @@ Library ------- +- Issue #7082: When falling back to the MIME 'name' parameter, the + correct place to look for it is the Content-Type header. + - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. From python-checkins at python.org Fri Oct 9 23:53:27 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 21:53:27 -0000 Subject: [Python-checkins] r75302 - in python/branches/release31-maint: Lib/test/test_tokenize.py Lib/tokenize.py Misc/NEWS Message-ID: Author: benjamin.peterson Date: Fri Oct 9 23:53:27 2009 New Revision: 75302 Log: Merged revisions 75299 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75299 | benjamin.peterson | 2009-10-09 16:43:09 -0500 (Fri, 09 Oct 2009) | 1 line normalize latin-1 and utf-8 variant encodings like the builtin tokenizer does ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_tokenize.py python/branches/release31-maint/Lib/tokenize.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/test_tokenize.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_tokenize.py (original) +++ python/branches/release31-maint/Lib/test/test_tokenize.py Fri Oct 9 23:53:27 2009 @@ -719,7 +719,7 @@ b'do_something(else)\n' ) encoding, consumed_lines = detect_encoding(self.get_readline(lines)) - self.assertEquals(encoding, 'latin-1') + self.assertEquals(encoding, 'iso-8859-1') self.assertEquals(consumed_lines, [b'# -*- coding: latin-1 -*-\n']) def test_matched_bom_and_cookie_first_line(self): @@ -775,6 +775,34 @@ readline = self.get_readline(lines) self.assertRaises(SyntaxError, detect_encoding, readline) + def test_latin1_normalization(self): + # See get_normal_name() in tokenizer.c. + encodings = ("latin-1", "iso-8859-1", "iso-latin-1", "latin-1-unix", + "iso-8859-1-unix", "iso-latin-1-mac") + for encoding in encodings: + for rep in ("-", "_"): + enc = encoding.replace("-", rep) + lines = (b"#!/usr/bin/python\n", + b"# coding: " + enc.encode("ascii") + b"\n", + b"print(things)\n", + b"do_something += 4\n") + rl = self.get_readline(lines) + found, consumed_lines = detect_encoding(rl) + self.assertEquals(found, "iso-8859-1") + + def test_utf8_normalization(self): + # See get_normal_name() in tokenizer.c. + encodings = ("utf-8", "utf-8-mac", "utf-8-unix") + for encoding in encodings: + for rep in ("-", "_"): + enc = encoding.replace("-", rep) + lines = (b"#!/usr/bin/python\n", + b"# coding: " + enc.encode("ascii") + b"\n", + b"1 + 3\n") + rl = self.get_readline(lines) + found, consumed_lines = detect_encoding(rl) + self.assertEquals(found, "utf-8") + def test_short_files(self): readline = self.get_readline((b'print(something)\n',)) encoding, consumed_lines = detect_encoding(readline) Modified: python/branches/release31-maint/Lib/tokenize.py ============================================================================== --- python/branches/release31-maint/Lib/tokenize.py (original) +++ python/branches/release31-maint/Lib/tokenize.py Fri Oct 9 23:53:27 2009 @@ -279,6 +279,17 @@ return out +def _get_normal_name(orig_enc): + """Imitates get_normal_name in tokenizer.c.""" + # Only care about the first 12 characters. + enc = orig_enc[:12].lower().replace("_", "-") + if enc == "utf-8" or enc.startswith("utf-8-"): + return "utf-8" + if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \ + enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")): + return "iso-8859-1" + return orig_enc + def detect_encoding(readline): """ The detect_encoding() function is used to detect the encoding that should @@ -313,7 +324,7 @@ matches = cookie_re.findall(line_string) if not matches: return None - encoding = matches[0] + encoding = _get_normal_name(matches[0]) try: codec = lookup(encoding) except LookupError: Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Fri Oct 9 23:53:27 2009 @@ -27,6 +27,9 @@ Library ------- +- Make tokenize.detect_coding() normalize utf-8 and iso-8859-1 variants like the + builtin tokenizer. + - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. From python-checkins at python.org Fri Oct 9 23:59:11 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 21:59:11 -0000 Subject: [Python-checkins] r75303 - sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Message-ID: Author: benjamin.peterson Date: Fri Oct 9 23:59:11 2009 New Revision: 75303 Log: port latin-1 and utf-8 cookie improvements Modified: sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Modified: sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py (original) +++ sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Fri Oct 9 23:59:11 2009 @@ -229,6 +229,17 @@ cookie_re = re.compile("coding[:=]\s*([-\w.]+)") +def _get_normal_name(orig_enc): + """Imitates get_normal_name in tokenizer.c.""" + # Only care about the first 12 characters. + enc = orig_enc[:12].lower().replace("_", "-") + if enc == "utf-8" or enc.startswith("utf-8-"): + return "utf-8" + if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \ + enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")): + return "iso-8859-1" + return orig_enc + def detect_encoding(readline): """ The detect_encoding() function is used to detect the encoding that should @@ -263,7 +274,7 @@ matches = cookie_re.findall(line_string) if not matches: return None - encoding = matches[0] + encoding = _get_normal_name(matches[0]) try: codec = lookup(encoding) except LookupError: From python-checkins at python.org Sat Oct 10 00:05:45 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 22:05:45 -0000 Subject: [Python-checkins] r75304 - in python/trunk/Lib: distutils/dist.py encodings/__init__.py idlelib/rpc.py imputil.py lib-tk/Tix.py lib-tk/Tkinter.py timeit.py Message-ID: Author: benjamin.peterson Date: Sat Oct 10 00:05:45 2009 New Revision: 75304 Log: replace callable() Modified: python/trunk/Lib/distutils/dist.py python/trunk/Lib/encodings/__init__.py python/trunk/Lib/idlelib/rpc.py python/trunk/Lib/imputil.py python/trunk/Lib/lib-tk/Tix.py python/trunk/Lib/lib-tk/Tkinter.py python/trunk/Lib/timeit.py Modified: python/trunk/Lib/distutils/dist.py ============================================================================== --- python/trunk/Lib/distutils/dist.py (original) +++ python/trunk/Lib/distutils/dist.py Sat Oct 10 00:05:45 2009 @@ -545,7 +545,7 @@ for (help_option, short, desc, func) in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option)): help_option_found=1 - if callable(func): + if hasattr(func, '__call__'): func() else: raise DistutilsClassError( Modified: python/trunk/Lib/encodings/__init__.py ============================================================================== --- python/trunk/Lib/encodings/__init__.py (original) +++ python/trunk/Lib/encodings/__init__.py Sat Oct 10 00:05:45 2009 @@ -123,12 +123,12 @@ raise CodecRegistryError,\ 'module "%s" (%s) failed to register' % \ (mod.__name__, mod.__file__) - if not callable(entry[0]) or \ - not callable(entry[1]) or \ - (entry[2] is not None and not callable(entry[2])) or \ - (entry[3] is not None and not callable(entry[3])) or \ - (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \ - (len(entry) > 5 and entry[5] is not None and not callable(entry[5])): + if not hasattr(entry[0], '__call__') or \ + not hasattr(entry[1], '__call__') or \ + (entry[2] is not None and not hasattr(entry[2], '__call__')) or \ + (entry[3] is not None and not hasattr(entry[3], '__call__')) or \ + (len(entry) > 4 and entry[4] is not None and not hasattr(entry[4], '__call__')) or \ + (len(entry) > 5 and entry[5] is not None and not hasattr(entry[5], '__call__')): raise CodecRegistryError,\ 'incompatible codecs in module "%s" (%s)' % \ (mod.__name__, mod.__file__) Modified: python/trunk/Lib/idlelib/rpc.py ============================================================================== --- python/trunk/Lib/idlelib/rpc.py (original) +++ python/trunk/Lib/idlelib/rpc.py Sat Oct 10 00:05:45 2009 @@ -570,7 +570,7 @@ # Adds names to dictionary argument 'methods' for name in dir(obj): attr = getattr(obj, name) - if callable(attr): + if hasattr(attr, '__call__'): methods[name] = 1 if type(obj) == types.InstanceType: _getmethods(obj.__class__, methods) @@ -581,7 +581,7 @@ def _getattributes(obj, attributes): for name in dir(obj): attr = getattr(obj, name) - if not callable(attr): + if not hasattr(attr, '__call__'): attributes[name] = 1 class MethodProxy(object): Modified: python/trunk/Lib/imputil.py ============================================================================== --- python/trunk/Lib/imputil.py (original) +++ python/trunk/Lib/imputil.py Sat Oct 10 00:05:45 2009 @@ -51,7 +51,7 @@ self.namespace['__import__'] = self.previous_importer def add_suffix(self, suffix, importFunc): - assert callable(importFunc) + assert hasattr(importFunc, '__call__') self.fs_imp.add_suffix(suffix, importFunc) ###################################################################### @@ -539,7 +539,7 @@ self.suffixes = [ ] def add_suffix(self, suffix, importFunc): - assert callable(importFunc) + assert hasattr(importFunc, '__call__') self.suffixes.append((suffix, importFunc)) def import_from_dir(self, dir, fqname): Modified: python/trunk/Lib/lib-tk/Tix.py ============================================================================== --- python/trunk/Lib/lib-tk/Tix.py (original) +++ python/trunk/Lib/lib-tk/Tix.py Sat Oct 10 00:05:45 2009 @@ -405,7 +405,7 @@ elif kw: cnf = kw options = () for k, v in cnf.items(): - if callable(v): + if hasattr(v, '__call__'): v = self._register(v) options = options + ('-'+k, v) return master.tk.call(('image', 'create', imgtype,) + options) Modified: python/trunk/Lib/lib-tk/Tkinter.py ============================================================================== --- python/trunk/Lib/lib-tk/Tkinter.py (original) +++ python/trunk/Lib/lib-tk/Tkinter.py Sat Oct 10 00:05:45 2009 @@ -1047,7 +1047,7 @@ for k, v in cnf.items(): if v is not None: if k[-1] == '_': k = k[:-1] - if callable(v): + if hasattr(v, '__call__'): v = self._register(v) elif isinstance(v, (tuple, list)): nv = [] @@ -3194,7 +3194,7 @@ elif kw: cnf = kw options = () for k, v in cnf.items(): - if callable(v): + if hasattr(v, '__call__'): v = self._register(v) options = options + ('-'+k, v) self.tk.call(('image', 'create', imgtype, name,) + options) @@ -3217,7 +3217,7 @@ for k, v in _cnfmerge(kw).items(): if v is not None: if k[-1] == '_': k = k[:-1] - if callable(v): + if hasattr(v, '__call__'): v = self._register(v) res = res + ('-'+k, v) self.tk.call((self.name, 'config') + res) Modified: python/trunk/Lib/timeit.py ============================================================================== --- python/trunk/Lib/timeit.py (original) +++ python/trunk/Lib/timeit.py Sat Oct 10 00:05:45 2009 @@ -126,7 +126,7 @@ if isinstance(setup, basestring): setup = reindent(setup, 4) src = template % {'stmt': stmt, 'setup': setup} - elif callable(setup): + elif hasattr(setup, '__call__'): src = template % {'stmt': stmt, 'setup': '_setup()'} ns['_setup'] = setup else: @@ -135,13 +135,13 @@ code = compile(src, dummy_src_name, "exec") exec code in globals(), ns self.inner = ns["inner"] - elif callable(stmt): + elif hasattr(stmt, '__call__'): self.src = None if isinstance(setup, basestring): _setup = setup def setup(): exec _setup in globals(), ns - elif not callable(setup): + elif not hasattr(setup, '__call__'): raise ValueError("setup is neither a string nor callable") self.inner = _template_func(setup, stmt) else: From python-checkins at python.org Sat Oct 10 00:15:51 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 22:15:51 -0000 Subject: [Python-checkins] r75305 - in python/trunk/Lib: bdb.py curses/has_key.py email/message.py encodings/__init__.py hotshot/log.py idlelib/EditorWindow.py idlelib/FileList.py idlelib/MultiCall.py idlelib/MultiStatusBar.py idlelib/ObjectBrowser.py idlelib/PathBrowser.py idlelib/RemoteDebugger.py idlelib/TreeWidget.py idlelib/configDialog.py idlelib/rpc.py lib-tk/FileDialog.py lib-tk/FixTk.py lib-tk/Tix.py lib-tk/Tkinter.py lib-tk/tkSimpleDialog.py lib-tk/turtle.py msilib/__init__.py trace.py wsgiref/handlers.py wsgiref/validate.py xml/dom/domreg.py xml/dom/minidom.py xml/dom/xmlbuilder.py xml/sax/__init__.py Message-ID: Author: benjamin.peterson Date: Sat Oct 10 00:15:50 2009 New Revision: 75305 Log: replace has_key with 'in' operator Modified: python/trunk/Lib/bdb.py python/trunk/Lib/curses/has_key.py python/trunk/Lib/email/message.py python/trunk/Lib/encodings/__init__.py python/trunk/Lib/hotshot/log.py python/trunk/Lib/idlelib/EditorWindow.py python/trunk/Lib/idlelib/FileList.py python/trunk/Lib/idlelib/MultiCall.py python/trunk/Lib/idlelib/MultiStatusBar.py python/trunk/Lib/idlelib/ObjectBrowser.py python/trunk/Lib/idlelib/PathBrowser.py python/trunk/Lib/idlelib/RemoteDebugger.py python/trunk/Lib/idlelib/TreeWidget.py python/trunk/Lib/idlelib/configDialog.py python/trunk/Lib/idlelib/rpc.py python/trunk/Lib/lib-tk/FileDialog.py python/trunk/Lib/lib-tk/FixTk.py python/trunk/Lib/lib-tk/Tix.py python/trunk/Lib/lib-tk/Tkinter.py python/trunk/Lib/lib-tk/tkSimpleDialog.py python/trunk/Lib/lib-tk/turtle.py python/trunk/Lib/msilib/__init__.py python/trunk/Lib/trace.py python/trunk/Lib/wsgiref/handlers.py python/trunk/Lib/wsgiref/validate.py python/trunk/Lib/xml/dom/domreg.py python/trunk/Lib/xml/dom/minidom.py python/trunk/Lib/xml/dom/xmlbuilder.py python/trunk/Lib/xml/sax/__init__.py Modified: python/trunk/Lib/bdb.py ============================================================================== --- python/trunk/Lib/bdb.py (original) +++ python/trunk/Lib/bdb.py Sat Oct 10 00:15:50 2009 @@ -257,7 +257,7 @@ # pair, then remove the breaks entry for bp in Breakpoint.bplist[filename, lineno][:]: bp.deleteMe() - if not Breakpoint.bplist.has_key((filename, lineno)): + if (filename, lineno) not in Breakpoint.bplist: self.breaks[filename].remove(lineno) if not self.breaks[filename]: del self.breaks[filename] @@ -464,7 +464,7 @@ Breakpoint.next = Breakpoint.next + 1 # Build the two lists self.bpbynumber.append(self) - if self.bplist.has_key((file, line)): + if (file, line) in self.bplist: self.bplist[file, line].append(self) else: self.bplist[file, line] = [self] Modified: python/trunk/Lib/curses/has_key.py ============================================================================== --- python/trunk/Lib/curses/has_key.py (original) +++ python/trunk/Lib/curses/has_key.py Sat Oct 10 00:15:50 2009 @@ -182,7 +182,7 @@ L = [] _curses.initscr() for key in _capability_names.keys(): - system = _curses.has_key(key) + system = key in _curses python = has_key(key) if system != python: L.append( 'Mismatch for key %s, system=%i, Python=%i' Modified: python/trunk/Lib/email/message.py ============================================================================== --- python/trunk/Lib/email/message.py (original) +++ python/trunk/Lib/email/message.py Sat Oct 10 00:15:50 2009 @@ -249,16 +249,16 @@ # BAW: should we accept strings that can serve as arguments to the # Charset constructor? self._charset = charset - if not self.has_key('MIME-Version'): + if 'MIME-Version' not in self: self.add_header('MIME-Version', '1.0') - if not self.has_key('Content-Type'): + if 'Content-Type' not in self: self.add_header('Content-Type', 'text/plain', charset=charset.get_output_charset()) else: self.set_param('charset', charset.get_output_charset()) if str(charset) != charset.get_output_charset(): self._payload = charset.body_encode(self._payload) - if not self.has_key('Content-Transfer-Encoding'): + if 'Content-Transfer-Encoding' not in self: cte = charset.get_body_encoding() try: cte(self) @@ -551,7 +551,7 @@ VALUE item in the 3-tuple) is always unquoted, unless unquote is set to False. """ - if not self.has_key(header): + if header not in self: return failobj for k, v in self._get_params_preserve(failobj, header): if k.lower() == param.lower(): @@ -582,7 +582,7 @@ if not isinstance(value, tuple) and charset: value = (charset, language, value) - if not self.has_key(header) and header.lower() == 'content-type': + if header not in self and header.lower() == 'content-type': ctype = 'text/plain' else: ctype = self.get(header) @@ -617,7 +617,7 @@ False. Optional header specifies an alternative to the Content-Type header. """ - if not self.has_key(header): + if header not in self: return new_ctype = '' for p, v in self.get_params(header=header, unquote=requote): @@ -653,7 +653,7 @@ if header.lower() == 'content-type': del self['mime-version'] self['MIME-Version'] = '1.0' - if not self.has_key(header): + if header not in self: self[header] = type return params = self.get_params(header=header, unquote=requote) Modified: python/trunk/Lib/encodings/__init__.py ============================================================================== --- python/trunk/Lib/encodings/__init__.py (original) +++ python/trunk/Lib/encodings/__init__.py Sat Oct 10 00:15:50 2009 @@ -147,7 +147,7 @@ pass else: for alias in codecaliases: - if not _aliases.has_key(alias): + if alias not in _aliases: _aliases[alias] = modname # Return the registry entry Modified: python/trunk/Lib/hotshot/log.py ============================================================================== --- python/trunk/Lib/hotshot/log.py (original) +++ python/trunk/Lib/hotshot/log.py Sat Oct 10 00:15:50 2009 @@ -30,7 +30,7 @@ self._reader = _hotshot.logreader(logfn) self._nextitem = self._reader.next self._info = self._reader.info - if self._info.has_key('current-directory'): + if 'current-directory' in self._info: self.cwd = self._info['current-directory'] else: self.cwd = None Modified: python/trunk/Lib/idlelib/EditorWindow.py ============================================================================== --- python/trunk/Lib/idlelib/EditorWindow.py (original) +++ python/trunk/Lib/idlelib/EditorWindow.py Sat Oct 10 00:15:50 2009 @@ -705,8 +705,8 @@ if accel: itemName = menu.entrycget(index, 'label') event = '' - if menuEventDict.has_key(menubarItem): - if menuEventDict[menubarItem].has_key(itemName): + if menubarItem in menuEventDict: + if itemName in menuEventDict[menubarItem]: event = menuEventDict[menubarItem][itemName] if event: accel = get_accelerator(keydefs, event) Modified: python/trunk/Lib/idlelib/FileList.py ============================================================================== --- python/trunk/Lib/idlelib/FileList.py (original) +++ python/trunk/Lib/idlelib/FileList.py Sat Oct 10 00:15:50 2009 @@ -25,7 +25,7 @@ master=self.root) return None key = os.path.normcase(filename) - if self.dict.has_key(key): + if key in self.dict: edit = self.dict[key] edit.top.wakeup() return edit @@ -79,7 +79,7 @@ newkey = os.path.normcase(filename) if newkey == key: return - if self.dict.has_key(newkey): + if newkey in self.dict: conflict = self.dict[newkey] self.inversedict[conflict] = None tkMessageBox.showerror( Modified: python/trunk/Lib/idlelib/MultiCall.py ============================================================================== --- python/trunk/Lib/idlelib/MultiCall.py (original) +++ python/trunk/Lib/idlelib/MultiCall.py Sat Oct 10 00:15:50 2009 @@ -185,7 +185,7 @@ seq, handler))) def bind(self, triplet, func): - if not self.bindedfuncs.has_key(triplet[2]): + if triplet[2] not in self.bindedfuncs: self.bindedfuncs[triplet[2]] = [[] for s in _states] for s in _states: lists = [ self.bindedfuncs[detail][i] Modified: python/trunk/Lib/idlelib/MultiStatusBar.py ============================================================================== --- python/trunk/Lib/idlelib/MultiStatusBar.py (original) +++ python/trunk/Lib/idlelib/MultiStatusBar.py Sat Oct 10 00:15:50 2009 @@ -9,7 +9,7 @@ self.labels = {} def set_label(self, name, text='', side=LEFT): - if not self.labels.has_key(name): + if name not in self.labels: label = Label(self, bd=1, relief=SUNKEN, anchor=W) label.pack(side=side) self.labels[name] = label Modified: python/trunk/Lib/idlelib/ObjectBrowser.py ============================================================================== --- python/trunk/Lib/idlelib/ObjectBrowser.py (original) +++ python/trunk/Lib/idlelib/ObjectBrowser.py Sat Oct 10 00:15:50 2009 @@ -126,7 +126,7 @@ def make_objecttreeitem(labeltext, object, setfunction=None): t = type(object) - if dispatch.has_key(t): + if t in dispatch: c = dispatch[t] else: c = ObjectTreeItem Modified: python/trunk/Lib/idlelib/PathBrowser.py ============================================================================== --- python/trunk/Lib/idlelib/PathBrowser.py (original) +++ python/trunk/Lib/idlelib/PathBrowser.py Sat Oct 10 00:15:50 2009 @@ -78,7 +78,7 @@ normed_name = os.path.normcase(name) if normed_name[i:] == suff: mod_name = name[:i] - if not modules.has_key(mod_name): + if mod_name not in modules: modules[mod_name] = None sorted.append((normed_name, name)) allnames.remove(name) Modified: python/trunk/Lib/idlelib/RemoteDebugger.py ============================================================================== --- python/trunk/Lib/idlelib/RemoteDebugger.py (original) +++ python/trunk/Lib/idlelib/RemoteDebugger.py Sat Oct 10 00:15:50 2009 @@ -230,7 +230,7 @@ return self._get_dict_proxy(did) def _get_dict_proxy(self, did): - if self._dictcache.has_key(did): + if did in self._dictcache: return self._dictcache[did] dp = DictProxy(self._conn, self._oid, did) self._dictcache[did] = dp Modified: python/trunk/Lib/idlelib/TreeWidget.py ============================================================================== --- python/trunk/Lib/idlelib/TreeWidget.py (original) +++ python/trunk/Lib/idlelib/TreeWidget.py Sat Oct 10 00:15:50 2009 @@ -409,7 +409,7 @@ class ScrolledCanvas: def __init__(self, master, **opts): - if not opts.has_key('yscrollincrement'): + if 'yscrollincrement' not in opts: opts['yscrollincrement'] = 17 self.master = master self.frame = Frame(master) Modified: python/trunk/Lib/idlelib/configDialog.py ============================================================================== --- python/trunk/Lib/idlelib/configDialog.py (original) +++ python/trunk/Lib/idlelib/configDialog.py Sat Oct 10 00:15:50 2009 @@ -562,7 +562,7 @@ def AddChangedItem(self,type,section,item,value): value=str(value) #make sure we use a string - if not self.changedItems[type].has_key(section): + if section not in self.changedItems[type]: self.changedItems[type][section]={} self.changedItems[type][section][item]=value @@ -709,7 +709,7 @@ return #remove key set from config idleConf.userCfg['keys'].remove_section(keySetName) - if self.changedItems['keys'].has_key(keySetName): + if keySetName in self.changedItems['keys']: del(self.changedItems['keys'][keySetName]) #write changes idleConf.userCfg['keys'].Save() @@ -736,7 +736,7 @@ return #remove theme from config idleConf.userCfg['highlight'].remove_section(themeName) - if self.changedItems['highlight'].has_key(themeName): + if themeName in self.changedItems['highlight']: del(self.changedItems['highlight'][themeName]) #write changes idleConf.userCfg['highlight'].Save() @@ -871,9 +871,9 @@ #handle any unsaved changes to this theme if theme in self.changedItems['highlight'].keys(): themeDict=self.changedItems['highlight'][theme] - if themeDict.has_key(element+'-foreground'): + if element+'-foreground' in themeDict: colours['foreground']=themeDict[element+'-foreground'] - if themeDict.has_key(element+'-background'): + if element+'-background' in themeDict: colours['background']=themeDict[element+'-background'] self.textHighlightSample.tag_config(element, **colours) self.SetColourSample() Modified: python/trunk/Lib/idlelib/rpc.py ============================================================================== --- python/trunk/Lib/idlelib/rpc.py (original) +++ python/trunk/Lib/idlelib/rpc.py Sat Oct 10 00:15:50 2009 @@ -169,7 +169,7 @@ how, (oid, methodname, args, kwargs) = request except TypeError: return ("ERROR", "Bad request format") - if not self.objtable.has_key(oid): + if oid not in self.objtable: return ("ERROR", "Unknown object id: %r" % (oid,)) obj = self.objtable[oid] if methodname == "__methods__": @@ -304,7 +304,7 @@ # wait for notification from socket handling thread cvar = self.cvars[myseq] cvar.acquire() - while not self.responses.has_key(myseq): + while myseq not in self.responses: cvar.wait() response = self.responses[myseq] self.debug("_getresponse:%s: thread woke up: response: %s" % @@ -550,7 +550,7 @@ return MethodProxy(self.sockio, self.oid, name) if self.__attributes is None: self.__getattributes() - if self.__attributes.has_key(name): + if name in self.__attributes: value = self.sockio.remotecall(self.oid, '__getattribute__', (name,), {}) return value Modified: python/trunk/Lib/lib-tk/FileDialog.py ============================================================================== --- python/trunk/Lib/lib-tk/FileDialog.py (original) +++ python/trunk/Lib/lib-tk/FileDialog.py Sat Oct 10 00:15:50 2009 @@ -107,7 +107,7 @@ self.top.bind('', self.cancel_command) def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None): - if key and dialogstates.has_key(key): + if key and key in dialogstates: self.directory, pattern = dialogstates[key] else: dir_or_file = os.path.expanduser(dir_or_file) Modified: python/trunk/Lib/lib-tk/FixTk.py ============================================================================== --- python/trunk/Lib/lib-tk/FixTk.py (original) +++ python/trunk/Lib/lib-tk/FixTk.py Sat Oct 10 00:15:50 2009 @@ -52,7 +52,7 @@ # if this does not exist, no further search is needed if os.path.exists(prefix): prefix = convert_path(prefix) - if not os.environ.has_key("TCL_LIBRARY"): + if "TCL_LIBRARY" not in os.environ: for name in os.listdir(prefix): if name.startswith("tcl"): tcldir = os.path.join(prefix,name) @@ -62,13 +62,13 @@ # as Tcl import _tkinter ver = str(_tkinter.TCL_VERSION) - if not os.environ.has_key("TK_LIBRARY"): + if "TK_LIBRARY" not in os.environ: v = os.path.join(prefix, 'tk'+ver) if os.path.exists(os.path.join(v, "tclIndex")): os.environ['TK_LIBRARY'] = v # We don't know the Tix version, so we must search the entire # directory - if not os.environ.has_key("TIX_LIBRARY"): + if "TIX_LIBRARY" not in os.environ: for name in os.listdir(prefix): if name.startswith("tix"): tixdir = os.path.join(prefix,name) Modified: python/trunk/Lib/lib-tk/Tix.py ============================================================================== --- python/trunk/Lib/lib-tk/Tix.py (original) +++ python/trunk/Lib/lib-tk/Tix.py Sat Oct 10 00:15:50 2009 @@ -336,7 +336,7 @@ # We can even do w.ok.invoke() because w.ok is subclassed from the # Button class if you go through the proper constructors def __getattr__(self, name): - if self.subwidget_list.has_key(name): + if name in self.subwidget_list: return self.subwidget_list[name] raise AttributeError, name @@ -464,9 +464,9 @@ # also destroys the parent NoteBook thus leading to an exception # in Tkinter when it finally calls Tcl to destroy the NoteBook for c in self.children.values(): c.destroy() - if self.master.children.has_key(self._name): + if self._name in self.master.children: del self.master.children[self._name] - if self.master.subwidget_list.has_key(self._name): + if self._name in self.master.subwidget_list: del self.master.subwidget_list[self._name] if self.destroy_physically: # This is bypassed only for a few widgets @@ -488,8 +488,8 @@ def __init__(self, itemtype, cnf={}, **kw): master = _default_root # global from Tkinter - if not master and cnf.has_key('refwindow'): master=cnf['refwindow'] - elif not master and kw.has_key('refwindow'): master= kw['refwindow'] + if not master and 'refwindow' in cnf: master=cnf['refwindow'] + elif not master and 'refwindow' in kw: master= kw['refwindow'] elif not master: raise RuntimeError, "Too early to create display style: no root window" self.tk = master.tk self.stylename = self.tk.call('tixDisplayStyle', itemtype, @@ -571,7 +571,7 @@ return btn def invoke(self, name): - if self.subwidget_list.has_key(name): + if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class ComboBox(TixWidget): @@ -1433,7 +1433,7 @@ self.subwidget_list['help'] = _dummyButton(self, 'help') def invoke(self, name): - if self.subwidget_list.has_key(name): + if name in self.subwidget_list: self.tk.call(self._w, 'invoke', name) class TList(TixWidget, XView, YView): Modified: python/trunk/Lib/lib-tk/Tkinter.py ============================================================================== --- python/trunk/Lib/lib-tk/Tkinter.py (original) +++ python/trunk/Lib/lib-tk/Tkinter.py Sat Oct 10 00:15:50 2009 @@ -547,7 +547,7 @@ A widget specified for the optional displayof keyword argument specifies the target display.""" - if not kw.has_key('displayof'): kw['displayof'] = self._w + if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('clipboard', 'clear') + self._options(kw)) def clipboard_append(self, string, **kw): """Append STRING to the Tk clipboard. @@ -555,7 +555,7 @@ A widget specified at the optional displayof keyword argument specifies the target display. The clipboard can be retrieved with selection_get.""" - if not kw.has_key('displayof'): kw['displayof'] = self._w + if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('clipboard', 'append') + self._options(kw) + ('--', string)) # XXX grab current w/o window argument @@ -613,7 +613,7 @@ self.tk.call('option', 'readfile', fileName, priority) def selection_clear(self, **kw): """Clear the current X selection.""" - if not kw.has_key('displayof'): kw['displayof'] = self._w + if 'displayof' not in kw: kw['displayof'] = self._w self.tk.call(('selection', 'clear') + self._options(kw)) def selection_get(self, **kw): """Return the contents of the current X selection. @@ -622,7 +622,7 @@ the selection and defaults to PRIMARY. A keyword parameter displayof specifies a widget on the display to use.""" - if not kw.has_key('displayof'): kw['displayof'] = self._w + if 'displayof' not in kw: kw['displayof'] = self._w return self.tk.call(('selection', 'get') + self._options(kw)) def selection_handle(self, command, **kw): """Specify a function COMMAND to call if the X @@ -653,7 +653,7 @@ be provided: selection - name of the selection (default PRIMARY), type - type of the selection (e.g. STRING, FILE_NAME).""" - if not kw.has_key('displayof'): kw['displayof'] = self._w + if 'displayof' not in kw: kw['displayof'] = self._w name = self.tk.call(('selection', 'own') + self._options(kw)) if not name: return None return self._nametowidget(name) @@ -1735,7 +1735,7 @@ the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if such a file exists in the home directory.""" import os - if os.environ.has_key('HOME'): home = os.environ['HOME'] + if 'HOME' in os.environ: home = os.environ['HOME'] else: home = os.curdir class_tcl = os.path.join(home, '.%s.tcl' % className) class_py = os.path.join(home, '.%s.py' % className) @@ -1942,7 +1942,7 @@ self.master = master self.tk = master.tk name = None - if cnf.has_key('name'): + if 'name' in cnf: name = cnf['name'] del cnf['name'] if not name: @@ -1953,7 +1953,7 @@ else: self._w = master._w + '.' + name self.children = {} - if self.master.children.has_key(self._name): + if self._name in self.master.children: self.master.children[self._name].destroy() self.master.children[self._name] = self def __init__(self, master, widgetName, cnf={}, kw={}, extra=()): @@ -1978,7 +1978,7 @@ """Destroy this and all descendants widgets.""" for c in self.children.values(): c.destroy() self.tk.call('destroy', self._w) - if self.master.children.has_key(self._name): + if self._name in self.master.children: del self.master.children[self._name] Misc.destroy(self) def _do(self, name, args=()): @@ -2006,7 +2006,7 @@ extra = () for wmkey in ['screen', 'class_', 'class', 'visual', 'colormap']: - if cnf.has_key(wmkey): + if wmkey in cnf: val = cnf[wmkey] # TBD: a hack needed because some keys # are not valid as keyword arguments @@ -2444,10 +2444,10 @@ highlightcolor, highlightthickness, relief, takefocus, visual, width.""" cnf = _cnfmerge((cnf, kw)) extra = () - if cnf.has_key('class_'): + if 'class_' in cnf: extra = ('-class', cnf['class_']) del cnf['class_'] - elif cnf.has_key('class'): + elif 'class' in cnf: extra = ('-class', cnf['class']) del cnf['class'] Widget.__init__(self, master, 'frame', cnf, {}, extra) @@ -3153,7 +3153,7 @@ self.menuname = menu._w # 'command' is the only supported keyword callback = kwargs.get('command') - if kwargs.has_key('command'): + if 'command' in kwargs: del kwargs['command'] if kwargs: raise TclError, 'unknown option -'+kwargs.keys()[0] Modified: python/trunk/Lib/lib-tk/tkSimpleDialog.py ============================================================================== --- python/trunk/Lib/lib-tk/tkSimpleDialog.py (original) +++ python/trunk/Lib/lib-tk/tkSimpleDialog.py Sat Oct 10 00:15:50 2009 @@ -283,7 +283,7 @@ class _QueryString(_QueryDialog): def __init__(self, *args, **kw): - if kw.has_key("show"): + if "show" in kw: self.__show = kw["show"] del kw["show"] else: Modified: python/trunk/Lib/lib-tk/turtle.py ============================================================================== --- python/trunk/Lib/lib-tk/turtle.py (original) +++ python/trunk/Lib/lib-tk/turtle.py Sat Oct 10 00:15:50 2009 @@ -335,10 +335,10 @@ if ex[:1] == '_' or ex[-1:] == '_': del _dict[ex] for ex in exclude: - if _dict.has_key(ex): + if ex in _dict: del _dict[ex] for ex in __methods(fromClass): - if _dict.has_key(ex): + if ex in _dict: del _dict[ex] for method, func in _dict.items(): Modified: python/trunk/Lib/msilib/__init__.py ============================================================================== --- python/trunk/Lib/msilib/__init__.py (original) +++ python/trunk/Lib/msilib/__init__.py Sat Oct 10 00:15:50 2009 @@ -330,7 +330,7 @@ file = os.path.basename(file) absolute = os.path.join(self.absolute, src) assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names - if self.keyfiles.has_key(file): + if file in self.keyfiles: logical = self.keyfiles[file] else: logical = None Modified: python/trunk/Lib/trace.py ============================================================================== --- python/trunk/Lib/trace.py (original) +++ python/trunk/Lib/trace.py Sat Oct 10 00:15:50 2009 @@ -124,7 +124,7 @@ self._ignore = { '': 1 } def names(self, filename, modulename): - if self._ignore.has_key(modulename): + if modulename in self._ignore: return self._ignore[modulename] # haven't seen this one before, so see if the module name is Modified: python/trunk/Lib/wsgiref/handlers.py ============================================================================== --- python/trunk/Lib/wsgiref/handlers.py (original) +++ python/trunk/Lib/wsgiref/handlers.py Sat Oct 10 00:15:50 2009 @@ -160,7 +160,7 @@ Subclasses can extend this to add other defaults. """ - if not self.headers.has_key('Content-Length'): + if 'Content-Length' not in self.headers: self.set_content_length() def start_response(self, status, headers,exc_info=None): @@ -195,11 +195,11 @@ if self.origin_server: if self.client_is_modern(): self._write('HTTP/%s %s\r\n' % (self.http_version,self.status)) - if not self.headers.has_key('Date'): + if 'Date' not in self.headers: self._write( 'Date: %s\r\n' % format_date_time(time.time()) ) - if self.server_software and not self.headers.has_key('Server'): + if self.server_software and 'Server' not in self.headers: self._write('Server: %s\r\n' % self.server_software) else: self._write('Status: %s\r\n' % self.status) Modified: python/trunk/Lib/wsgiref/validate.py ============================================================================== --- python/trunk/Lib/wsgiref/validate.py (original) +++ python/trunk/Lib/wsgiref/validate.py Sat Oct 10 00:15:50 2009 @@ -345,7 +345,7 @@ "Invalid CONTENT_LENGTH: %r" % environ['CONTENT_LENGTH']) if not environ.get('SCRIPT_NAME'): - assert_(environ.has_key('PATH_INFO'), + assert_('PATH_INFO' in environ, "One of SCRIPT_NAME or PATH_INFO are required (PATH_INFO " "should at least be '/' if SCRIPT_NAME is empty)") assert_(environ.get('SCRIPT_NAME') != '/', Modified: python/trunk/Lib/xml/dom/domreg.py ============================================================================== --- python/trunk/Lib/xml/dom/domreg.py (original) +++ python/trunk/Lib/xml/dom/domreg.py Sat Oct 10 00:15:50 2009 @@ -57,7 +57,7 @@ return mod.getDOMImplementation() elif name: return registered[name]() - elif os.environ.has_key("PYTHON_DOM"): + elif "PYTHON_DOM" in os.environ: return getDOMImplementation(name = os.environ["PYTHON_DOM"]) # User did not specify a name, try implementations in arbitrary Modified: python/trunk/Lib/xml/dom/minidom.py ============================================================================== --- python/trunk/Lib/xml/dom/minidom.py (original) +++ python/trunk/Lib/xml/dom/minidom.py Sat Oct 10 00:15:50 2009 @@ -491,9 +491,9 @@ def has_key(self, key): if isinstance(key, StringTypes): - return self._attrs.has_key(key) + return key in self._attrs else: - return self._attrsNS.has_key(key) + return key in self._attrsNS def keys(self): return self._attrs.keys() @@ -775,10 +775,10 @@ removeAttributeNodeNS = removeAttributeNode def hasAttribute(self, name): - return self._attrs.has_key(name) + return name in self._attrs def hasAttributeNS(self, namespaceURI, localName): - return self._attrsNS.has_key((namespaceURI, localName)) + return (namespaceURI, localName) in self._attrsNS def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) Modified: python/trunk/Lib/xml/dom/xmlbuilder.py ============================================================================== --- python/trunk/Lib/xml/dom/xmlbuilder.py (original) +++ python/trunk/Lib/xml/dom/xmlbuilder.py Sat Oct 10 00:15:50 2009 @@ -91,7 +91,7 @@ def canSetFeature(self, name, state): key = (_name_xform(name), state and 1 or 0) - return self._settings.has_key(key) + return key in self._settings # This dictionary maps from (feature,value) to a list of # (option,value) pairs that should be set on the Options object. @@ -247,7 +247,7 @@ def _guess_media_encoding(self, source): info = source.byteStream.info() - if info.has_key("Content-Type"): + if "Content-Type" in info: for param in info.getplist(): if param.startswith("charset="): return param.split("=", 1)[1].lower() Modified: python/trunk/Lib/xml/sax/__init__.py ============================================================================== --- python/trunk/Lib/xml/sax/__init__.py (original) +++ python/trunk/Lib/xml/sax/__init__.py Sat Oct 10 00:15:50 2009 @@ -59,7 +59,7 @@ import xml.sax.expatreader import os, sys -if os.environ.has_key("PY_SAX_PARSER"): +if "PY_SAX_PARSER" in os.environ: default_parser_list = os.environ["PY_SAX_PARSER"].split(",") del os From python-checkins at python.org Sat Oct 10 00:34:44 2009 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 09 Oct 2009 22:34:44 -0000 Subject: [Python-checkins] r75306 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sat Oct 10 00:34:44 2009 New Revision: 75306 Log: Blocked revisions 75304-75305 via svnmerge ........ r75304 | benjamin.peterson | 2009-10-09 17:05:45 -0500 (Fri, 09 Oct 2009) | 1 line replace callable() ........ r75305 | benjamin.peterson | 2009-10-09 17:15:50 -0500 (Fri, 09 Oct 2009) | 1 line replace has_key with 'in' operator ........ Modified: python/branches/py3k/ (props changed) From nnorwitz at gmail.com Sat Oct 10 00:36:13 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 9 Oct 2009 18:36:13 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091009223613.GA9213@python.psfb.org> More important issues: ---------------------- test_distutils leaked [0, 25, 0] references, sum=25 test_ssl leaked [0, -420, 81] references, sum=-339 Less important issues: ---------------------- test_cmd_line leaked [0, 0, -25] references, sum=-25 test_docxmlrpc leaked [-184, -4, 4] references, sum=-184 test_popen2 leaked [-29, 25, 4] references, sum=0 test_smtplib leaked [6, 0, -88] references, sum=-82 test_sys leaked [-21, 83, -62] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Sat Oct 10 02:13:32 2009 From: python-checkins at python.org (r.david.murray) Date: Sat, 10 Oct 2009 00:13:32 -0000 Subject: [Python-checkins] r75307 - in python/branches/py3k: Lib/email/message.py Lib/email/test/data/msg_44.txt Misc/ACKS Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Oct 10 02:13:32 2009 New Revision: 75307 Log: Merged revisions 75301 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75301 | r.david.murray | 2009-10-09 17:50:54 -0400 (Fri, 09 Oct 2009) | 5 lines Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. Patch by Darren Worrall. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/email/message.py python/branches/py3k/Lib/email/test/data/msg_44.txt python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/email/message.py ============================================================================== --- python/branches/py3k/Lib/email/message.py (original) +++ python/branches/py3k/Lib/email/message.py Sat Oct 10 02:13:32 2009 @@ -681,7 +681,7 @@ missing = object() filename = self.get_param('filename', missing, 'content-disposition') if filename is missing: - filename = self.get_param('name', missing, 'content-disposition') + filename = self.get_param('name', missing, 'content-type') if filename is missing: return failobj return utils.collapse_rfc2231_value(filename).strip() Modified: python/branches/py3k/Lib/email/test/data/msg_44.txt ============================================================================== --- python/branches/py3k/Lib/email/test/data/msg_44.txt (original) +++ python/branches/py3k/Lib/email/test/data/msg_44.txt Sat Oct 10 02:13:32 2009 @@ -16,16 +16,14 @@ --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror to reflect upon our own --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Sat Oct 10 02:13:32 2009 @@ -820,6 +820,7 @@ Klaus-Juergen Wolf Dan Wolfe Richard Wolff +Darren Worrall Gordon Worley Thomas Wouters Heiko Wundram Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 10 02:13:32 2009 @@ -87,6 +87,9 @@ Library ------- +- Issue #7082: When falling back to the MIME 'name' parameter, the + correct place to look for it is the Content-Type header. + - Make tokenize.detect_coding() normalize utf-8 and iso-8859-1 variants like the builtin tokenizer. From python-checkins at python.org Sat Oct 10 02:57:05 2009 From: python-checkins at python.org (r.david.murray) Date: Sat, 10 Oct 2009 00:57:05 -0000 Subject: [Python-checkins] r75308 - in python/branches/release31-maint: Lib/email/message.py Lib/email/test/data/msg_44.txt Misc/ACKS Misc/NEWS Message-ID: Author: r.david.murray Date: Sat Oct 10 02:57:04 2009 New Revision: 75308 Log: Merged revisions 75307 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75307 | r.david.murray | 2009-10-09 20:13:32 -0400 (Fri, 09 Oct 2009) | 12 lines Merged revisions 75301 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75301 | r.david.murray | 2009-10-09 17:50:54 -0400 (Fri, 09 Oct 2009) | 5 lines Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. Patch by Darren Worrall. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/email/message.py python/branches/release31-maint/Lib/email/test/data/msg_44.txt python/branches/release31-maint/Misc/ACKS python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/email/message.py ============================================================================== --- python/branches/release31-maint/Lib/email/message.py (original) +++ python/branches/release31-maint/Lib/email/message.py Sat Oct 10 02:57:04 2009 @@ -681,7 +681,7 @@ missing = object() filename = self.get_param('filename', missing, 'content-disposition') if filename is missing: - filename = self.get_param('name', missing, 'content-disposition') + filename = self.get_param('name', missing, 'content-type') if filename is missing: return failobj return utils.collapse_rfc2231_value(filename).strip() Modified: python/branches/release31-maint/Lib/email/test/data/msg_44.txt ============================================================================== --- python/branches/release31-maint/Lib/email/test/data/msg_44.txt (original) +++ python/branches/release31-maint/Lib/email/test/data/msg_44.txt Sat Oct 10 02:57:04 2009 @@ -16,16 +16,14 @@ --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror to reflect upon our own --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Sat Oct 10 02:57:04 2009 @@ -811,6 +811,7 @@ Klaus-Juergen Wolf Dan Wolfe Richard Wolff +Darren Worrall Gordon Worley Thomas Wouters Heiko Wundram Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sat Oct 10 02:57:04 2009 @@ -27,6 +27,9 @@ Library ------- +- Issue #7082: When falling back to the MIME 'name' parameter, the + correct place to look for it is the Content-Type header. + - Make tokenize.detect_coding() normalize utf-8 and iso-8859-1 variants like the builtin tokenizer. From python-checkins at python.org Sat Oct 10 03:16:07 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 10 Oct 2009 01:16:07 -0000 Subject: [Python-checkins] r75309 - in python/branches/py3k: Doc/library/weakref.rst Modules/_threadmodule.c Message-ID: Author: benjamin.peterson Date: Sat Oct 10 03:16:07 2009 New Revision: 75309 Log: Merged revisions 74524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74524 | gregory.p.smith | 2009-08-20 04:39:38 -0500 (Thu, 20 Aug 2009) | 2 lines Add weakref support to the thread.lock type. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Modules/_threadmodule.c Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Sat Oct 10 03:16:07 2009 @@ -61,6 +61,9 @@ frozensets, file objects, :term:`generator`\s, type objects, sockets, arrays, deques, and regular expression pattern objects. +.. versionchanged:: 3.2 + Added support for thread.lock and threading.Lock. + Several built-in types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: Modified: python/branches/py3k/Modules/_threadmodule.c ============================================================================== --- python/branches/py3k/Modules/_threadmodule.c (original) +++ python/branches/py3k/Modules/_threadmodule.c Sat Oct 10 03:16:07 2009 @@ -3,6 +3,7 @@ /* Interface to Sjoerd's portable C thread library */ #include "Python.h" +#include "structmember.h" /* offsetof */ #ifndef WITH_THREAD #error "Error! The rest of Python is not compiled with thread support." @@ -20,12 +21,15 @@ typedef struct { PyObject_HEAD PyThread_type_lock lock_lock; + PyObject *in_weakreflist; } lockobject; static void lock_dealloc(lockobject *self) { assert(self->lock_lock); + if (self->in_weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); /* Unlock the lock so it's safe to free it */ PyThread_acquire_lock(self->lock_lock, 0); PyThread_release_lock(self->lock_lock); @@ -145,7 +149,7 @@ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ + offsetof(lockobject, in_weakreflist), /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ lock_methods, /*tp_methods*/ @@ -159,6 +163,7 @@ if (self == NULL) return NULL; self->lock_lock = PyThread_allocate_lock(); + self->in_weakreflist = NULL; if (self->lock_lock == NULL) { PyObject_Del(self); self = NULL; From nnorwitz at gmail.com Sat Oct 10 11:45:20 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 10 Oct 2009 05:45:20 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091010094520.GA32436@python.psfb.org> More important issues: ---------------------- test_ssl leaked [339, 0, -420] references, sum=-81 Less important issues: ---------------------- test_asynchat leaked [0, 0, 139] references, sum=139 test_file2k leaked [0, 80, -80] references, sum=0 test_smtplib leaked [-115, -161, -2] references, sum=-278 test_socketserver leaked [80, -80, 0] references, sum=0 test_sys leaked [21, 0, -21] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Sat Oct 10 22:32:36 2009 From: python-checkins at python.org (vinay.sajip) Date: Sat, 10 Oct 2009 20:32:36 -0000 Subject: [Python-checkins] r75310 - in python: branches/py3k/Doc/library/logging.rst branches/py3k/Lib/logging/__init__.py branches/py3k/Lib/logging/config.py branches/py3k/Lib/logging/handlers.py branches/py3k/Misc/NEWS trunk/Doc/library/logging.rst trunk/Lib/logging/__init__.py trunk/Lib/logging/config.py trunk/Lib/logging/handlers.py trunk/Misc/NEWS Message-ID: Author: vinay.sajip Date: Sat Oct 10 22:32:36 2009 New Revision: 75310 Log: Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code. Modified: python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Lib/logging/config.py python/branches/py3k/Lib/logging/handlers.py python/branches/py3k/Misc/NEWS python/trunk/Doc/library/logging.rst python/trunk/Lib/logging/__init__.py python/trunk/Lib/logging/config.py python/trunk/Lib/logging/handlers.py python/trunk/Misc/NEWS Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Sat Oct 10 22:32:36 2009 @@ -763,11 +763,13 @@ Does basic configuration for the logging system by creating a :class:`StreamHandler` with a default :class:`Formatter` and adding it to the - root logger. The function does nothing if any handlers have been defined for - the root logger. The functions :func:`debug`, :func:`info`, :func:`warning`, + root logger. The functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` and :func:`critical` will call :func:`basicConfig` automatically if no handlers are defined for the root logger. + This function does nothing if the root logger already has handlers + configured for it. + The following keyword arguments are supported. +--------------+---------------------------------------------+ @@ -1957,16 +1959,22 @@ supports sending logging messages to a remote or local Unix syslog. -.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER) +.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM) Returns a new instance of the :class:`SysLogHandler` class intended to communicate with a remote Unix machine whose address is given by *address* in the form of a ``(host, port)`` tuple. If *address* is not specified, - ``('localhost', 514)`` is used. The address is used to open a UDP socket. An + ``('localhost', 514)`` is used. The address is used to open a socket. An alternative to providing a ``(host, port)`` tuple is providing an address as a string, for example "/dev/log". In this case, a Unix domain socket is used to send the message to the syslog. If *facility* is not specified, - :const:`LOG_USER` is used. + :const:`LOG_USER` is used. The type of socket opened depends on the + *socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus + opens a UDP socket. To open a TCP socket (for use with the newer syslog + daemons such as rsyslog), specify a value of :const:`socket.SOCK_STREAM`. + + .. versionchanged:: 3.2 + *socktype* was added. .. method:: close() Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Sat Oct 10 22:32:36 2009 @@ -46,8 +46,8 @@ __author__ = "Vinay Sajip " __status__ = "production" -__version__ = "0.5.0.7" -__date__ = "20 January 2009" +__version__ = "0.5.0.9" +__date__ = "09 October 2009" #--------------------------------------------------------------------------- # Miscellaneous module data Modified: python/branches/py3k/Lib/logging/config.py ============================================================================== --- python/branches/py3k/Lib/logging/config.py (original) +++ python/branches/py3k/Lib/logging/config.py Sat Oct 10 22:32:36 2009 @@ -19,7 +19,7 @@ is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ Modified: python/branches/py3k/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k/Lib/logging/handlers.py (original) +++ python/branches/py3k/Lib/logging/handlers.py Sat Oct 10 22:32:36 2009 @@ -1,4 +1,4 @@ -# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -41,6 +41,7 @@ DEFAULT_HTTP_LOGGING_PORT = 9022 DEFAULT_SOAP_LOGGING_PORT = 9023 SYSLOG_UDP_PORT = 514 +SYSLOG_TCP_PORT = 514 _MIDNIGHT = 24 * 60 * 60 # number of seconds in a day @@ -155,7 +156,7 @@ If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted. """ - def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=False): + def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False): BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay) self.when = when.upper() self.backupCount = backupCount @@ -690,7 +691,8 @@ "CRITICAL" : "critical" } - def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): + def __init__(self, address=('localhost', SYSLOG_UDP_PORT), + facility=LOG_USER, socktype=socket.SOCK_DGRAM): """ Initialize a handler. @@ -702,13 +704,16 @@ self.address = address self.facility = facility + self.socktype = socktype + if isinstance(address, str): self.unixsocket = 1 self._connect_unixsocket(address) else: self.unixsocket = 0 - self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - + self.socket = socket.socket(socket.AF_INET, socktype) + if socktype == socket.SOCK_STREAM: + self.socket.connect(address) self.formatter = None def _connect_unixsocket(self, address): @@ -781,8 +786,10 @@ except socket.error: self._connect_unixsocket(self.address) self.socket.send(msg) - else: + elif self.socktype == socket.SOCK_DGRAM: self.socket.sendto(msg, self.address) + else: + self.socket.sendall(msg) except (KeyboardInterrupt, SystemExit): raise except: Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 10 22:32:36 2009 @@ -87,6 +87,9 @@ Library ------- +- Issue #7086: Added TCP support to SysLogHandler, and tidied up some + anachronisms in the code which were a relic of 1.5.2 compatibility. + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. Modified: python/trunk/Doc/library/logging.rst ============================================================================== --- python/trunk/Doc/library/logging.rst (original) +++ python/trunk/Doc/library/logging.rst Sat Oct 10 22:32:36 2009 @@ -764,12 +764,12 @@ Does basic configuration for the logging system by creating a :class:`StreamHandler` with a default :class:`Formatter` and adding it to the - root logger. The function does nothing if any handlers have been defined for - the root logger. The functions :func:`debug`, :func:`info`, :func:`warning`, + root logger. The functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` and :func:`critical` will call :func:`basicConfig` automatically if no handlers are defined for the root logger. - This function does nothing if the root logger already has handlers configured. + This function does nothing if the root logger already has handlers + configured for it. .. versionchanged:: 2.4 Formerly, :func:`basicConfig` did not take any keyword arguments. @@ -2008,16 +2008,22 @@ supports sending logging messages to a remote or local Unix syslog. -.. class:: SysLogHandler([address[, facility]]) +.. class:: SysLogHandler([address[, facility[, socktype]]]) Returns a new instance of the :class:`SysLogHandler` class intended to communicate with a remote Unix machine whose address is given by *address* in the form of a ``(host, port)`` tuple. If *address* is not specified, - ``('localhost', 514)`` is used. The address is used to open a UDP socket. An + ``('localhost', 514)`` is used. The address is used to open a socket. An alternative to providing a ``(host, port)`` tuple is providing an address as a string, for example "/dev/log". In this case, a Unix domain socket is used to send the message to the syslog. If *facility* is not specified, - :const:`LOG_USER` is used. + :const:`LOG_USER` is used. The type of socket opened depends on the + *socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus + opens a UDP socket. To open a TCP socket (for use with the newer syslog + daemons such as rsyslog), specify a value of :const:`socket.SOCK_STREAM`. + + .. versionchanged:: 2.7 + *socktype* was added. .. method:: close() Modified: python/trunk/Lib/logging/__init__.py ============================================================================== --- python/trunk/Lib/logging/__init__.py (original) +++ python/trunk/Lib/logging/__init__.py Sat Oct 10 22:32:36 2009 @@ -23,6 +23,8 @@ To use, simply 'import logging' and log away! """ +import sys, os, time, cStringIO, traceback, warnings + __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', 'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO', 'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'NullHandler', @@ -31,8 +33,6 @@ 'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass', 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning'] -import sys, os, types, time, string, cStringIO, traceback, warnings - try: import codecs except ImportError: @@ -46,12 +46,17 @@ __author__ = "Vinay Sajip " __status__ = "production" -__version__ = "0.5.0.8" -__date__ = "27 April 2009" +__version__ = "0.5.0.9" +__date__ = "09 October 2009" #--------------------------------------------------------------------------- # Miscellaneous module data #--------------------------------------------------------------------------- +try: + unicode + _unicode = True +except NameError: + _unicode = False # # _srcfile is used when walking the stack to check when we've got the first @@ -59,7 +64,7 @@ # if hasattr(sys, 'frozen'): #support for py2exe _srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:]) -elif string.lower(__file__[-4:]) in ['.pyc', '.pyo']: +elif __file__[-4:].lower() in ['.pyc', '.pyo']: _srcfile = __file__[:-4] + '.py' else: _srcfile = __file__ @@ -71,7 +76,7 @@ try: raise Exception except: - return sys.exc_traceback.tb_frame.f_back + return sys.exc_info()[2].tb_frame.f_back if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3) # done filching @@ -255,9 +260,7 @@ # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. - if args and len(args) == 1 and ( - type(args[0]) == types.DictType - ) and args[0]: + if args and len(args) == 1 and isinstance(args[0], dict) and args[0]: args = args[0] self.args = args self.levelname = getLevelName(level) @@ -306,11 +309,11 @@ Return the message for this LogRecord after merging any user-supplied arguments with the message. """ - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... msg = str(self.msg) else: msg = self.msg - if type(msg) not in (types.UnicodeType, types.StringType): + if not isinstance(msg, basestring): try: msg = str(self.msg) except UnicodeError: @@ -447,7 +450,7 @@ formatException() and appended to the message. """ record.message = record.getMessage() - if string.find(self._fmt,"%(asctime)") >= 0: + if self._fmt.find("%(asctime)") >= 0: record.asctime = self.formatTime(record, self.datefmt) s = self._fmt % record.__dict__ if record.exc_info: @@ -541,7 +544,7 @@ return 1 elif self.name == record.name: return 1 - elif string.find(record.name, self.name, 0, self.nlen) != 0: + elif record.name.find(self.name, 0, self.nlen) != 0: return 0 return (record.name[self.nlen] == ".") @@ -667,8 +670,8 @@ This version is intended to be implemented by subclasses and so raises a NotImplementedError. """ - raise NotImplementedError, 'emit must be implemented '\ - 'by Handler subclasses' + raise NotImplementedError('emit must be implemented ' + 'by Handler subclasses') def handle(self, record): """ @@ -781,7 +784,7 @@ msg = self.format(record) stream = self.stream fs = "%s\n" - if not hasattr(types, "UnicodeType"): #if no unicode support... + if not _unicode: #if no unicode support... stream.write(fs % msg) else: try: @@ -903,8 +906,8 @@ """ if klass != Logger: if not issubclass(klass, Logger): - raise TypeError, "logger not derived from logging.Logger: " + \ - klass.__name__ + raise TypeError("logger not derived from logging.Logger: " + + klass.__name__) global _loggerClass _loggerClass = klass @@ -967,7 +970,7 @@ from the specified logger to the root of the logger hierarchy. """ name = alogger.name - i = string.rfind(name, ".") + i = name.rfind(".") rv = None while (i > 0) and not rv: substr = name[:i] @@ -980,7 +983,7 @@ else: assert isinstance(obj, PlaceHolder) obj.append(alogger) - i = string.rfind(name, ".", 0, i - 1) + i = name.rfind(".", 0, i - 1) if not rv: rv = self.root alogger.parent = rv @@ -994,7 +997,6 @@ namelen = len(name) for c in ph.loggerMap.keys(): #The if means ... if not c.parent.name.startswith(nm) - #if string.find(c.parent.name, nm) <> 0: if c.parent.name[:namelen] != name: alogger.parent = c.parent c.parent = alogger @@ -1090,7 +1092,7 @@ """ Convenience method for logging an ERROR with exception information. """ - self.error(*((msg,) + args), **{'exc_info': 1}) + self.error(msg, exc_info=1, *args) def critical(self, msg, *args, **kwargs): """ @@ -1115,9 +1117,9 @@ logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ - if type(level) != types.IntType: + if not isinstance(level, int): if raiseExceptions: - raise TypeError, "level must be an integer" + raise TypeError("level must be an integer") else: return if self.isEnabledFor(level): @@ -1173,7 +1175,7 @@ else: fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: - if type(exc_info) != types.TupleType: + if not isinstance(exc_info, tuple): exc_info = sys.exc_info() record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra) self.handle(record) @@ -1449,7 +1451,7 @@ """ if len(root.handlers) == 0: basicConfig() - root.critical(*((msg,)+args), **kwargs) + root.critical(msg, *args, **kwargs) fatal = critical @@ -1459,14 +1461,14 @@ """ if len(root.handlers) == 0: basicConfig() - root.error(*((msg,)+args), **kwargs) + root.error(msg, *args, **kwargs) def exception(msg, *args): """ Log a message with severity 'ERROR' on the root logger, with exception information. """ - error(*((msg,)+args), **{'exc_info': 1}) + error(msg, exc_info=1, *args) def warning(msg, *args, **kwargs): """ @@ -1474,7 +1476,7 @@ """ if len(root.handlers) == 0: basicConfig() - root.warning(*((msg,)+args), **kwargs) + root.warning(msg, *args, **kwargs) warn = warning @@ -1484,7 +1486,7 @@ """ if len(root.handlers) == 0: basicConfig() - root.info(*((msg,)+args), **kwargs) + root.info(msg, *args, **kwargs) def debug(msg, *args, **kwargs): """ @@ -1492,7 +1494,7 @@ """ if len(root.handlers) == 0: basicConfig() - root.debug(*((msg,)+args), **kwargs) + root.debug(msg, *args, **kwargs) def log(level, msg, *args, **kwargs): """ @@ -1500,7 +1502,7 @@ """ if len(root.handlers) == 0: basicConfig() - root.log(*((level, msg)+args), **kwargs) + root.log(level, msg, *args, **kwargs) def disable(level): """ Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Sat Oct 10 22:32:36 2009 @@ -19,15 +19,12 @@ is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. -Should work under Python versions >= 1.5.2, except that source line -information is not available unless 'sys._getframe()' is. - -Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback, types +import sys, logging, logging.handlers, socket, struct, os, traceback try: import thread @@ -52,7 +49,7 @@ # _listener holds the server object doing the listening _listener = None -def fileConfig(fname, defaults=None, disable_existing_loggers=1): +def fileConfig(fname, defaults=None, disable_existing_loggers=True): """ Read the logging configuration from a ConfigParser-format file. @@ -89,7 +86,7 @@ def _resolve(name): """Resolve a dotted name to a global object.""" - name = string.split(name, '.') + name = name.split('.') used = name.pop(0) found = __import__(used) for n in name: @@ -102,14 +99,14 @@ return found def _strip_spaces(alist): - return map(lambda x: string.strip(x), alist) + return map(lambda x: x.strip(), alist) def _create_formatters(cp): """Create and return formatters""" flist = cp.get("formatters", "keys") if not len(flist): return {} - flist = string.split(flist, ",") + flist = flist.split(",") flist = _strip_spaces(flist) formatters = {} for form in flist: @@ -138,7 +135,7 @@ hlist = cp.get("handlers", "keys") if not len(hlist): return {} - hlist = string.split(hlist, ",") + hlist = hlist.split(",") hlist = _strip_spaces(hlist) handlers = {} fixups = [] #for inter-handler references @@ -181,8 +178,8 @@ # configure the root first llist = cp.get("loggers", "keys") - llist = string.split(llist, ",") - llist = map(lambda x: string.strip(x), llist) + llist = llist.split(",") + llist = list(map(lambda x: x.strip(), llist)) llist.remove("root") sectname = "logger_root" root = logging.root @@ -195,7 +192,7 @@ root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): - hlist = string.split(hlist, ",") + hlist = hlist.split(",") hlist = _strip_spaces(hlist) for hand in hlist: log.addHandler(handlers[hand]) @@ -209,7 +206,7 @@ #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. - existing = root.manager.loggerDict.keys() + existing = list(root.manager.loggerDict.keys()) #The list needs to be sorted so that we can #avoid disabling child loggers of explicitly #named loggers. With a sorted list it is easier @@ -247,7 +244,7 @@ logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): - hlist = string.split(hlist, ",") + hlist = hlist.split(",") hlist = _strip_spaces(hlist) for hand in hlist: logger.addHandler(handlers[hand]) @@ -278,7 +275,7 @@ stopListening(). """ if not thread: - raise NotImplementedError, "listen() needs threading to work" + raise NotImplementedError("listen() needs threading to work") class ConfigStreamHandler(StreamRequestHandler): """ @@ -321,7 +318,7 @@ traceback.print_exc() os.remove(file) except socket.error, e: - if type(e.args) != types.TupleType: + if not isinstance(e.args, tuple): raise else: errcode = e.args[0] Modified: python/trunk/Lib/logging/handlers.py ============================================================================== --- python/trunk/Lib/logging/handlers.py (original) +++ python/trunk/Lib/logging/handlers.py Sat Oct 10 22:32:36 2009 @@ -24,7 +24,7 @@ To use, simply 'import logging.handlers' and log away! """ -import logging, socket, types, os, string, cPickle, struct, time, re +import logging, socket, os, cPickle, struct, time, re from stat import ST_DEV, ST_INO try: @@ -41,6 +41,7 @@ DEFAULT_HTTP_LOGGING_PORT = 9022 DEFAULT_SOAP_LOGGING_PORT = 9023 SYSLOG_UDP_PORT = 514 +SYSLOG_TCP_PORT = 514 _MIDNIGHT = 24 * 60 * 60 # number of seconds in a day @@ -155,9 +156,9 @@ If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted. """ - def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=0): + def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False): BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay) - self.when = string.upper(when) + self.when = when.upper() self.backupCount = backupCount self.utc = utc # Calculate the real rollover interval, which is just the number of @@ -204,8 +205,6 @@ self.interval = self.interval * interval # multiply by units requested self.rolloverAt = self.computeRollover(int(time.time())) - #print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime) - def computeRollover(self, currentTime): """ Work out the rollover time based on the specified time. @@ -692,7 +691,8 @@ "CRITICAL" : "critical" } - def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): + def __init__(self, address=('localhost', SYSLOG_UDP_PORT), + facility=LOG_USER, socktype=socket.SOCK_DGRAM): """ Initialize a handler. @@ -704,13 +704,16 @@ self.address = address self.facility = facility - if type(address) == types.StringType: + self.socktype = socktype + + if isinstance(address, basestring): self.unixsocket = 1 self._connect_unixsocket(address) else: self.unixsocket = 0 - self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - + self.socket = socket.socket(socket.AF_INET, socktype) + if socktype == socket.SOCK_STREAM: + self.socket.connect(address) self.formatter = None def _connect_unixsocket(self, address): @@ -736,9 +739,9 @@ priority_names mapping dictionaries are used to convert them to integers. """ - if type(facility) == types.StringType: + if isinstance(facility, basestring): facility = self.facility_names[facility] - if type(priority) == types.StringType: + if isinstance(priority, basestring): priority = self.priority_names[priority] return (facility << 3) | priority @@ -783,8 +786,10 @@ except socket.error: self._connect_unixsocket(self.address) self.socket.send(msg) - else: + elif self.socktype == socket.SOCK_DGRAM: self.socket.sendto(msg, self.address) + else: + self.socket.sendall(msg) except (KeyboardInterrupt, SystemExit): raise except: @@ -805,16 +810,16 @@ for the credentials argument. """ logging.Handler.__init__(self) - if type(mailhost) == types.TupleType: + if isinstance(mailhost, tuple): self.mailhost, self.mailport = mailhost else: self.mailhost, self.mailport = mailhost, None - if type(credentials) == types.TupleType: + if isinstance(credentials, tuple): self.username, self.password = credentials else: self.username = None self.fromaddr = fromaddr - if type(toaddrs) == types.StringType: + if isinstance(toaddrs, basestring): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject @@ -865,7 +870,7 @@ msg = self.format(record) msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % ( self.fromaddr, - string.join(self.toaddrs, ","), + ",".join(self.toaddrs), self.getSubject(record), formatdate(), msg) if self.username: @@ -909,8 +914,8 @@ logging.CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE, } except ImportError: - print "The Python Win32 extensions for NT (service, event "\ - "logging) appear not to be available." + print("The Python Win32 extensions for NT (service, event "\ + "logging) appear not to be available.") self._welu = None def getMessageID(self, record): @@ -988,9 +993,9 @@ ("GET" or "POST") """ logging.Handler.__init__(self) - method = string.upper(method) + method = method.upper() if method not in ["GET", "POST"]: - raise ValueError, "method must be GET or POST" + raise ValueError("method must be GET or POST") self.host = host self.url = url self.method = method @@ -1016,7 +1021,7 @@ url = self.url data = urllib.urlencode(self.mapLogRecord(record)) if self.method == "GET": - if (string.find(url, '?') >= 0): + if (url.find('?') >= 0): sep = '&' else: sep = '?' @@ -1024,7 +1029,7 @@ h.putrequest(self.method, url) # support multiple hosts on one IP address... # need to strip optional :port from host, if present - i = string.find(host, ":") + i = host.find(":") if i >= 0: host = host[:i] h.putheader("Host", host) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 10 22:32:36 2009 @@ -398,6 +398,9 @@ Library ------- +- Issue #7086: Added TCP support to SysLogHandler, and tidied up some + anachronisms in the code which were a relic of 1.5.2 compatibility. + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. From python-checkins at python.org Sat Oct 10 22:39:25 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 10 Oct 2009 20:39:25 -0000 Subject: [Python-checkins] r75311 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Sat Oct 10 22:39:25 2009 New Revision: 75311 Log: Blocked revisions 75310 via svnmerge ........ r75310 | vinay.sajip | 2009-10-10 15:32:36 -0500 (Sat, 10 Oct 2009) | 1 line Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 10 22:52:11 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 10 Oct 2009 20:52:11 -0000 Subject: [Python-checkins] r75312 - in python/trunk: Lib/test/test___all__.py Misc/NEWS Message-ID: Author: antoine.pitrou Date: Sat Oct 10 22:52:11 2009 New Revision: 75312 Log: Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. Modified: python/trunk/Lib/test/test___all__.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test___all__.py ============================================================================== --- python/trunk/Lib/test/test___all__.py (original) +++ python/trunk/Lib/test/test___all__.py Sat Oct 10 22:52:11 2009 @@ -1,9 +1,18 @@ +from __future__ import print_function + import unittest -from test.test_support import run_unittest +from test import test_support as support +import os import sys import warnings +class NoAll(RuntimeError): + pass + +class FailedImport(RuntimeError): + pass + class AllTest(unittest.TestCase): @@ -14,171 +23,97 @@ DeprecationWarning) try: exec "import %s" % modname in names - except ImportError: + except: # Silent fail here seems the best route since some modules - # may not be available in all environments. - return - self.assertTrue(hasattr(sys.modules[modname], "__all__"), - "%s has no __all__ attribute" % modname) + # may not be available or not initialize properly in all + # environments. + raise FailedImport(modname) + if not hasattr(sys.modules[modname], "__all__"): + raise NoAll(modname) names = {} - exec "from %s import *" % modname in names + try: + exec "from %s import *" % modname in names + except Exception as e: + # Include the module name in the exception string + self.fail("__all__ failure in {}: {}: {}".format( + modname, e.__class__.__name__, e)) if "__builtins__" in names: del names["__builtins__"] keys = set(names) all = set(sys.modules[modname].__all__) self.assertEqual(keys, all) + def walk_modules(self, basedir, modpath): + for fn in sorted(os.listdir(basedir)): + path = os.path.join(basedir, fn) + if os.path.isdir(path): + pkg_init = os.path.join(path, '__init__.py') + if os.path.exists(pkg_init): + yield pkg_init, modpath + fn + for p, m in self.walk_modules(path, modpath + fn + "."): + yield p, m + continue + if not fn.endswith('.py') or fn == '__init__.py': + continue + yield path, modpath + fn[:-3] + def test_all(self): + # Blacklisted modules and packages + blacklist = set([ + # Will raise a SyntaxError when compiling the exec statement + '__future__', + ]) + if not sys.platform.startswith('java'): # In case _socket fails to build, make this test fail more gracefully # than an AttributeError somewhere deep in CGIHTTPServer. import _socket - self.check_all("BaseHTTPServer") - self.check_all("Bastion") - self.check_all("CGIHTTPServer") - self.check_all("ConfigParser") - self.check_all("Cookie") - self.check_all("MimeWriter") - self.check_all("Queue") - self.check_all("SimpleHTTPServer") - self.check_all("SocketServer") - self.check_all("StringIO") - self.check_all("UserString") - self.check_all("aifc") - self.check_all("atexit") - self.check_all("audiodev") - self.check_all("base64") - self.check_all("bdb") - self.check_all("binhex") - self.check_all("calendar") - self.check_all("cgi") - self.check_all("cmd") - self.check_all("code") - self.check_all("codecs") - self.check_all("codeop") - self.check_all("colorsys") - self.check_all("commands") - self.check_all("compileall") - self.check_all("copy") - self.check_all("copy_reg") - self.check_all("csv") - self.check_all("dbhash") - self.check_all("decimal") - self.check_all("difflib") - self.check_all("dircache") - self.check_all("dis") - self.check_all("doctest") - self.check_all("dummy_thread") - self.check_all("dummy_threading") - self.check_all("filecmp") - self.check_all("fileinput") - self.check_all("fnmatch") - self.check_all("fpformat") - self.check_all("ftplib") - self.check_all("getopt") - self.check_all("getpass") - self.check_all("gettext") - self.check_all("glob") - self.check_all("gzip") - self.check_all("heapq") - self.check_all("htmllib") - self.check_all("httplib") - self.check_all("ihooks") - self.check_all("imaplib") - self.check_all("imghdr") - self.check_all("imputil") - self.check_all("keyword") - self.check_all("linecache") - self.check_all("locale") - self.check_all("logging") - self.check_all("macpath") - self.check_all("macurl2path") - self.check_all("mailbox") - self.check_all("mailcap") - self.check_all("mhlib") - self.check_all("mimetools") - self.check_all("mimetypes") - self.check_all("mimify") - self.check_all("multifile") - self.check_all("netrc") - self.check_all("nntplib") - self.check_all("ntpath") - self.check_all("opcode") - self.check_all("optparse") - self.check_all("os") - self.check_all("os2emxpath") - self.check_all("pdb") - self.check_all("pickle") - self.check_all("pickletools") - self.check_all("pipes") - self.check_all("popen2") - self.check_all("poplib") - self.check_all("posixpath") - self.check_all("pprint") - self.check_all("profile") - self.check_all("pstats") - self.check_all("pty") - self.check_all("py_compile") - self.check_all("pyclbr") - self.check_all("quopri") - self.check_all("random") - self.check_all("re") - self.check_all("repr") - self.check_all("rexec") - self.check_all("rfc822") - self.check_all("rlcompleter") - self.check_all("robotparser") - self.check_all("sched") - self.check_all("sets") - self.check_all("sgmllib") - self.check_all("shelve") - self.check_all("shlex") - self.check_all("shutil") - self.check_all("smtpd") - self.check_all("smtplib") - self.check_all("sndhdr") - self.check_all("socket") - self.check_all("_strptime") - self.check_all("symtable") - self.check_all("tabnanny") - self.check_all("tarfile") - self.check_all("telnetlib") - self.check_all("tempfile") - self.check_all("test.test_support") - self.check_all("textwrap") - self.check_all("threading") - self.check_all("timeit") - self.check_all("toaiff") - self.check_all("tokenize") - self.check_all("traceback") - self.check_all("tty") - self.check_all("unittest") - self.check_all("urllib") - self.check_all("urlparse") - self.check_all("uu") - self.check_all("warnings") - self.check_all("wave") - self.check_all("weakref") - self.check_all("webbrowser") - self.check_all("xdrlib") - self.check_all("zipfile") - # rlcompleter needs special consideration; it import readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( try: - self.check_all("rlcompleter") - finally: + import rlcompleter + import locale + except ImportError: + pass + else: + locale.setlocale(locale.LC_CTYPE, 'C') + + ignored = [] + failed_imports = [] + lib_dir = os.path.dirname(os.path.dirname(__file__)) + for path, modname in self.walk_modules(lib_dir, ""): + m = modname + blacklisted = False + while m: + if m in blacklist: + blacklisted = True + break + m = m.rpartition('.')[0] + if blacklisted: + continue + if support.verbose: + print(modname) try: - import locale - except ImportError: - pass - else: - locale.setlocale(locale.LC_CTYPE, 'C') + # This heuristic speeds up the process by removing, de facto, + # most test modules (and avoiding the auto-executing ones). + with open(path, "rb") as f: + if "__all__" not in f.read(): + raise NoAll(modname) + self.check_all(modname) + except NoAll: + ignored.append(modname) + except FailedImport: + failed_imports.append(modname) + + if support.verbose: + print('Following modules have no __all__ and have been ignored:', + ignored) + print('Following modules failed to be imported:', failed_imports) def test_main(): - run_unittest(AllTest) + support.run_unittest(AllTest) if __name__ == "__main__": test_main() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 10 22:52:11 2009 @@ -1452,6 +1452,9 @@ Tests ----- +- Issue #7055: test___all__ now greedily detects all modules which have an + __all__ attribute, rather than using a hardcoded and incomplete list. + - Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. From python-checkins at python.org Sat Oct 10 23:07:35 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:07:35 -0000 Subject: [Python-checkins] r75313 - python/trunk/Demo/scripts/pp.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:07:35 2009 New Revision: 75313 Log: Bring old demo up-to-date. Modified: python/trunk/Demo/scripts/pp.py Modified: python/trunk/Demo/scripts/pp.py ============================================================================== --- python/trunk/Demo/scripts/pp.py (original) +++ python/trunk/Demo/scripts/pp.py Sat Oct 10 23:07:35 2009 @@ -22,7 +22,6 @@ # - except for -n/-p, run directly from the file if at all possible import sys -import string import getopt FS = '' @@ -36,7 +35,7 @@ try: optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np') except getopt.error, msg: - sys.stderr.write(sys.argv[0] + ': ' + msg + '\n') + sys.stderr.write('%s: %s\n' % (sys.argv[0], msg)) sys.exit(2) for option, optarg in optlist: @@ -47,7 +46,7 @@ elif option == '-d': DFLAG = 1 elif option == '-e': - for line in string.splitfields(optarg, '\n'): + for line in optarg.split('\n'): SCRIPT.append(line) elif option == '-F': FS = optarg @@ -81,31 +80,31 @@ elif NFLAG: # Note that it is on purpose that AFLAG and PFLAG are # tested dynamically each time through the loop - prologue = [ \ - 'LINECOUNT = 0', \ - 'for FILE in ARGS:', \ - ' \tif FILE == \'-\':', \ - ' \t \tFP = sys.stdin', \ - ' \telse:', \ - ' \t \tFP = open(FILE, \'r\')', \ - ' \tLINENO = 0', \ - ' \twhile 1:', \ - ' \t \tLINE = FP.readline()', \ - ' \t \tif not LINE: break', \ - ' \t \tLINENO = LINENO + 1', \ - ' \t \tLINECOUNT = LINECOUNT + 1', \ - ' \t \tL = LINE[:-1]', \ - ' \t \taflag = AFLAG', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: F = string.splitfields(L, FS)', \ - ' \t \t \telse: F = string.split(L)' \ + prologue = [ + 'LINECOUNT = 0', + 'for FILE in ARGS:', + ' \tif FILE == \'-\':', + ' \t \tFP = sys.stdin', + ' \telse:', + ' \t \tFP = open(FILE, \'r\')', + ' \tLINENO = 0', + ' \twhile 1:', + ' \t \tLINE = FP.readline()', + ' \t \tif not LINE: break', + ' \t \tLINENO = LINENO + 1', + ' \t \tLINECOUNT = LINECOUNT + 1', + ' \t \tL = LINE[:-1]', + ' \t \taflag = AFLAG', + ' \t \tif aflag:', + ' \t \t \tif FS: F = L.split(FS)', + ' \t \t \telse: F = L.split()' ] - epilogue = [ \ - ' \t \tif not PFLAG: continue', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: print string.joinfields(F, FS)', \ - ' \t \t \telse: print string.join(F)', \ - ' \t \telse: print L', \ + epilogue = [ + ' \t \tif not PFLAG: continue', + ' \t \tif aflag:', + ' \t \t \tif FS: print FS.join(F)', + ' \t \t \telse: print \' \'.join(F)', + ' \t \telse: print L', ] else: prologue = ['if 1:'] @@ -114,10 +113,10 @@ # Note that we indent using tabs only, so that any indentation style # used in 'command' will come out right after re-indentation. -program = string.joinfields(prologue, '\n') + '\n' +program = '\n'.join(prologue) + '\n' for line in SCRIPT: - program = program + (' \t \t' + line + '\n') -program = program + (string.joinfields(epilogue, '\n') + '\n') + program += ' \t \t' + line + '\n' +program += '\n'.join(epilogue) + '\n' import tempfile fp = tempfile.NamedTemporaryFile() @@ -125,6 +124,6 @@ fp.flush() if DFLAG: import pdb - pdb.run('execfile(%r)' % (tfn,)) + pdb.run('execfile(%r)' % (fp.name,)) else: - execfile(tfn) + execfile(fp.name) From python-checkins at python.org Sat Oct 10 23:08:32 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 10 Oct 2009 21:08:32 -0000 Subject: [Python-checkins] r75314 - in python/branches/py3k: Lib/dbm/__init__.py Lib/test/test___all__.py Misc/NEWS Message-ID: Author: antoine.pitrou Date: Sat Oct 10 23:08:31 2009 New Revision: 75314 Log: Merged revisions 75312 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75312 | antoine.pitrou | 2009-10-10 22:52:11 +0200 (sam., 10 oct. 2009) | 4 lines Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/dbm/__init__.py python/branches/py3k/Lib/test/test___all__.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/dbm/__init__.py ============================================================================== --- python/branches/py3k/Lib/dbm/__init__.py (original) +++ python/branches/py3k/Lib/dbm/__init__.py Sat Oct 10 23:08:31 2009 @@ -36,7 +36,7 @@ only if it doesn't exist; and 'n' always creates a new database. """ -__all__ = ['open', 'whichdb', 'error', 'errors'] +__all__ = ['open', 'whichdb', 'error', 'error'] import io import os Modified: python/branches/py3k/Lib/test/test___all__.py ============================================================================== --- python/branches/py3k/Lib/test/test___all__.py (original) +++ python/branches/py3k/Lib/test/test___all__.py Sat Oct 10 23:08:31 2009 @@ -1,9 +1,17 @@ import unittest -from test.support import run_unittest +from test import support +import os import sys import warnings +class NoAll(RuntimeError): + pass + +class FailedImport(RuntimeError): + pass + + class AllTest(unittest.TestCase): def check_all(self, modname): @@ -13,153 +21,97 @@ DeprecationWarning) try: exec("import %s" % modname, names) - except ImportError: + except: # Silent fail here seems the best route since some modules - # may not be available in all environments. - return - self.assertTrue(hasattr(sys.modules[modname], "__all__"), - "%s has no __all__ attribute" % modname) + # may not be available or not initialize properly in all + # environments. + raise FailedImport(modname) + if not hasattr(sys.modules[modname], "__all__"): + raise NoAll(modname) names = {} - exec("from %s import *" % modname, names) + try: + exec("from %s import *" % modname, names) + except Exception as e: + # Include the module name in the exception string + self.fail("__all__ failure in {}: {}: {}".format( + modname, e.__class__.__name__, e)) if "__builtins__" in names: del names["__builtins__"] keys = set(names) all = set(sys.modules[modname].__all__) self.assertEqual(keys, all) + def walk_modules(self, basedir, modpath): + for fn in sorted(os.listdir(basedir)): + path = os.path.join(basedir, fn) + if os.path.isdir(path): + pkg_init = os.path.join(path, '__init__.py') + if os.path.exists(pkg_init): + yield pkg_init, modpath + fn + for p, m in self.walk_modules(path, modpath + fn + "."): + yield p, m + continue + if not fn.endswith('.py') or fn == '__init__.py': + continue + yield path, modpath + fn[:-3] + def test_all(self): + # Blacklisted modules and packages + blacklist = set([ + # Will raise a SyntaxError when compiling the exec statement + '__future__', + ]) + if not sys.platform.startswith('java'): # In case _socket fails to build, make this test fail more gracefully # than an AttributeError somewhere deep in CGIHTTPServer. import _socket - self.check_all("http.server") - self.check_all("configparser") - self.check_all("http.cookies") - self.check_all("queue") - self.check_all("socketserver") - self.check_all("aifc") - self.check_all("base64") - self.check_all("bdb") - self.check_all("binhex") - self.check_all("calendar") - self.check_all("collections") - self.check_all("cgi") - self.check_all("cmd") - self.check_all("code") - self.check_all("codecs") - self.check_all("codeop") - self.check_all("colorsys") - self.check_all("compileall") - self.check_all("copy") - self.check_all("copyreg") - self.check_all("csv") - self.check_all("dbm.bsd") - self.check_all("decimal") - self.check_all("difflib") - self.check_all("dircache") - self.check_all("dis") - self.check_all("doctest") - self.check_all("_dummy_thread") - self.check_all("dummy_threading") - self.check_all("filecmp") - self.check_all("fileinput") - self.check_all("fnmatch") - self.check_all("fpformat") - self.check_all("ftplib") - self.check_all("getopt") - self.check_all("getpass") - self.check_all("gettext") - self.check_all("glob") - self.check_all("gzip") - self.check_all("heapq") - self.check_all("http.client") - self.check_all("ihooks") - self.check_all("io") - self.check_all("_pyio") - self.check_all("imaplib") - self.check_all("imghdr") - self.check_all("keyword") - self.check_all("linecache") - self.check_all("locale") - self.check_all("logging") - self.check_all("macpath") - self.check_all("macurl2path") - self.check_all("mailbox") - self.check_all("mailcap") - self.check_all("mhlib") - self.check_all("mimetypes") - self.check_all("multifile") - self.check_all("netrc") - self.check_all("nntplib") - self.check_all("ntpath") - self.check_all("opcode") - self.check_all("optparse") - self.check_all("os") - self.check_all("os2emxpath") - self.check_all("pdb") - self.check_all("pickle") - self.check_all("pickletools") - self.check_all("pipes") - self.check_all("poplib") - self.check_all("posixpath") - self.check_all("pprint") - self.check_all("profile") - self.check_all("pstats") - self.check_all("pty") - self.check_all("py_compile") - self.check_all("pyclbr") - self.check_all("quopri") - self.check_all("random") - self.check_all("re") - self.check_all("reprlib") - self.check_all("rlcompleter") - self.check_all("urllib.robotparser") - self.check_all("sched") - self.check_all("shelve") - self.check_all("shlex") - self.check_all("shutil") - self.check_all("smtpd") - self.check_all("smtplib") - self.check_all("sndhdr") - self.check_all("socket") - self.check_all("_strptime") - self.check_all("symtable") - self.check_all("tabnanny") - self.check_all("tarfile") - self.check_all("telnetlib") - self.check_all("tempfile") - self.check_all("test.support") - self.check_all("textwrap") - self.check_all("threading") - self.check_all("timeit") - self.check_all("tokenize") - self.check_all("traceback") - self.check_all("tty") - self.check_all("unittest") - self.check_all("uu") - self.check_all("warnings") - self.check_all("wave") - self.check_all("weakref") - self.check_all("webbrowser") - self.check_all("xdrlib") - self.check_all("zipfile") - # rlcompleter needs special consideration; it import readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( try: - self.check_all("rlcompleter") - finally: + import rlcompleter + import locale + except ImportError: + pass + else: + locale.setlocale(locale.LC_CTYPE, 'C') + + ignored = [] + failed_imports = [] + lib_dir = os.path.dirname(os.path.dirname(__file__)) + for path, modname in self.walk_modules(lib_dir, ""): + m = modname + blacklisted = False + while m: + if m in blacklist: + blacklisted = True + break + m = m.rpartition('.')[0] + if blacklisted: + continue + if support.verbose: + print(modname) try: - import locale - except ImportError: - pass - else: - locale.setlocale(locale.LC_CTYPE, 'C') + # This heuristic speeds up the process by removing, de facto, + # most test modules (and avoiding the auto-executing ones). + with open(path, "rb") as f: + if b"__all__" not in f.read(): + raise NoAll(modname) + self.check_all(modname) + except NoAll: + ignored.append(modname) + except FailedImport: + failed_imports.append(modname) + + if support.verbose: + print('Following modules have no __all__ and have been ignored:', + ignored) + print('Following modules failed to be imported:', failed_imports) def test_main(): - run_unittest(AllTest) + support.run_unittest(AllTest) if __name__ == "__main__": test_main() Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 10 23:08:31 2009 @@ -271,6 +271,9 @@ Tests ----- +- Issue #7055: test___all__ now greedily detects all modules which have an + __all__ attribute, rather than using a hardcoded and incomplete list. + - Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. From python-checkins at python.org Sat Oct 10 23:10:05 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:10:05 -0000 Subject: [Python-checkins] r75315 - python/trunk/Demo/scripts/pi.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:10:05 2009 New Revision: 75315 Log: Remove unneeded "L" suffixes. Modified: python/trunk/Demo/scripts/pi.py Modified: python/trunk/Demo/scripts/pi.py ============================================================================== --- python/trunk/Demo/scripts/pi.py (original) +++ python/trunk/Demo/scripts/pi.py Sat Oct 10 23:10:05 2009 @@ -11,21 +11,20 @@ import sys def main(): - k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L - while 1: + k, a, b, a1, b1 = 2, 4, 1, 12, 4 + while True: # Next approximation - p, q, k = k*k, 2L*k+1L, k+1L + p, q, k = k*k, 2*k+1, k+1 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 # Print common digits d, d1 = a//b, a1//b1 while d == d1: output(d) - a, a1 = 10L*(a%b), 10L*(a1%b1) + a, a1 = 10*(a%b), 10*(a1%b1) d, d1 = a//b, a1//b1 def output(d): # Use write() to avoid spaces between the digits - # Use str() to avoid the 'L' sys.stdout.write(str(d)) # Flush so the output is seen immediately sys.stdout.flush() From python-checkins at python.org Sat Oct 10 23:12:35 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:12:35 -0000 Subject: [Python-checkins] r75316 - in python/branches/py3k: Demo/scripts/pp.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:12:35 2009 New Revision: 75316 Log: Merged revisions 75313 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75313 | georg.brandl | 2009-10-10 23:07:35 +0200 (Sa, 10 Okt 2009) | 1 line Bring old demo up-to-date. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/pp.py Modified: python/branches/py3k/Demo/scripts/pp.py ============================================================================== --- python/branches/py3k/Demo/scripts/pp.py (original) +++ python/branches/py3k/Demo/scripts/pp.py Sat Oct 10 23:12:35 2009 @@ -22,7 +22,6 @@ # - except for -n/-p, run directly from the file if at all possible import sys -import string import getopt FS = '' @@ -36,7 +35,7 @@ try: optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np') except getopt.error as msg: - sys.stderr.write(sys.argv[0] + ': ' + msg + '\n') + sys.stderr.write('%s: %s\n' % (sys.argv[0], msg)) sys.exit(2) for option, optarg in optlist: @@ -47,7 +46,7 @@ elif option == '-d': DFLAG = 1 elif option == '-e': - for line in string.splitfields(optarg, '\n'): + for line in optarg.split('\n'): SCRIPT.append(line) elif option == '-F': FS = optarg @@ -81,31 +80,31 @@ elif NFLAG: # Note that it is on purpose that AFLAG and PFLAG are # tested dynamically each time through the loop - prologue = [ \ - 'LINECOUNT = 0', \ - 'for FILE in ARGS:', \ - ' \tif FILE == \'-\':', \ - ' \t \tFP = sys.stdin', \ - ' \telse:', \ - ' \t \tFP = open(FILE, \'r\')', \ - ' \tLINENO = 0', \ - ' \twhile 1:', \ - ' \t \tLINE = FP.readline()', \ - ' \t \tif not LINE: break', \ - ' \t \tLINENO = LINENO + 1', \ - ' \t \tLINECOUNT = LINECOUNT + 1', \ - ' \t \tL = LINE[:-1]', \ - ' \t \taflag = AFLAG', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: F = string.splitfields(L, FS)', \ - ' \t \t \telse: F = string.split(L)' \ + prologue = [ + 'LINECOUNT = 0', + 'for FILE in ARGS:', + ' \tif FILE == \'-\':', + ' \t \tFP = sys.stdin', + ' \telse:', + ' \t \tFP = open(FILE, \'r\')', + ' \tLINENO = 0', + ' \twhile 1:', + ' \t \tLINE = FP.readline()', + ' \t \tif not LINE: break', + ' \t \tLINENO = LINENO + 1', + ' \t \tLINECOUNT = LINECOUNT + 1', + ' \t \tL = LINE[:-1]', + ' \t \taflag = AFLAG', + ' \t \tif aflag:', + ' \t \t \tif FS: F = L.split(FS)', + ' \t \t \telse: F = L.split()' ] - epilogue = [ \ - ' \t \tif not PFLAG: continue', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: print string.joinfields(F, FS)', \ - ' \t \t \telse: print string.join(F)', \ - ' \t \telse: print L', \ + epilogue = [ + ' \t \tif not PFLAG: continue', + ' \t \tif aflag:', + ' \t \t \tif FS: print(FS.join(F))', + ' \t \t \telse: print(\' \'.join(F))', + ' \t \telse: print(L)', ] else: prologue = ['if 1:'] @@ -114,18 +113,13 @@ # Note that we indent using tabs only, so that any indentation style # used in 'command' will come out right after re-indentation. -program = string.joinfields(prologue, '\n') + '\n' +program = '\n'.join(prologue) + '\n' for line in SCRIPT: - program = program + (' \t \t' + line + '\n') -program = program + (string.joinfields(epilogue, '\n') + '\n') + program += ' \t \t' + line + '\n' +program += '\n'.join(epilogue) + '\n' -import tempfile -fp = tempfile.NamedTemporaryFile() -fp.write(program) -fp.flush() -script = open(tfn).read() if DFLAG: import pdb - pdb.run(script) + pdb.run(program) else: - exec(script) + exec(program) From python-checkins at python.org Sat Oct 10 23:13:21 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:13:21 -0000 Subject: [Python-checkins] r75317 - in python/branches/py3k: Demo/scripts/pi.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:13:21 2009 New Revision: 75317 Log: Merged revisions 75315 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75315 | georg.brandl | 2009-10-10 23:10:05 +0200 (Sa, 10 Okt 2009) | 1 line Remove unneeded "L" suffixes. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/pi.py Modified: python/branches/py3k/Demo/scripts/pi.py ============================================================================== --- python/branches/py3k/Demo/scripts/pi.py (original) +++ python/branches/py3k/Demo/scripts/pi.py Sat Oct 10 23:13:21 2009 @@ -12,7 +12,7 @@ def main(): k, a, b, a1, b1 = 2, 4, 1, 12, 4 - while 1: + while True: # Next approximation p, q, k = k*k, 2*k+1, k+1 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 @@ -25,7 +25,6 @@ def output(d): # Use write() to avoid spaces between the digits - # Use str() to avoid the 'L' sys.stdout.write(str(d)) # Flush so the output is seen immediately sys.stdout.flush() From python-checkins at python.org Sat Oct 10 23:15:59 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 10 Oct 2009 21:15:59 -0000 Subject: [Python-checkins] r75318 - python/trunk/Demo/scripts/wh.py Message-ID: Author: benjamin.peterson Date: Sat Oct 10 23:15:58 2009 New Revision: 75318 Log: remove script which uses long gone module Removed: python/trunk/Demo/scripts/wh.py Deleted: python/trunk/Demo/scripts/wh.py ============================================================================== --- python/trunk/Demo/scripts/wh.py Sat Oct 10 23:15:58 2009 +++ (empty file) @@ -1,2 +0,0 @@ -# This is here so I can use 'wh' instead of 'which' in '~/bin/generic_python' -import which From python-checkins at python.org Sat Oct 10 23:27:03 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 10 Oct 2009 21:27:03 -0000 Subject: [Python-checkins] r75319 - in python/branches/py3k: Doc/library/unittest.rst Lib/test/test_unittest.py Lib/unittest/case.py Message-ID: Author: benjamin.peterson Date: Sat Oct 10 23:27:03 2009 New Revision: 75319 Log: Rolled back revisions 74556 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/unittest.rst python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/unittest/case.py Modified: python/branches/py3k/Doc/library/unittest.rst ============================================================================== --- python/branches/py3k/Doc/library/unittest.rst (original) +++ python/branches/py3k/Doc/library/unittest.rst Sat Oct 10 23:27:03 2009 @@ -891,10 +891,6 @@ with self.failUnlessRaises(some_error_class): do_something() - The context manager will store the caught exception object in its - :attr:`exc_value` attribute. This can be useful if the intention - is to perform additional checks on the exception raised. - .. versionchanged:: 3.1 Added the ability to use :meth:`assertRaises` as a context manager. Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sat Oct 10 23:27:03 2009 @@ -2846,21 +2846,6 @@ self.assertRaisesRegexp, Exception, re.compile('^Expected$'), Stub) - def testAssertRaisesExcValue(self): - class ExceptionMock(Exception): - pass - - def Stub(foo): - raise ExceptionMock(foo) - v = "particular value" - - ctx = self.assertRaises(ExceptionMock) - with ctx: - Stub(v) - e = ctx.exc_value - self.assertTrue(isinstance(e, ExceptionMock)) - self.assertEqual(e.args[0], v) - def testSynonymAssertMethodNames(self): """Test undocumented method name synonyms. Modified: python/branches/py3k/Lib/unittest/case.py ============================================================================== --- python/branches/py3k/Lib/unittest/case.py (original) +++ python/branches/py3k/Lib/unittest/case.py Sat Oct 10 23:27:03 2009 @@ -116,7 +116,6 @@ if not issubclass(exc_type, self.expected): # let unexpected exceptions pass through return False - self.exc_value = exc_value #store for later retrieval if self.expected_regex is None: return True From python-checkins at python.org Sat Oct 10 23:28:29 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 10 Oct 2009 21:28:29 -0000 Subject: [Python-checkins] r75320 - python/branches/py3k/Lib/dbm/__init__.py Message-ID: Author: antoine.pitrou Date: Sat Oct 10 23:28:29 2009 New Revision: 75320 Log: Redundancy isn't needed here. Redundancy isn't needed here. Modified: python/branches/py3k/Lib/dbm/__init__.py Modified: python/branches/py3k/Lib/dbm/__init__.py ============================================================================== --- python/branches/py3k/Lib/dbm/__init__.py (original) +++ python/branches/py3k/Lib/dbm/__init__.py Sat Oct 10 23:28:29 2009 @@ -36,7 +36,7 @@ only if it doesn't exist; and 'n' always creates a new database. """ -__all__ = ['open', 'whichdb', 'error', 'error'] +__all__ = ['open', 'whichdb', 'error'] import io import os From python-checkins at python.org Sat Oct 10 23:43:22 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:43:22 -0000 Subject: [Python-checkins] r75321 - python/trunk/Demo/scripts/unbirthday.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:43:21 2009 New Revision: 75321 Log: Remove outdated comment and fix a few style issues. Modified: python/trunk/Demo/scripts/unbirthday.py Modified: python/trunk/Demo/scripts/unbirthday.py ============================================================================== --- python/trunk/Demo/scripts/unbirthday.py (original) +++ python/trunk/Demo/scripts/unbirthday.py Sat Oct 10 23:43:21 2009 @@ -10,29 +10,26 @@ import calendar def main(): - # Note that the range checks below also check for bad types, - # e.g. 3.14 or (). However syntactically invalid replies - # will raise an exception. if sys.argv[1:]: year = int(sys.argv[1]) else: year = int(raw_input('In which year were you born? ')) - if 0<=year<100: + if 0 <= year < 100: print "I'll assume that by", year, year = year + 1900 print 'you mean', year, 'and not the early Christian era' - elif not (1850<=year<=2002): + elif not (1850 <= year <= time.localtime()[0]): print "It's hard to believe you were born in", year return - # + if sys.argv[2:]: month = int(sys.argv[2]) else: month = int(raw_input('And in which month? (1-12) ')) - if not (1<=month<=12): + if not (1 <= month <= 12): print 'There is no month numbered', month return - # + if sys.argv[3:]: day = int(sys.argv[3]) else: @@ -41,36 +38,36 @@ maxday = 29 else: maxday = calendar.mdays[month] - if not (1<=day<=maxday): + if not (1 <= day <= maxday): print 'There are no', day, 'days in that month!' return - # + bdaytuple = (year, month, day) bdaydate = mkdate(bdaytuple) print 'You were born on', format(bdaytuple) - # + todaytuple = time.localtime()[:3] todaydate = mkdate(todaytuple) print 'Today is', format(todaytuple) - # + if bdaytuple > todaytuple: print 'You are a time traveler. Go back to the future!' return - # + if bdaytuple == todaytuple: print 'You were born today. Have a nice life!' return - # + days = todaydate - bdaydate print 'You have lived', days, 'days' - # + age = 0 for y in range(year, todaytuple[0] + 1): if bdaytuple < (y, month, day) <= todaytuple: age = age + 1 - # + print 'You are', age, 'years old' - # + if todaytuple[1:] == bdaytuple[1:]: print 'Congratulations! Today is your', nth(age), 'birthday' print 'Yesterday was your', @@ -88,10 +85,10 @@ return '%dth' % n def mkdate((year, month, day)): - # Januari 1st, in 0 A.D. is arbitrarily defined to be day 1, + # January 1st, in 0 A.D. is arbitrarily defined to be day 1, # even though that day never actually existed and the calendar # was different then... - days = year*365 # years, roughly + days = year*365 # years, roughly days = days + (year+3)//4 # plus leap years, roughly days = days - (year+99)//100 # minus non-leap years every century days = days + (year+399)//400 # plus leap years every 4 centirues From python-checkins at python.org Sat Oct 10 23:47:31 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:47:31 -0000 Subject: [Python-checkins] r75322 - python/trunk/Demo/scripts/beer.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:47:31 2009 New Revision: 75322 Log: Show use of range() step argument nicely. Modified: python/trunk/Demo/scripts/beer.py Modified: python/trunk/Demo/scripts/beer.py ============================================================================== --- python/trunk/Demo/scripts/beer.py (original) +++ python/trunk/Demo/scripts/beer.py Sat Oct 10 23:47:31 2009 @@ -1,14 +1,20 @@ #! /usr/bin/env python + # By GvR, demystified after a version by Fredrik Lundh. + import sys + n = 100 -if sys.argv[1:]: n = int(sys.argv[1]) +if sys.argv[1:]: + n = int(sys.argv[1]) + def bottle(n): if n == 0: return "no more bottles of beer" if n == 1: return "one bottle of beer" return str(n) + " bottles of beer" -for i in range(n): - print bottle(n-i), "on the wall," - print bottle(n-i) + "." + +for i in range(n, 0, -1): + print bottle(i), "on the wall," + print bottle(i) + "." print "Take one down, pass it around," - print bottle(n-i-1), "on the wall." + print bottle(i-1), "on the wall." From python-checkins at python.org Sat Oct 10 23:48:05 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:48:05 -0000 Subject: [Python-checkins] r75323 - in python/branches/py3k: Demo/scripts/unbirthday.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:48:05 2009 New Revision: 75323 Log: Recorded merge of revisions 75321 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75321 | georg.brandl | 2009-10-10 23:43:21 +0200 (Sa, 10 Okt 2009) | 1 line Remove outdated comment and fix a few style issues. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/unbirthday.py Modified: python/branches/py3k/Demo/scripts/unbirthday.py ============================================================================== --- python/branches/py3k/Demo/scripts/unbirthday.py (original) +++ python/branches/py3k/Demo/scripts/unbirthday.py Sat Oct 10 23:48:05 2009 @@ -9,35 +9,27 @@ import time import calendar -def raw_input(prompt): - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - def main(): - # Note that the range checks below also check for bad types, - # e.g. 3.14 or (). However syntactically invalid replies - # will raise an exception. if sys.argv[1:]: year = int(sys.argv[1]) else: year = int(input('In which year were you born? ')) - if 0<=year<100: + if 0 <= year < 100: print("I'll assume that by", year, end=' ') year = year + 1900 print('you mean', year, 'and not the early Christian era') - elif not (1850<=year<=2002): + elif not (1850 <= year <= time.localtime()[0]): print("It's hard to believe you were born in", year) return - # + if sys.argv[2:]: month = int(sys.argv[2]) else: month = int(input('And in which month? (1-12) ')) - if not (1<=month<=12): + if not (1 <= month <= 12): print('There is no month numbered', month) return - # + if sys.argv[3:]: day = int(sys.argv[3]) else: @@ -46,36 +38,36 @@ maxday = 29 else: maxday = calendar.mdays[month] - if not (1<=day<=maxday): + if not (1 <= day <= maxday): print('There are no', day, 'days in that month!') return - # + bdaytuple = (year, month, day) bdaydate = mkdate(bdaytuple) print('You were born on', format(bdaytuple)) - # + todaytuple = time.localtime()[:3] todaydate = mkdate(todaytuple) print('Today is', format(todaytuple)) - # + if bdaytuple > todaytuple: print('You are a time traveler. Go back to the future!') return - # + if bdaytuple == todaytuple: print('You were born today. Have a nice life!') return - # + days = todaydate - bdaydate print('You have lived', days, 'days') - # + age = 0 for y in range(year, todaytuple[0] + 1): if bdaytuple < (y, month, day) <= todaytuple: age = age + 1 - # + print('You are', age, 'years old') - # + if todaytuple[1:] == bdaytuple[1:]: print('Congratulations! Today is your', nth(age), 'birthday') print('Yesterday was your', end=' ') @@ -83,8 +75,8 @@ print('Today is your', end=' ') print(nth(days - age), 'unbirthday') -def format(xxx_todo_changeme): - (year, month, day) = xxx_todo_changeme +def format(date): + (year, month, day) = date return '%d %s %d' % (day, calendar.month_name[month], year) def nth(n): @@ -93,12 +85,12 @@ if n == 3: return '3rd' return '%dth' % n -def mkdate(xxx_todo_changeme1): - # Januari 1st, in 0 A.D. is arbitrarily defined to be day 1, +def mkdate(date): + # January 1st, in 0 A.D. is arbitrarily defined to be day 1, # even though that day never actually existed and the calendar # was different then... - (year, month, day) = xxx_todo_changeme1 - days = year*365 # years, roughly + (year, month, day) = date + days = year*365 # years, roughly days = days + (year+3)//4 # plus leap years, roughly days = days - (year+99)//100 # minus non-leap years every century days = days + (year+399)//400 # plus leap years every 4 centirues From python-checkins at python.org Sat Oct 10 23:49:25 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:49:25 -0000 Subject: [Python-checkins] r75324 - in python/branches/py3k: Demo/scripts/beer.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:49:24 2009 New Revision: 75324 Log: Merged revisions 75322 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75322 | georg.brandl | 2009-10-10 23:47:31 +0200 (Sa, 10 Okt 2009) | 1 line Show use of range() step argument nicely. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/beer.py Modified: python/branches/py3k/Demo/scripts/beer.py ============================================================================== --- python/branches/py3k/Demo/scripts/beer.py (original) +++ python/branches/py3k/Demo/scripts/beer.py Sat Oct 10 23:49:24 2009 @@ -1,14 +1,20 @@ #! /usr/bin/env python + # By GvR, demystified after a version by Fredrik Lundh. + import sys + n = 100 -if sys.argv[1:]: n = int(sys.argv[1]) +if sys.argv[1:]: + n = int(sys.argv[1]) + def bottle(n): if n == 0: return "no more bottles of beer" if n == 1: return "one bottle of beer" return str(n) + " bottles of beer" -for i in range(n): - print(bottle(n-i), "on the wall,") - print(bottle(n-i) + ".") + +for i in range(n, 0, -1): + print(bottle(i), "on the wall,") + print(bottle(i) + ".") print("Take one down, pass it around,") - print(bottle(n-i-1), "on the wall.") + print(bottle(i-1), "on the wall.") From python-checkins at python.org Sat Oct 10 23:55:11 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:55:11 -0000 Subject: [Python-checkins] r75325 - python/trunk/Demo/scripts/fact.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:55:11 2009 New Revision: 75325 Log: Modernize factorisation demo (mostly augassign.) Modified: python/trunk/Demo/scripts/fact.py Modified: python/trunk/Demo/scripts/fact.py ============================================================================== --- python/trunk/Demo/scripts/fact.py (original) +++ python/trunk/Demo/scripts/fact.py Sat Oct 10 23:55:11 2009 @@ -9,39 +9,41 @@ from math import sqrt def fact(n): - if n < 1: raise ValueError # fact() argument should be >= 1 - if n == 1: return [] # special case + if n < 1: + raise ValueError('fact() argument should be >= 1') + if n == 1: + return [] # special case res = [] - # Treat even factors special, so we can use i = i+2 later - while n%2 == 0: + # Treat even factors special, so we can use i += 2 later + while n % 2 == 0: res.append(2) - n = n//2 + n //= 2 # Try odd numbers up to sqrt(n) - limit = sqrt(float(n+1)) + limit = sqrt(n+1) i = 3 while i <= limit: - if n%i == 0: + if n % i == 0: res.append(i) - n = n//i + n //= i limit = sqrt(n+1) else: - i = i+2 + i += 2 if n != 1: res.append(n) return res def main(): if len(sys.argv) > 1: - for arg in sys.argv[1:]: - n = eval(arg) - print n, fact(n) + source = sys.argv[1:] else: + source = iter(raw_input, '') + for arg in source: try: - while 1: - n = input() - print n, fact(n) - except EOFError: - pass + n = int(arg) + except ValueError: + print arg, 'is not an integer' + else: + print n, fact(n) if __name__ == "__main__": main() From python-checkins at python.org Sat Oct 10 23:57:04 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 21:57:04 -0000 Subject: [Python-checkins] r75326 - in python/branches/py3k: Demo/scripts/fact.py Message-ID: Author: georg.brandl Date: Sat Oct 10 23:57:03 2009 New Revision: 75326 Log: Merged revisions 75325 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75325 | georg.brandl | 2009-10-10 23:55:11 +0200 (Sa, 10 Okt 2009) | 1 line Modernize factorisation demo (mostly augassign.) ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/fact.py Modified: python/branches/py3k/Demo/scripts/fact.py ============================================================================== --- python/branches/py3k/Demo/scripts/fact.py (original) +++ python/branches/py3k/Demo/scripts/fact.py Sat Oct 10 23:57:03 2009 @@ -9,39 +9,41 @@ from math import sqrt def fact(n): - if n < 1: raise ValueError # fact() argument should be >= 1 - if n == 1: return [] # special case + if n < 1: + raise ValueError('fact() argument should be >= 1') + if n == 1: + return [] # special case res = [] - # Treat even factors special, so we can use i = i+2 later - while n%2 == 0: + # Treat even factors special, so we can use i += 2 later + while n % 2 == 0: res.append(2) - n = n//2 + n //= 2 # Try odd numbers up to sqrt(n) - limit = sqrt(float(n+1)) + limit = sqrt(n+1) i = 3 while i <= limit: - if n%i == 0: + if n % i == 0: res.append(i) - n = n//i + n //= i limit = sqrt(n+1) else: - i = i+2 + i += 2 if n != 1: res.append(n) return res def main(): if len(sys.argv) > 1: - for arg in sys.argv[1:]: - n = eval(arg) - print(n, fact(n)) + source = sys.argv[1:] else: + source = iter(input, '') + for arg in source: try: - while 1: - n = eval(input()) - print(n, fact(n)) - except EOFError: - pass + n = int(arg) + except ValueError: + print(arg, 'is not an integer') + else: + print(n, fact(n)) if __name__ == "__main__": main() From python-checkins at python.org Sun Oct 11 00:03:44 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 22:03:44 -0000 Subject: [Python-checkins] r75327 - python/trunk/Demo/scripts/find-uname.py Message-ID: Author: georg.brandl Date: Sun Oct 11 00:03:43 2009 New Revision: 75327 Log: Style fixes. Modified: python/trunk/Demo/scripts/find-uname.py Modified: python/trunk/Demo/scripts/find-uname.py ============================================================================== --- python/trunk/Demo/scripts/find-uname.py (original) +++ python/trunk/Demo/scripts/find-uname.py Sun Oct 11 00:03:43 2009 @@ -21,20 +21,20 @@ import re def main(args): - unicode_names= [] + unicode_names = [] for ix in range(sys.maxunicode+1): try: - unicode_names.append( (ix, unicodedata.name(unichr(ix))) ) + unicode_names.append((ix, unicodedata.name(unichr(ix)))) except ValueError: # no name for the character pass for arg in args: pat = re.compile(arg, re.I) - matches = [(x,y) for (x,y) in unicode_names - if pat.search(y) is not None] + matches = [(y,x) for (x,y) in unicode_names + if pat.search(y) is not None] if matches: print "***", arg, "matches", "***" - for (x,y) in matches: - print "%s (%d)" % (y,x) + for match in matches: + print "%s (%d)" % match if __name__ == "__main__": main(sys.argv[1:]) From python-checkins at python.org Sun Oct 11 00:05:26 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 22:05:26 -0000 Subject: [Python-checkins] r75328 - in python/branches/py3k: Demo/scripts/find-uname.py Message-ID: Author: georg.brandl Date: Sun Oct 11 00:05:26 2009 New Revision: 75328 Log: Merged revisions 75327 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75327 | georg.brandl | 2009-10-11 00:03:43 +0200 (So, 11 Okt 2009) | 1 line Style fixes. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/find-uname.py Modified: python/branches/py3k/Demo/scripts/find-uname.py ============================================================================== --- python/branches/py3k/Demo/scripts/find-uname.py (original) +++ python/branches/py3k/Demo/scripts/find-uname.py Sun Oct 11 00:05:26 2009 @@ -21,20 +21,20 @@ import re def main(args): - unicode_names= [] + unicode_names = [] for ix in range(sys.maxunicode+1): try: - unicode_names.append( (ix, unicodedata.name(chr(ix))) ) + unicode_names.append((ix, unicodedata.name(chr(ix)))) except ValueError: # no name for the character pass for arg in args: pat = re.compile(arg, re.I) - matches = [(x,y) for (x,y) in unicode_names - if pat.search(y) is not None] + matches = [(y,x) for (x,y) in unicode_names + if pat.search(y) is not None] if matches: print("***", arg, "matches", "***") - for (x,y) in matches: - print("%s (%d)" % (y,x)) + for match in matches: + print("%s (%d)" % match) if __name__ == "__main__": main(sys.argv[1:]) From nnorwitz at gmail.com Sun Oct 11 00:18:25 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 10 Oct 2009 18:18:25 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091010221825.GA32347@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 0, -420] references, sum=-420 Less important issues: ---------------------- test_popen2 leaked [0, 0, 25] references, sum=25 test_smtplib leaked [-88, 88, -88] references, sum=-88 test_socketserver leaked [1, 13, -83] references, sum=-69 test_threadedtempfile leaked [-104, 0, 0] references, sum=-104 test_threading leaked [43, 48, 48] references, sum=139 From python-checkins at python.org Sun Oct 11 00:26:46 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 22:26:46 -0000 Subject: [Python-checkins] r75329 - python/trunk/Demo/scripts/newslist.py Message-ID: Author: georg.brandl Date: Sun Oct 11 00:26:45 2009 New Revision: 75329 Log: Modernize all around (dont ask me how useful that script is nowadays...) Modified: python/trunk/Demo/scripts/newslist.py Modified: python/trunk/Demo/scripts/newslist.py ============================================================================== --- python/trunk/Demo/scripts/newslist.py (original) +++ python/trunk/Demo/scripts/newslist.py Sun Oct 11 00:26:45 2009 @@ -32,22 +32,22 @@ # fraser at europarc.xerox.com qs101 at cl.cam.ac.uk # # ####################################################################### -import sys,nntplib, string, marshal, time, os, posix, string +import sys, nntplib, marshal, time, os ####################################################################### # Check these variables before running! # # Top directory. # Filenames which don't start with / are taken as being relative to this. -topdir='/anfs/qsbigdisc/web/html/newspage' +topdir = os.path.expanduser('~/newspage') # The name of your NNTP host # eg. # newshost = 'nntp-serv.cl.cam.ac.uk' # or use following to get the name from the NNTPSERVER environment # variable: -# newshost = posix.environ['NNTPSERVER'] -newshost = 'nntp-serv.cl.cam.ac.uk' +# newshost = os.environ['NNTPSERVER'] +newshost = 'news.example.com' # The filename for a local cache of the newsgroup list treefile = 'grouptree' @@ -81,7 +81,7 @@ # pagelinkicon can contain html to put an icon after links to # further pages. This helps to make important links stand out. # Set to '' if not wanted, or '...' is quite a good one. -pagelinkicon='... ' +pagelinkicon = '... ' # --------------------------------------------------------------------- # Less important personal preferences: @@ -106,7 +106,7 @@ from stat import * rcsrev = '$Revision$' -rcsrev = string.join(filter(lambda s: '$' not in s, string.split(rcsrev))) +rcsrev = ' '.join(filter(lambda s: '$' not in s, rcsrev.split())) desc = {} # Make (possibly) relative filenames into absolute ones @@ -120,7 +120,7 @@ def addtotree(tree, groups): print 'Updating tree...' for i in groups: - parts = string.splitfields(i,'.') + parts = i.split('.') makeleaf(tree, parts) # Makeleaf makes a leaf and the branch leading to it if necessary @@ -141,34 +141,38 @@ # to those groups beginning with . def createpage(root, tree, p): - filename = os.path.join(pagedir,root+'.html') + filename = os.path.join(pagedir, root+'.html') if root == rootpage: detail = '' else: detail = ' under ' + root - f = open(filename,'w') - # f.write('Content-Type: text/html\n') - f.write('Newsgroups available' + detail + '\n') - f.write('

Newsgroups available' + detail +'

\n') - f.write('
Back to top level

\n') - printtree(f,tree,0,p) - f.write('This page automatically created by \'newslist\' v. '+rcsrev+'.') - f.write(time.ctime(time.time()) + '

') - f.close() + with open(filename, 'w') as f: + # f.write('Content-Type: text/html\n') + f.write('\n\n') + f.write('Newsgroups available%s\n' % detail) + f.write('\n\n') + f.write('

Newsgroups available%s

\n' % detail) + f.write('Back to top level

\n' % + (httppref, rootpage)) + printtree(f, tree, 0, p) + f.write('\n

') + f.write("This page automatically created by 'newslist' v. %s." % + rcsrev) + f.write(time.ctime(time.time()) + '\n') + f.write('\n\n') # Printtree prints the groups as a bulleted list. Groups with # more than subgroups will be put on a separate page. # Other sets of subgroups are just indented. def printtree(f, tree, indent, p): - global desc l = len(tree) - if l > sublistsize and indent>0: + if l > sublistsize and indent > 0: # Create a new page and a link to it - f.write('

  • ') - f.write(p[1:]+'.*') - f.write(''+pagelinkicon+'\n') + f.write('
  • ' % (httppref, p[1:])) + f.write(p[1:] + '.*') + f.write('%s\n' % pagelinkicon) createpage(p[1:], tree, p) return @@ -178,67 +182,64 @@ kl.sort() if indent > 0: # Create a sub-list - f.write('
  • '+p[1:]+'\n
      ') + f.write('
    • %s\n
        ' % p[1:]) else: # Create a main list - f.write('
          ') + f.write('
            ') indent = indent + 1 for i in kl: if i == '.': # Output a newsgroup - f.write('
          • '+ p[1:] + ' ') - if desc.has_key(p[1:]): - f.write(' '+desc[p[1:]]+'\n') + f.write('
          • %s ' % (p[1:], p[1:])) + if p[1:] in desc: + f.write(' %s\n' % desc[p[1:]]) else: f.write('\n') else: # Output a hierarchy - printtree(f,tree[i], indent, p+'.'+i) + printtree(f, tree[i], indent, p+'.'+i) if l > 1: - f.write('\n
          ') + f.write('\n
        ') # Reading descriptions file --------------------------------------- -# This returns an array mapping group name to its description +# This returns a dict mapping group name to its description def readdesc(descfile): global desc - desc = {} if descfile == '': return try: - d = open(descfile, 'r') - print 'Reading descriptions...' - except (IOError): + with open(descfile, 'r') as d: + print 'Reading descriptions...' + for l in d: + bits = l.split() + try: + grp = bits[0] + dsc = ' '.join(bits[1:]) + if len(dsc) > 1: + desc[grp] = dsc + except IndexError: + pass + except IOError: print 'Failed to open description file ' + descfile return - l = d.readline() - while l != '': - bits = string.split(l) - try: - grp = bits[0] - dsc = string.join(bits[1:]) - if len(dsc)>1: - desc[grp] = dsc - except (IndexError): - pass - l = d.readline() # Check that ouput directory exists, ------------------------------ # and offer to create it if not def checkopdir(pagedir): if not os.path.isdir(pagedir): - print 'Directory '+pagedir+' does not exist.' + print 'Directory %s does not exist.' % pagedir print 'Shall I create it for you? (y/n)' if sys.stdin.readline()[0] == 'y': try: - os.mkdir(pagedir,0777) + os.mkdir(pagedir, 0777) except: print 'Sorry - failed!' sys.exit(1) @@ -258,23 +259,21 @@ print 'If this is the first time you have run newslist, then' print 'use the -a option to create it.' sys.exit(1) - treedate = '%02d%02d%02d' % (treetime[0] % 100 ,treetime[1], treetime[2]) + treedate = '%02d%02d%02d' % (treetime[0] % 100, treetime[1], treetime[2]) try: - dump = open(treefile,'r') - tree = marshal.load(dump) - dump.close() - except (IOError): + with open(treefile, 'rb') as dump: + tree = marshal.load(dump) + except IOError: print 'Cannot open local group list ' + treefile return (tree, treedate) def writelocallist(treefile, tree): try: - dump = open(treefile,'w') - groups = marshal.dump(tree,dump) - dump.close() - print 'Saved list to '+treefile+'\n' + with open(treefile, 'wb') as dump: + groups = marshal.dump(tree, dump) + print 'Saved list to %s\n' % treefile except: - print 'Sorry - failed to write to local group cache '+treefile + print 'Sorry - failed to write to local group cache', treefile print 'Does it (or its directory) have the correct permissions?' sys.exit(1) @@ -282,16 +281,16 @@ def getallgroups(server): print 'Getting list of all groups...' - treedate='010101' + treedate = '010101' info = server.list()[1] groups = [] print 'Processing...' if skipempty: print '\nIgnoring following empty groups:' for i in info: - grpname = string.split(i[0])[0] - if skipempty and string.atoi(i[1]) < string.atoi(i[2]): - print grpname+' ', + grpname = i[0].split()[0] + if skipempty and int(i[1]) < int(i[2]): + print grpname + ' ', else: groups.append(grpname) print '\n' @@ -302,13 +301,13 @@ # Return list of new groups on server ----------------------------- def getnewgroups(server, treedate): - print 'Getting list of new groups since start of '+treedate+'...', - info = server.newgroups(treedate,'000001')[1] + print 'Getting list of new groups since start of %s...' % treedate, + info = server.newgroups(treedate, '000001')[1] print 'got %d.' % len(info) print 'Processing...', groups = [] for i in info: - grpname = string.split(i)[0] + grpname = i.split()[0] groups.append(grpname) print 'Done' return groups @@ -316,28 +315,25 @@ # Now the main program -------------------------------------------- def main(): - global desc - - tree={} + tree = {} # Check that the output directory exists checkopdir(pagedir) try: - print 'Connecting to '+newshost+'...' + print 'Connecting to %s...' % newshost if sys.version[0] == '0': s = NNTP.init(newshost) else: s = NNTP(newshost) - connected = 1 + connected = True except (nntplib.error_temp, nntplib.error_perm), x: print 'Error connecting to host:', x print 'I\'ll try to use just the local list.' - connected = 0 + connected = False # If -a is specified, read the full list of groups from server if connected and len(sys.argv) > 1 and sys.argv[1] == '-a': - groups = getallgroups(s) # Otherwise just read the local file and then add From python-checkins at python.org Sun Oct 11 00:32:28 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 10 Oct 2009 22:32:28 -0000 Subject: [Python-checkins] r75330 - in python/branches/py3k: Demo/scripts/newslist.py Message-ID: Author: georg.brandl Date: Sun Oct 11 00:32:28 2009 New Revision: 75330 Log: Merged revisions 75329 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75329 | georg.brandl | 2009-10-11 00:26:45 +0200 (So, 11 Okt 2009) | 1 line Modernize all around (dont ask me how useful that script is nowadays...) ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/newslist.py Modified: python/branches/py3k/Demo/scripts/newslist.py ============================================================================== --- python/branches/py3k/Demo/scripts/newslist.py (original) +++ python/branches/py3k/Demo/scripts/newslist.py Sun Oct 11 00:32:28 2009 @@ -32,22 +32,22 @@ # fraser at europarc.xerox.com qs101 at cl.cam.ac.uk # # ####################################################################### -import sys,nntplib, string, marshal, time, os, posix, string +import sys, nntplib, marshal, time, os ####################################################################### # Check these variables before running! # # Top directory. # Filenames which don't start with / are taken as being relative to this. -topdir='/anfs/qsbigdisc/web/html/newspage' +topdir = os.path.expanduser('~/newspage') # The name of your NNTP host # eg. # newshost = 'nntp-serv.cl.cam.ac.uk' # or use following to get the name from the NNTPSERVER environment # variable: -# newshost = posix.environ['NNTPSERVER'] -newshost = 'nntp-serv.cl.cam.ac.uk' +# newshost = os.environ['NNTPSERVER'] +newshost = 'news.example.com' # The filename for a local cache of the newsgroup list treefile = 'grouptree' @@ -81,7 +81,7 @@ # pagelinkicon can contain html to put an icon after links to # further pages. This helps to make important links stand out. # Set to '' if not wanted, or '...' is quite a good one. -pagelinkicon='... ' +pagelinkicon = '... ' # --------------------------------------------------------------------- # Less important personal preferences: @@ -106,7 +106,7 @@ from stat import * rcsrev = '$Revision$' -rcsrev = string.join([s for s in string.split(rcsrev) if '$' not in s]) +rcsrev = ' '.join([s for s in rcsrev.split() if '$' not in s]) desc = {} # Make (possibly) relative filenames into absolute ones @@ -120,7 +120,7 @@ def addtotree(tree, groups): print('Updating tree...') for i in groups: - parts = string.splitfields(i,'.') + parts = i.split('.') makeleaf(tree, parts) # Makeleaf makes a leaf and the branch leading to it if necessary @@ -141,34 +141,38 @@ # to those groups beginning with . def createpage(root, tree, p): - filename = os.path.join(pagedir,root+'.html') + filename = os.path.join(pagedir, root+'.html') if root == rootpage: detail = '' else: detail = ' under ' + root - f = open(filename,'w') - # f.write('Content-Type: text/html\n') - f.write('Newsgroups available' + detail + '\n') - f.write('

        Newsgroups available' + detail +'

        \n') - f.write('Back to top level

        \n') - printtree(f,tree,0,p) - f.write('This page automatically created by \'newslist\' v. '+rcsrev+'.') - f.write(time.ctime(time.time()) + '

        ') - f.close() + with open(filename, 'w') as f: + # f.write('Content-Type: text/html\n') + f.write('\n\n') + f.write('Newsgroups available%s\n' % detail) + f.write('\n\n') + f.write('

        Newsgroups available%s

        \n' % detail) + f.write('Back to top level

        \n' % + (httppref, rootpage)) + printtree(f, tree, 0, p) + f.write('\n

        ') + f.write("This page automatically created by 'newslist' v. %s." % + rcsrev) + f.write(time.ctime(time.time()) + '\n') + f.write('\n\n') # Printtree prints the groups as a bulleted list. Groups with # more than subgroups will be put on a separate page. # Other sets of subgroups are just indented. def printtree(f, tree, indent, p): - global desc l = len(tree) - if l > sublistsize and indent>0: + if l > sublistsize and indent > 0: # Create a new page and a link to it - f.write('

      • ') - f.write(p[1:]+'.*') - f.write(''+pagelinkicon+'\n') + f.write('
      • ' % (httppref, p[1:])) + f.write(p[1:] + '.*') + f.write('%s\n' % pagelinkicon) createpage(p[1:], tree, p) return @@ -177,67 +181,64 @@ if l > 1: if indent > 0: # Create a sub-list - f.write('
      • '+p[1:]+'\n
          ') + f.write('
        • %s\n
            ' % p[1:]) else: # Create a main list - f.write('
              ') + f.write('
                ') indent = indent + 1 for i in kl: if i == '.': # Output a newsgroup - f.write('
              • '+ p[1:] + ' ') + f.write('
              • %s ' % (p[1:], p[1:])) if p[1:] in desc: - f.write(' '+desc[p[1:]]+'\n') + f.write(' %s\n' % desc[p[1:]]) else: f.write('\n') else: # Output a hierarchy - printtree(f,tree[i], indent, p+'.'+i) + printtree(f, tree[i], indent, p+'.'+i) if l > 1: - f.write('\n
              ') + f.write('\n
            ') # Reading descriptions file --------------------------------------- -# This returns an array mapping group name to its description +# This returns a dict mapping group name to its description def readdesc(descfile): global desc - desc = {} if descfile == '': return try: - d = open(descfile, 'r') - print('Reading descriptions...') - except (IOError): + with open(descfile, 'r') as d: + print('Reading descriptions...') + for l in d: + bits = l.split() + try: + grp = bits[0] + dsc = ' '.join(bits[1:]) + if len(dsc) > 1: + desc[grp] = dsc + except IndexError: + pass + except IOError: print('Failed to open description file ' + descfile) return - l = d.readline() - while l != '': - bits = string.split(l) - try: - grp = bits[0] - dsc = string.join(bits[1:]) - if len(dsc)>1: - desc[grp] = dsc - except (IndexError): - pass - l = d.readline() # Check that ouput directory exists, ------------------------------ # and offer to create it if not def checkopdir(pagedir): if not os.path.isdir(pagedir): - print('Directory '+pagedir+' does not exist.') + print('Directory %s does not exist.' % pagedir) print('Shall I create it for you? (y/n)') if sys.stdin.readline()[0] == 'y': try: - os.mkdir(pagedir,0o777) + os.mkdir(pagedir, 0o777) except: print('Sorry - failed!') sys.exit(1) @@ -257,23 +258,21 @@ print('If this is the first time you have run newslist, then') print('use the -a option to create it.') sys.exit(1) - treedate = '%02d%02d%02d' % (treetime[0] % 100 ,treetime[1], treetime[2]) + treedate = '%02d%02d%02d' % (treetime[0] % 100, treetime[1], treetime[2]) try: - dump = open(treefile,'r') - tree = marshal.load(dump) - dump.close() - except (IOError): + with open(treefile, 'rb') as dump: + tree = marshal.load(dump) + except IOError: print('Cannot open local group list ' + treefile) return (tree, treedate) def writelocallist(treefile, tree): try: - dump = open(treefile,'w') - groups = marshal.dump(tree,dump) - dump.close() - print('Saved list to '+treefile+'\n') + with open(treefile, 'wb') as dump: + groups = marshal.dump(tree, dump) + print('Saved list to %s\n' % treefile) except: - print('Sorry - failed to write to local group cache '+treefile) + print('Sorry - failed to write to local group cache', treefile) print('Does it (or its directory) have the correct permissions?') sys.exit(1) @@ -281,18 +280,18 @@ def getallgroups(server): print('Getting list of all groups...') - treedate='010101' + treedate = '010101' info = server.list()[1] groups = [] print('Processing...') if skipempty: print('\nIgnoring following empty groups:') for i in info: - grpname = string.split(i[0])[0] - if skipempty and string.atoi(i[1]) < string.atoi(i[2]): - print(grpname+' ', end=' ') + grpname = i[0].split()[0] + if skipempty and int(i[1]) < int(i[2]): + print(grpname.decode() + ' ', end=' ') else: - groups.append(grpname) + groups.append(grpname.decode()) print('\n') if skipempty: print('(End of empty groups)') @@ -301,42 +300,39 @@ # Return list of new groups on server ----------------------------- def getnewgroups(server, treedate): - print('Getting list of new groups since start of '+treedate+'...', end=' ') - info = server.newgroups(treedate,'000001')[1] + print('Getting list of new groups since start of %s...' % treedate, end=' ') + info = server.newgroups(treedate, '000001')[1] print('got %d.' % len(info)) print('Processing...', end=' ') groups = [] for i in info: - grpname = string.split(i)[0] - groups.append(grpname) + grpname = i.split()[0] + groups.append(grpname.decode()) print('Done') return groups # Now the main program -------------------------------------------- def main(): - global desc - - tree={} + tree = {} # Check that the output directory exists checkopdir(pagedir) try: - print('Connecting to '+newshost+'...') + print('Connecting to %s...' % newshost) if sys.version[0] == '0': s = NNTP.init(newshost) else: s = NNTP(newshost) - connected = 1 + connected = True except (nntplib.error_temp, nntplib.error_perm) as x: print('Error connecting to host:', x) print('I\'ll try to use just the local list.') - connected = 0 + connected = False # If -a is specified, read the full list of groups from server if connected and len(sys.argv) > 1 and sys.argv[1] == '-a': - groups = getallgroups(s) # Otherwise just read the local file and then add From python-checkins at python.org Sun Oct 11 01:56:31 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 10 Oct 2009 23:56:31 -0000 Subject: [Python-checkins] r75331 - peps/trunk/pep-0390.txt Message-ID: Author: tarek.ziade Date: Sun Oct 11 01:56:30 2009 New Revision: 75331 Log: first draft for PEP 390 Added: peps/trunk/pep-0390.txt Added: peps/trunk/pep-0390.txt ============================================================================== --- (empty file) +++ peps/trunk/pep-0390.txt Sun Oct 11 01:56:30 2009 @@ -0,0 +1,164 @@ +PEP: 390 +Title: Static metadata for Distutils +Version: $Revision: 70705 $ +Last-Modified: $Date: 2009-03-30 06:53:39 +0200 (Lun 30 mar 2009) $ +Author: Tarek Ziad? +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 10-October-2009 +Python-Version: 2.7 and 3.2 +Post-History: + +Abstract +======== + +This PEP describes a new section and a new format for the ``setup.cfg`` file, +that allows describing the Metadata of a package without using ``setup.py``. + +Rationale +========= + +Today, if you want to list all the Metadata of a distribution (see PEP 314) +that is not installed, you need to use the ``setup.py`` command line interface. + +So, basically, you download it, and run:: + + $ python setup.py --name + Distribute + + $ python setup.py --version + 0.6.4 + +Where ``name`` and ``version`` are metadata fields. This is working fine but +as soon as the developers add more code in ``setup.py``, this feature might +break or in worst cases might do unwanted things on the target system. + +Moreover, when an OS packager wants to get the metadata of a distribution +he is re-packaging, he might encounter some problems to understand +the ``setup.py`` file he's working with. + +So the rationale of this PEP is to provide a way to declare the metadata +in a static configuration file alongside ``setup.py`` that doesn't require +any third party code to run. + + +Adding a ``metadata`` section in ``setup.cfg`` +============================================== + +The first thing we want to introduce is a ``[metadata]`` section, in the +``setup.cfg`` file, that may contain any field from the Metadata:: + + [metadata] + name = Distribute + version = 0.6.4 + +The ``setup.cfg`` file is used to avoid adding yet another configuration +file to work with in Distutils. + +This file is already read by Distutils when a command is executed, and +if the ``metadata`` section is found, it will be used to fill the metadata +fields. If an option that corresponds to a Metadata field is given to +``setup()``, it will override the value that was possibly present in +``setup.cfg``. + +Context-dependant sections +========================== + +The ``metadata`` section will also be able to use context-dependant sections. + +A context-dependant section is a section with a condition about the execution +environment. Here's some examples:: + + [metadata] + name = Distribute + version = 0.6.4 + + [metadata:sys_platform == 'win32'] + requires: pywin32 + requires: bar > 1.0 + + [metadata:os_machine == 'i386'] + requires: foo + + [metadata:python_version == '2.4' or python_version == '2.5'] + requires: bar + + [metadata:'linux' in sys_platform] + requires: baz + +Every ``[metadata:condition]`` section will be used only if the condition +is met when the file is read. The background motivation for these +context-dependant sections is to be able to define requirements that varies +depending on the platform the distribution might be installed on. +(see PEP 314). + +The micro-language behind this is the simplest possible: it compares only +strings, with the ``==`` and ``in`` operators (and their opposites), and +with the ability to combine expressions. It makes it also easy to understand +to non-pythoneers. + +The pseudo-grammar is :: + + EXPR [in|==|!=|not in]?EXPR [or|and] ... + +where ``EXPR`` belongs to any of those: + +- python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1]) +- os_name = os.name +- sys_platform = sys.platform +- os_version = os.uname()[3] +- os_machine = os.uname()[4] +- a free string, like ``2.4``, or ``win32`` + +Distutils will provide a function that is able to read the metadata +of a distribution, given a ``setup.cfg`` file, for the execution environment:: + + >>> from distutils.util import local_metadata + >>> local_metadata('setup.cfg') + + +This means that a vanilla Python will be able to read the metadata of a +package without running any third party code. + +Compatiblity +============ + +This change is fully backward compatible since it just adds a section in the +``ConfigParser``-compatible ``setup.cfg`` file. + +Limitations +=========== + +We are not providing ``<`` and ``>`` operators at this time, and +``python_version`` is a regular string. This implies using ``or`` operators +when a section needs to be restricted to a couple of Python versions. +Although, if PEP 386 is accepted, ``python_version`` could be changed +internally into something comparable with strings, and +``<`` and ``>`` operators introduced. + +Last, if a distribution is unable to set all metadata fields in ``setup.cfg``, +that's fine, the fields will be set to ``UNKNOWN`` when ``local_metadata`` is +called. Getting ``UNKNOWN`` values will mean that it might be necessary to +run the ``setup.py`` command line interface to get the whole set of metadata. + +Aknowledgments +============== + +The Distutils-SIG. + + +Copyright +========= + +This document has been placed in the public domain. + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: From python-checkins at python.org Sun Oct 11 02:00:42 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 11 Oct 2009 00:00:42 -0000 Subject: [Python-checkins] r75332 - peps/trunk/pep-0390.txt Message-ID: Author: tarek.ziade Date: Sun Oct 11 02:00:42 2009 New Revision: 75332 Log: using '=' (even if ':' works in configparser) Modified: peps/trunk/pep-0390.txt Modified: peps/trunk/pep-0390.txt ============================================================================== --- peps/trunk/pep-0390.txt (original) +++ peps/trunk/pep-0390.txt Sun Oct 11 02:00:42 2009 @@ -75,17 +75,17 @@ version = 0.6.4 [metadata:sys_platform == 'win32'] - requires: pywin32 - requires: bar > 1.0 + requires = pywin32 + requires = bar > 1.0 [metadata:os_machine == 'i386'] - requires: foo + requires = foo [metadata:python_version == '2.4' or python_version == '2.5'] - requires: bar + requires = bar [metadata:'linux' in sys_platform] - requires: baz + requires = baz Every ``[metadata:condition]`` section will be used only if the condition is met when the file is read. The background motivation for these From python-checkins at python.org Sun Oct 11 04:00:07 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 11 Oct 2009 02:00:07 -0000 Subject: [Python-checkins] r75333 - in python/trunk: Lib/test/test_urllib2.py Lib/urllib2.py Misc/NEWS Message-ID: Author: senthil.kumaran Date: Sun Oct 11 04:00:07 2009 New Revision: 75333 Log: Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment Modified: python/trunk/Lib/test/test_urllib2.py python/trunk/Lib/urllib2.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_urllib2.py ============================================================================== --- python/trunk/Lib/test/test_urllib2.py (original) +++ python/trunk/Lib/test/test_urllib2.py Sun Oct 11 04:00:07 2009 @@ -943,6 +943,22 @@ self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) + def test_proxy_no_proxy(self): + os.environ['no_proxy'] = 'python.org' + o = OpenerDirector() + ph = urllib2.ProxyHandler(dict(http="proxy.example.com")) + o.add_handler(ph) + req = Request("http://www.perl.org/") + self.assertEqual(req.get_host(), "www.perl.org") + r = o.open(req) + self.assertEqual(req.get_host(), "proxy.example.com") + req = Request("http://www.python.org") + self.assertEqual(req.get_host(), "www.python.org") + r = o.open(req) + self.assertEqual(req.get_host(), "www.python.org") + del os.environ['no_proxy'] + + def test_proxy_https(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) Modified: python/trunk/Lib/urllib2.py ============================================================================== --- python/trunk/Lib/urllib2.py (original) +++ python/trunk/Lib/urllib2.py Sun Oct 11 04:00:07 2009 @@ -111,7 +111,7 @@ splitattr, ftpwrapper, splituser, splitpasswd, splitvalue) # support for FileHandler, proxies via environment variables -from urllib import localhost, url2pathname, getproxies +from urllib import localhost, url2pathname, getproxies, proxy_bypass # used in User-Agent header sent __version__ = sys.version[:3] @@ -698,14 +698,20 @@ def proxy_open(self, req, proxy, type): orig_type = req.get_type() proxy_type, user, password, hostport = _parse_proxy(proxy) + if proxy_type is None: proxy_type = orig_type + + if req.host and proxy_bypass(req.host): + return None + if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) creds = base64.b64encode(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) + if orig_type == proxy_type or orig_type == 'https': # let other handlers take care of it return None Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 11 04:00:07 2009 @@ -398,6 +398,8 @@ Library ------- +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment + - Issue #7086: Added TCP support to SysLogHandler, and tidied up some anachronisms in the code which were a relic of 1.5.2 compatibility. From python-checkins at python.org Sun Oct 11 06:58:55 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 11 Oct 2009 04:58:55 -0000 Subject: [Python-checkins] r75334 - in python/branches/py3k: Lib/test/test_urllib2.py Lib/urllib/request.py Misc/NEWS Message-ID: Author: senthil.kumaran Date: Sun Oct 11 06:58:55 2009 New Revision: 75334 Log: Merged revisions 75333 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75333 | senthil.kumaran | 2009-10-11 07:30:07 +0530 (Sun, 11 Oct 2009) | 3 lines Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_urllib2.py python/branches/py3k/Lib/urllib/request.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_urllib2.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib2.py (original) +++ python/branches/py3k/Lib/test/test_urllib2.py Sun Oct 11 06:58:55 2009 @@ -947,6 +947,22 @@ self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) + def test_proxy_no_proxy(self): + os.environ['no_proxy'] = 'python.org' + o = OpenerDirector() + ph = urllib.request.ProxyHandler(dict(http="proxy.example.com")) + o.add_handler(ph) + req = Request("http://www.perl.org/") + self.assertEqual(req.get_host(), "www.perl.org") + r = o.open(req) + self.assertEqual(req.get_host(), "proxy.example.com") + req = Request("http://www.python.org") + self.assertEqual(req.get_host(), "www.python.org") + r = o.open(req) + self.assertEqual(req.get_host(), "www.python.org") + del os.environ['no_proxy'] + + def test_proxy_https(self): o = OpenerDirector() ph = urllib.request.ProxyHandler(dict(https="proxy.example.com:3128")) Modified: python/branches/py3k/Lib/urllib/request.py ============================================================================== --- python/branches/py3k/Lib/urllib/request.py (original) +++ python/branches/py3k/Lib/urllib/request.py Sun Oct 11 06:58:55 2009 @@ -657,6 +657,10 @@ proxy_type, user, password, hostport = _parse_proxy(proxy) if proxy_type is None: proxy_type = orig_type + + if req.host and proxy_bypass(req.host): + return None + if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Oct 11 06:58:55 2009 @@ -87,6 +87,8 @@ Library ------- +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment + - Issue #7086: Added TCP support to SysLogHandler, and tidied up some anachronisms in the code which were a relic of 1.5.2 compatibility. From python-checkins at python.org Sun Oct 11 07:35:45 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 11 Oct 2009 05:35:45 -0000 Subject: [Python-checkins] r75335 - in python/branches/release26-maint: Lib/test/test_urllib2.py Lib/urllib2.py Misc/NEWS Message-ID: Author: senthil.kumaran Date: Sun Oct 11 07:35:44 2009 New Revision: 75335 Log: Merged revisions 75333 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75333 | senthil.kumaran | 2009-10-11 07:30:07 +0530 (Sun, 11 Oct 2009) | 3 lines Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_urllib2.py python/branches/release26-maint/Lib/urllib2.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/test/test_urllib2.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_urllib2.py (original) +++ python/branches/release26-maint/Lib/test/test_urllib2.py Sun Oct 11 07:35:44 2009 @@ -943,6 +943,22 @@ self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) + def test_proxy_no_proxy(self): + os.environ['no_proxy'] = 'python.org' + o = OpenerDirector() + ph = urllib2.ProxyHandler(dict(http="proxy.example.com")) + o.add_handler(ph) + req = Request("http://www.perl.org/") + self.assertEqual(req.get_host(), "www.perl.org") + r = o.open(req) + self.assertEqual(req.get_host(), "proxy.example.com") + req = Request("http://www.python.org") + self.assertEqual(req.get_host(), "www.python.org") + r = o.open(req) + self.assertEqual(req.get_host(), "www.python.org") + del os.environ['no_proxy'] + + def test_proxy_https(self): o = OpenerDirector() ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128')) Modified: python/branches/release26-maint/Lib/urllib2.py ============================================================================== --- python/branches/release26-maint/Lib/urllib2.py (original) +++ python/branches/release26-maint/Lib/urllib2.py Sun Oct 11 07:35:44 2009 @@ -111,7 +111,7 @@ splitattr, ftpwrapper, splituser, splitpasswd, splitvalue) # support for FileHandler, proxies via environment variables -from urllib import localhost, url2pathname, getproxies +from urllib import localhost, url2pathname, getproxies, proxy_bypass # used in User-Agent header sent __version__ = sys.version[:3] @@ -698,14 +698,20 @@ def proxy_open(self, req, proxy, type): orig_type = req.get_type() proxy_type, user, password, hostport = _parse_proxy(proxy) + if proxy_type is None: proxy_type = orig_type + + if req.host and proxy_bypass(req.host): + return None + if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) creds = base64.b64encode(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) + if orig_type == proxy_type or orig_type == 'https': # let other handlers take care of it return None Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Oct 11 07:35:44 2009 @@ -124,6 +124,8 @@ Library ------- +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment + - Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. From python-checkins at python.org Sun Oct 11 08:07:46 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 11 Oct 2009 06:07:46 -0000 Subject: [Python-checkins] r75336 - in python/branches/release31-maint: Lib/test/test_urllib2.py Lib/urllib/request.py Misc/NEWS Message-ID: Author: senthil.kumaran Date: Sun Oct 11 08:07:46 2009 New Revision: 75336 Log: Merged revisions 75334 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75334 | senthil.kumaran | 2009-10-11 10:28:55 +0530 (Sun, 11 Oct 2009) | 9 lines Merged revisions 75333 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75333 | senthil.kumaran | 2009-10-11 07:30:07 +0530 (Sun, 11 Oct 2009) | 3 lines Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_urllib2.py python/branches/release31-maint/Lib/urllib/request.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/test/test_urllib2.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_urllib2.py (original) +++ python/branches/release31-maint/Lib/test/test_urllib2.py Sun Oct 11 08:07:46 2009 @@ -947,6 +947,22 @@ self.assertEqual([(handlers[0], "http_open")], [tup[0:2] for tup in o.calls]) + def test_proxy_no_proxy(self): + os.environ['no_proxy'] = 'python.org' + o = OpenerDirector() + ph = urllib.request.ProxyHandler(dict(http="proxy.example.com")) + o.add_handler(ph) + req = Request("http://www.perl.org/") + self.assertEqual(req.get_host(), "www.perl.org") + r = o.open(req) + self.assertEqual(req.get_host(), "proxy.example.com") + req = Request("http://www.python.org") + self.assertEqual(req.get_host(), "www.python.org") + r = o.open(req) + self.assertEqual(req.get_host(), "www.python.org") + del os.environ['no_proxy'] + + def test_proxy_https(self): o = OpenerDirector() ph = urllib.request.ProxyHandler(dict(https="proxy.example.com:3128")) Modified: python/branches/release31-maint/Lib/urllib/request.py ============================================================================== --- python/branches/release31-maint/Lib/urllib/request.py (original) +++ python/branches/release31-maint/Lib/urllib/request.py Sun Oct 11 08:07:46 2009 @@ -657,6 +657,10 @@ proxy_type, user, password, hostport = _parse_proxy(proxy) if proxy_type is None: proxy_type = orig_type + + if req.host and proxy_bypass(req.host): + return None + if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sun Oct 11 08:07:46 2009 @@ -27,6 +27,8 @@ Library ------- +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. From python-checkins at python.org Sun Oct 11 10:18:44 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:18:44 -0000 Subject: [Python-checkins] r75337 - python/trunk/Demo/scripts/morse.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:18:44 2009 New Revision: 75337 Log: Update morse script, avoid globals, use iterators. Modified: python/trunk/Demo/scripts/morse.py Modified: python/trunk/Demo/scripts/morse.py ============================================================================== --- python/trunk/Demo/scripts/morse.py (original) +++ python/trunk/Demo/scripts/morse.py Sun Oct 11 10:18:44 2009 @@ -1,3 +1,5 @@ +#! /usr/bin/env python + # DAH should be three DOTs. # Space between DOTs and DAHs should be one DOT. # Space between two letters should be one DAH. @@ -36,53 +38,44 @@ 'X': '-..-', 'x': '-..-', 'Y': '-.--', 'y': '-.--', 'Z': '--..', 'z': '--..', - '0': '-----', - '1': '.----', - '2': '..---', - '3': '...--', - '4': '....-', - '5': '.....', - '6': '-....', - '7': '--...', - '8': '---..', - '9': '----.', - ',': '--..--', - '.': '.-.-.-', - '?': '..--..', - ';': '-.-.-.', - ':': '---...', - "'": '.----.', - '-': '-....-', - '/': '-..-.', - '(': '-.--.-', - ')': '-.--.-', - '_': '..--.-', - ' ': ' ' + '0': '-----', ',': '--..--', + '1': '.----', '.': '.-.-.-', + '2': '..---', '?': '..--..', + '3': '...--', ';': '-.-.-.', + '4': '....-', ':': '---...', + '5': '.....', "'": '.----.', + '6': '-....', '-': '-....-', + '7': '--...', '/': '-..-.', + '8': '---..', '(': '-.--.-', + '9': '----.', ')': '-.--.-', + ' ': ' ', '_': '..--.-', } +nowave = '\0' * 200 + # If we play at 44.1 kHz (which we do), then if we produce one sine # wave in 100 samples, we get a tone of 441 Hz. If we produce two # sine waves in these 100 samples, we get a tone of 882 Hz. 882 Hz # appears to be a nice one for playing morse code. def mkwave(octave): - global sinewave, nowave sinewave = '' for i in range(100): - val = int(math.sin(math.pi * float(i) * octave / 50.0) * 30000) + val = int(math.sin(math.pi * i * octave / 50.0) * 30000) sinewave = sinewave + chr((val >> 8) & 255) + chr(val & 255) - nowave = '\0' * 200 + return sinewave -mkwave(OCTAVE) +defaultwave = mkwave(OCTAVE) def main(): - import getopt, string + import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'o:p:') except getopt.error: sys.stderr.write('Usage ' + sys.argv[0] + - ' [ -o outfile ] [ args ] ...\n') + ' [ -o outfile ] [ -p octave ] [ words ] ...\n') sys.exit(1) dev = None + wave = defaultwave for o, a in opts: if o == '-o': import aifc @@ -91,7 +84,7 @@ dev.setsampwidth(2) dev.setnchannels(1) if o == '-p': - mkwave(string.atoi(a)) + wave = mkwave(int(a)) if not dev: import audiodev dev = audiodev.AudioDev() @@ -101,18 +94,14 @@ dev.close = dev.stop dev.writeframesraw = dev.writeframes if args: - line = string.join(args) + source = [' '.join(args)] else: - line = sys.stdin.readline() - while line: + source = iter(sys.stdin.readline, '') + for line in source: mline = morse(line) - play(mline, dev) + play(mline, dev, wave) if hasattr(dev, 'wait'): dev.wait() - if not args: - line = sys.stdin.readline() - else: - line = '' dev.close() # Convert a string to morse code with \001 between the characters in @@ -121,29 +110,29 @@ res = '' for c in line: try: - res = res + morsetab[c] + '\001' + res += morsetab[c] + '\001' except KeyError: pass return res # Play a line of morse code. -def play(line, dev): +def play(line, dev, wave): for c in line: if c == '.': - sine(dev, DOT) + sine(dev, DOT, wave) elif c == '-': - sine(dev, DAH) + sine(dev, DAH, wave) else: # space pause(dev, DAH + DOT) pause(dev, DOT) -def sine(dev, length): +def sine(dev, length, wave): for i in range(length): - dev.writeframesraw(sinewave) + dev.writeframesraw(wave) def pause(dev, length): for i in range(length): dev.writeframesraw(nowave) -if __name__ == '__main__' or sys.argv[0] == __name__: +if __name__ == '__main__': main() From python-checkins at python.org Sun Oct 11 10:31:41 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:31:41 -0000 Subject: [Python-checkins] r75338 - in python/branches/py3k: Demo/scripts/morse.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:31:41 2009 New Revision: 75338 Log: Merged revisions 75337 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75337 | georg.brandl | 2009-10-11 10:18:44 +0200 (So, 11 Okt 2009) | 1 line Update morse script, avoid globals, use iterators. ........ Added: python/branches/py3k/Demo/scripts/morse.py (contents, props changed) Modified: python/branches/py3k/ (props changed) Added: python/branches/py3k/Demo/scripts/morse.py ============================================================================== --- (empty file) +++ python/branches/py3k/Demo/scripts/morse.py Sun Oct 11 10:31:41 2009 @@ -0,0 +1,128 @@ +#! /usr/bin/env python + +# DAH should be three DOTs. +# Space between DOTs and DAHs should be one DOT. +# Space between two letters should be one DAH. +# Space between two words should be DOT DAH DAH. + +import sys, math, aifc +from contextlib import closing + +DOT = 30 +DAH = 3 * DOT +OCTAVE = 2 # 1 == 441 Hz, 2 == 882 Hz, ... + +morsetab = { + 'A': '.-', 'a': '.-', + 'B': '-...', 'b': '-...', + 'C': '-.-.', 'c': '-.-.', + 'D': '-..', 'd': '-..', + 'E': '.', 'e': '.', + 'F': '..-.', 'f': '..-.', + 'G': '--.', 'g': '--.', + 'H': '....', 'h': '....', + 'I': '..', 'i': '..', + 'J': '.---', 'j': '.---', + 'K': '-.-', 'k': '-.-', + 'L': '.-..', 'l': '.-..', + 'M': '--', 'm': '--', + 'N': '-.', 'n': '-.', + 'O': '---', 'o': '---', + 'P': '.--.', 'p': '.--.', + 'Q': '--.-', 'q': '--.-', + 'R': '.-.', 'r': '.-.', + 'S': '...', 's': '...', + 'T': '-', 't': '-', + 'U': '..-', 'u': '..-', + 'V': '...-', 'v': '...-', + 'W': '.--', 'w': '.--', + 'X': '-..-', 'x': '-..-', + 'Y': '-.--', 'y': '-.--', + 'Z': '--..', 'z': '--..', + '0': '-----', ',': '--..--', + '1': '.----', '.': '.-.-.-', + '2': '..---', '?': '..--..', + '3': '...--', ';': '-.-.-.', + '4': '....-', ':': '---...', + '5': '.....', "'": '.----.', + '6': '-....', '-': '-....-', + '7': '--...', '/': '-..-.', + '8': '---..', '(': '-.--.-', + '9': '----.', ')': '-.--.-', + ' ': ' ', '_': '..--.-', +} + +nowave = b'\0' * 200 + +# If we play at 44.1 kHz (which we do), then if we produce one sine +# wave in 100 samples, we get a tone of 441 Hz. If we produce two +# sine waves in these 100 samples, we get a tone of 882 Hz. 882 Hz +# appears to be a nice one for playing morse code. +def mkwave(octave): + sinewave = bytearray() + for i in range(100): + val = int(math.sin(math.pi * i * octave / 50.0) * 30000) + sinewave.extend([(val >> 8) & 255, val & 255]) + return bytes(sinewave) + +defaultwave = mkwave(OCTAVE) + +def main(): + import getopt + try: + opts, args = getopt.getopt(sys.argv[1:], 'o:p:') + except getopt.error: + sys.stderr.write('Usage ' + sys.argv[0] + + ' [ -o outfile ] [ -p octave ] [ words ] ...\n') + sys.exit(1) + wave = defaultwave + outfile = 'morse.aifc' + for o, a in opts: + if o == '-o': + outfile = a + if o == '-p': + wave = mkwave(int(a)) + with closing(aifc.open(outfile, 'w')) as fp: + fp.setframerate(44100) + fp.setsampwidth(2) + fp.setnchannels(1) + if args: + source = [' '.join(args)] + else: + source = iter(sys.stdin.readline, '') + for line in source: + mline = morse(line) + play(mline, fp, wave) + +# Convert a string to morse code with \001 between the characters in +# the string. +def morse(line): + res = '' + for c in line: + try: + res += morsetab[c] + '\001' + except KeyError: + pass + return res + +# Play a line of morse code. +def play(line, fp, wave): + for c in line: + if c == '.': + sine(fp, DOT, wave) + elif c == '-': + sine(fp, DAH, wave) + else: # space + pause(fp, DAH + DOT) + pause(fp, DOT) + +def sine(fp, length, wave): + for i in range(length): + fp.writeframesraw(wave) + +def pause(fp, length): + for i in range(length): + fp.writeframesraw(nowave) + +if __name__ == '__main__': + main() From python-checkins at python.org Sun Oct 11 10:39:17 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:39:17 -0000 Subject: [Python-checkins] r75339 - in python/trunk/Demo/scripts: markov.py morse.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:39:16 2009 New Revision: 75339 Log: Update markov demo. Modified: python/trunk/Demo/scripts/markov.py python/trunk/Demo/scripts/morse.py Modified: python/trunk/Demo/scripts/markov.py ============================================================================== --- python/trunk/Demo/scripts/markov.py (original) +++ python/trunk/Demo/scripts/markov.py Sun Oct 11 10:39:16 2009 @@ -5,11 +5,10 @@ self.histsize = histsize self.choice = choice self.trans = {} + def add(self, state, next): - if not self.trans.has_key(state): - self.trans[state] = [next] - else: - self.trans[state].append(next) + self.trans.setdefault(state, []).append(next) + def put(self, seq): n = self.histsize add = self.add @@ -17,26 +16,29 @@ for i in range(len(seq)): add(seq[max(0, i-n):i], seq[i:i+1]) add(seq[len(seq)-n:], None) + def get(self): choice = self.choice trans = self.trans n = self.histsize seq = choice(trans[None]) - while 1: + while True: subseq = seq[max(0, len(seq)-n):] options = trans[subseq] next = choice(options) - if not next: break - seq = seq + next + if not next: + break + seq += next return seq + def test(): - import sys, string, random, getopt + import sys, random, getopt args = sys.argv[1:] try: - opts, args = getopt.getopt(args, '0123456789cdw') + opts, args = getopt.getopt(args, '0123456789cdwq') except getopt.error: - print 'Usage: markov [-#] [-cddqw] [file] ...' + print 'Usage: %s [-#] [-cddqw] [file] ...' % sys.argv[0] print 'Options:' print '-#: 1-digit history size (default 2)' print '-c: characters (default)' @@ -49,16 +51,19 @@ print 'exactly one space separating words.' print 'Output consists of paragraphs separated by blank' print 'lines, where lines are no longer than 72 characters.' + sys.exit(2) histsize = 2 - do_words = 0 + do_words = False debug = 1 for o, a in opts: - if '-0' <= o <= '-9': histsize = eval(o[1:]) - if o == '-c': do_words = 0 - if o == '-d': debug = debug + 1 + if '-0' <= o <= '-9': histsize = int(o[1:]) + if o == '-c': do_words = False + if o == '-d': debug += 1 if o == '-q': debug = 0 - if o == '-w': do_words = 1 - if not args: args = ['-'] + if o == '-w': do_words = True + if not args: + args = ['-'] + m = Markov(histsize, random.choice) try: for filename in args: @@ -72,13 +77,15 @@ if debug: print 'processing', filename, '...' text = f.read() f.close() - paralist = string.splitfields(text, '\n\n') + paralist = text.split('\n\n') for para in paralist: if debug > 1: print 'feeding ...' - words = string.split(para) + words = para.split() if words: - if do_words: data = tuple(words) - else: data = string.joinfields(words, ' ') + if do_words: + data = tuple(words) + else: + data = ' '.join(words) m.put(data) except KeyboardInterrupt: print 'Interrupted -- continue with data read so far' @@ -86,16 +93,19 @@ print 'No valid input files' return if debug: print 'done.' + if debug > 1: for key in m.trans.keys(): if key is None or len(key) < histsize: print repr(key), m.trans[key] if histsize == 0: print repr(''), m.trans[''] print - while 1: + while True: data = m.get() - if do_words: words = data - else: words = string.split(data) + if do_words: + words = data + else: + words = data.split() n = 0 limit = 72 for w in words: @@ -103,15 +113,9 @@ print n = 0 print w, - n = n + len(w) + 1 + n += len(w) + 1 print print -def tuple(list): - if len(list) == 0: return () - if len(list) == 1: return (list[0],) - i = len(list)//2 - return tuple(list[:i]) + tuple(list[i:]) - if __name__ == "__main__": test() Modified: python/trunk/Demo/scripts/morse.py ============================================================================== --- python/trunk/Demo/scripts/morse.py (original) +++ python/trunk/Demo/scripts/morse.py Sun Oct 11 10:39:16 2009 @@ -61,7 +61,7 @@ sinewave = '' for i in range(100): val = int(math.sin(math.pi * i * octave / 50.0) * 30000) - sinewave = sinewave + chr((val >> 8) & 255) + chr(val & 255) + sinewave += chr((val >> 8) & 255) + chr(val & 255) return sinewave defaultwave = mkwave(OCTAVE) From python-checkins at python.org Sun Oct 11 10:42:09 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:42:09 -0000 Subject: [Python-checkins] r75340 - in python/branches/py3k: Demo/scripts/markov.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:42:09 2009 New Revision: 75340 Log: Merged revisions 75339 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75339 | georg.brandl | 2009-10-11 10:39:16 +0200 (So, 11 Okt 2009) | 1 line Update markov demo. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/markov.py Modified: python/branches/py3k/Demo/scripts/markov.py ============================================================================== --- python/branches/py3k/Demo/scripts/markov.py (original) +++ python/branches/py3k/Demo/scripts/markov.py Sun Oct 11 10:42:09 2009 @@ -5,11 +5,10 @@ self.histsize = histsize self.choice = choice self.trans = {} + def add(self, state, next): - if state not in self.trans: - self.trans[state] = [next] - else: - self.trans[state].append(next) + self.trans.setdefault(state, []).append(next) + def put(self, seq): n = self.histsize add = self.add @@ -17,26 +16,29 @@ for i in range(len(seq)): add(seq[max(0, i-n):i], seq[i:i+1]) add(seq[len(seq)-n:], None) + def get(self): choice = self.choice trans = self.trans n = self.histsize seq = choice(trans[None]) - while 1: + while True: subseq = seq[max(0, len(seq)-n):] options = trans[subseq] next = choice(options) - if not next: break - seq = seq + next + if not next: + break + seq += next return seq + def test(): - import sys, string, random, getopt + import sys, random, getopt args = sys.argv[1:] try: - opts, args = getopt.getopt(args, '0123456789cdw') + opts, args = getopt.getopt(args, '0123456789cdwq') except getopt.error: - print('Usage: markov [-#] [-cddqw] [file] ...') + print('Usage: %s [-#] [-cddqw] [file] ...' % sys.argv[0]) print('Options:') print('-#: 1-digit history size (default 2)') print('-c: characters (default)') @@ -49,16 +51,19 @@ print('exactly one space separating words.') print('Output consists of paragraphs separated by blank') print('lines, where lines are no longer than 72 characters.') + sys.exit(2) histsize = 2 - do_words = 0 + do_words = False debug = 1 for o, a in opts: - if '-0' <= o <= '-9': histsize = eval(o[1:]) - if o == '-c': do_words = 0 - if o == '-d': debug = debug + 1 + if '-0' <= o <= '-9': histsize = int(o[1:]) + if o == '-c': do_words = False + if o == '-d': debug += 1 if o == '-q': debug = 0 - if o == '-w': do_words = 1 - if not args: args = ['-'] + if o == '-w': do_words = True + if not args: + args = ['-'] + m = Markov(histsize, random.choice) try: for filename in args: @@ -72,13 +77,15 @@ if debug: print('processing', filename, '...') text = f.read() f.close() - paralist = string.splitfields(text, '\n\n') + paralist = text.split('\n\n') for para in paralist: if debug > 1: print('feeding ...') - words = string.split(para) + words = para.split() if words: - if do_words: data = tuple(words) - else: data = string.joinfields(words, ' ') + if do_words: + data = tuple(words) + else: + data = ' '.join(words) m.put(data) except KeyboardInterrupt: print('Interrupted -- continue with data read so far') @@ -86,16 +93,19 @@ print('No valid input files') return if debug: print('done.') + if debug > 1: for key in m.trans.keys(): if key is None or len(key) < histsize: print(repr(key), m.trans[key]) if histsize == 0: print(repr(''), m.trans['']) print() - while 1: + while True: data = m.get() - if do_words: words = data - else: words = string.split(data) + if do_words: + words = data + else: + words = data.split() n = 0 limit = 72 for w in words: @@ -103,15 +113,9 @@ print() n = 0 print(w, end=' ') - n = n + len(w) + 1 + n += len(w) + 1 print() print() -def tuple(list): - if len(list) == 0: return () - if len(list) == 1: return (list[0],) - i = len(list)//2 - return tuple(list[:i]) + tuple(list[i:]) - if __name__ == "__main__": test() From python-checkins at python.org Sun Oct 11 10:43:08 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:43:08 -0000 Subject: [Python-checkins] r75341 - python/branches/py3k/Demo/scripts/README Message-ID: Author: georg.brandl Date: Sun Oct 11 10:43:08 2009 New Revision: 75341 Log: Fix README description. Modified: python/branches/py3k/Demo/scripts/README Modified: python/branches/py3k/Demo/scripts/README ============================================================================== --- python/branches/py3k/Demo/scripts/README (original) +++ python/branches/py3k/Demo/scripts/README Sun Oct 11 10:43:08 2009 @@ -13,7 +13,7 @@ markov.py Markov chain simulation of words or characters mboxconvvert.py Convert MH or MMDF mailboxes to unix mailbox format mkrcs.py Fix symlinks named RCS into parallel tree -morse.py Produce morse code (audible or on AIFF file) +morse.py Produce morse code (as an AIFF file) pi.py Print all digits of pi -- given enough time and memory pp.py Emulate some Perl command line options primes.py Print prime numbers From python-checkins at python.org Sun Oct 11 10:45:03 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:45:03 -0000 Subject: [Python-checkins] r75342 - in python/trunk/Demo/scripts: README mkrcs.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:45:03 2009 New Revision: 75342 Log: Remove useless script "mkrcs" and update README. Removed: python/trunk/Demo/scripts/mkrcs.py Modified: python/trunk/Demo/scripts/README Modified: python/trunk/Demo/scripts/README ============================================================================== --- python/trunk/Demo/scripts/README (original) +++ python/trunk/Demo/scripts/README Sun Oct 11 10:45:03 2009 @@ -5,15 +5,15 @@ beer.py Print the classic 'bottles of beer' list. eqfix.py Fix .py files to use the correct equality test operator fact.py Factorize numbers -find-uname.py Search for Unicode characters using regexps. +find-uname.py Search for Unicode characters using regexps from.py Summarize mailbox ftpstats.py Summarize ftp daemon log file lpwatch.py Watch BSD line printer queues makedir.py Like mkdir -p markov.py Markov chain simulation of words or characters -mboxconvvert.py Convert MH or MMDF mailboxes to unix mailbox format -mkrcs.py Fix symlinks named RCS into parallel tree +mboxconvert.py Convert MH or MMDF mailboxes to unix mailbox format morse.py Produce morse code (audible or on AIFF file) +newslist.py List all newsgroups on a NNTP server as HTML pages pi.py Print all digits of pi -- given enough time and memory pp.py Emulate some Perl command line options primes.py Print prime numbers Deleted: python/trunk/Demo/scripts/mkrcs.py ============================================================================== --- python/trunk/Demo/scripts/mkrcs.py Sun Oct 11 10:45:03 2009 +++ (empty file) @@ -1,61 +0,0 @@ -#! /usr/bin/env python - -# A rather specialized script to make sure that a symbolic link named -# RCS exists pointing to a real RCS directory in a parallel tree -# referenced as RCStree in an ancestor directory. -# (I use this because I like my RCS files to reside on a physically -# different machine). - -import os - -def main(): - rcstree = 'RCStree' - rcs = 'RCS' - if os.path.islink(rcs): - print '%r is a symlink to %r' % (rcs, os.readlink(rcs)) - return - if os.path.isdir(rcs): - print '%r is an ordinary directory' % (rcs,) - return - if os.path.exists(rcs): - print '%r is a file?!?!' % (rcs,) - return - # - p = os.getcwd() - up = '' - down = '' - # Invariants: - # (1) join(p, down) is the current directory - # (2) up is the same directory as p - # Ergo: - # (3) join(up, down) is the current directory - #print 'p =', repr(p) - while not os.path.isdir(os.path.join(p, rcstree)): - head, tail = os.path.split(p) - #print 'head = %r; tail = %r' % (head, tail) - if not tail: - print 'Sorry, no ancestor dir contains %r' % (rcstree,) - return - p = head - up = os.path.join(os.pardir, up) - down = os.path.join(tail, down) - #print 'p = %r; up = %r; down = %r' % (p, up, down) - there = os.path.join(up, rcstree) - there = os.path.join(there, down) - there = os.path.join(there, rcs) - if os.path.isdir(there): - print '%r already exists' % (there, ) - else: - print 'making %r' % (there,) - makedirs(there) - print 'making symlink %r -> %r' % (rcs, there) - os.symlink(there, rcs) - -def makedirs(p): - if not os.path.isdir(p): - head, tail = os.path.split(p) - makedirs(head) - os.mkdir(p, 0777) - -if __name__ == "__main__": - main() From python-checkins at python.org Sun Oct 11 10:46:56 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:46:56 -0000 Subject: [Python-checkins] r75343 - in python/branches/py3k: Demo/scripts/README Demo/scripts/mkrcs.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:46:56 2009 New Revision: 75343 Log: Merged revisions 75342 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75342 | georg.brandl | 2009-10-11 10:45:03 +0200 (So, 11 Okt 2009) | 1 line Remove useless script "mkrcs" and update README. ........ Removed: python/branches/py3k/Demo/scripts/mkrcs.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/README Modified: python/branches/py3k/Demo/scripts/README ============================================================================== --- python/branches/py3k/Demo/scripts/README (original) +++ python/branches/py3k/Demo/scripts/README Sun Oct 11 10:46:56 2009 @@ -5,15 +5,15 @@ beer.py Print the classic 'bottles of beer' list. eqfix.py Fix .py files to use the correct equality test operator fact.py Factorize numbers -find-uname.py Search for Unicode characters using regexps. +find-uname.py Search for Unicode characters using regexps from.py Summarize mailbox ftpstats.py Summarize ftp daemon log file lpwatch.py Watch BSD line printer queues makedir.py Like mkdir -p markov.py Markov chain simulation of words or characters -mboxconvvert.py Convert MH or MMDF mailboxes to unix mailbox format -mkrcs.py Fix symlinks named RCS into parallel tree +mboxconvert.py Convert MH or MMDF mailboxes to unix mailbox format morse.py Produce morse code (as an AIFF file) +newslist.py List all newsgroups on a NNTP server as HTML pages pi.py Print all digits of pi -- given enough time and memory pp.py Emulate some Perl command line options primes.py Print prime numbers Deleted: python/branches/py3k/Demo/scripts/mkrcs.py ============================================================================== --- python/branches/py3k/Demo/scripts/mkrcs.py Sun Oct 11 10:46:56 2009 +++ (empty file) @@ -1,61 +0,0 @@ -#! /usr/bin/env python - -# A rather specialized script to make sure that a symbolic link named -# RCS exists pointing to a real RCS directory in a parallel tree -# referenced as RCStree in an ancestor directory. -# (I use this because I like my RCS files to reside on a physically -# different machine). - -import os - -def main(): - rcstree = 'RCStree' - rcs = 'RCS' - if os.path.islink(rcs): - print('%r is a symlink to %r' % (rcs, os.readlink(rcs))) - return - if os.path.isdir(rcs): - print('%r is an ordinary directory' % (rcs,)) - return - if os.path.exists(rcs): - print('%r is a file?!?!' % (rcs,)) - return - # - p = os.getcwd() - up = '' - down = '' - # Invariants: - # (1) join(p, down) is the current directory - # (2) up is the same directory as p - # Ergo: - # (3) join(up, down) is the current directory - #print 'p =', repr(p) - while not os.path.isdir(os.path.join(p, rcstree)): - head, tail = os.path.split(p) - #print 'head = %r; tail = %r' % (head, tail) - if not tail: - print('Sorry, no ancestor dir contains %r' % (rcstree,)) - return - p = head - up = os.path.join(os.pardir, up) - down = os.path.join(tail, down) - #print 'p = %r; up = %r; down = %r' % (p, up, down) - there = os.path.join(up, rcstree) - there = os.path.join(there, down) - there = os.path.join(there, rcs) - if os.path.isdir(there): - print('%r already exists' % (there, )) - else: - print('making %r' % (there,)) - makedirs(there) - print('making symlink %r -> %r' % (rcs, there)) - os.symlink(there, rcs) - -def makedirs(p): - if not os.path.isdir(p): - head, tail = os.path.split(p) - makedirs(head) - os.mkdir(p, 0o777) - -if __name__ == "__main__": - main() From python-checkins at python.org Sun Oct 11 10:48:29 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:48:29 -0000 Subject: [Python-checkins] r75344 - in python/trunk/Demo/scripts: README primes.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:48:28 2009 New Revision: 75344 Log: Update primes script. Modified: python/trunk/Demo/scripts/README python/trunk/Demo/scripts/primes.py Modified: python/trunk/Demo/scripts/README ============================================================================== --- python/trunk/Demo/scripts/README (original) +++ python/trunk/Demo/scripts/README Sun Oct 11 10:48:28 2009 @@ -2,7 +2,7 @@ See also the Tools/scripts directory! -beer.py Print the classic 'bottles of beer' list. +beer.py Print the classic 'bottles of beer' list eqfix.py Fix .py files to use the correct equality test operator fact.py Factorize numbers find-uname.py Search for Unicode characters using regexps Modified: python/trunk/Demo/scripts/primes.py ============================================================================== --- python/trunk/Demo/scripts/primes.py (original) +++ python/trunk/Demo/scripts/primes.py Sun Oct 11 10:48:28 2009 @@ -2,26 +2,29 @@ # Print prime numbers in a given range -def main(): - import sys - min, max = 2, 0x7fffffff - if sys.argv[1:]: - min = int(eval(sys.argv[1])) - if sys.argv[2:]: - max = int(eval(sys.argv[2])) - primes(min, max) - def primes(min, max): - if 2 >= min: print 2 + if 2 >= min: + print 2 primes = [2] i = 3 while i <= max: for p in primes: - if i%p == 0 or p*p > i: break - if i%p <> 0: + if i % p == 0 or p*p > i: + break + if i % p != 0: primes.append(i) - if i >= min: print i - i = i+2 + if i >= min: + print i + i += 2 + +def main(): + import sys + min, max = 2, 0x7fffffff + if sys.argv[1:]: + min = int(sys.argv[1]) + if sys.argv[2:]: + max = int(sys.argv[2]) + primes(min, max) if __name__ == "__main__": main() From python-checkins at python.org Sun Oct 11 10:49:58 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 08:49:58 -0000 Subject: [Python-checkins] r75345 - in python/branches/py3k: Demo/scripts/README Demo/scripts/primes.py Message-ID: Author: georg.brandl Date: Sun Oct 11 10:49:57 2009 New Revision: 75345 Log: Merged revisions 75344 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75344 | georg.brandl | 2009-10-11 10:48:28 +0200 (So, 11 Okt 2009) | 1 line Update primes script. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/README python/branches/py3k/Demo/scripts/primes.py Modified: python/branches/py3k/Demo/scripts/README ============================================================================== --- python/branches/py3k/Demo/scripts/README (original) +++ python/branches/py3k/Demo/scripts/README Sun Oct 11 10:49:57 2009 @@ -2,7 +2,7 @@ See also the Tools/scripts directory! -beer.py Print the classic 'bottles of beer' list. +beer.py Print the classic 'bottles of beer' list eqfix.py Fix .py files to use the correct equality test operator fact.py Factorize numbers find-uname.py Search for Unicode characters using regexps Modified: python/branches/py3k/Demo/scripts/primes.py ============================================================================== --- python/branches/py3k/Demo/scripts/primes.py (original) +++ python/branches/py3k/Demo/scripts/primes.py Sun Oct 11 10:49:57 2009 @@ -2,26 +2,30 @@ # Print prime numbers in a given range +def primes(min, max): + if 2 >= min: + print(2) + primes = [2] + i = 3 + while i <= max: + for p in primes: + if i % p == 0 or p*p > i: + break + if i % p != 0: + primes.append(i) + if i >= min: + print(i) + i += 2 + def main(): import sys min, max = 2, 0x7fffffff if sys.argv[1:]: - min = int(eval(sys.argv[1])) + min = int(sys.argv[1]) if sys.argv[2:]: - max = int(eval(sys.argv[2])) + max = int(sys.argv[2]) primes(min, max) -def primes(min, max): - if 2 >= min: print(2) - primes = [2] - i = 3 - while i <= max: - for p in primes: - if i%p == 0 or p*p > i: break - if i%p != 0: - primes.append(i) - if i >= min: print(i) - i = i+2 if __name__ == "__main__": main() From python-checkins at python.org Sun Oct 11 11:35:58 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 11 Oct 2009 09:35:58 -0000 Subject: [Python-checkins] r75346 - python/trunk/Demo/scripts/primes.py Message-ID: Author: mark.dickinson Date: Sun Oct 11 11:35:57 2009 New Revision: 75346 Log: Fix 'primes 0 1' Modified: python/trunk/Demo/scripts/primes.py Modified: python/trunk/Demo/scripts/primes.py ============================================================================== --- python/trunk/Demo/scripts/primes.py (original) +++ python/trunk/Demo/scripts/primes.py Sun Oct 11 11:35:57 2009 @@ -3,7 +3,7 @@ # Print prime numbers in a given range def primes(min, max): - if 2 >= min: + if max >= 2 >= min: print 2 primes = [2] i = 3 From orsenthil at gmail.com Sun Oct 11 11:38:10 2009 From: orsenthil at gmail.com (Senthil Kumaran) Date: Sun, 11 Oct 2009 15:08:10 +0530 Subject: [Python-checkins] r75344 - in python/trunk/Demo/scripts: README primes.py In-Reply-To: <4ad19be8.1a67f10a.3295.0fb7SMTPIN_ADDED@mx.google.com> References: <4ad19be8.1a67f10a.3295.0fb7SMTPIN_ADDED@mx.google.com> Message-ID: <7c42eba10910110238j3d7aa27ao390d9c8643cfae70@mail.gmail.com> > Modified: python/trunk/Demo/scripts/primes.py > ============================================================================== > --- python/trunk/Demo/scripts/primes.py (original) > +++ python/trunk/Demo/scripts/primes.py Sun Oct 11 10:48:28 2009 I also think that we can just replace that one with a script that uses generator. http://code.activestate.com/recipes/117119/#c2 FWIW, it is in Python Cookbook too. -- Senthil From python-checkins at python.org Sun Oct 11 11:40:17 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 11 Oct 2009 09:40:17 -0000 Subject: [Python-checkins] r75347 - in python/branches/py3k: Demo/scripts/primes.py Message-ID: Author: mark.dickinson Date: Sun Oct 11 11:40:17 2009 New Revision: 75347 Log: Merged revisions 75346 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75346 | mark.dickinson | 2009-10-11 10:35:57 +0100 (Sun, 11 Oct 2009) | 1 line Fix 'primes 0 1' ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/primes.py Modified: python/branches/py3k/Demo/scripts/primes.py ============================================================================== --- python/branches/py3k/Demo/scripts/primes.py (original) +++ python/branches/py3k/Demo/scripts/primes.py Sun Oct 11 11:40:17 2009 @@ -3,7 +3,7 @@ # Print prime numbers in a given range def primes(min, max): - if 2 >= min: + if max >= 2 >= min: print(2) primes = [2] i = 3 From python-checkins at python.org Sun Oct 11 12:01:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 11 Oct 2009 10:01:18 -0000 Subject: [Python-checkins] r75348 - in python/trunk/Demo/scripts: beer.py find-uname.py Message-ID: Author: mark.dickinson Date: Sun Oct 11 12:01:17 2009 New Revision: 75348 Log: Set missing executable property on scripts Modified: python/trunk/Demo/scripts/beer.py (props changed) python/trunk/Demo/scripts/find-uname.py (props changed) From nnorwitz at gmail.com Sun Oct 11 12:14:14 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 11 Oct 2009 06:14:14 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091011101414.GA7225@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_distutils leaked [-25, 0, 0] references, sum=-25 Less important issues: ---------------------- test_asynchat leaked [-128, 0, 0] references, sum=-128 test_smtplib leaked [88, -88, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Sun Oct 11 12:32:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 11 Oct 2009 10:32:51 -0000 Subject: [Python-checkins] r75349 - in python/branches/py3k: Demo/scripts/beer.py Demo/scripts/find-uname.py Demo/scripts/toaiff.py Message-ID: Author: mark.dickinson Date: Sun Oct 11 12:32:51 2009 New Revision: 75349 Log: Merged revisions 75348 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75348 | mark.dickinson | 2009-10-11 11:01:17 +0100 (Sun, 11 Oct 2009) | 1 line Set missing executable property on scripts ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/beer.py (props changed) python/branches/py3k/Demo/scripts/find-uname.py (props changed) python/branches/py3k/Demo/scripts/toaiff.py (props changed) From python-checkins at python.org Sun Oct 11 14:00:18 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 12:00:18 -0000 Subject: [Python-checkins] r75350 - python/trunk/Demo/scripts/script.py Message-ID: Author: georg.brandl Date: Sun Oct 11 14:00:18 2009 New Revision: 75350 Log: Use getopt in script.py demo. Modified: python/trunk/Demo/scripts/script.py Modified: python/trunk/Demo/scripts/script.py ============================================================================== --- python/trunk/Demo/scripts/script.py (original) +++ python/trunk/Demo/scripts/script.py Sun Oct 11 14:00:18 2009 @@ -1,4 +1,5 @@ #! /usr/bin/env python + # script.py -- Make typescript of terminal session. # Usage: # -a Append to typescript. @@ -6,7 +7,7 @@ # Author: Steen Lumholt. -import os, time, sys +import os, time, sys, getopt import pty def read(fd): @@ -19,15 +20,23 @@ mode = 'w' if os.environ.has_key('SHELL'): shell = os.environ['SHELL'] -if '-a' in sys.argv: - mode = 'a' -if '-p' in sys.argv: - shell = 'python' -file = open(filename, mode) +try: + opts, args = getopt.getopt(sys.argv[1:], 'ap') +except getopt.error, msg: + print '%s: %s' % (sys.argv[0], msg) + sys.exit(2) + +for o, a in opts: + if o == '-a': + mode = 'a' + elif o == '-p': + shell = 'python' + +script = open(filename, mode) sys.stdout.write('Script started, file is %s\n' % filename) -file.write('Script started on %s\n' % time.ctime(time.time())) +script.write('Script started on %s\n' % time.ctime(time.time())) pty.spawn(shell, read) -file.write('Script done on %s\n' % time.ctime(time.time())) +script.write('Script done on %s\n' % time.ctime(time.time())) sys.stdout.write('Script done, file is %s\n' % filename) From python-checkins at python.org Sun Oct 11 14:03:01 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 12:03:01 -0000 Subject: [Python-checkins] r75351 - python/trunk/Demo/scripts/script.py Message-ID: Author: georg.brandl Date: Sun Oct 11 14:03:01 2009 New Revision: 75351 Log: Fix variable. Modified: python/trunk/Demo/scripts/script.py Modified: python/trunk/Demo/scripts/script.py ============================================================================== --- python/trunk/Demo/scripts/script.py (original) +++ python/trunk/Demo/scripts/script.py Sun Oct 11 14:03:01 2009 @@ -12,7 +12,7 @@ def read(fd): data = os.read(fd, 1024) - file.write(data) + script.write(data) return data shell = 'sh' From python-checkins at python.org Sun Oct 11 14:04:10 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 12:04:10 -0000 Subject: [Python-checkins] r75352 - in python/branches/py3k: Demo/scripts/script.py Message-ID: Author: georg.brandl Date: Sun Oct 11 14:04:10 2009 New Revision: 75352 Log: Merged revisions 75350 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75350 | georg.brandl | 2009-10-11 14:00:18 +0200 (So, 11 Okt 2009) | 1 line Use getopt in script.py demo. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/script.py Modified: python/branches/py3k/Demo/scripts/script.py ============================================================================== --- python/branches/py3k/Demo/scripts/script.py (original) +++ python/branches/py3k/Demo/scripts/script.py Sun Oct 11 14:04:10 2009 @@ -1,4 +1,5 @@ #! /usr/bin/env python + # script.py -- Make typescript of terminal session. # Usage: # -a Append to typescript. @@ -6,28 +7,36 @@ # Author: Steen Lumholt. -import os, time, sys +import os, time, sys, getopt import pty def read(fd): data = os.read(fd, 1024) - file.write(data) + script.write(data) return data shell = 'sh' filename = 'typescript' -mode = 'w' +mode = 'wb' if 'SHELL' in os.environ: shell = os.environ['SHELL'] -if '-a' in sys.argv: - mode = 'a' -if '-p' in sys.argv: - shell = 'python' -file = open(filename, mode) +try: + opts, args = getopt.getopt(sys.argv[1:], 'ap') +except getopt.error as msg: + print('%s: %s' % (sys.argv[0], msg)) + sys.exit(2) + +for o, a in opts: + if o == '-a': + mode = 'ab' + elif o == '-p': + shell = 'python' + +script = open(filename, mode) sys.stdout.write('Script started, file is %s\n' % filename) -file.write('Script started on %s\n' % time.ctime(time.time())) +script.write(('Script started on %s\n' % time.ctime(time.time())).encode()) pty.spawn(shell, read) -file.write('Script done on %s\n' % time.ctime(time.time())) +script.write(('Script done on %s\n' % time.ctime(time.time())).encode()) sys.stdout.write('Script done, file is %s\n' % filename) From python-checkins at python.org Sun Oct 11 14:04:41 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 12:04:41 -0000 Subject: [Python-checkins] r75353 - python/branches/py3k Message-ID: Author: georg.brandl Date: Sun Oct 11 14:04:40 2009 New Revision: 75353 Log: Merged revisions 75351 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75351 | georg.brandl | 2009-10-11 14:03:01 +0200 (So, 11 Okt 2009) | 1 line Fix variable. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 11 16:23:50 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 14:23:50 -0000 Subject: [Python-checkins] r75354 - in python/trunk/Demo/scripts: lpwatch.py newslist.py queens.py Message-ID: Author: georg.brandl Date: Sun Oct 11 16:23:49 2009 New Revision: 75354 Log: Update lpwatch script. Modified: python/trunk/Demo/scripts/lpwatch.py python/trunk/Demo/scripts/newslist.py python/trunk/Demo/scripts/queens.py Modified: python/trunk/Demo/scripts/lpwatch.py ============================================================================== --- python/trunk/Demo/scripts/lpwatch.py (original) +++ python/trunk/Demo/scripts/lpwatch.py Sun Oct 11 16:23:49 2009 @@ -3,10 +3,9 @@ # Watch line printer queue(s). # Intended for BSD 4.3 lpq. -import posix +import os import sys import time -import string DEF_PRINTER = 'psc' DEF_DELAY = 10 @@ -14,94 +13,87 @@ def main(): delay = DEF_DELAY # XXX Use getopt() later try: - thisuser = posix.environ['LOGNAME'] + thisuser = os.environ['LOGNAME'] except: - thisuser = posix.environ['USER'] + thisuser = os.environ['USER'] printers = sys.argv[1:] if printers: # Strip '-P' from printer names just in case # the user specified it... - for i in range(len(printers)): - if printers[i][:2] == '-P': - printers[i] = printers[i][2:] + for i, name in enumerate(printers): + if name[:2] == '-P': + printers[i] = name[2:] else: - if posix.environ.has_key('PRINTER'): - printers = [posix.environ['PRINTER']] + if os.environ.has_key('PRINTER'): + printers = [os.environ['PRINTER']] else: printers = [DEF_PRINTER] - # - clearhome = posix.popen('clear', 'r').read() - # - while 1: + + clearhome = os.popen('clear', 'r').read() + + while True: text = clearhome for name in printers: - text = text + makestatus(name, thisuser) + '\n' + text += makestatus(name, thisuser) + '\n' print text time.sleep(delay) def makestatus(name, thisuser): - pipe = posix.popen('lpq -P' + name + ' 2>&1', 'r') + pipe = os.popen('lpq -P' + name + ' 2>&1', 'r') lines = [] users = {} aheadbytes = 0 aheadjobs = 0 - userseen = 0 + userseen = False totalbytes = 0 totaljobs = 0 - while 1: - line = pipe.readline() - if not line: break - fields = string.split(line) + for line in pipe: + fields = line.split() n = len(fields) if len(fields) >= 6 and fields[n-1] == 'bytes': - rank = fields[0] - user = fields[1] - job = fields[2] + rank, user, job = fields[0:3] files = fields[3:-2] - bytes = eval(fields[n-2]) + bytes = int(fields[n-2]) if user == thisuser: - userseen = 1 + userseen = True elif not userseen: - aheadbytes = aheadbytes + bytes - aheadjobs = aheadjobs + 1 - totalbytes = totalbytes + bytes - totaljobs = totaljobs + 1 - if users.has_key(user): - ujobs, ubytes = users[user] - else: - ujobs, ubytes = 0, 0 - ujobs = ujobs + 1 - ubytes = ubytes + bytes + aheadbytes += bytes + aheadjobs += 1 + totalbytes += bytes + totaljobs += 1 + ujobs, ubytes = users.get(user, (0, 0)) + ujobs += 1 + ubytes += bytes users[user] = ujobs, ubytes else: - if fields and fields[0] <> 'Rank': - line = string.strip(line) + if fields and fields[0] != 'Rank': + line = line.strip() if line == 'no entries': line = name + ': idle' elif line[-22:] == ' is ready and printing': line = name lines.append(line) - # + if totaljobs: - line = '%d K' % ((totalbytes+1023)//1024) - if totaljobs <> len(users): - line = line + ' (%d jobs)' % totaljobs + line = '%d K' % ((totalbytes+1023) // 1024) + if totaljobs != len(users): + line += ' (%d jobs)' % totaljobs if len(users) == 1: - line = line + ' for %s' % (users.keys()[0],) + line += ' for %s' % (users.keys()[0],) else: - line = line + ' for %d users' % len(users) + line += ' for %d users' % len(users) if userseen: if aheadjobs == 0: - line = line + ' (%s first)' % thisuser + line += ' (%s first)' % thisuser else: - line = line + ' (%d K before %s)' % ( - (aheadbytes+1023)//1024, thisuser) + line += ' (%d K before %s)' % ( + (aheadbytes+1023) // 1024, thisuser) lines.append(line) - # + sts = pipe.close() if sts: lines.append('lpq exit status %r' % (sts,)) - return string.joinfields(lines, ': ') + return ': '.join(lines) if __name__ == "__main__": try: Modified: python/trunk/Demo/scripts/newslist.py ============================================================================== --- python/trunk/Demo/scripts/newslist.py (original) +++ python/trunk/Demo/scripts/newslist.py Sun Oct 11 16:23:49 2009 @@ -128,7 +128,7 @@ j = path[0] l = len(path) - if not tree.has_key(j): + if j not in tree: tree[j] = {} if l == 1: tree[j]['.'] = '.' Modified: python/trunk/Demo/scripts/queens.py ============================================================================== --- python/trunk/Demo/scripts/queens.py (original) +++ python/trunk/Demo/scripts/queens.py Sun Oct 11 16:23:49 2009 @@ -19,8 +19,8 @@ def reset(self): n = self.n - self.y = [None]*n # Where is the queen in column x - self.row = [0]*n # Is row[y] safe? + self.y = [None] * n # Where is the queen in column x + self.row = [0] * n # Is row[y] safe? self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe? self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe? self.nfound = 0 # Instrumentation @@ -50,7 +50,7 @@ self.up[x-y] = 0 self.down[x+y] = 0 - silent = 0 # If set, count solutions only + silent = 0 # If true, count solutions only def display(self): self.nfound = self.nfound + 1 From python-checkins at python.org Sun Oct 11 16:27:51 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 14:27:51 -0000 Subject: [Python-checkins] r75355 - in python/branches/py3k: Demo/scripts/lpwatch.py Demo/scripts/queens.py Message-ID: Author: georg.brandl Date: Sun Oct 11 16:27:51 2009 New Revision: 75355 Log: Merged revisions 75354 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75354 | georg.brandl | 2009-10-11 16:23:49 +0200 (So, 11 Okt 2009) | 1 line Update lpwatch script. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/lpwatch.py python/branches/py3k/Demo/scripts/queens.py Modified: python/branches/py3k/Demo/scripts/lpwatch.py ============================================================================== --- python/branches/py3k/Demo/scripts/lpwatch.py (original) +++ python/branches/py3k/Demo/scripts/lpwatch.py Sun Oct 11 16:27:51 2009 @@ -3,10 +3,9 @@ # Watch line printer queue(s). # Intended for BSD 4.3 lpq. -import posix +import os import sys import time -import string DEF_PRINTER = 'psc' DEF_DELAY = 10 @@ -14,94 +13,87 @@ def main(): delay = DEF_DELAY # XXX Use getopt() later try: - thisuser = posix.environ['LOGNAME'] + thisuser = os.environ['LOGNAME'] except: - thisuser = posix.environ['USER'] + thisuser = os.environ['USER'] printers = sys.argv[1:] if printers: # Strip '-P' from printer names just in case # the user specified it... - for i in range(len(printers)): - if printers[i][:2] == '-P': - printers[i] = printers[i][2:] + for i, name in enumerate(printers): + if name[:2] == '-P': + printers[i] = name[2:] else: - if 'PRINTER' in posix.environ: - printers = [posix.environ['PRINTER']] + if 'PRINTER' in os.environ: + printers = [os.environ['PRINTER']] else: printers = [DEF_PRINTER] - # - clearhome = posix.popen('clear', 'r').read() - # - while 1: + + clearhome = os.popen('clear', 'r').read() + + while True: text = clearhome for name in printers: - text = text + makestatus(name, thisuser) + '\n' + text += makestatus(name, thisuser) + '\n' print(text) time.sleep(delay) def makestatus(name, thisuser): - pipe = posix.popen('lpq -P' + name + ' 2>&1', 'r') + pipe = os.popen('lpq -P' + name + ' 2>&1', 'r') lines = [] users = {} aheadbytes = 0 aheadjobs = 0 - userseen = 0 + userseen = False totalbytes = 0 totaljobs = 0 - while 1: - line = pipe.readline() - if not line: break - fields = string.split(line) + for line in pipe: + fields = line.split() n = len(fields) if len(fields) >= 6 and fields[n-1] == 'bytes': - rank = fields[0] - user = fields[1] - job = fields[2] + rank, user, job = fields[0:3] files = fields[3:-2] - bytes = eval(fields[n-2]) + bytes = int(fields[n-2]) if user == thisuser: - userseen = 1 + userseen = True elif not userseen: - aheadbytes = aheadbytes + bytes - aheadjobs = aheadjobs + 1 - totalbytes = totalbytes + bytes - totaljobs = totaljobs + 1 - if user in users: - ujobs, ubytes = users[user] - else: - ujobs, ubytes = 0, 0 - ujobs = ujobs + 1 - ubytes = ubytes + bytes + aheadbytes += bytes + aheadjobs += 1 + totalbytes += bytes + totaljobs += 1 + ujobs, ubytes = users.get(user, (0, 0)) + ujobs += 1 + ubytes += bytes users[user] = ujobs, ubytes else: if fields and fields[0] != 'Rank': - line = string.strip(line) + line = line.strip() if line == 'no entries': line = name + ': idle' elif line[-22:] == ' is ready and printing': line = name lines.append(line) - # + if totaljobs: - line = '%d K' % ((totalbytes+1023)//1024) + line = '%d K' % ((totalbytes+1023) // 1024) if totaljobs != len(users): - line = line + ' (%d jobs)' % totaljobs + line += ' (%d jobs)' % totaljobs if len(users) == 1: - line = line + ' for %s' % (list(users.keys())[0],) + line += ' for %s' % next(iter(users)) else: - line = line + ' for %d users' % len(users) + line += ' for %d users' % len(users) if userseen: if aheadjobs == 0: - line = line + ' (%s first)' % thisuser + line += ' (%s first)' % thisuser else: - line = line + ' (%d K before %s)' % ( - (aheadbytes+1023)//1024, thisuser) + line += ' (%d K before %s)' % ( + (aheadbytes+1023) // 1024, thisuser) lines.append(line) - # + sts = pipe.close() if sts: lines.append('lpq exit status %r' % (sts,)) - return string.joinfields(lines, ': ') + return ': '.join(lines) if __name__ == "__main__": try: Modified: python/branches/py3k/Demo/scripts/queens.py ============================================================================== --- python/branches/py3k/Demo/scripts/queens.py (original) +++ python/branches/py3k/Demo/scripts/queens.py Sun Oct 11 16:27:51 2009 @@ -19,8 +19,8 @@ def reset(self): n = self.n - self.y = [None]*n # Where is the queen in column x - self.row = [0]*n # Is row[y] safe? + self.y = [None] * n # Where is the queen in column x + self.row = [0] * n # Is row[y] safe? self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe? self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe? self.nfound = 0 # Instrumentation @@ -50,7 +50,7 @@ self.up[x-y] = 0 self.down[x+y] = 0 - silent = 0 # If set, count solutions only + silent = 0 # If true, count solutions only def display(self): self.nfound = self.nfound + 1 From python-checkins at python.org Sun Oct 11 16:49:37 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 14:49:37 -0000 Subject: [Python-checkins] r75356 - in python/trunk/Demo/scripts: README ftpstats.py Message-ID: Author: georg.brandl Date: Sun Oct 11 16:49:37 2009 New Revision: 75356 Log: Remove ftpstats script, the daemon whose log files it reads is long gone. Removed: python/trunk/Demo/scripts/ftpstats.py Modified: python/trunk/Demo/scripts/README Modified: python/trunk/Demo/scripts/README ============================================================================== --- python/trunk/Demo/scripts/README (original) +++ python/trunk/Demo/scripts/README Sun Oct 11 16:49:37 2009 @@ -7,7 +7,6 @@ fact.py Factorize numbers find-uname.py Search for Unicode characters using regexps from.py Summarize mailbox -ftpstats.py Summarize ftp daemon log file lpwatch.py Watch BSD line printer queues makedir.py Like mkdir -p markov.py Markov chain simulation of words or characters Deleted: python/trunk/Demo/scripts/ftpstats.py ============================================================================== --- python/trunk/Demo/scripts/ftpstats.py Sun Oct 11 16:49:37 2009 +++ (empty file) @@ -1,145 +0,0 @@ -#! /usr/bin/env python - -# Extract statistics from ftp daemon log. - -# Usage: -# ftpstats [-m maxitems] [-s search] [file] -# -m maxitems: restrict number of items in "top-N" lists, default 25. -# -s string: restrict statistics to lines containing this string. -# Default file is /usr/adm/ftpd; a "-" means read standard input. - -# The script must be run on the host where the ftp daemon runs. -# (At CWI this is currently buizerd.) - -import os -import sys -import re -import string -import getopt - -pat = '^([a-zA-Z0-9 :]*)!(.*)!(.*)!([<>].*)!([0-9]+)!([0-9]+)$' -prog = re.compile(pat) - -def main(): - maxitems = 25 - search = None - try: - opts, args = getopt.getopt(sys.argv[1:], 'm:s:') - except getopt.error, msg: - print msg - print 'usage: ftpstats [-m maxitems] [file]' - sys.exit(2) - for o, a in opts: - if o == '-m': - maxitems = string.atoi(a) - if o == '-s': - search = a - file = '/usr/adm/ftpd' - if args: file = args[0] - if file == '-': - f = sys.stdin - else: - try: - f = open(file, 'r') - except IOError, msg: - print file, ':', msg - sys.exit(1) - bydate = {} - bytime = {} - byfile = {} - bydir = {} - byhost = {} - byuser = {} - bytype = {} - lineno = 0 - try: - while 1: - line = f.readline() - if not line: break - lineno = lineno + 1 - if search and string.find(line, search) < 0: - continue - if prog.match(line) < 0: - print 'Bad line', lineno, ':', repr(line) - continue - items = prog.group(1, 2, 3, 4, 5, 6) - (logtime, loguser, loghost, logfile, logbytes, - logxxx2) = items -## print logtime -## print '-->', loguser -## print '--> -->', loghost -## print '--> --> -->', logfile -## print '--> --> --> -->', logbytes -## print '--> --> --> --> -->', logxxx2 -## for i in logtime, loghost, logbytes, logxxx2: -## if '!' in i: print '???', i - add(bydate, logtime[-4:] + ' ' + logtime[:6], items) - add(bytime, logtime[7:9] + ':00-59', items) - direction, logfile = logfile[0], logfile[1:] - # The real path probably starts at the last //... - while 1: - i = string.find(logfile, '//') - if i < 0: break - logfile = logfile[i+1:] - add(byfile, logfile + ' ' + direction, items) - logdir = os.path.dirname(logfile) -## logdir = os.path.normpath(logdir) + '/.' - while 1: - add(bydir, logdir + ' ' + direction, items) - dirhead = os.path.dirname(logdir) - if dirhead == logdir: break - logdir = dirhead - add(byhost, loghost, items) - add(byuser, loguser, items) - add(bytype, direction, items) - except KeyboardInterrupt: - print 'Interrupted at line', lineno - show(bytype, 'by transfer direction', maxitems) - show(bydir, 'by directory', maxitems) - show(byfile, 'by file', maxitems) - show(byhost, 'by host', maxitems) - show(byuser, 'by user', maxitems) - showbar(bydate, 'by date') - showbar(bytime, 'by time of day') - -def showbar(dict, title): - n = len(title) - print '='*((70-n)//2), title, '='*((71-n)//2) - list = [] - keys = dict.keys() - keys.sort() - for key in keys: - n = len(str(key)) - list.append((len(dict[key]), key)) - maxkeylength = 0 - maxcount = 0 - for count, key in list: - maxkeylength = max(maxkeylength, len(key)) - maxcount = max(maxcount, count) - maxbarlength = 72 - maxkeylength - 7 - for count, key in list: - barlength = int(round(maxbarlength*float(count)/maxcount)) - bar = '*'*barlength - print '%5d %-*s %s' % (count, maxkeylength, key, bar) - -def show(dict, title, maxitems): - if len(dict) > maxitems: - title = title + ' (first %d)'%maxitems - n = len(title) - print '='*((70-n)//2), title, '='*((71-n)//2) - list = [] - keys = dict.keys() - for key in keys: - list.append((-len(dict[key]), key)) - list.sort() - for count, key in list[:maxitems]: - print '%5d %s' % (-count, key) - -def add(dict, key, item): - if dict.has_key(key): - dict[key].append(item) - else: - dict[key] = [item] - -if __name__ == "__main__": - main() From python-checkins at python.org Sun Oct 11 16:50:57 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 14:50:57 -0000 Subject: [Python-checkins] r75357 - in python/branches/py3k: Demo/scripts/README Demo/scripts/ftpstats.py Message-ID: Author: georg.brandl Date: Sun Oct 11 16:50:57 2009 New Revision: 75357 Log: Merged revisions 75356 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75356 | georg.brandl | 2009-10-11 16:49:37 +0200 (So, 11 Okt 2009) | 1 line Remove ftpstats script, the daemon whose log files it reads is long gone. ........ Removed: python/branches/py3k/Demo/scripts/ftpstats.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/scripts/README Modified: python/branches/py3k/Demo/scripts/README ============================================================================== --- python/branches/py3k/Demo/scripts/README (original) +++ python/branches/py3k/Demo/scripts/README Sun Oct 11 16:50:57 2009 @@ -7,7 +7,6 @@ fact.py Factorize numbers find-uname.py Search for Unicode characters using regexps from.py Summarize mailbox -ftpstats.py Summarize ftp daemon log file lpwatch.py Watch BSD line printer queues makedir.py Like mkdir -p markov.py Markov chain simulation of words or characters Deleted: python/branches/py3k/Demo/scripts/ftpstats.py ============================================================================== --- python/branches/py3k/Demo/scripts/ftpstats.py Sun Oct 11 16:50:57 2009 +++ (empty file) @@ -1,142 +0,0 @@ -#! /usr/bin/env python - -# Extract statistics from ftp daemon log. - -# Usage: -# ftpstats [-m maxitems] [-s search] [file] -# -m maxitems: restrict number of items in "top-N" lists, default 25. -# -s string: restrict statistics to lines containing this string. -# Default file is /usr/adm/ftpd; a "-" means read standard input. - -# The script must be run on the host where the ftp daemon runs. -# (At CWI this is currently buizerd.) - -import os -import sys -import re -import string -import getopt - -pat = '^([a-zA-Z0-9 :]*)!(.*)!(.*)!([<>].*)!([0-9]+)!([0-9]+)$' -prog = re.compile(pat) - -def main(): - maxitems = 25 - search = None - try: - opts, args = getopt.getopt(sys.argv[1:], 'm:s:') - except getopt.error as msg: - print(msg) - print('usage: ftpstats [-m maxitems] [file]') - sys.exit(2) - for o, a in opts: - if o == '-m': - maxitems = string.atoi(a) - if o == '-s': - search = a - file = '/usr/adm/ftpd' - if args: file = args[0] - if file == '-': - f = sys.stdin - else: - try: - f = open(file, 'r') - except IOError as msg: - print(file, ':', msg) - sys.exit(1) - bydate = {} - bytime = {} - byfile = {} - bydir = {} - byhost = {} - byuser = {} - bytype = {} - lineno = 0 - try: - while 1: - line = f.readline() - if not line: break - lineno = lineno + 1 - if search and string.find(line, search) < 0: - continue - if prog.match(line) < 0: - print('Bad line', lineno, ':', repr(line)) - continue - items = prog.group(1, 2, 3, 4, 5, 6) - (logtime, loguser, loghost, logfile, logbytes, - logxxx2) = items -## print logtime -## print '-->', loguser -## print '--> -->', loghost -## print '--> --> -->', logfile -## print '--> --> --> -->', logbytes -## print '--> --> --> --> -->', logxxx2 -## for i in logtime, loghost, logbytes, logxxx2: -## if '!' in i: print '???', i - add(bydate, logtime[-4:] + ' ' + logtime[:6], items) - add(bytime, logtime[7:9] + ':00-59', items) - direction, logfile = logfile[0], logfile[1:] - # The real path probably starts at the last //... - while 1: - i = string.find(logfile, '//') - if i < 0: break - logfile = logfile[i+1:] - add(byfile, logfile + ' ' + direction, items) - logdir = os.path.dirname(logfile) -## logdir = os.path.normpath(logdir) + '/.' - while 1: - add(bydir, logdir + ' ' + direction, items) - dirhead = os.path.dirname(logdir) - if dirhead == logdir: break - logdir = dirhead - add(byhost, loghost, items) - add(byuser, loguser, items) - add(bytype, direction, items) - except KeyboardInterrupt: - print('Interrupted at line', lineno) - show(bytype, 'by transfer direction', maxitems) - show(bydir, 'by directory', maxitems) - show(byfile, 'by file', maxitems) - show(byhost, 'by host', maxitems) - show(byuser, 'by user', maxitems) - showbar(bydate, 'by date') - showbar(bytime, 'by time of day') - -def showbar(dict, title): - n = len(title) - print('='*((70-n)//2), title, '='*((71-n)//2)) - list = [] - for key in sorted(dict.keys()): - n = len(str(key)) - list.append((len(dict[key]), key)) - maxkeylength = 0 - maxcount = 0 - for count, key in list: - maxkeylength = max(maxkeylength, len(key)) - maxcount = max(maxcount, count) - maxbarlength = 72 - maxkeylength - 7 - for count, key in list: - barlength = int(round(maxbarlength*float(count)/maxcount)) - bar = '*'*barlength - print('%5d %-*s %s' % (count, maxkeylength, key, bar)) - -def show(dict, title, maxitems): - if len(dict) > maxitems: - title = title + ' (first %d)'%maxitems - n = len(title) - print('='*((70-n)//2), title, '='*((71-n)//2)) - list = [] - for key in dict.keys(): - list.append((-len(dict[key]), key)) - list.sort() - for count, key in list[:maxitems]: - print('%5d %s' % (-count, key)) - -def add(dict, key, item): - if key in dict: - dict[key].append(item) - else: - dict[key] = [item] - -if __name__ == "__main__": - main() From python-checkins at python.org Sun Oct 11 17:06:45 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 15:06:45 -0000 Subject: [Python-checkins] r75358 - in python/trunk/Demo/xml: elem_count.py roundtrip.py rss2html.py Message-ID: Author: georg.brandl Date: Sun Oct 11 17:06:44 2009 New Revision: 75358 Log: Overhaul of Demo/xml. Modified: python/trunk/Demo/xml/elem_count.py python/trunk/Demo/xml/roundtrip.py python/trunk/Demo/xml/rss2html.py Modified: python/trunk/Demo/xml/elem_count.py ============================================================================== --- python/trunk/Demo/xml/elem_count.py (original) +++ python/trunk/Demo/xml/elem_count.py Sun Oct 11 17:06:44 2009 @@ -1,4 +1,10 @@ +""" +A simple demo that reads in an XML document and displays the number of +elements and attributes as well as a tally of elements and attributes by name. +""" + import sys +from collections import defaultdict from xml.sax import make_parser, handler @@ -7,16 +13,16 @@ def __init__(self): self._elems = 0 self._attrs = 0 - self._elem_types = {} - self._attr_types = {} + self._elem_types = defaultdict(int) + self._attr_types = defaultdict(int) def startElement(self, name, attrs): - self._elems = self._elems + 1 - self._attrs = self._attrs + len(attrs) - self._elem_types[name] = self._elem_types.get(name, 0) + 1 + self._elems += 1 + self._attrs += len(attrs) + self._elem_types[name] += 1 for name in attrs.keys(): - self._attr_types[name] = self._attr_types.get(name, 0) + 1 + self._attr_types[name] += 1 def endDocument(self): print "There were", self._elems, "elements." @@ -30,7 +36,7 @@ for pair in self._attr_types.items(): print "%20s %d" % pair - -parser = make_parser() -parser.setContentHandler(FancyCounter()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(FancyCounter()) + parser.parse(sys.argv[1]) Modified: python/trunk/Demo/xml/roundtrip.py ============================================================================== --- python/trunk/Demo/xml/roundtrip.py (original) +++ python/trunk/Demo/xml/roundtrip.py Sun Oct 11 17:06:44 2009 @@ -3,7 +3,7 @@ but not necessarily identical, document. """ -import sys, string +import sys from xml.sax import saxutils, handler, make_parser @@ -11,7 +11,7 @@ class ContentGenerator(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out @@ -40,6 +40,7 @@ # --- The main program -parser = make_parser() -parser.setContentHandler(ContentGenerator()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(ContentGenerator()) + parser.parse(sys.argv[1]) Modified: python/trunk/Demo/xml/rss2html.py ============================================================================== --- python/trunk/Demo/xml/rss2html.py (original) +++ python/trunk/Demo/xml/rss2html.py Sun Oct 11 17:06:44 2009 @@ -1,45 +1,50 @@ +""" +A demo that reads in an RSS XML document and emits an HTML file containing +a list of the individual items in the feed. +""" + import sys +import codecs from xml.sax import make_parser, handler # --- Templates -top = \ -""" +top = """\ - - - %s - + + + %s + + - -

            %s

            + +

            %s

            """ -bottom = \ -""" +bottom = """
          -
          -
          -Converted to HTML by sax_rss2html.py. -
          +
          +
          +Converted to HTML by rss2html.py. +
          - - + + """ # --- The ContentHandler class RSSHandler(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) - self._out = out + self._out = codecs.getwriter('utf-8')(out) self._text = "" self._parent = None - self._list_started = 0 + self._list_started = False self._title = None self._link = None self._descr = "" @@ -69,7 +74,7 @@ elif name == "item": if not self._list_started: self._out.write("
            \n") - self._list_started = 1 + self._list_started = True self._out.write('
          • %s %s\n' % (self._link, self._title, self._descr)) @@ -86,6 +91,7 @@ # --- Main program -parser = make_parser() -parser.setContentHandler(RSSHandler()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(RSSHandler()) + parser.parse(sys.argv[1]) From python-checkins at python.org Sun Oct 11 17:56:07 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 15:56:07 -0000 Subject: [Python-checkins] r75359 - in python/branches/py3k: Demo/xml/elem_count.py Demo/xml/roundtrip.py Demo/xml/rss2html.py Message-ID: Author: georg.brandl Date: Sun Oct 11 17:56:06 2009 New Revision: 75359 Log: Merged revisions 75358 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75358 | georg.brandl | 2009-10-11 17:06:44 +0200 (So, 11 Okt 2009) | 1 line Overhaul of Demo/xml. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/xml/elem_count.py python/branches/py3k/Demo/xml/roundtrip.py python/branches/py3k/Demo/xml/rss2html.py Modified: python/branches/py3k/Demo/xml/elem_count.py ============================================================================== --- python/branches/py3k/Demo/xml/elem_count.py (original) +++ python/branches/py3k/Demo/xml/elem_count.py Sun Oct 11 17:56:06 2009 @@ -1,4 +1,10 @@ +""" +A simple demo that reads in an XML document and displays the number of +elements and attributes as well as a tally of elements and attributes by name. +""" + import sys +from collections import defaultdict from xml.sax import make_parser, handler @@ -7,16 +13,16 @@ def __init__(self): self._elems = 0 self._attrs = 0 - self._elem_types = {} - self._attr_types = {} + self._elem_types = defaultdict(int) + self._attr_types = defaultdict(int) def startElement(self, name, attrs): - self._elems = self._elems + 1 - self._attrs = self._attrs + len(attrs) - self._elem_types[name] = self._elem_types.get(name, 0) + 1 + self._elems += 1 + self._attrs += len(attrs) + self._elem_types[name] += 1 for name in attrs.keys(): - self._attr_types[name] = self._attr_types.get(name, 0) + 1 + self._attr_types[name] += 1 def endDocument(self): print("There were", self._elems, "elements.") @@ -30,7 +36,7 @@ for pair in self._attr_types.items(): print("%20s %d" % pair) - -parser = make_parser() -parser.setContentHandler(FancyCounter()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(FancyCounter()) + parser.parse(sys.argv[1]) Modified: python/branches/py3k/Demo/xml/roundtrip.py ============================================================================== --- python/branches/py3k/Demo/xml/roundtrip.py (original) +++ python/branches/py3k/Demo/xml/roundtrip.py Sun Oct 11 17:56:06 2009 @@ -3,7 +3,7 @@ but not necessarily identical, document. """ -import sys, string +import sys from xml.sax import saxutils, handler, make_parser @@ -11,7 +11,7 @@ class ContentGenerator(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out @@ -40,6 +40,7 @@ # --- The main program -parser = make_parser() -parser.setContentHandler(ContentGenerator()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(ContentGenerator()) + parser.parse(sys.argv[1]) Modified: python/branches/py3k/Demo/xml/rss2html.py ============================================================================== --- python/branches/py3k/Demo/xml/rss2html.py (original) +++ python/branches/py3k/Demo/xml/rss2html.py Sun Oct 11 17:56:06 2009 @@ -1,45 +1,50 @@ +""" +A demo that reads in an RSS XML document and emits an HTML file containing +a list of the individual items in the feed. +""" + import sys +import codecs from xml.sax import make_parser, handler # --- Templates -top = \ -""" +top = """\ - - - %s - + + + %s + + - -

            %s

            + +

            %s

            """ -bottom = \ -""" +bottom = """
          -
          -
          -Converted to HTML by sax_rss2html.py. -
          +
          +
          +Converted to HTML by rss2html.py. +
          - - + + """ # --- The ContentHandler class RSSHandler(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out self._text = "" self._parent = None - self._list_started = 0 + self._list_started = False self._title = None self._link = None self._descr = "" @@ -69,7 +74,7 @@ elif name == "item": if not self._list_started: self._out.write("
            \n") - self._list_started = 1 + self._list_started = True self._out.write('
          • %s %s\n' % (self._link, self._title, self._descr)) @@ -86,6 +91,7 @@ # --- Main program -parser = make_parser() -parser.setContentHandler(RSSHandler()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(RSSHandler()) + parser.parse(sys.argv[1]) From python-checkins at python.org Sun Oct 11 20:12:16 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 18:12:16 -0000 Subject: [Python-checkins] r75360 - in sandbox/trunk/faq: design.rst extending.rst general.rst gui.rst index.rst installed.rst library.rst programming.rst windows.rst Message-ID: Author: georg.brandl Date: Sun Oct 11 20:12:15 2009 New Revision: 75360 Log: General style update for inclusion in Doc/. Also fixed some errors and updated some sections as I went along, and added some XXX comments where more work needs to be done. Modified: sandbox/trunk/faq/design.rst sandbox/trunk/faq/extending.rst sandbox/trunk/faq/general.rst sandbox/trunk/faq/gui.rst sandbox/trunk/faq/index.rst sandbox/trunk/faq/installed.rst sandbox/trunk/faq/library.rst sandbox/trunk/faq/programming.rst sandbox/trunk/faq/windows.rst Modified: sandbox/trunk/faq/design.rst ============================================================================== --- sandbox/trunk/faq/design.rst (original) +++ sandbox/trunk/faq/design.rst Sun Oct 11 20:12:15 2009 @@ -1,326 +1,320 @@ - -==================================== +====================== Design and History FAQ -==================================== - +====================== Why does Python use indentation for grouping of statements? ----------------------------------------------------------- -Guido van Rossum believes that using indentation for grouping is extremely elegant -and contributes a lot to the clarity of the average Python program. Most -people learn to love this feature after awhile. +Guido van Rossum believes that using indentation for grouping is extremely +elegant and contributes a lot to the clarity of the average Python program. +Most people learn to love this feature after awhile. Since there are no begin/end brackets there cannot be a disagreement between grouping perceived by the parser and the human reader. Occasionally C programmers will encounter a fragment of code like this:: - if (x <= y) - x++; - y--; - z++; - -Only the ``x++`` statement is executed if the condition is true, but -the indentation leads you to believe otherwise. -Even experienced C programmers will sometimes -stare at it a long time wondering why ``y`` is being decremented even for -``x > y``. + if (x <= y) + x++; + y--; + z++; + +Only the ``x++`` statement is executed if the condition is true, but the +indentation leads you to believe otherwise. Even experienced C programmers will +sometimes stare at it a long time wondering why ``y`` is being decremented even +for ``x > y``. Because there are no begin/end brackets, Python is much less prone to -coding-style conflicts. In C there are many different ways to place the -braces. If you're used to reading -and writing code that uses one style, you will feel at least slightly -uneasy when reading (or being required to write) another style. - -Many coding styles place begin/end brackets on a line by themself. This -makes programs considerably longer and wastes valuable screen space, making -it harder to get a good overview of a program. Ideally, a function should -fit on one screen (say, 20-30 lines). 20 lines of Python can do -a lot more work than 20 lines of C. This is not solely due to the lack of -begin/end brackets -- the lack of declarations and the high-level data types -are also responsible -- but the indentation-based syntax certainly helps. +coding-style conflicts. In C there are many different ways to place the braces. +If you're used to reading and writing code that uses one style, you will feel at +least slightly uneasy when reading (or being required to write) another style. + +Many coding styles place begin/end brackets on a line by themself. This makes +programs considerably longer and wastes valuable screen space, making it harder +to get a good overview of a program. Ideally, a function should fit on one +screen (say, 20-30 lines). 20 lines of Python can do a lot more work than 20 +lines of C. This is not solely due to the lack of begin/end brackets -- the +lack of declarations and the high-level data types are also responsible -- but +the indentation-based syntax certainly helps. + Why am I getting strange results with simple arithmetic operations? ------------------------------------------------------------------- See the next question. + Why are floating point calculations so inaccurate? -------------------------------------------------- People are often very surprised by results like this:: - >>> 1.2-1.0 - 0.199999999999999996 + >>> 1.2-1.0 + 0.199999999999999996 -and think it is a bug in Python. It's not. This has nothing to do -with Python, but with how the underlying C platform handles floating -point numbers, and ultimately with the inaccuracies introduced when -writing down numbers as a string of a fixed number of digits. - -The internal representation of floating point numbers uses a fixed -number of binary digits to represent a decimal number. Some decimal -numbers can't be represented exactly in binary, resulting in small -roundoff errors. - -In decimal math, there are many numbers that can't be represented with a -fixed number of decimal digits, e.g. 1/3 = 0.3333333333....... - -In base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. -.2 equals 2/10 equals 1/5, resulting in the binary fractional number -0.001100110011001... - -Floating point numbers only have 32 or 64 bits of precision, so the digits are cut off at some point, -and the resulting number is 0.199999999999999996 in decimal, not 0.2. +and think it is a bug in Python. It's not. This has nothing to do with Python, +but with how the underlying C platform handles floating point numbers, and +ultimately with the inaccuracies introduced when writing down numbers as a +string of a fixed number of digits. + +The internal representation of floating point numbers uses a fixed number of +binary digits to represent a decimal number. Some decimal numbers can't be +represented exactly in binary, resulting in small roundoff errors. + +In decimal math, there are many numbers that can't be represented with a fixed +number of decimal digits, e.g. 1/3 = 0.3333333333....... + +In base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. .2 equals 2/10 equals 1/5, +resulting in the binary fractional number 0.001100110011001... + +Floating point numbers only have 32 or 64 bits of precision, so the digits are +cut off at some point, and the resulting number is 0.199999999999999996 in +decimal, not 0.2. A floating point number's ``repr()`` function prints as many digits are -necessary to make ``eval(repr(f)) == f`` true for any float f. The -``str()`` function prints fewer digits and this often results in the -more sensible number that was probably intended:: - - >>> 0.2 - 0.20000000000000001 - >>> print 0.2 - 0.2 - -One of the consequences of this is that it is error-prone to compare -the result of some computation to a float with ``==``. Tiny -inaccuracies may mean that ``==`` fails. Instead, you have to check -that the difference between the two numbers is less than a certain -threshold:: +necessary to make ``eval(repr(f)) == f`` true for any float f. The ``str()`` +function prints fewer digits and this often results in the more sensible number +that was probably intended:: + + >>> 0.2 + 0.20000000000000001 + >>> print 0.2 + 0.2 + +One of the consequences of this is that it is error-prone to compare the result +of some computation to a float with ``==``. Tiny inaccuracies may mean that +``==`` fails. Instead, you have to check that the difference between the two +numbers is less than a certain threshold:: - epsilon = 0.0000000000001 # Tiny allowed error - expected_result = 0.4 + epsilon = 0.0000000000001 # Tiny allowed error + expected_result = 0.4 - if expected_result-epsilon <= computation() <= expected_result+epsilon: + if expected_result-epsilon <= computation() <= expected_result+epsilon: ... -Please see the chapter on -`floating point arithmetic `_ -in the Python tutorial for more information. +Please see the chapter on `floating point arithmetic +`_ in the Python tutorial for +more information. Why are Python strings immutable? --------------------------------- -There are several advantages. +There are several advantages. + +One is performance: knowing that a string is immutable means we can allocate +space for it at creation time, and the storage requirements are fixed and +unchanging. This is also one of the reasons for the distinction between tuples +and lists. + +Another advantage is that strings in Python are considered as "elemental" as +numbers. No amount of activity will change the value 8 to anything else, and in +Python, no amount of activity will change the string "eight" to anything else. -One is performance: knowing that a string is immutable means we can -allocate space for it at creation time, and the storage requirements -are fixed and unchanging. This is also one of the reasons for the -distinction between tuples and lists. - -Another advantage is that strings in Python are considered as -"elemental" as numbers. No amount of activity will change the value 8 -to anything else, and in Python, no amount of activity will change the -string "eight" to anything else. +.. _why-self: Why must 'self' be used explicitly in method definitions and calls? ------------------------------------------------------------------- -The idea was borrowed from Modula-3. It turns out to be very useful, -for a variety of reasons. - -First, it's more obvious that you are using a method or instance -attribute instead of a local variable. Reading ``self.x`` or ``self.meth()`` -makes it absolutely clear that an instance variable or method is used even -if you don't know the class definition by heart. In C++, you can sort of -tell by the lack of a local variable declaration (assuming globals are rare -or easily recognizable) -- but in Python, there are no local variable -declarations, so you'd have to look up the class definition to be sure. -Some C++ and Java coding standards call for instance attributes to have an -``m_`` prefix, so this explicitness is still useful in those languages, too. - -Second, it means that no special syntax is necessary if you want to -explicitly reference or call the method from a particular class. In C++, if -you want to use a method from a base class which is overridden in a derived -class, you have to use the :: operator -- in Python you can write -baseclass.methodname(self, ). This is particularly useful -for __init__() methods, and in general in cases where a derived class method -wants to extend the base class method of the same name and thus has to call -the base class method somehow. - -Finally, for instance variables it solves a syntactic problem with -assignment: since local variables in Python are (by definition!) those -variables to which a value assigned in a function body (and that aren't -explicitly declared global), there has to be some way to tell the -interpreter that an assignment was meant to assign to an instance variable -instead of to a local variable, and it should preferably be syntactic (for -efficiency reasons). C++ does this through declarations, but Python doesn't -have declarations and it would be a pity having to introduce them just for -this purpose. Using the explicit "self.var" solves this nicely. Similarly, -for using instance variables, having to write "self.var" means that -references to unqualified names inside a method don't have to search the -instance's directories. To put it another way, local variables and -instance variables live in two different namespaces, and you need to -tell Python which namespace to use. +The idea was borrowed from Modula-3. It turns out to be very useful, for a +variety of reasons. +First, it's more obvious that you are using a method or instance attribute +instead of a local variable. Reading ``self.x`` or ``self.meth()`` makes it +absolutely clear that an instance variable or method is used even if you don't +know the class definition by heart. In C++, you can sort of tell by the lack of +a local variable declaration (assuming globals are rare or easily recognizable) +-- but in Python, there are no local variable declarations, so you'd have to +look up the class definition to be sure. Some C++ and Java coding standards +call for instance attributes to have an ``m_`` prefix, so this explicitness is +still useful in those languages, too. + +Second, it means that no special syntax is necessary if you want to explicitly +reference or call the method from a particular class. In C++, if you want to +use a method from a base class which is overridden in a derived class, you have +to use the ``::`` operator -- in Python you can write baseclass.methodname(self, +). This is particularly useful for :meth:`__init__` methods, and +in general in cases where a derived class method wants to extend the base class +method of the same name and thus has to call the base class method somehow. + +Finally, for instance variables it solves a syntactic problem with assignment: +since local variables in Python are (by definition!) those variables to which a +value assigned in a function body (and that aren't explicitly declared global), +there has to be some way to tell the interpreter that an assignment was meant to +assign to an instance variable instead of to a local variable, and it should +preferably be syntactic (for efficiency reasons). C++ does this through +declarations, but Python doesn't have declarations and it would be a pity having +to introduce them just for this purpose. Using the explicit "self.var" solves +this nicely. Similarly, for using instance variables, having to write +"self.var" means that references to unqualified names inside a method don't have +to search the instance's directories. To put it another way, local variables +and instance variables live in two different namespaces, and you need to tell +Python which namespace to use. Why can't I use an assignment in an expression? -------------------------------------------------------- +----------------------------------------------- -Many people used to C or Perl complain that they want to -use this C idiom:: +Many people used to C or Perl complain that they want to use this C idiom: - while (line = readline(f)) { - ...do something with line... - } +.. code-block:: c + + while (line = readline(f)) { + // do something with line + } where in Python you're forced to write this:: - while True: - line = f.readline() - if not line: - break - ...do something with line... - -The reason for not allowing assignment in Python expressions -is a common, hard-to-find bug in those other languages, -caused by this construct:: + while True: + line = f.readline() + if not line: + break + ... # do something with line + +The reason for not allowing assignment in Python expressions is a common, +hard-to-find bug in those other languages, caused by this construct: + +.. code-block:: c if (x = 0) { - ...error handling... + // error handling } else { - ...code that only works for nonzero x... + // code that only works for nonzero x } -The error is a simple typo: ``x = 0``, which assigns 0 to the variable ``x``, +The error is a simple typo: ``x = 0``, which assigns 0 to the variable ``x``, was written while the comparison ``x == 0`` is certainly what was intended. -Many alternatives have been proposed. Most are hacks that save some -typing but use arbitrary or cryptic syntax or keywords, -and fail the simple criterion for language change proposals: -it should intuitively suggest the proper meaning to a human reader -who has not yet been introduced to the construct. - -An interesting phenomenon is that most experienced Python programmers -recognize the "while True" idiom and don't seem to be missing the -assignment in expression construct much; it's only newcomers -who express a strong desire to add this to the language. - -There's an alternative way of spelling this that seems -attractive but is generally less robust than the "while True" solution:: - - line = f.readline() - while line: - ...do something with line... - line = f.readline() - -The problem with this is that if you change your mind about exactly -how you get the next line (e.g. you want to change it into -``sys.stdin.readline()``) you have to remember to change two places in -your program -- the second occurrence is hidden at the bottom of the -loop. - -The best approach is to use iterators, making it possible to loop -through objects using the ``for`` statement. For example, in the -current version of Python file objects support the iterator protocol, so you -can now write simply:: +Many alternatives have been proposed. Most are hacks that save some typing but +use arbitrary or cryptic syntax or keywords, and fail the simple criterion for +language change proposals: it should intuitively suggest the proper meaning to a +human reader who has not yet been introduced to the construct. + +An interesting phenomenon is that most experienced Python programmers recognize +the ``while True`` idiom and don't seem to be missing the assignment in +expression construct much; it's only newcomers who express a strong desire to +add this to the language. + +There's an alternative way of spelling this that seems attractive but is +generally less robust than the "while True" solution:: + + line = f.readline() + while line: + ... # do something with line... + line = f.readline() + +The problem with this is that if you change your mind about exactly how you get +the next line (e.g. you want to change it into ``sys.stdin.readline()``) you +have to remember to change two places in your program -- the second occurrence +is hidden at the bottom of the loop. + +The best approach is to use iterators, making it possible to loop through +objects using the ``for`` statement. For example, in the current version of +Python file objects support the iterator protocol, so you can now write simply:: - for line in f: - ... do something with line... + for line in f: + ... # do something with line... Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))? ---------------------------------------------------------------------------------------------------------------- -The major reason is history. Functions were used for those operations -that were generic for a group of types and which were intended to work -even for objects that didn't have methods at all (e.g. tuples). It is -also convenient to have a function that can readily be applied to an -amorphous collection of objects when you use the functional features -of Python (``map()``, ``apply()`` et al). - -In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in -function is actually less code than implementing them as methods for -each type. One can quibble about individual cases but it's a part of -Python, and it's too late to make such fundamental changes now. The -functions have to remain to avoid massive code breakage. +The major reason is history. Functions were used for those operations that were +generic for a group of types and which were intended to work even for objects +that didn't have methods at all (e.g. tuples). It is also convenient to have a +function that can readily be applied to an amorphous collection of objects when +you use the functional features of Python (``map()``, ``apply()`` et al). + +In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is +actually less code than implementing them as methods for each type. One can +quibble about individual cases but it's a part of Python, and it's too late to +make such fundamental changes now. The functions have to remain to avoid massive +code breakage. + +.. XXX talk about protocols? + +Note that for string operations Python has moved from external functions (the +``string`` module) to methods. However, ``len()`` is still a function. -Note that for string operations Python has moved from external functions -(the ``string`` module) to methods. However, ``len()`` is still a function. Why is join() a string method instead of a list or tuple method? ---------------------------------------------------------------- -Strings became much more like other standard types starting in Python -1.6, when methods were added which give the same functionality that -has always been available using the functions of the string module. -Most of these new methods have been widely accepted, but the one which -appears to make some programmers feel uncomfortable is:: +Strings became much more like other standard types starting in Python 1.6, when +methods were added which give the same functionality that has always been +available using the functions of the string module. Most of these new methods +have been widely accepted, but the one which appears to make some programmers +feel uncomfortable is:: - ", ".join(['1', '2', '4', '8', '16']) + ", ".join(['1', '2', '4', '8', '16']) which gives the result:: - "1, 2, 4, 8, 16" + "1, 2, 4, 8, 16" There are two common arguments against this usage. The first runs along the lines of: "It looks really ugly using a method of a -string literal (string constant)", to which the answer is that it might, but -a string literal is just a fixed value. If the methods are to be allowed on -names bound to strings there is no logical reason to make them unavailable -on literals. - -The second objection is typically cast as: "I am really telling a sequence -to join its members together with a string constant". Sadly, you aren't. For -some reason there seems to be much less difficulty with having split() as a -string method, since in that case it is easy to see that :: - - "1, 2, 4, 8, 16".split(", ") - -is an instruction to a string literal to return the substrings delimited by -the given separator (or, by default, arbitrary runs of white space). In this -case a Unicode string returns a list of Unicode strings, an ASCII string -returns a list of ASCII strings, and everyone is happy. - -join() is a string method because in using it you are telling the -separator string to iterate over a sequence of strings and insert -itself between adjacent elements. This method can be used with any -argument which obeys the rules for sequence objects, including any new -classes you might define yourself. - -Because this is a string method it can work for Unicode strings as well as -plain ASCII strings. If join() were a method of the sequence types then the -sequence types would have to decide which type of string to return depending -on the type of the separator. - -If none of these arguments persuade you, then for the moment you can -continue to use the join() function from the string module, which allows you -to write :: +string literal (string constant)", to which the answer is that it might, but a +string literal is just a fixed value. If the methods are to be allowed on names +bound to strings there is no logical reason to make them unavailable on +literals. + +The second objection is typically cast as: "I am really telling a sequence to +join its members together with a string constant". Sadly, you aren't. For some +reason there seems to be much less difficulty with having :meth:`~str.split` as +a string method, since in that case it is easy to see that :: + + "1, 2, 4, 8, 16".split(", ") + +is an instruction to a string literal to return the substrings delimited by the +given separator (or, by default, arbitrary runs of white space). In this case a +Unicode string returns a list of Unicode strings, an ASCII string returns a list +of ASCII strings, and everyone is happy. + +:meth:`~str.join` is a string method because in using it you are telling the +separator string to iterate over a sequence of strings and insert itself between +adjacent elements. This method can be used with any argument which obeys the +rules for sequence objects, including any new classes you might define yourself. + +Because this is a string method it can work for Unicode strings as well as plain +ASCII strings. If ``join()`` were a method of the sequence types then the +sequence types would have to decide which type of string to return depending on +the type of the separator. - string.join(['1', '2', '4', '8', '16'], ", ") +.. XXX remove next paragraph eventually + +If none of these arguments persuade you, then for the moment you can continue to +use the ``join()`` function from the string module, which allows you to write :: + + string.join(['1', '2', '4', '8', '16'], ", ") How fast are exceptions? ------------------------ -A try/except block is extremely efficient. Actually executing an exception -is expensive. In versions of Python prior to 2.0 it was common to use this -idiom:: - - try: - value = dict[key] - except KeyError: - dict[key] = getvalue(key) - value = dict[key] - -This only made sense when you expected the dict to have the key almost all -the time. If that wasn't the case, you coded it like this:: - - if dict.has_key(key): - value = dict[key] - else: - dict[key] = getvalue(key) - value = dict[key] +A try/except block is extremely efficient. Actually catching an exception is +expensive. In versions of Python prior to 2.0 it was common to use this idiom:: + + try: + value = dict[key] + except KeyError: + dict[key] = getvalue(key) + value = dict[key] + +This only made sense when you expected the dict to have the key almost all the +time. If that wasn't the case, you coded it like this:: + + if dict.has_key(key): + value = dict[key] + else: + dict[key] = getvalue(key) + value = dict[key] -(In Python 2.0 and higher, you can code this as -``value = dict.setdefault(key, getvalue(key))``.) +(In Python 2.0 and higher, you can code this as ``value = dict.setdefault(key, +getvalue(key))``.) Why isn't there a switch or case statement in Python? @@ -329,55 +323,53 @@ You can do this easily enough with a sequence of ``if... elif... elif... else``. There have been some proposals for switch statement syntax, but there is no consensus (yet) on whether and how to do range tests. See `PEP 275 -`_ for complete details and -the current status. +`_ for complete details and the current +status. + +For cases where you need to choose from a very large number of possibilities, +you can create a dictionary mapping case values to functions to call. For +example:: + + def function_1(...): + ... + + functions = {'a': function_1, + 'b': function_2, + 'c': self.method_1, ...} + + func = functions[value] + func() -For cases where you need to choose from a very large number of -possibilities, you can create a dictionary mapping case values to -functions to call. For example:: - - def function_1 (...): - ... - - functions = {'a': function_1, - 'b': function_2, - 'c': self.method_1, ...} - - func = functions[value] - func() - -For calling methods on objects, you can simplify yet further by using -the ``getattr()`` built-in to retrieve methods with a particular name:: - - def visit_a (self, ...): - ... - ... - - def dispatch (self, value): - method_name = 'visit_' + str(value) - method = getattr(self, method_name) - method() - -It's suggested that you use a prefix for the method names, such as -``visit_`` in this example. Without such a prefix, if values are coming -from an untrusted source, an attacker would be able to call any method -on your object. +For calling methods on objects, you can simplify yet further by using the +:func:`getattr` built-in to retrieve methods with a particular name:: + + def visit_a(self, ...): + ... + ... + + def dispatch(self, value): + method_name = 'visit_' + str(value) + method = getattr(self, method_name) + method() + +It's suggested that you use a prefix for the method names, such as ``visit_`` in +this example. Without such a prefix, if values are coming from an untrusted +source, an attacker would be able to call any method on your object. Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation? -------------------------------------------------------------------------------------------------------- -Answer 1: Unfortunately, the interpreter pushes at least one C stack frame -for each Python stack frame. Also, extensions can call back into Python at -almost random moments. Therefore, a complete threads implementation -requires thread support for C. - -Answer 2: Fortunately, there is `Stackless Python -`_, which has a completely redesigned interpreter -loop that avoids the C stack. It's still experimental but looks very -promising. Although it is binary compatible with standard Python, it's -still unclear whether Stackless will make it into the core -- maybe it's -just too revolutionary. +Answer 1: Unfortunately, the interpreter pushes at least one C stack frame for +each Python stack frame. Also, extensions can call back into Python at almost +random moments. Therefore, a complete threads implementation requires thread +support for C. + +Answer 2: Fortunately, there is `Stackless Python `_, +which has a completely redesigned interpreter loop that avoids the C stack. +It's still experimental but looks very promising. Although it is binary +compatible with standard Python, it's still unclear whether Stackless will make +it into the core -- maybe it's just too revolutionary. Why can't lambda forms contain statements? @@ -385,63 +377,60 @@ Python lambda forms cannot contain statements because Python's syntactic framework can't handle statements nested inside expressions. However, in -Python, this is not a serious problem. Unlike lambda forms in other -languages, where they add functionality, Python lambdas are only a shorthand -notation if you're too lazy to define a function. - -Functions are already first class objects in Python, and can be declared in -a local scope. Therefore the only advantage of using a lambda form instead -of a locally-defined function is that you don't need to invent a name for -the function -- but that's just a local variable to which the function -object (which is exactly the same type of object that a lambda form yields) -is assigned! +Python, this is not a serious problem. Unlike lambda forms in other languages, +where they add functionality, Python lambdas are only a shorthand notation if +you're too lazy to define a function. + +Functions are already first class objects in Python, and can be declared in a +local scope. Therefore the only advantage of using a lambda form instead of a +locally-defined function is that you don't need to invent a name for the +function -- but that's just a local variable to which the function object (which +is exactly the same type of object that a lambda form yields) is assigned! Can Python be compiled to machine code, C or some other language? ----------------------------------------------------------------- Not easily. Python's high level data types, dynamic typing of objects and -run-time invocation of the interpreter (using ``eval()`` or ``exec``) together mean -that a "compiled" Python program would probably consist mostly of calls into -the Python run-time system, even for seemingly simple operations like +run-time invocation of the interpreter (using :func:`eval` or :keyword:`exec`) +together mean that a "compiled" Python program would probably consist mostly of +calls into the Python run-time system, even for seemingly simple operations like ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this -approach is feasible, although the speedups reached so far are only -modest (e.g. 2x). Jython uses the same strategy for compiling to Java -bytecode. (Jim Hugunin has demonstrated that in combination with -whole-program analysis, speedups of 1000x are feasible for small demo -programs. See the proceedings from the `1997 Python conference -`_ for more -information.) +conferences `_ have shown that this approach is feasible, +although the speedups reached so far are only modest (e.g. 2x). Jython uses the +same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated +that in combination with whole-program analysis, speedups of 1000x are feasible +for small demo programs. See the proceedings from the `1997 Python conference +`_ for more information.) Internally, Python source code is always translated into a bytecode -representation, and this bytecode is then executed by the Python -virtual machine. In order to avoid the overhead of repeatedly parsing -and translating modules that rarely change, this byte code is written -into a file whose name ends in ".pyc" whenever a module is parsed. -When the corresponding .py file is changed, it is parsed and -translated again and the .pyc file is rewritten. - -There is no performance difference once the .pyc file has been loaded, -as the bytecode read from the .pyc file is exactly the same as the -bytecode created by direct translation. The only difference is that -loading code from a .pyc file is faster than parsing and translating a -.py file, so the presence of precompiled .pyc files improves the -start-up time of Python scripts. If desired, the Lib/compileall.py -module can be used to create valid .pyc files for a given set of -modules. - -Note that the main script executed by Python, even if its filename -ends in .py, is not compiled to a .pyc file. It is compiled to -bytecode, but the bytecode is not saved to a file. Usually main -scripts are quite short, so this doesn't cost much speed. - -There are also several programs which make it easier to intermingle -Python and C code in various ways to increase performance. See, for -example, `Psyco `_, -`Pyrex `_, `PyInline +representation, and this bytecode is then executed by the Python virtual +machine. In order to avoid the overhead of repeatedly parsing and translating +modules that rarely change, this byte code is written into a file whose name +ends in ".pyc" whenever a module is parsed. When the corresponding .py file is +changed, it is parsed and translated again and the .pyc file is rewritten. + +There is no performance difference once the .pyc file has been loaded, as the +bytecode read from the .pyc file is exactly the same as the bytecode created by +direct translation. The only difference is that loading code from a .pyc file +is faster than parsing and translating a .py file, so the presence of +precompiled .pyc files improves the start-up time of Python scripts. If +desired, the Lib/compileall.py module can be used to create valid .pyc files for +a given set of modules. + +Note that the main script executed by Python, even if its filename ends in .py, +is not compiled to a .pyc file. It is compiled to bytecode, but the bytecode is +not saved to a file. Usually main scripts are quite short, so this doesn't cost +much speed. + +.. XXX check which of these projects are still alive + +There are also several programs which make it easier to intermingle Python and C +code in various ways to increase performance. See, for example, `Psyco +`_, `Pyrex +`_, `PyInline `_, `Py2Cmod `_, and `Weave `_. @@ -450,19 +439,17 @@ How does Python manage memory? ------------------------------ -The details of Python memory management depend on the implementation. -The standard C implementation of Python uses reference counting to -detect inaccessible objects, and another mechanism to collect -reference cycles, periodically executing a cycle detection algorithm -which looks for inaccessible cycles and deletes the objects -involved. The ``gc`` module provides functions to perform a garbage -collection, obtain debugging statistics, and tune the collector's -parameters. - -Jython relies on the Java runtime so the JVM's garbage collector is -used. This difference can cause some subtle porting problems if your -Python code depends on the behavior of the reference counting -implementation. +The details of Python memory management depend on the implementation. The +standard C implementation of Python uses reference counting to detect +inaccessible objects, and another mechanism to collect reference cycles, +periodically executing a cycle detection algorithm which looks for inaccessible +cycles and deletes the objects involved. The :mod:`gc` module provides functions +to perform a garbage collection, obtain debugging statistics, and tune the +collector's parameters. + +Jython relies on the Java runtime so the JVM's garbage collector is used. This +difference can cause some subtle porting problems if your Python code depends on +the behavior of the reference counting implementation. Sometimes objects get stuck in tracebacks temporarily and hence are not deallocated when you might expect. Clear the tracebacks with:: @@ -475,339 +462,314 @@ things. They contain a portion of the program state extracted during the handling of an exception (usually the most recent exception). -In the absence of circularities and tracebacks, Python programs need -not explicitly manage memory. +In the absence of circularities and tracebacks, Python programs need not +explicitly manage memory. -Why doesn't Python use a more traditional garbage collection scheme? -For one thing, this is not a C standard feature and hence it's not -portable. (Yes, we know about the Boehm GC library. It has bits of -assembler code for *most* common platforms, not for all of them, and -although it is mostly transparent, it isn't completely transparent; -patches are required to get Python to work with it.) +Why doesn't Python use a more traditional garbage collection scheme? For one +thing, this is not a C standard feature and hence it's not portable. (Yes, we +know about the Boehm GC library. It has bits of assembler code for *most* +common platforms, not for all of them, and although it is mostly transparent, it +isn't completely transparent; patches are required to get Python to work with +it.) Traditional GC also becomes a problem when Python is embedded into other -applications. While in a standalone Python it's fine to replace the -standard malloc() and free() with versions provided by the GC library, an -application embedding Python may want to have its *own* substitute for -malloc() and free(), and may not want Python's. Right now, Python works -with anything that implements malloc() and free() properly. - -In Jython, the following code (which is fine in CPython) will probably run -out of file descriptors long before it runs out of memory:: - - for file in : - f = open(file) - c = f.read(1) - -Using the current reference counting and destructor scheme, each new -assignment to f closes the previous file. Using GC, this is not -guaranteed. If you want to write code that will work with any Python -implementation, you should explicitly close the file; this will work -regardless of GC:: - - for file in : - f = open(file) - c = f.read(1) - f.close() +applications. While in a standalone Python it's fine to replace the standard +malloc() and free() with versions provided by the GC library, an application +embedding Python may want to have its *own* substitute for malloc() and free(), +and may not want Python's. Right now, Python works with anything that +implements malloc() and free() properly. + +In Jython, the following code (which is fine in CPython) will probably run out +of file descriptors long before it runs out of memory:: + + for file in : + f = open(file) + c = f.read(1) + +Using the current reference counting and destructor scheme, each new assignment +to f closes the previous file. Using GC, this is not guaranteed. If you want +to write code that will work with any Python implementation, you should +explicitly close the file; this will work regardless of GC:: + + for file in : + f = open(file) + c = f.read(1) + f.close() Why isn't all memory freed when Python exits? ------------------------------------------------------ +--------------------------------------------- + +Objects referenced from the global namespaces of Python modules are not always +deallocated when Python exits. This may happen if there are circular +references. There are also certain bits of memory that are allocated by the C +library that are impossible to free (e.g. a tool like Purify will complain about +these). Python is, however, aggressive about cleaning up memory on exit and +does try to destroy every single object. -Objects referenced from the global namespaces of -Python modules are not always deallocated when Python exits. -This may happen if there are circular references. There are also -certain bits of memory that are allocated by the C library that are -impossible to free (e.g. a tool like Purify will complain about -these). Python is, however, aggressive about cleaning up memory on -exit and does try to destroy every single object. - -If you want to force Python to delete certain things on deallocation -use the ``sys.exitfunc()`` hook to run a function that will force -those deletions. +If you want to force Python to delete certain things on deallocation use the +:mod:`atexit` module to run a function that will force those deletions. Why are there separate tuple and list data types? ------------------------------------------------- -Lists and tuples, while similar in many respects, are generally used -in fundamentally different ways. Tuples can be thought of as being -similar to Pascal records or C structs; they're small collections of -related data which may be of different types which are operated on as -a group. For example, a Cartesian coordinate is appropriately -represented as a tuple of two or three numbers. - -Lists, on the other hand, are more like arrays in other languages. They -tend to hold a varying number of objects all of which have the same type and -which are operated on one-by-one. For example, ``os.listdir('.')`` returns -a list of strings representing the files in the current directory. -Functions which operate on this output would generally not break if you -added another file or two to the directory. - -Tuples are immutable, meaning that once a tuple has been created, you -can't replace any of its elements with a new value. Lists are -mutable, meaning that you can always change a list's elements. Only -immutable elements can be used as dictionary keys, and hence only -tuples and not lists can be used as keys. +Lists and tuples, while similar in many respects, are generally used in +fundamentally different ways. Tuples can be thought of as being similar to +Pascal records or C structs; they're small collections of related data which may +be of different types which are operated on as a group. For example, a +Cartesian coordinate is appropriately represented as a tuple of two or three +numbers. + +Lists, on the other hand, are more like arrays in other languages. They tend to +hold a varying number of objects all of which have the same type and which are +operated on one-by-one. For example, ``os.listdir('.')`` returns a list of +strings representing the files in the current directory. Functions which +operate on this output would generally not break if you added another file or +two to the directory. + +Tuples are immutable, meaning that once a tuple has been created, you can't +replace any of its elements with a new value. Lists are mutable, meaning that +you can always change a list's elements. Only immutable elements can be used as +dictionary keys, and hence only tuples and not lists can be used as keys. How are lists implemented? -------------------------- -Python's lists are really variable-length arrays, not Lisp-style -linked lists. The implementation uses a contiguous array of -references to other objects, and keeps a pointer to this array and the -array's length in a list head structure. +Python's lists are really variable-length arrays, not Lisp-style linked lists. +The implementation uses a contiguous array of references to other objects, and +keeps a pointer to this array and the array's length in a list head structure. This makes indexing a list ``a[i]`` an operation whose cost is independent of the size of the list or the value of the index. -When items are appended or inserted, the array of references is resized. -Some cleverness is applied to improve the performance of appending items -repeatedly; when the array must be grown, some extra space is allocated so -the next few times don't require an actual resize. +When items are appended or inserted, the array of references is resized. Some +cleverness is applied to improve the performance of appending items repeatedly; +when the array must be grown, some extra space is allocated so the next few +times don't require an actual resize. How are dictionaries implemented? ------------------------------------------ -Python's dictionaries are implemented as resizable hash tables. -Compared to B-trees, this gives better performance for lookup -(the most common operation by far) under most circumstances, -and the implementation is simpler. - -Dictionaries work by computing a hash code for each key stored in the -dictionary using the ``hash()`` built-in function. The hash code -varies widely depending on the key; for example, "Python" hashes to --539294296 while "python", a string that differs by a single bit, -hashes to 1142331976. The hash code is then used to calculate a -location in an internal array where the value will be stored. -Assuming that you're storing keys that all have different hash values, -this means that dictionaries take constant time -- O(1), in computer -science notation -- to retrieve a key. It also means that no sorted -order of the keys is maintained, and traversing the array as the -``.keys()`` and ``.items()`` do will output the dictionary's content -in some arbitrary jumbled order. +--------------------------------- + +Python's dictionaries are implemented as resizable hash tables. Compared to +B-trees, this gives better performance for lookup (the most common operation by +far) under most circumstances, and the implementation is simpler. + +Dictionaries work by computing a hash code for each key stored in the dictionary +using the :func:`hash` built-in function. The hash code varies widely depending +on the key; for example, "Python" hashes to -539294296 while "python", a string +that differs by a single bit, hashes to 1142331976. The hash code is then used +to calculate a location in an internal array where the value will be stored. +Assuming that you're storing keys that all have different hash values, this +means that dictionaries take constant time -- O(1), in computer science notation +-- to retrieve a key. It also means that no sorted order of the keys is +maintained, and traversing the array as the ``.keys()`` and ``.items()`` do will +output the dictionary's content in some arbitrary jumbled order. Why must dictionary keys be immutable? ----------------------------------------------- +-------------------------------------- -The hash table implementation of dictionaries uses a hash value -calculated from the key value to find the key. If the key were a -mutable object, its value could change, and thus its hash could also -change. But since whoever changes the key object can't tell that it -was being used as a dictionary key, it can't move the entry around in the -dictionary. Then, when you try to look up the same object in the -dictionary it won't be found because its hash value is different. -If you tried to look up the old value it wouldn't be found either, because -the value of the object found in that hash bin would be different. - -If you want a dictionary indexed with a list, simply convert the list -to a tuple first; the function ``tuple(L)`` creates a tuple with the -same entries as the list ``L``. Tuples are immutable and can -therefore be used as dictionary keys. +The hash table implementation of dictionaries uses a hash value calculated from +the key value to find the key. If the key were a mutable object, its value +could change, and thus its hash could also change. But since whoever changes +the key object can't tell that it was being used as a dictionary key, it can't +move the entry around in the dictionary. Then, when you try to look up the same +object in the dictionary it won't be found because its hash value is different. +If you tried to look up the old value it wouldn't be found either, because the +value of the object found in that hash bin would be different. + +If you want a dictionary indexed with a list, simply convert the list to a tuple +first; the function ``tuple(L)`` creates a tuple with the same entries as the +list ``L``. Tuples are immutable and can therefore be used as dictionary keys. Some unacceptable solutions that have been proposed: -- Hash lists by their address (object ID). This doesn't work because - if you construct a new list with the same value it won't be found; - e.g.:: - - d = {[1,2]: '12'} - print d[[1,2]] - - would raise a KeyError exception because the id of the ``[1,2]`` used in - the second line differs from that in the first line. In other - words, dictionary keys should be compared using ``==``, not using - 'is'. - -- Make a copy when using a list as a key. This doesn't work because - the list, being a mutable object, could contain a reference to - itself, and then the copying code would run into an infinite loop. - -- Allow lists as keys but tell the user not to modify them. This - would allow a class of hard-to-track bugs in programs when you forgot - or modified a list by accident. It also - invalidates an important invariant of - dictionaries: every value in ``d.keys()`` is usable as a key of the - dictionary. - -- Mark lists as read-only once they are used as a dictionary key. The - problem is that it's not just the top-level object that could change - its value; you could use a tuple containing a list as a key. - Entering anything as a key into a dictionary would require marking - all objects reachable from there as read-only -- and again, - self-referential objects could cause an infinite loop. - -There is a trick to get around this if you need to, but -use it at your own risk: You -can wrap a mutable structure inside a class instance which -has both a __cmp__ and a __hash__ method. -You must then make sure that the hash value for all such wrapper objects -that reside in a dictionary (or other hash based structure), remain -fixed while the object is in the dictionary (or other structure).:: +- Hash lists by their address (object ID). This doesn't work because if you + construct a new list with the same value it won't be found; e.g.:: + + d = {[1,2]: '12'} + print d[[1,2]] + + would raise a KeyError exception because the id of the ``[1,2]`` used in the + second line differs from that in the first line. In other words, dictionary + keys should be compared using ``==``, not using :keyword:`is`. + +- Make a copy when using a list as a key. This doesn't work because the list, + being a mutable object, could contain a reference to itself, and then the + copying code would run into an infinite loop. + +- Allow lists as keys but tell the user not to modify them. This would allow a + class of hard-to-track bugs in programs when you forgot or modified a list by + accident. It also invalidates an important invariant of dictionaries: every + value in ``d.keys()`` is usable as a key of the dictionary. + +- Mark lists as read-only once they are used as a dictionary key. The problem + is that it's not just the top-level object that could change its value; you + could use a tuple containing a list as a key. Entering anything as a key into + a dictionary would require marking all objects reachable from there as + read-only -- and again, self-referential objects could cause an infinite loop. + +There is a trick to get around this if you need to, but use it at your own risk: +You can wrap a mutable structure inside a class instance which has both a +:meth:`__cmp_` and a :meth:`__hash__` method. You must then make sure that the +hash value for all such wrapper objects that reside in a dictionary (or other +hash based structure), remain fixed while the object is in the dictionary (or +other structure). :: class ListWrapper: - def __init__(self, the_list): - self.the_list = the_list - def __cmp__(self, other): - return self.the_list == other.the_list - def __hash__(self): - l = self.the_list - result = 98767 - len(l)*555 - for i in range(len(l)): - try: - result = result + (hash(l[i]) % 9999999) * 1001 + i - except: - result = (result % 7777777) + i * 333 - return result - -Note that the hash computation is complicated by the -possibility that some members of the list may be unhashable -and also by the possibility of arithmetic overflow. - -Furthermore it must always be the case that if -``o1 == o2`` (ie ``o1.__cmp__(o2)==0``) then ``hash(o1)==hash(o2)`` -(ie, ``o1.__hash__() == o2.__hash__()``), regardless of whether -the object is in a dictionary or not. -If you fail to meet these restrictions dictionaries and other -hash based structures will misbehave. - -In the case of ListWrapper, whenever the wrapper -object is in a dictionary the wrapped list must not change -to avoid anomalies. Don't do this unless you are prepared -to think hard about the requirements and the consequences -of not meeting them correctly. Consider yourself warned. + def __init__(self, the_list): + self.the_list = the_list + def __cmp__(self, other): + return self.the_list == other.the_list + def __hash__(self): + l = self.the_list + result = 98767 - len(l)*555 + for i in range(len(l)): + try: + result = result + (hash(l[i]) % 9999999) * 1001 + i + except: + result = (result % 7777777) + i * 333 + return result + +Note that the hash computation is complicated by the possibility that some +members of the list may be unhashable and also by the possibility of arithmetic +overflow. + +Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1.__cmp__(o2) +== 0``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == o2.__hash__()``), +regardless of whether the object is in a dictionary or not. If you fail to meet +these restrictions dictionaries and other hash based structures will misbehave. + +In the case of ListWrapper, whenever the wrapper object is in a dictionary the +wrapped list must not change to avoid anomalies. Don't do this unless you are +prepared to think hard about the requirements and the consequences of not +meeting them correctly. Consider yourself warned. Why doesn't list.sort() return the sorted list? -------------------------------------------------------- +----------------------------------------------- + +In situations where performance matters, making a copy of the list just to sort +it would be wasteful. Therefore, :meth:`list.sort` sorts the list in place. In +order to remind you of that fact, it does not return the sorted list. This way, +you won't be fooled into accidentally overwriting a list when you need a sorted +copy but also need to keep the unsorted version around. + +In Python 2.4 a new builtin -- :func:`sorted` -- has been added. This function +creates a new list from a provided iterable, sorts it and returns it. For +example, here's how to iterate over the keys of a dictionary in sorted order:: + + for key in sorted(dict.iterkeys()): + ... # do whatever with dict[key]... -In situations where performance matters, making a copy -of the list just to sort it would be wasteful. Therefore, -list.sort() sorts the list in place. In order to remind you -of that fact, it does not return the sorted list. This way, -you won't be fooled into accidentally overwriting a list -when you need a sorted copy but also need to keep the -unsorted version around. - -In Python 2.4 a new builtin - sorted() - has been added. -This function creates a new list from a provided -iterable, sorts it and returns it. -For example, here's how to iterate over the keys of a -dictionary in sorted order:: - - for key in sorted(dict.iterkeys()): - ...do whatever with dict[key]... How do you specify and enforce an interface spec in Python? -------------------------------------------------------------------- +----------------------------------------------------------- -An interface specification for a module as provided by languages such -as C++ and Java describes the prototypes for the methods and functions -of the module. Many feel that compile-time enforcement of interface -specifications helps in the construction of large programs. - -Python 2.6 adds an ``abc`` module that lets you define Abstract Base -Classes (ABCs). You can then use ``isinstance()`` -and ``issubclass`` to check whether an instance or a class -implements a particular ABC. The ``collections`` modules defines a set -of useful ABCs such as ``Iterable``, ``Container``, -and ``MutableMapping``. - -For Python, many of the advantages of interface specifications can be -obtained by an appropriate test discipline for components. There is -also a tool, PyChecker, which can be used to find problems due to -subclassing. - -A good test suite for a module can both provide a regression test -and serve as a module interface specification and a set of -examples. Many Python modules can be run as a script to provide a -simple "self test." Even modules which use complex external -interfaces can often be tested in isolation using trivial "stub" -emulations of the external interface. The ``doctest`` and -``unittest`` modules or third-party test frameworks can be used to construct +An interface specification for a module as provided by languages such as C++ and +Java describes the prototypes for the methods and functions of the module. Many +feel that compile-time enforcement of interface specifications helps in the +construction of large programs. + +Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base Classes +(ABCs). You can then use :func:`isinstance` and :func:`issubclass` to check +whether an instance or a class implements a particular ABC. The +:mod:`collections` modules defines a set of useful ABCs such as +:class:`Iterable`, :class:`Container`, and :class:`MutableMapping`. + +For Python, many of the advantages of interface specifications can be obtained +by an appropriate test discipline for components. There is also a tool, +PyChecker, which can be used to find problems due to subclassing. + +A good test suite for a module can both provide a regression test and serve as a +module interface specification and a set of examples. Many Python modules can +be run as a script to provide a simple "self test." Even modules which use +complex external interfaces can often be tested in isolation using trivial +"stub" emulations of the external interface. The :mod:`doctest` and +:mod:`unittest` modules or third-party test frameworks can be used to construct exhaustive test suites that exercise every line of code in a module. -An appropriate testing discipline can help build large complex -applications in Python as well as having interface specifications -would. In fact, it can be better because an interface specification -cannot test certain properties of a program. For example, the -``append()`` method is expected to add new elements to the end of some -internal list; an interface specification cannot test that your -``append()`` implementation will actually do this correctly, but it's +An appropriate testing discipline can help build large complex applications in +Python as well as having interface specifications would. In fact, it can be +better because an interface specification cannot test certain properties of a +program. For example, the :meth:`append` method is expected to add new elements +to the end of some internal list; an interface specification cannot test that +your :meth:`append` implementation will actually do this correctly, but it's trivial to check this property in a test suite. -Writing test suites is very helpful, and you might want to design your -code with an eye to making it easily tested. One increasingly popular -technique, test-directed development, calls for writing parts of the -test suite first, before you write any of the actual code. Of course -Python allows you to be sloppy and not write test cases at all. +Writing test suites is very helpful, and you might want to design your code with +an eye to making it easily tested. One increasingly popular technique, +test-directed development, calls for writing parts of the test suite first, +before you write any of the actual code. Of course Python allows you to be +sloppy and not write test cases at all. Why are default values shared between objects? ----------------------------------------------------------------- +---------------------------------------------- This type of bug commonly bites neophyte programmers. Consider this function:: - def foo(D={}): # Danger: shared reference to one dict for all calls - ... compute something ... - D[key] = value - return D - -The first time you call this function, ``D`` contains a single item. -The second time, ``D`` contains two items because when ``foo()`` begins executing, -``D`` starts out with an item already in it. - -It is often expected that a function call creates new objects for -default values. This is not what happens. Default values are created -exactly once, when the function is defined. If that object is -changed, like the dictionary in this example, subsequent calls to the -function will refer to this changed object. - -By definition, immutable objects such as numbers, strings, tuples, and -``None``, are safe from change. Changes to mutable objects such as -dictionaries, lists, and class instances can lead to confusion. + def foo(D={}): # Danger: shared reference to one dict for all calls + ... compute something ... + D[key] = value + return D + +The first time you call this function, ``D`` contains a single item. The second +time, ``D`` contains two items because when ``foo()`` begins executing, ``D`` +starts out with an item already in it. + +It is often expected that a function call creates new objects for default +values. This is not what happens. Default values are created exactly once, when +the function is defined. If that object is changed, like the dictionary in this +example, subsequent calls to the function will refer to this changed object. + +By definition, immutable objects such as numbers, strings, tuples, and ``None``, +are safe from change. Changes to mutable objects such as dictionaries, lists, +and class instances can lead to confusion. Because of this feature, it is good programming practice to not use mutable -objects as default values. Instead, use ``None`` as the default value -and inside the function, check if the parameter is ``None`` and create a new list/dictionary/whatever -if it is. For example, don't write:: +objects as default values. Instead, use ``None`` as the default value and +inside the function, check if the parameter is ``None`` and create a new +list/dictionary/whatever if it is. For example, don't write:: - def foo(dict={}): - ... + def foo(dict={}): + ... but:: - def foo(dict=None): - if dict is None: - dict = {} # create a new dict for local namespace - -This feature can be useful. When you have a function that's time-consuming to compute, -a common technique is to cache the parameters and the resulting value of each -call to the function, and return the cached value if the same value is requested again. -This is called "memoizing", and can be implemented like this:: - - # Callers will never provide a third parameter for this function. - def expensive (arg1, arg2, _cache={}): - if _cache.has_key((arg1, arg2)): - return _cache[(arg1, arg2)] - - # Calculate the value - result = ... expensive computation ... - _cache[(arg1, arg2)] = result # Store result in the cache - return result - -You could use a global variable containing a dictionary instead of -the default value; it's a matter of taste. + def foo(dict=None): + if dict is None: + dict = {} # create a new dict for local namespace + +This feature can be useful. When you have a function that's time-consuming to +compute, a common technique is to cache the parameters and the resulting value +of each call to the function, and return the cached value if the same value is +requested again. This is called "memoizing", and can be implemented like this:: + + # Callers will never provide a third parameter for this function. + def expensive (arg1, arg2, _cache={}): + if _cache.has_key((arg1, arg2)): + return _cache[(arg1, arg2)] + + # Calculate the value + result = ... expensive computation ... + _cache[(arg1, arg2)] = result # Store result in the cache + return result + +You could use a global variable containing a dictionary instead of the default +value; it's a matter of taste. + Why is there no goto? ------------------------- +--------------------- -You can use exceptions to provide a "structured goto" -that even works across function calls. Many feel that exceptions -can conveniently emulate all reasonable uses of the "go" or "goto" -constructs of C, Fortran, and other languages. For example:: +You can use exceptions to provide a "structured goto" that even works across +function calls. Many feel that exceptions can conveniently emulate all +reasonable uses of the "go" or "goto" constructs of C, Fortran, and other +languages. For example:: class label: pass # declare a label @@ -819,128 +781,123 @@ pass ... -This doesn't allow you to jump into the middle of a loop, but -that's usually considered an abuse of goto anyway. Use sparingly. +This doesn't allow you to jump into the middle of a loop, but that's usually +considered an abuse of goto anyway. Use sparingly. Why can't raw strings (r-strings) end with a backslash? ---------------------------------------------------------------- -More precisely, they can't end with an odd number of backslashes: -the unpaired backslash at the end escapes the closing quote character, -leaving an unterminated string. - -Raw strings were designed to ease creating input for processors -(chiefly regular expression engines) that want to do their own -backslash escape processing. Such processors consider an unmatched -trailing backslash to be an error anyway, so raw strings disallow -that. In return, they allow you to pass on the string quote character -by escaping it with a backslash. These rules work well when r-strings -are used for their intended purpose. +------------------------------------------------------- + +More precisely, they can't end with an odd number of backslashes: the unpaired +backslash at the end escapes the closing quote character, leaving an +unterminated string. + +Raw strings were designed to ease creating input for processors (chiefly regular +expression engines) that want to do their own backslash escape processing. Such +processors consider an unmatched trailing backslash to be an error anyway, so +raw strings disallow that. In return, they allow you to pass on the string +quote character by escaping it with a backslash. These rules work well when +r-strings are used for their intended purpose. -If you're trying to build Windows pathnames, note that all Windows -system calls accept forward slashes too:: +If you're trying to build Windows pathnames, note that all Windows system calls +accept forward slashes too:: - f = open("/mydir/file.txt") # works fine! + f = open("/mydir/file.txt") # works fine! If you're trying to build a pathname for a DOS command, try e.g. one of :: - dir = r"\this\is\my\dos\dir" "\\" - dir = r"\this\is\my\dos\dir\ "[:-1] - dir = "\\this\\is\\my\\dos\\dir\\" + dir = r"\this\is\my\dos\dir" "\\" + dir = r"\this\is\my\dos\dir\ "[:-1] + dir = "\\this\\is\\my\\dos\\dir\\" Why doesn't Python have a "with" statement for attribute assignments? ---------------------------------------------------------------------------------------- +--------------------------------------------------------------------- -Python has a 'with' statement that wraps the execution of a block, -calling code on the entrance and exit from the block. -Some language have a construct that looks like this:: - - with obj: - a = 1 # equivalent to obj.a = 1 - total = total + 1 # obj.total = obj.total + 1 +Python has a 'with' statement that wraps the execution of a block, calling code +on the entrance and exit from the block. Some language have a construct that +looks like this:: + + with obj: + a = 1 # equivalent to obj.a = 1 + total = total + 1 # obj.total = obj.total + 1 In Python, such a construct would be ambiguous. -Other languages, such as Object Pascal, Delphi, and C++, use static -types, so it's possible to know, in an unambiguous way, what member is -being assigned to. This is the main point of static typing -- the -compiler *always* knows the scope of every variable at compile time. - -Python uses dynamic types. It is impossible to know in advance which -attribute will be referenced at runtime. Member attributes may be -added or removed from objects on the fly. This makes it -impossible to know, from a simple reading, what attribute is being -referenced: a local one, a global one, or a member attribute? +Other languages, such as Object Pascal, Delphi, and C++, use static types, so +it's possible to know, in an unambiguous way, what member is being assigned +to. This is the main point of static typing -- the compiler *always* knows the +scope of every variable at compile time. + +Python uses dynamic types. It is impossible to know in advance which attribute +will be referenced at runtime. Member attributes may be added or removed from +objects on the fly. This makes it impossible to know, from a simple reading, +what attribute is being referenced: a local one, a global one, or a member +attribute? For instance, take the following incomplete snippet:: def foo(a): - with a: - print x + with a: + print x -The snippet assumes that "a" must have a member attribute called "x". -However, there is nothing in Python that tells the interpreter -this. What should happen if "a" is, let us say, an integer? If there is -a global variable named "x", will it be used inside the -with block? As you see, the dynamic nature of Python makes such -choices much harder. - -The primary benefit of "with" and similar language features (reduction -of code volume) can, however, easily be achieved in Python by -assignment. Instead of:: - - function(args).dict[index][index].a = 21 - function(args).dict[index][index].b = 42 - function(args).dict[index][index].c = 63 +The snippet assumes that "a" must have a member attribute called "x". However, +there is nothing in Python that tells the interpreter this. What should happen +if "a" is, let us say, an integer? If there is a global variable named "x", +will it be used inside the with block? As you see, the dynamic nature of Python +makes such choices much harder. + +The primary benefit of "with" and similar language features (reduction of code +volume) can, however, easily be achieved in Python by assignment. Instead of:: + + function(args).dict[index][index].a = 21 + function(args).dict[index][index].b = 42 + function(args).dict[index][index].c = 63 write this:: - ref = function(args).dict[index][index] - ref.a = 21 - ref.b = 42 - ref.c = 63 - -This also has the side-effect of increasing execution speed because -name bindings are resolved at run-time in Python, and the second -version only needs to perform the resolution once. If the referenced -object does not have a, b and c attributes, of course, the end result -is still a run-time exception. + ref = function(args).dict[index][index] + ref.a = 21 + ref.b = 42 + ref.c = 63 + +This also has the side-effect of increasing execution speed because name +bindings are resolved at run-time in Python, and the second version only needs +to perform the resolution once. If the referenced object does not have a, b and +c attributes, of course, the end result is still a run-time exception. Why are colons required for the if/while/def/class statements? --------------------------------------------------------------------- +-------------------------------------------------------------- -The colon is required primarily to enhance readability (one of the -results of the experimental ABC language). Consider this:: +The colon is required primarily to enhance readability (one of the results of +the experimental ABC language). Consider this:: - if a==b - print a + if a == b + print a versus :: - if a==b: - print a + if a == b: + print a + +Notice how the second one is slightly easier to read. Notice further how a +colon sets off the example in this FAQ answer; it's a standard usage in English. -Notice how the second one is slightly easier to read. Notice further how -a colon sets off the example in the second line of this FAQ answer; it's -a standard usage in English. - -Another minor reason is that the colon makes it easier for editors -with syntax highlighting; they can look for colons to decide when -indentation needs to be increased instead of having to do a more -elaborate parsing of the program text. +Another minor reason is that the colon makes it easier for editors with syntax +highlighting; they can look for colons to decide when indentation needs to be +increased instead of having to do a more elaborate parsing of the program text. Why does Python allow commas at the end of lists and tuples? ------------------------------------------------------------------------------- +------------------------------------------------------------ -Python lets you add a trailing comma at the end of lists, tuples, and +Python lets you add a trailing comma at the end of lists, tuples, and dictionaries:: [1, 2, 3,] ('a', 'b', 'c',) - d = { + d = { "A": [1, 5], "B": [6, 7], # last trailing comma is optional but good style } @@ -948,13 +905,13 @@ There are several reasons to allow this. -When you have a literal value for a list, tuple, or dictionary spread -across multiple lines, it's easier to add more elements because you -don't have to remember to add a comma to the previous line. The lines -can also be sorted in your editor without creating a syntax error. +When you have a literal value for a list, tuple, or dictionary spread across +multiple lines, it's easier to add more elements because you don't have to +remember to add a comma to the previous line. The lines can also be sorted in +your editor without creating a syntax error. -Accidentally omitting the comma can lead to errors that are hard to -diagnose. For example:: +Accidentally omitting the comma can lead to errors that are hard to diagnose. +For example:: x = [ "fee", @@ -963,9 +920,7 @@ "fum" ] -This list looks like it has four elements, but it actually contains -three: "fee", "fiefoo" and "fum". Always adding the comma avoids this -source of error. +This list looks like it has four elements, but it actually contains three: +"fee", "fiefoo" and "fum". Always adding the comma avoids this source of error. -Allowing the trailing comma may also make programmatic code generation -easier. +Allowing the trailing comma may also make programmatic code generation easier. Modified: sandbox/trunk/faq/extending.rst ============================================================================== --- sandbox/trunk/faq/extending.rst (original) +++ sandbox/trunk/faq/extending.rst Sun Oct 11 20:12:15 2009 @@ -1,225 +1,242 @@ -==================================== +======================= Extending/Embedding FAQ -==================================== +======================= .. contents:: +.. highlight:: c + Can I create my own functions in C? ------------------------------------------- -Yes, you can create built-in modules containing functions, -variables, exceptions and even new types in C. This is explained in -the document "Extending and Embedding the Python Interpreter" (http://docs.python.org/ext/ext.html). +----------------------------------- + +Yes, you can create built-in modules containing functions, variables, exceptions +and even new types in C. This is explained in the document "Extending and +Embedding the Python Interpreter" (http://docs.python.org/ext/ext.html). + +Most intermediate or advanced Python books will also cover this topic. -Most intermediate or advanced Python books will also -cover this topic. Can I create my own functions in C++? --------------------------------------------- -Yes, using the C compatibility features found in C++. -Place ``extern "C" { ... }`` around the Python include files and put -``extern "C"`` before each function that is going to be called by the -Python interpreter. Global or static C++ objects with constructors -are probably not a good idea. +------------------------------------- + +Yes, using the C compatibility features found in C++. Place ``extern "C" { +... }`` around the Python include files and put ``extern "C"`` before each +function that is going to be called by the Python interpreter. Global or static +C++ objects with constructors are probably not a good idea. + Writing C is hard; are there any alternatives? ---------------------------------------------------- +---------------------------------------------- + +There are a number of alternatives to writing your own C extensions, depending +on what you're trying to do. -There are a number of alternatives to writing your own C extensions, -depending on what you're trying to do. +.. XXX make sure these all work; mention Cython -If you need more speed, `Psyco `_ generates x86 assembly code -from Python bytecode. You can use Psyco to compile the most -time-critical functions in your code, and gain a significant -improvement with very little effort, as long as you're running on a -machine with an x86-compatible processor. - -`Pyrex `_ is a compiler that accepts a slightly modified form of Python -and generates the corresponding C code. Pyrex makes it possible to write -an extension without having to learn Python's C API. - -If you need to interface to some C or C++ library for which no Python -extension currently exists, you can try wrapping the library's data types -and functions with a tool such as `SWIG `_. `SIP +If you need more speed, `Psyco `_ generates x86 +assembly code from Python bytecode. You can use Psyco to compile the most +time-critical functions in your code, and gain a significant improvement with +very little effort, as long as you're running on a machine with an +x86-compatible processor. + +`Pyrex `_ is a compiler +that accepts a slightly modified form of Python and generates the corresponding +C code. Pyrex makes it possible to write an extension without having to learn +Python's C API. + +If you need to interface to some C or C++ library for which no Python extension +currently exists, you can try wrapping the library's data types and functions +with a tool such as `SWIG `_. `SIP `_, `CXX `_ `Boost `_, or `Weave -`_ are also alternatives for -wrapping C++ libraries. +`_ are also alternatives for wrapping +C++ libraries. How can I execute arbitrary Python statements from C? ------------------------------------------------------------- -The highest-level function to do this is ``PyRun_SimpleString()`` which takes +----------------------------------------------------- + +The highest-level function to do this is :cfunc:`PyRun_SimpleString` which takes a single string argument to be executed in the context of the module ``__main__`` and returns 0 for success and -1 when an exception occurred -(including ``SyntaxError``). If you want more control, use ``PyRun_String()``; -see the source for ``PyRun_SimpleString()`` in Python/pythonrun.c. +(including ``SyntaxError``). If you want more control, use +:cfunc:`PyRun_String`; see the source for :cfunc:`PyRun_SimpleString` in +``Python/pythonrun.c``. How can I evaluate an arbitrary Python expression from C? ----------------------------------------------------------------- -Call the function ``PyRun_String()`` from the previous question with the -start symbol ``Py_eval_input``; it -parses an expression, evaluates it and returns its value. +--------------------------------------------------------- + +Call the function :cfunc:`PyRun_String` from the previous question with the +start symbol :cdata:`Py_eval_input`; it parses an expression, evaluates it and +returns its value. + How do I extract C values from a Python object? ------------------------------------------------------- -That depends on the object's type. If it's a tuple, -``PyTupleSize(o)`` returns its length and ``PyTuple_GetItem(o, i)`` -returns its i'th item. Lists have similar functions, ``PyListSize(o)`` -and ``PyList_GetItem(o, i)``. - -For strings, ``PyString_Size(o)`` returns -its length and ``PyString_AsString(o)`` a pointer to its value. -Note that Python strings may contain null bytes so C's ``strlen()`` -should not be used. - -To test the type of an object, first make sure -it isn't NULL, and then use ``PyString_Check(o)``, ``PyTuple_Check(o)``, -``PyList_Check(o)``, etc. - -There is also a high-level API to Python objects which is -provided by the so-called 'abstract' interface -- read -``Include/abstract.h`` for further details. It allows -interfacing with any kind of Python sequence -using calls like ``PySequence_Length()``, ``PySequence_GetItem()``, etc.) -as well as many other useful protocols. +----------------------------------------------- + +That depends on the object's type. If it's a tuple, :cfunc:`PyTuple_Size` +returns its length and :cfunc:`PyTuple_GetItem` returns the item at a specified +index. Lists have similar functions, :cfunc:`PyListSize` and +:cfunc:`PyList_GetItem`. + +For strings, :cfunc:`PyString_Size` returns its length and +:cfunc:`PyString_AsString` a pointer to its value. Note that Python strings may +contain null bytes so C's :cfunc:`strlen` should not be used. + +To test the type of an object, first make sure it isn't *NULL*, and then use +:cfunc:`PyString_Check`, :cfunc:`PyTuple_Check`, :cfunc:`PyList_Check`, etc. + +There is also a high-level API to Python objects which is provided by the +so-called 'abstract' interface -- read ``Include/abstract.h`` for further +details. It allows interfacing with any kind of Python sequence using calls +like :cfunc:`PySequence_Length`, :cfunc:`PySequence_GetItem`, etc.) as well as +many other useful protocols. + How do I use Py_BuildValue() to create a tuple of arbitrary length? --------------------------------------------------------------------------- -You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with -objects using ``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a -reference count of ``o``, so you have to ``Py_INCREF`` it. -Lists have similar functions ``PyList_New(n)`` and -``PyList_SetItem(l, i, o)``. Note that you *must* set all the tuple items to -some value before you pass the tuple to Python code -- -``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python -value. +------------------------------------------------------------------- + +You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using +``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of +``o``, so you have to :cfunc:`Py_INCREF` it. Lists have similar functions +``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all +the tuple items to some value before you pass the tuple to Python code -- +``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value. + How do I call an object's method from C? ------------------------------------------------ -The ``PyObject_CallMethod()`` function can be used to call an arbitrary -method of an object. The parameters are the object, the name of the -method to call, a format string like that used with ``Py_BuildValue()``, and the argument values:: - - PyObject * - PyObject_CallMethod(PyObject *object, char *method_name, - char *arg_format, ...); - -This works for any object that has methods -- whether built-in or -user-defined. You are responsible for eventually ``Py_DECREF``'ing the -return value. - -To call, e.g., a file object's "seek" method with arguments 10, 0 -(assuming the file object pointer is "f"):: - - res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); - if (res == NULL) { - ... an exception occurred ... - } - else { - Py_DECREF(res); - } - -Note that since ``PyObject_CallObject()`` *always* wants a tuple for the -argument list, to call a function without arguments, pass "()" for the -format, and to call a function with one argument, surround the argument -in parentheses, e.g. "(i)". +---------------------------------------- + +The :cfunc:`PyObject_CallMethod` function can be used to call an arbitrary +method of an object. The parameters are the object, the name of the method to +call, a format string like that used with :cfunc:`Py_BuildValue`, and the +argument values:: + + PyObject * + PyObject_CallMethod(PyObject *object, char *method_name, + char *arg_format, ...); + +This works for any object that has methods -- whether built-in or user-defined. +You are responsible for eventually :cfunc:`Py_DECREF`\ 'ing the return value. + +To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the +file object pointer is "f"):: + + res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); + if (res == NULL) { + ... an exception occurred ... + } + else { + Py_DECREF(res); + } + +Note that since :cfunc:`PyObject_CallObject` *always* wants a tuple for the +argument list, to call a function without arguments, pass "()" for the format, +and to call a function with one argument, surround the argument in parentheses, +e.g. "(i)". How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ------------------------------------------------------------------------------------------------ -In Python code, define an object that supports the ``write()`` method. -Assign this object to ``sys.stdout`` and ``sys.stderr``. -Call print_error, or just allow the standard traceback mechanism to -work. Then, the output will go wherever your ``write()`` method sends it. - -The easiest way to do this is to use the StringIO class in the standard -library. - -Sample code and use for catching stdout:: - - >>> class StdoutCatcher: - ... def __init__(self): - ... self.data = '' - ... def write(self, stuff): - ... self.data = self.data + stuff - ... - >>> import sys - >>> sys.stdout = StdoutCatcher() - >>> print 'foo' - >>> print 'hello world!' - >>> sys.stderr.write(sys.stdout.data) - foo - hello world! +---------------------------------------------------------------------------------------- + +In Python code, define an object that supports the ``write()`` method. Assign +this object to :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or +just allow the standard traceback mechanism to work. Then, the output will go +wherever your ``write()`` method sends it. + +The easiest way to do this is to use the StringIO class in the standard library. + +Sample code and use for catching stdout: + + >>> class StdoutCatcher: + ... def __init__(self): + ... self.data = '' + ... def write(self, stuff): + ... self.data = self.data + stuff + ... + >>> import sys + >>> sys.stdout = StdoutCatcher() + >>> print 'foo' + >>> print 'hello world!' + >>> sys.stderr.write(sys.stdout.data) + foo + hello world! How do I access a module written in Python from C? ---------------------------------------------------------- +-------------------------------------------------- + You can get a pointer to the module object as follows:: - module = PyImport_ImportModule(""); + module = PyImport_ImportModule(""); If the module hasn't been imported yet (i.e. it is not yet present in -``sys.modules``), this initializes the module; otherwise it simply returns -the value of ``sys.modules[""]``. Note that it doesn't enter -the module into any namespace -- it only ensures it has been -initialized and is stored in ``sys.modules``. +:data:`sys.modules`), this initializes the module; otherwise it simply returns +the value of ``sys.modules[""]``. Note that it doesn't enter the +module into any namespace -- it only ensures it has been initialized and is +stored in :data:`sys.modules`. -You can then access the module's attributes (i.e. any name defined in -the module) as follows:: +You can then access the module's attributes (i.e. any name defined in the +module) as follows:: - attr = PyObject_GetAttrString(module, ""); + attr = PyObject_GetAttrString(module, ""); -Calling ``PyObject_SetAttrString()`` to assign to variables in the module also works. +Calling :cfunc:`PyObject_SetAttrString` to assign to variables in the module +also works. How do I interface to C++ objects from Python? ------------------------------------------------------- -Depending on your requirements, there are many approaches. To do -this manually, begin by reading `the "Extending and Embedding" document `_. Realize -that for the Python run-time system, there isn't a 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 `_ +---------------------------------------------- + +Depending on your requirements, there are many approaches. To do this manually, +begin by reading :ref:`the "Extending and Embedding" document +`. Realize that for the Python run-time system, there isn't a +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 `_ I added a module using the Setup file and the make fails; why? ----------------------------------------------------------------------- +-------------------------------------------------------------- + +Setup must end in a newline, if there is no newline there, the build process +fails. (Fixing this requires some ugly shell script hackery, and this bug is so +minor that it doesn't seem worth the effort.) -Setup must end in a newline, if there is no newline there, the build -process fails. (Fixing this requires some ugly shell script hackery, -and this bug is so minor that it doesn't seem worth the effort.) How do I debug an extension? ------------------------------------- -When using GDB with dynamically loaded extensions, you can't set a -breakpoint in your extension until your extension is loaded. +---------------------------- + +When using GDB with dynamically loaded extensions, you can't set a breakpoint in +your extension until your extension is loaded. In your ``.gdbinit`` file (or interactively), add the command:: - br _PyImport_LoadDynamicModule + br _PyImport_LoadDynamicModule Then, when you run GDB:: - $ gdb /local/bin/python - gdb) run myscript.py - gdb) continue # repeat until your extension is loaded - gdb) finish # so that your extension is loaded - gdb) br myfunction.c:50 - gdb) continue + $ gdb /local/bin/python + gdb) run myscript.py + gdb) continue # repeat until your extension is loaded + gdb) finish # so that your extension is loaded + gdb) br myfunction.c:50 + gdb) continue I want to compile a Python module on my Linux system, but some files are missing. Why? -------------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------- Most packaged versions of Python don't include the -/usr/lib/python2.x/config/ directory, which contains various files required -for compiling Python extensions. +:file:`/usr/lib/python2.{x}/config/` directory, which contains various files +required for compiling Python extensions. For Red Hat, install the python-devel RPM to get the necessary files. @@ -227,236 +244,238 @@ What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean? -------------------------------------------------------------------------------------------------------- -This means that you have created an extension module named "yourmodule", but your module init function does not initialize with that name. +------------------------------------------------------------------------------------- + +This means that you have created an extension module named "yourmodule", but +your module init function does not initialize with that name. Every module init function will have a line similar to:: - module = Py_InitModule("yourmodule", yourmodule_functions); + module = Py_InitModule("yourmodule", yourmodule_functions); -If the string passed to this function is not the same name as your -extension module, the ``SystemError`` exception will be raised. +If the string passed to this function is not the same name as your extension +module, the :exc:`SystemError` exception will be raised. How do I tell "incomplete input" from "invalid input"? --------------------------------------------------------------------------------- -Sometimes you want to emulate the Python interactive interpreter's -behavior, where it gives you a continuation prompt when the input -is incomplete (e.g. you typed the start of an "if" statement -or you didn't close your parentheses or triple string quotes), -but it gives you a syntax error message immediately when the input -is invalid. - -In Python you can use the ``codeop`` module, which approximates the -parser's behavior sufficiently. IDLE uses this, for example. - -The easiest way to do it in C is to call ``PyRun_InteractiveLoop()`` -(perhaps in a separate thread) and let the Python interpreter handle -the input for you. You can also set the ``PyOS_ReadlineFunctionPointer`` -to point at your custom input function. See ``Modules/readline.c`` and -``Parser/myreadline.c`` for more hints. - -However sometimes you have to run the embedded Python interpreter in -the same thread as your rest application and you can't allow the -``PyRun_InteractiveLoop()`` to stop while waiting for user input. The -one solution then is to call ``PyParser_ParseString()`` and test for -``e.error`` equal to ``E_EOF``, which means the input is incomplete). -Here's a sample code fragment, untested, inspired by code from Alex Farber:: - - #include - #include - #include - #include - #include - #include - - int testcomplete(char *code) - /* code should end in \n */ - /* return -1 for error, 0 for incomplete, 1 for complete */ - { - node *n; - perrdetail e; - - n = PyParser_ParseString(code, &_PyParser_Grammar, - Py_file_input, &e); - if (n == NULL) { - if (e.error == E_EOF) - return 0; - return -1; - } - - PyNode_Free(n); - return 1; - } - -Another solution is trying to compile the received string with -``Py_CompileString()``. If it compiles without errors, try to execute the returned -code object by calling ``PyEval_EvalCode()``. Otherwise save the input for -later. If the compilation fails, find out if it's an error or just -more input is required - by extracting the message string from the -exception tuple and comparing it to the string "unexpected EOF while parsing". -Here is a complete example using the GNU readline library (you may -want to ignore SIGINT while calling readline()):: - - #include - #include - - #include - #include - #include - #include - - int main (int argc, char* argv[]) - { - int i, j, done = 0; /* lengths of line, code */ - char ps1[] = ">>> "; - char ps2[] = "... "; - char *prompt = ps1; - char *msg, *line, *code = NULL; - PyObject *src, *glb, *loc; - PyObject *exc, *val, *trb, *obj, *dum; - - Py_Initialize (); - loc = PyDict_New (); - glb = PyDict_New (); - PyDict_SetItemString (glb, "__builtins__", PyEval_GetBuiltins ()); - - while (!done) - { - line = readline (prompt); - - if (NULL == line) /* CTRL-D pressed */ - { - done = 1; - } - else - { - i = strlen (line); - - if (i > 0) - add_history (line); /* save non-empty lines */ - - if (NULL == code) /* nothing in code yet */ - j = 0; - else - j = strlen (code); - - code = realloc (code, i + j + 2); - if (NULL == code) /* out of memory */ - exit (1); - - if (0 == j) /* code was empty, so */ - code[0] = '\0'; /* keep strncat happy */ - - strncat (code, line, i); /* append line to code */ - code[i + j] = '\n'; /* append '\n' to code */ - code[i + j + 1] = '\0'; - - src = Py_CompileString (code, "", Py_single_input); - - if (NULL != src) /* compiled just fine - */ - { - if (ps1 == prompt || /* ">>> " or */ - '\n' == code[i + j - 1]) /* "... " and double '\n' */ - { /* so execute it */ - dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc); - Py_XDECREF (dum); - Py_XDECREF (src); - free (code); - code = NULL; - if (PyErr_Occurred ()) - PyErr_Print (); - prompt = ps1; - } - } /* syntax error or E_EOF? */ - else if (PyErr_ExceptionMatches (PyExc_SyntaxError)) - { - PyErr_Fetch (&exc, &val, &trb); /* clears exception! */ - - if (PyArg_ParseTuple (val, "sO", &msg, &obj) && - !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ - { - Py_XDECREF (exc); - Py_XDECREF (val); - Py_XDECREF (trb); - prompt = ps2; - } - else /* some other syntax error */ - { - PyErr_Restore (exc, val, trb); - PyErr_Print (); - free (code); - code = NULL; - prompt = ps1; - } - } - else /* some non-syntax error */ - { - PyErr_Print (); - free (code); - code = NULL; - prompt = ps1; - } - - free (line); - } - } - - Py_XDECREF(glb); - Py_XDECREF(loc); - Py_Finalize(); - exit(0); - } +------------------------------------------------------ +Sometimes you want to emulate the Python interactive interpreter's behavior, +where it gives you a continuation prompt when the input is incomplete (e.g. you +typed the start of an "if" statement or you didn't close your parentheses or +triple string quotes), but it gives you a syntax error message immediately when +the input is invalid. + +In Python you can use the :mod:`codeop` module, which approximates the parser's +behavior sufficiently. IDLE uses this, for example. + +The easiest way to do it in C is to call :cfunc:`PyRun_InteractiveLoop` (perhaps +in a separate thread) and let the Python interpreter handle the input for +you. You can also set the :cfunc:`PyOS_ReadlineFunctionPointer` to point at your +custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` +for more hints. + +However sometimes you have to run the embedded Python interpreter in the same +thread as your rest application and you can't allow the +:cfunc:`PyRun_InteractiveLoop` to stop while waiting for user input. The one +solution then is to call :cfunc:`PyParser_ParseString` and test for ``e.error`` +equal to ``E_EOF``, which means the input is incomplete). Here's a sample code +fragment, untested, inspired by code from Alex Farber:: + + #include + #include + #include + #include + #include + #include + + int testcomplete(char *code) + /* code should end in \n */ + /* return -1 for error, 0 for incomplete, 1 for complete */ + { + node *n; + perrdetail e; + + n = PyParser_ParseString(code, &_PyParser_Grammar, + Py_file_input, &e); + if (n == NULL) { + if (e.error == E_EOF) + return 0; + return -1; + } + + PyNode_Free(n); + return 1; + } + +Another solution is trying to compile the received string with +:cfunc:`Py_CompileString`. If it compiles without errors, try to execute the +returned code object by calling :cfunc:`PyEval_EvalCode`. Otherwise save the +input for later. If the compilation fails, find out if it's an error or just +more input is required - by extracting the message string from the exception +tuple and comparing it to the string "unexpected EOF while parsing". Here is a +complete example using the GNU readline library (you may want to ignore +**SIGINT** while calling readline()):: + + #include + #include + + #include + #include + #include + #include + + int main (int argc, char* argv[]) + { + int i, j, done = 0; /* lengths of line, code */ + char ps1[] = ">>> "; + char ps2[] = "... "; + char *prompt = ps1; + char *msg, *line, *code = NULL; + PyObject *src, *glb, *loc; + PyObject *exc, *val, *trb, *obj, *dum; + + Py_Initialize (); + loc = PyDict_New (); + glb = PyDict_New (); + PyDict_SetItemString (glb, "__builtins__", PyEval_GetBuiltins ()); + + while (!done) + { + line = readline (prompt); + + if (NULL == line) /* CTRL-D pressed */ + { + done = 1; + } + else + { + i = strlen (line); + + if (i > 0) + add_history (line); /* save non-empty lines */ + + if (NULL == code) /* nothing in code yet */ + j = 0; + else + j = strlen (code); + + code = realloc (code, i + j + 2); + if (NULL == code) /* out of memory */ + exit (1); + + if (0 == j) /* code was empty, so */ + code[0] = '\0'; /* keep strncat happy */ + + strncat (code, line, i); /* append line to code */ + code[i + j] = '\n'; /* append '\n' to code */ + code[i + j + 1] = '\0'; + + src = Py_CompileString (code, "", Py_single_input); + + if (NULL != src) /* compiled just fine - */ + { + if (ps1 == prompt || /* ">>> " or */ + '\n' == code[i + j - 1]) /* "... " and double '\n' */ + { /* so execute it */ + dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc); + Py_XDECREF (dum); + Py_XDECREF (src); + free (code); + code = NULL; + if (PyErr_Occurred ()) + PyErr_Print (); + prompt = ps1; + } + } /* syntax error or E_EOF? */ + else if (PyErr_ExceptionMatches (PyExc_SyntaxError)) + { + PyErr_Fetch (&exc, &val, &trb); /* clears exception! */ + + if (PyArg_ParseTuple (val, "sO", &msg, &obj) && + !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ + { + Py_XDECREF (exc); + Py_XDECREF (val); + Py_XDECREF (trb); + prompt = ps2; + } + else /* some other syntax error */ + { + PyErr_Restore (exc, val, trb); + PyErr_Print (); + free (code); + code = NULL; + prompt = ps1; + } + } + else /* some non-syntax error */ + { + PyErr_Print (); + free (code); + code = NULL; + prompt = ps1; + } + + free (line); + } + } + + Py_XDECREF(glb); + Py_XDECREF(loc); + Py_Finalize(); + exit(0); + } How do I find undefined g++ symbols __builtin_new or __pure_virtual? ------------------------------------------------------------------------------------ +-------------------------------------------------------------------- -To dynamically load g++ extension modules, you must recompile Python, relink it using g++ (change LINKCC in the python Modules Makefile), and link your extension module using g++ (e.g., "g++ -shared -o mymodule.so mymodule.o"). +To dynamically load g++ extension modules, you must recompile Python, relink it +using g++ (change LINKCC in the python Modules Makefile), and link your +extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``). -Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ------------------------------------------------------------------------------------------------------------------------------------------------------ +Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? +---------------------------------------------------------------------------------------------------------------- -In Python 2.2, you can inherit from builtin classes such as int, list, dict, etc. +In Python 2.2, you can inherit from builtin classes such as :class:`int`, +:class:`list`, :class:`dict`, etc. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) -provides a way of doing this from C++ (i.e. you can inherit from an -extension class written in C++ using the BPL). +provides a way of doing this from C++ (i.e. you can inherit from an extension +class written in C++ using the BPL). + When importing module X, why do I get "undefined symbol: PyUnicodeUCS2*"? --------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------- -You are using a version of Python that uses a 4-byte representation -for Unicode characters, but some C extension module you are importing -was compiled using a Python that uses a 2-byte representation for -Unicode characters (the default). - -If instead the name of the undefined symbol starts with -``PyUnicodeUCS4``, the problem is the reverse: Python was built using -2-byte Unicode characters, and the extension module was compiled using -a Python with 4-byte Unicode characters. - -This can easily occur when using pre-built extension packages. RedHat -Linux 7.x, in particular, provided a "python2" binary that is compiled -with 4-byte Unicode. This only causes the link failure if the extension -uses any of the ``PyUnicode_*()`` functions. It is also a problem if an -extension uses any of the Unicode-related format specifiers for -``Py_BuildValue`` (or similar) or parameter specifications for -``PyArg_ParseTuple()``. - -You can check the size of the Unicode character a Python interpreter is -using by checking the value of sys.maxunicode:: - - >>> import sys - >>> if sys.maxunicode > 65535: - ... print 'UCS4 build' - ... else: - ... print 'UCS2 build' +You are using a version of Python that uses a 4-byte representation for Unicode +characters, but some C extension module you are importing was compiled using a +Python that uses a 2-byte representation for Unicode characters (the default). + +If instead the name of the undefined symbol starts with ``PyUnicodeUCS4``, the +problem is the reverse: Python was built using 2-byte Unicode characters, and +the extension module was compiled using a Python with 4-byte Unicode characters. + +This can easily occur when using pre-built extension packages. RedHat Linux +7.x, in particular, provided a "python2" binary that is compiled with 4-byte +Unicode. This only causes the link failure if the extension uses any of the +``PyUnicode_*()`` functions. It is also a problem if an extension uses any of +the Unicode-related format specifiers for :cfunc:`Py_BuildValue` (or similar) or +parameter specifications for :cfunc:`PyArg_ParseTuple`. + +You can check the size of the Unicode character a Python interpreter is using by +checking the value of sys.maxunicode: + + >>> import sys + >>> if sys.maxunicode > 65535: + ... print 'UCS4 build' + ... else: + ... print 'UCS2 build' -The only way to solve this problem is to use extension modules compiled -with a Python binary built using the same size for Unicode characters. +The only way to solve this problem is to use extension modules compiled with a +Python binary built using the same size for Unicode characters. Modified: sandbox/trunk/faq/general.rst ============================================================================== --- sandbox/trunk/faq/general.rst (original) +++ sandbox/trunk/faq/general.rst Sun Oct 11 20:12:15 2009 @@ -1,156 +1,151 @@ +:tocdepth: 2 -==================================== +================== General Python FAQ -==================================== +================== .. contents:: General Information -===================== +=================== What is Python? ----------------------- +--------------- -Python is an interpreted, interactive, object-oriented programming -language. It incorporates modules, exceptions, dynamic typing, very -high level dynamic data types, and classes. Python combines -remarkable power with very clear syntax. It has interfaces to many -system calls and libraries, as well as to various window systems, and -is extensible in C or C++. It is also usable as an extension language -for applications that need a programmable interface. Finally, Python -is portable: it runs on many Unix variants, on the Mac, and on PCs -under MS-DOS, Windows, Windows NT, and OS/2. - -To find out more, start -with :ref:`tutorial-index`. The -`Beginner's Guide to Python `_ -links to other introductory tutorials and resources for learning Python. +Python is an interpreted, interactive, object-oriented programming language. It +incorporates modules, exceptions, dynamic typing, very high level dynamic data +types, and classes. Python combines remarkable power with very clear syntax. +It has interfaces to many system calls and libraries, as well as to various +window systems, and is extensible in C or C++. It is also usable as an +extension language for applications that need a programmable interface. +Finally, Python is portable: it runs on many Unix variants, on the Mac, and on +PCs under MS-DOS, Windows, Windows NT, and OS/2. + +To find out more, start with :ref:`tutorial-index`. The `Beginner's Guide to +Python `_ links to other +introductory tutorials and resources for learning Python. What is the Python Software Foundation? ------------------------------------------ +--------------------------------------- -The Python Software Foundation is an independent non-profit -organization that holds the copyright on Python versions 2.1 and -newer. The PSF's mission is to advance open source technology related -to the Python programming language and to publicize the use of -Python. The PSF's home page is at http://www.python.org/psf/. +The Python Software Foundation is an independent non-profit organization that +holds the copyright on Python versions 2.1 and newer. The PSF's mission is to +advance open source technology related to the Python programming language and to +publicize the use of Python. The PSF's home page is at +http://www.python.org/psf/. -Donations to the PSF are tax-exempt in the US. If you use Python and -find it helpful, please contribute via `the PSF donation page +Donations to the PSF are tax-exempt in the US. If you use Python and find it +helpful, please contribute via `the PSF donation page `_. + Are there copyright restrictions on the use of Python? --------------------------------------------------------------- +------------------------------------------------------ + +You can do anything you want with the source, as long as you leave the +copyrights in and display those copyrights in any documentation about Python +that you produce. If you honor the copyright rules, it's OK to use Python for +commercial use, to sell copies of Python in source or binary form (modified or +unmodified), or to sell products that incorporate Python in some form. We would +still like to know about all commercial use of Python, of course. + +See `the PSF license page `_ to find further explanations and a +link to the full text of the license. + +The Python logo is trademarked, and in certain cases permission is required to +use it. Consult `the Trademark Usage Policy +`__ for more information. -You can do anything you want with the source, as long as -you leave the copyrights in and display those copyrights in any -documentation about Python that you produce. If you honor the -copyright rules, it's OK to use Python for commercial use, to sell -copies of Python in source or binary form (modified or unmodified), or -to sell products that incorporate Python in some form. We would still -like to know about all commercial use of Python, of course. - -See `the PSF license page `_ -to find further explanations and a link to the full text of the -license. - -The Python logo is trademarked, and in certain cases permission -is required to use it. Consult -`the Trademark Usage Policy `__ -for more information. Why was Python created in the first place? --------------------------------------------------- -Here's a *very* brief summary of what started it all, written -by Guido van Rossum: +------------------------------------------ - I had extensive experience with implementing an interpreted language - in the ABC group at CWI, and from working with this group I had - learned a lot about language design. This is the origin of many - Python features, including the use of indentation for statement - grouping and the inclusion of very-high-level data types (although the - details are all different in Python). - - I had a number of gripes about the ABC language, but also liked many - of its features. It was impossible to extend the ABC language (or its - implementation) to remedy my complaints -- in fact its lack of - extensibility was one of its biggest problems. I had some experience - with using Modula-2+ and talked with the designers of Modula-3 and - read the Modula-3 report. Modula-3 is the origin of the syntax and - semantics used for exceptions, and some other Python features. - - I was working in the Amoeba distributed operating system group at - CWI. We needed a better way to do system administration than by - writing either C programs or Bourne shell scripts, since Amoeba had - its own system call interface which wasn't easily accessible from the - Bourne shell. My experience with error handling in Amoeba made me - acutely aware of the importance of exceptions as a programming - language feature. - - It occurred to me that a scripting language with a syntax like ABC - but with access to the Amoeba system calls would fill the need. I - realized that it would be foolish to write an Amoeba-specific - language, so I decided that I needed a language that was generally - extensible. - - During the 1989 Christmas holidays, I had a lot of time on my hand, - so I decided to give it a try. During the next year, while still - mostly working on it in my own time, Python was used in the Amoeba - project with increasing success, and the feedback from colleagues made - me add many early improvements. +Here's a *very* brief summary of what started it all, written by Guido van +Rossum: - In February 1991, after just over a year of development, I decided - to post to USENET. The rest is in the Misc/HISTORY file. + I had extensive experience with implementing an interpreted language in the + ABC group at CWI, and from working with this group I had learned a lot about + language design. This is the origin of many Python features, including the + use of indentation for statement grouping and the inclusion of + very-high-level data types (although the details are all different in + Python). + + I had a number of gripes about the ABC language, but also liked many of its + features. It was impossible to extend the ABC language (or its + implementation) to remedy my complaints -- in fact its lack of extensibility + was one of its biggest problems. I had some experience with using Modula-2+ + and talked with the designers of Modula-3 and read the Modula-3 report. + Modula-3 is the origin of the syntax and semantics used for exceptions, and + some other Python features. + + I was working in the Amoeba distributed operating system group at CWI. We + needed a better way to do system administration than by writing either C + programs or Bourne shell scripts, since Amoeba had its own system call + interface which wasn't easily accessible from the Bourne shell. My + experience with error handling in Amoeba made me acutely aware of the + importance of exceptions as a programming language feature. + + It occurred to me that a scripting language with a syntax like ABC but with + access to the Amoeba system calls would fill the need. I realized that it + would be foolish to write an Amoeba-specific language, so I decided that I + needed a language that was generally extensible. + + During the 1989 Christmas holidays, I had a lot of time on my hand, so I + decided to give it a try. During the next year, while still mostly working + on it in my own time, Python was used in the Amoeba project with increasing + success, and the feedback from colleagues made me add many early + improvements. + + In February 1991, after just over a year of development, I decided to post to + USENET. The rest is in the ``Misc/HISTORY`` file. What is Python good for? --------------------------------- -Python is a high-level general-purpose programming language -that can be applied to many different classes of problems. - -The language comes with a large standard library that covers areas -such as string processing (regular expressions, Unicode, calculating -differences between files), Internet protocols (HTTP, FTP, SMTP, -XML-RPC, POP, IMAP, CGI programming), software engineering (unit testing, -logging, profiling, parsing Python code), and operating system -interfaces (system calls, filesystems, TCP/IP sockets). Look at the -table of contents for :ref:`library-index` to get an idea of what's available. -A wide variety of third-party extensions are also available. -Consult `the Python Package Index `_ to find -packages of interest to you. +------------------------ + +Python is a high-level general-purpose programming language that can be applied +to many different classes of problems. + +The language comes with a large standard library that covers areas such as +string processing (regular expressions, Unicode, calculating differences between +files), Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, CGI +programming), software engineering (unit testing, logging, profiling, parsing +Python code), and operating system interfaces (system calls, filesystems, TCP/IP +sockets). Look at the table of contents for :ref:`library-index` to get an idea +of what's available. A wide variety of third-party extensions are also +available. Consult `the Python Package Index `_ to +find packages of interest to you. How does the Python version numbering scheme work? ----------------------------------------------------------- -Python versions are numbered A.B.C or A.B. A is the major version -number -- it is only incremented for really major changes in -the language. B is the minor version number, incremented for less -earth-shattering changes. C is the micro-level -- it is incremented -for each bugfix release. See `PEP 6 `_ -for more information about bugfix releases. - -Not all releases are bugfix releases. In the run-up to a new major -release, a series of development releases are made, denoted as alpha, -beta, or release candidate. Alphas are early releases in which -interfaces aren't yet finalized; it's not unexpected to see an -interface change between two alpha releases. Betas are more stable, -preserving existing interfaces but possibly adding new modules, and -release candidates are frozen, making no changes except as needed to -fix critical bugs. - -Alpha, beta and release candidate versions have an additional -suffix. The suffix for an alpha version is "aN" for some small -number N, the suffix for a beta version is "bN" for some small number -N, and the suffix for a release candidate version is "cN" for some -small number N. In other words, all versions labeled 2.0aN precede -the versions labeled 2.0bN, which precede versions labeled 2.0cN, and -*those* precede 2.0. - -You may also find version numbers with a "+" suffix, e.g. "2.2+". -These are unreleased versions, built directly from the Subversion trunk. In -practice, after a final minor release is made, the Subversion trunk is -incremented to the next minor version, which becomes the "a0" version, +-------------------------------------------------- + +Python versions are numbered A.B.C or A.B. A is the major version number -- it +is only incremented for really major changes in the language. B is the minor +version number, incremented for less earth-shattering changes. C is the +micro-level -- it is incremented for each bugfix release. See `PEP 6 +`_ for more information about bugfix releases. + +Not all releases are bugfix releases. In the run-up to a new major release, a +series of development releases are made, denoted as alpha, beta, or release +candidate. Alphas are early releases in which interfaces aren't yet finalized; +it's not unexpected to see an interface change between two alpha releases. +Betas are more stable, preserving existing interfaces but possibly adding new +modules, and release candidates are frozen, making no changes except as needed +to fix critical bugs. + +Alpha, beta and release candidate versions have an additional suffix. The +suffix for an alpha version is "aN" for some small number N, the suffix for a +beta version is "bN" for some small number N, and the suffix for a release +candidate version is "cN" for some small number N. In other words, all versions +labeled 2.0aN precede the versions labeled 2.0bN, which precede versions labeled +2.0cN, and *those* precede 2.0. + +You may also find version numbers with a "+" suffix, e.g. "2.2+". These are +unreleased versions, built directly from the Subversion trunk. In practice, +after a final minor release is made, the Subversion trunk is incremented to the +next minor version, which becomes the "a0" version, e.g. "2.4a0". See also the documentation for ``sys.version``, ``sys.hexversion``, and @@ -158,155 +153,158 @@ How do I obtain a copy of the Python source? ---------------------------------------------------- +-------------------------------------------- -The latest Python source distribution is always available from -python.org, at http://www.python.org/download/. The latest -development sources can be obtained via anonymous Subversion -at http://svn.python.org/projects/python/trunk. - -The source distribution is a gzipped tar file containing the complete -C source, Sphinx-formatted documentation, Python library modules, example -programs, and several useful pieces of freely distributable software. -The source will compile and run out of the box on most UNIX platforms. +The latest Python source distribution is always available from python.org, at +http://www.python.org/download/. The latest development sources can be obtained +via anonymous Subversion at http://svn.python.org/projects/python/trunk. + +The source distribution is a gzipped tar file containing the complete C source, +Sphinx-formatted documentation, Python library modules, example programs, and +several useful pieces of freely distributable software. The source will compile +and run out of the box on most UNIX platforms. + +Consult the `Developer FAQ +`__ for more information +on getting the source code and compiling it. -Consult the `Developer FAQ `__ -for more information on getting the source code and compiling it. How do I get documentation on Python? --------------------------------------------- +------------------------------------- + +.. XXX mention py3k -The standard documentation for the current stable version of Python is -available at http://docs.python.org/. PDF, plain text, and downloadable HTML -versions are also available. - -The documentation is written using -`the Sphinx documentation tool `__. -The Sphinx source for the documentation is part of the Python source -distribution. +The standard documentation for the current stable version of Python is available +at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are +also available at http://docs.python.org/download/. + +The documentation is written in reStructuredText and processed by `the Sphinx +documentation tool `__. The reStructuredText source +for the documentation is part of the Python source distribution. I've never programmed before. Is there a Python tutorial? ------------------------------------------------------------------ +--------------------------------------------------------- + +There are numerous tutorials and books available. The standard documentation +includes :ref:`tutorial-index`. -There are numerous tutorials and books available. -The standard documentation includes -:ref:`tutorial-index`. +Consult `the Beginner's Guide `_ to +find information for beginning Python programmers, including lists of tutorials. -Consult `the Beginner's Guide `_ to find information for -beginning Python programmers, including lists of tutorials. Is there a newsgroup or mailing list devoted to Python? --------------------------------------------------------------- +------------------------------------------------------- -There is a newsgroup, comp.lang.python, and a mailing list, -`python-list `_. -The newsgroup and mailing list are gatewayed into each other -- if you -can read news it's unnecessary to subscribe to the mailing list. -comp.lang.python is high-traffic, receiving hundreds of postings every day, -and Usenet readers are often more able to cope with this volume. +There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, +`python-list `_. The +newsgroup and mailing list are gatewayed into each other -- if you can read news +it's unnecessary to subscribe to the mailing list. +:newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of postings +every day, and Usenet readers are often more able to cope with this volume. Announcements of new software releases and events can be found in -comp.lang.python.announce, a low-traffic moderated list that receives -about five postings per day. -It's available as -`the python-announce mailing list `_. +comp.lang.python.announce, a low-traffic moderated list that receives about five +postings per day. It's available as `the python-announce mailing list +`_. More info about other mailing lists and newsgroups can be found at http://www.python.org/community/lists/. + How do I get a beta test version of Python? ---------------------------------------------------- +------------------------------------------- -Alpha and beta releases are available from -http://www.python.org/download/. All releases are announced on the -comp.lang.python and comp.lang.python.announce newsgroups and on the -Python home page at http://www.python.org/; an RSS feed of news is -available. +Alpha and beta releases are available from http://www.python.org/download/. All +releases are announced on the comp.lang.python and comp.lang.python.announce +newsgroups and on the Python home page at http://www.python.org/; an RSS feed of +news is available. + +You can also access the development version of Python through Subversion. See +http://www.python.org/dev/devfaq.html#subversion-svn for details. -You can also access the development version of Python through Subversion. -See http://www.python.org/dev/devfaq.html#subversion-svn for details. How do I submit bug reports and patches for Python? ----------------------------------------------------------- +--------------------------------------------------- -To report a bug or submit a patch, please use the Roundup -installation at http://bugs.python.org/. +To report a bug or submit a patch, please use the Roundup installation at +http://bugs.python.org/. -You must have a Roundup account to report bugs; this makes it -possible for us to contact you if we have follow-up questions. It -will also enable Roundup to send you updates as we act on your -bug. If you had previously used SourceForge to report bugs to -Python, you can obtain your Roundup password through Roundup's +You must have a Roundup account to report bugs; this makes it possible for us to +contact you if we have follow-up questions. It will also enable Roundup to send +you updates as we act on your bug. If you had previously used SourceForge to +report bugs to Python, you can obtain your Roundup password through Roundup's `password reset procedure `_. -For more information on how Python is developed, consult -`the Python Developer's Guide `_. +.. XXX adapt link to dev guide + +For more information on how Python is developed, consult `the Python Developer's +Guide `_. + Are there any published articles about Python that I can reference? ---------------------------------------------------------------------------- -It's probably best to cite your favorite book about Python. +------------------------------------------------------------------- -The very first article about Python was written in 1991 and is now -quite outdated. +It's probably best to cite your favorite book about Python. - Guido van Rossum and Jelke de Boer, "Interactively Testing Remote - Servers Using the Python Programming Language", CWI Quarterly, Volume - 4, Issue 4 (December 1991), Amsterdam, pp 283-303. +The very first article about Python was written in 1991 and is now quite +outdated. + Guido van Rossum and Jelke de Boer, "Interactively Testing Remote Servers + Using the Python Programming Language", CWI Quarterly, Volume 4, Issue 4 + (December 1991), Amsterdam, pp 283-303. Are there any books on Python? -------------------------------------- +------------------------------ -Yes, there are many, and more are being published. See -the python.org wiki at http://wiki.python.org/moin/PythonBooks for a list. +Yes, there are many, and more are being published. See the python.org wiki at +http://wiki.python.org/moin/PythonBooks for a list. -You can also search online bookstores for "Python" -and filter out the Monty Python references; or -perhaps search for "Python" and "language". +You can also search online bookstores for "Python" and filter out the Monty +Python references; or perhaps search for "Python" and "language". Where in the world is www.python.org located? ------------------------------------------------------ +--------------------------------------------- It's currently in Amsterdam, graciously hosted by `XS4ALL -`_. Thanks to Thomas Wouters for his work in -arranging python.org's hosting. +`_. Thanks to Thomas Wouters for his work in arranging +python.org's hosting. -Why is it called Python? -------------------------------- -When he began implementing Python, Guido van Rossum was also reading -the published scripts from `"Monty Python's Flying Circus" -`__, a BBC comedy series from the 1970s. Van -Rossum thought he needed a name that was short, unique, and slightly -mysterious, so he decided to call the language Python. +Why is it called Python? +------------------------ +When he began implementing Python, Guido van Rossum was also reading the +published scripts from `"Monty Python's Flying Circus" +`__, a BBC comedy series from the 1970s. Van Rossum +thought he needed a name that was short, unique, and slightly mysterious, so he +decided to call the language Python. Do I have to like "Monty Python's Flying Circus"? -------------------------------------------------------------------- +------------------------------------------------- No, but it helps. :) Python in the real world -============================ +======================== How stable is Python? ----------------------------- +--------------------- -Very stable. New, stable releases have been coming out roughly every -6 to 18 months since 1991, and this seems likely to continue. -Currently there are usually around 18 months between major releases. - -The developers issue "bugfix" releases of older versions, so the -stability of existing releases gradually improves. Bugfix releases, -indicated by a third component of the version number (e.g. 2.5.3, -2.6.2), are managed for stability; only fixes for known problems are -included in a bugfix release, and it's guaranteed that interfaces will -remain the same throughout a series of bugfix releases. +Very stable. New, stable releases have been coming out roughly every 6 to 18 +months since 1991, and this seems likely to continue. Currently there are +usually around 18 months between major releases. + +The developers issue "bugfix" releases of older versions, so the stability of +existing releases gradually improves. Bugfix releases, indicated by a third +component of the version number (e.g. 2.5.3, 2.6.2), are managed for stability; +only fixes for known problems are included in a bugfix release, and it's +guaranteed that interfaces will remain the same throughout a series of bugfix +releases. The `2.6.2 release `_ is recommended production-ready version at this point in time. Python 3.1 is also considered production-ready, but may be @@ -316,175 +314,168 @@ How many people are using Python? ----------------------------------------- +--------------------------------- -There are probably tens of thousands of users, though it's difficult -to obtain an exact count. +There are probably tens of thousands of users, though it's difficult to obtain +an exact count. -Python is available for free download, so there are no sales figures, -and it's available from many different sites and packaged with many -Linux distributions, so download statistics don't tell the whole story -either. +Python is available for free download, so there are no sales figures, and it's +available from many different sites and packaged with many Linux distributions, +so download statistics don't tell the whole story either. + +The comp.lang.python newsgroup is very active, but not all Python users post to +the group or even read it. -The comp.lang.python newsgroup is very active, but not all Python -users post to the group or even read it. Have any significant projects been done in Python? ---------------------------------------------------------- +-------------------------------------------------- -See http://python.org/about/success for a list of projects that -use Python. Consulting the proceedings for `past Python conferences -`_ will reveal contributions from -many different companies and organizations. +See http://python.org/about/success for a list of projects that use Python. +Consulting the proceedings for `past Python conferences +`_ will reveal contributions from many +different companies and organizations. High-profile Python projects include `the Mailman mailing list manager `_ and `the Zope application server -`_. Several Linux distributions, most -notably `Red Hat `_, have written part or all -of their installer and system administration software in Python. Companies -that use Python internally include Google, -Yahoo, and Lucasfilm Ltd. +`_. Several Linux distributions, most notably `Red Hat +`_, have written part or all of their installer and +system administration software in Python. Companies that use Python internally +include Google, Yahoo, and Lucasfilm Ltd. What new developments are expected for Python in the future? -------------------------------------------------------------------- +------------------------------------------------------------ See http://www.python.org/dev/peps/ for the Python Enhancement Proposals -(PEPs). PEPs are design documents describing a suggested new feature -for Python, providing a concise technical specification and a -rationale. Look for a PEP titled "Python X.Y Release Schedule", -where X.Y is a version that hasn't been publicly released yet. +(PEPs). PEPs are design documents describing a suggested new feature for Python, +providing a concise technical specification and a rationale. Look for a PEP +titled "Python X.Y Release Schedule", where X.Y is a version that hasn't been +publicly released yet. -New development is discussed on `the python-dev mailing list `_. +New development is discussed on `the python-dev mailing list +`_. Is it reasonable to propose incompatible changes to Python? ------------------------------------------------------------------- +----------------------------------------------------------- + +In general, no. There are already millions of lines of Python code around the +world, so any change in the language that invalidates more than a very small +fraction of existing programs has to be frowned upon. Even if you can provide a +conversion program, there's still the problem of updating all documentation; +many books have been written about Python, and we don't want to invalidate them +all at a single stroke. + +Providing a gradual upgrade path is necessary if a feature has to be changed. +`PEP 5 `_ describes the procedure followed +for introducing backward-incompatible changes while minimizing disruption for +users. -In general, no. There are already millions of lines of Python code -around the world, so any change in the language that invalidates more -than a very small fraction of existing programs has to be frowned -upon. Even if you can provide a conversion program, there's still -the problem of updating all documentation; many books have been -written about Python, and we don't want to invalidate them all at a -single stroke. - -Providing a gradual upgrade path is necessary if a feature has to be -changed. `PEP 5 `_ -describes the procedure followed for introducing backward-incompatible -changes while minimizing disruption for users. Is Python Y2K (Year 2000) Compliant? --------------------------------------------- +------------------------------------ .. remove this question? -As of August, 2003 no major problems have been reported and Y2K -compliance seems to be a non-issue. +As of August, 2003 no major problems have been reported and Y2K compliance seems +to be a non-issue. -Python does very few date calculations and for those it does perform relies -on the C library functions. Python generally represents times either -as seconds since 1970 or as a ``(year, month, day, ...)`` tuple where the -year is expressed with four digits, which makes Y2K bugs unlikely. So -as long as your C library is okay, Python should be okay. Of course, -it's possible that a particular application written in Python -makes assumptions about 2-digit years. - -Because Python is available free of charge, there are no absolute -guarantees. If there *are* unforeseen problems, liability is the -user's problem rather than the developers', and there is nobody you can sue -for damages. The Python copyright notice contains the following -disclaimer: +Python does very few date calculations and for those it does perform relies on +the C library functions. Python generally represents times either as seconds +since 1970 or as a ``(year, month, day, ...)`` tuple where the year is expressed +with four digits, which makes Y2K bugs unlikely. So as long as your C library +is okay, Python should be okay. Of course, it's possible that a particular +application written in Python makes assumptions about 2-digit years. + +Because Python is available free of charge, there are no absolute guarantees. +If there *are* unforeseen problems, liability is the user's problem rather than +the developers', and there is nobody you can sue for damages. The Python +copyright notice contains the following disclaimer: 4. PSF is making Python 2.3 available to Licensee on an "AS IS" - basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR - IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND - DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS - FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT - INFRINGE ANY THIRD PARTY RIGHTS. + basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY + WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY + REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR + PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT INFRINGE ANY THIRD PARTY + RIGHTS. 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. -The good news is that *if* you encounter a problem, you have full -source available to track it down and fix it. This is one advantage of -an open source programming environment. +The good news is that *if* you encounter a problem, you have full source +available to track it down and fix it. This is one advantage of an open source +programming environment. Is Python a good language for beginning programmers? ------------------------------------------------------------------------ +---------------------------------------------------- -Yes. +Yes. -It is still common to start students with a procedural and -statically typed language such as Pascal, C, or a subset of C++ or -Java. Students may be better served by learning Python as their first -language. Python has a very simple and consistent syntax and a large -standard library and, most importantly, using Python in a beginning -programming course lets students concentrate on important -programming skills such as problem decomposition and data type design. -With Python, students can be quickly introduced to basic concepts such -as loops and procedures. They can probably even work with -user-defined objects in their very first course. - -For a student who has never programmed before, using a statically -typed language seems unnatural. It presents additional complexity -that the student must master and slows the pace of the course. The -students are trying to learn to think like a computer, decompose -problems, design consistent interfaces, and encapsulate data. While -learning to use a statically typed language is important in the long -term, it is not necessarily the best topic to address in the students' -first programming course. - -Many other aspects of Python make it a good first language. -Like Java, Python has a large standard library so that -students can be assigned programming projects very early in the -course that *do* something. Assignments aren't restricted to the -standard four-function calculator and check balancing programs. -By using the standard library, students can gain the satisfaction -of working on realistic applications as they learn the fundamentals -of programming. Using the standard library also teaches students -about code reuse. Third-party modules such as PyGame are also helpful in -extending the students' reach. - -Python's interactive interpreter enables students to -test language features while they're programming. They can keep -a window with the interpreter running while they enter their -program's source in another window. If they can't remember the -methods for a list, they can do something like this:: - - >>> L = [] - >>> dir(L) - ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', - 'reverse', 'sort'] - >>> help(L.append) - Help on built-in function append: - - append(...) - L.append(object) -- append object to end - >>> L.append(1) - >>> L - [1] - -With the interpreter, documentation is never far from the -student as he's programming. - -There are also good IDEs for Python. IDLE is a cross-platform IDE for -Python that is written in Python using Tkinter. PythonWin is a -Windows-specific IDE. Emacs users will be happy to know that there is -a very good Python mode for Emacs. All of these programming -environments provide syntax highlighting, auto-indenting, and access -to the interactive interpreter while coding. Consult -http://www.python.org/editors/ for a full list of Python editing -environments. +It is still common to start students with a procedural and statically typed +language such as Pascal, C, or a subset of C++ or Java. Students may be better +served by learning Python as their first language. Python has a very simple and +consistent syntax and a large standard library and, most importantly, using +Python in a beginning programming course lets students concentrate on important +programming skills such as problem decomposition and data type design. With +Python, students can be quickly introduced to basic concepts such as loops and +procedures. They can probably even work with user-defined objects in their very +first course. + +For a student who has never programmed before, using a statically typed language +seems unnatural. It presents additional complexity that the student must master +and slows the pace of the course. The students are trying to learn to think +like a computer, decompose problems, design consistent interfaces, and +encapsulate data. While learning to use a statically typed language is +important in the long term, it is not necessarily the best topic to address in +the students' first programming course. + +Many other aspects of Python make it a good first language. Like Java, Python +has a large standard library so that students can be assigned programming +projects very early in the course that *do* something. Assignments aren't +restricted to the standard four-function calculator and check balancing +programs. By using the standard library, students can gain the satisfaction of +working on realistic applications as they learn the fundamentals of programming. +Using the standard library also teaches students about code reuse. Third-party +modules such as PyGame are also helpful in extending the students' reach. + +Python's interactive interpreter enables students to test language features +while they're programming. They can keep a window with the interpreter running +while they enter their program's source in another window. If they can't +remember the methods for a list, they can do something like this:: + + >>> L = [] + >>> dir(L) + ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', + 'reverse', 'sort'] + >>> help(L.append) + Help on built-in function append: + + append(...) + L.append(object) -- append object to end + >>> L.append(1) + >>> L + [1] + +With the interpreter, documentation is never far from the student as he's +programming. + +There are also good IDEs for Python. IDLE is a cross-platform IDE for Python +that is written in Python using Tkinter. PythonWin is a Windows-specific IDE. +Emacs users will be happy to know that there is a very good Python mode for +Emacs. All of these programming environments provide syntax highlighting, +auto-indenting, and access to the interactive interpreter while coding. Consult +http://www.python.org/editors/ for a full list of Python editing environments. + +If you want to discuss Python's use in education, you may be interested in +joining `the edu-sig mailing list +`_. -If you want to discuss Python's use in education, you may -be interested in joining `the edu-sig mailing list `_. Upgrading Python -===================== +================ What is this bsddb185 module my application keeps complaining about? -------------------------------------------------------------------- @@ -493,27 +484,26 @@ Starting with Python2.3, the distribution includes the `PyBSDDB package ` as a replacement for the old bsddb module. It -includes functions which provide backward compatibility at the API level, -but requires a newer version of the underlying `Berkeley DB -`_ library. Files created with the older bsddb -module can't be opened directly using the new module. - -Using your old version of Python and a pair of scripts which are part of -Python 2.3 (db2pickle.py and pickle2db.py, in the Tools/scripts directory) -you can convert your old database files to the new format. Using your old -Python version, run the db2pickle.py script to convert it to a pickle, -e.g.:: +includes functions which provide backward compatibility at the API level, but +requires a newer version of the underlying `Berkeley DB +`_ library. Files created with the older bsddb module +can't be opened directly using the new module. + +Using your old version of Python and a pair of scripts which are part of Python +2.3 (db2pickle.py and pickle2db.py, in the Tools/scripts directory) you can +convert your old database files to the new format. Using your old Python +version, run the db2pickle.py script to convert it to a pickle, e.g.:: - python2.2 /db2pickley.py database.db database.pck + python2.2 /db2pickley.py database.db database.pck Rename your database file:: - mv database.db olddatabase.db + mv database.db olddatabase.db Now convert the pickle file to a new format database:: - python2.3 /pickle2db.py database.db database.pck + python /pickle2db.py database.db database.pck The precise commands you use will vary depending on the particulars of your -installation. For full details about operation of these two scripts check -the doc string at the start of each one. +installation. For full details about operation of these two scripts check the +doc string at the start of each one. Modified: sandbox/trunk/faq/gui.rst ============================================================================== --- sandbox/trunk/faq/gui.rst (original) +++ sandbox/trunk/faq/gui.rst Sun Oct 11 20:12:15 2009 @@ -1,166 +1,160 @@ +:tocdepth: 2 -==================================== +========================== Graphic User Interface FAQ -==================================== +========================== .. contents:: General GUI Questions -============================ +===================== What platform-independent GUI toolkits exist for Python? ----------------------------------------------------------------- +-------------------------------------------------------- + Depending on what platform(s) you are aiming at, there are several. +.. XXX check links + Tkinter -'''''''''''' +''''''' -Standard builds of Python include an object-oriented interface to the -Tcl/Tk widget set, called Tkinter. This is probably the easiest to -install and use. For more info about Tk, including pointers to the -source, see the Tcl/Tk home page at http://www.tcl.tk. Tcl/Tk is -fully portable to the MacOS, Windows, and Unix platforms. +Standard builds of Python include an object-oriented interface to the Tcl/Tk +widget set, called Tkinter. This is probably the easiest to install and use. +For more info about Tk, including pointers to the source, see the Tcl/Tk home +page at http://www.tcl.tk. Tcl/Tk is fully portable to the MacOS, Windows, and +Unix platforms. wxWindows -''''''''''''' - - -wxWindows is a portable GUI class library written in C++ that's a -portable interface to various platform-specific libraries; wxWidgets is -a Python interface to wxWindows. wxWindows supports Windows and MacOS; -on Unix variants, it supports both GTk+ and Motif toolkits. -wxWindows preserves the look and feel of the underlying graphics -toolkit, and there is quite a rich widget set and collection of GDI -classes. See `the wxWindows page `_ for more -details. - -`wxWidgets `_ is an extension module that -wraps many of the wxWindows C++ classes, and is quickly gaining -popularity amongst Python developers. You can get wxWidgets as part of -the source or CVS distribution of wxWindows, or directly from its home -page. +''''''''' +wxWindows is a portable GUI class library written in C++ that's a portable +interface to various platform-specific libraries; wxWidgets is a Python +interface to wxWindows. wxWindows supports Windows and MacOS; on Unix variants, +it supports both GTk+ and Motif toolkits. wxWindows preserves the look and feel +of the underlying graphics toolkit, and there is quite a rich widget set and +collection of GDI classes. See `the wxWindows page `_ +for more details. + +`wxWidgets `_ is an extension module that wraps many of +the wxWindows C++ classes, and is quickly gaining popularity amongst Python +developers. You can get wxWidgets as part of the source or CVS distribution of +wxWindows, or directly from its home page. Qt -'''''' +''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). -If you're writing open source software, you don't need to pay for -PyQt, but if you want to write proprietary applications, you must buy -a PyQt license from `Riverbank Computing -`_ and a Qt license from +`_) and for KDE (PyKDE). If you're +writing open source software, you don't need to pay for PyQt, but if you want to +write proprietary applications, you must buy a PyQt license from `Riverbank +Computing `_ and a Qt license from `Trolltech `_. -GTk+ -''''''''''' +Gtk+ +'''' -PyGTk bindings for the `GTk+ toolkit `_ have been -implemented by by James Henstridge; see -ftp://ftp.gtk.org/pub/gtk/python/. +PyGtk bindings for the `Gtk+ toolkit `_ have been +implemented by by James Henstridge; see ftp://ftp.gtk.org/pub/gtk/python/. FLTK -''''''''''' +'''' -Python bindings for `the FLTK toolkit `_, a simple yet powerful -and mature cross-platform windowing system, are available from `the +Python bindings for `the FLTK toolkit `_, a simple yet +powerful and mature cross-platform windowing system, are available from `the PyFLTK project `_. FOX -''''''''''' +''' -A wrapper for `the FOX toolkit `_ -called `FXpy `_ is available. -FOX supports both Unix variants and Windows. +A wrapper for `the FOX toolkit `_ called `FXpy +`_ is available. FOX supports both Unix variants +and Windows. OpenGL -''''''''''''' +'''''' For OpenGL bindings, see `PyOpenGL `_. What platform-specific GUI toolkits exist for Python? ----------------------------------------------------------------- +----------------------------------------------------- -`The Mac port `_ by -Jack Jansen has a rich and ever-growing set of modules that support -the native Mac toolbox calls. The port includes support for MacOS9 -and MacOS X's Carbon libraries. By installing the `PyObjc Objective-C -bridge `_, Python programs can use -MacOS X's Cocoa libraries. See the documentation that comes with the -Mac port. - -`Pythonwin <../windows/>`_ by Mark Hammond -includes an interface to the Microsoft Foundation -Classes and a Python programming environment using it that's written -mostly in Python. +`The Mac port `_ by Jack Jansen has a rich and +ever-growing set of modules that support the native Mac toolbox calls. The port +includes support for MacOS9 and MacOS X's Carbon libraries. By installing the +`PyObjc Objective-C bridge `_, Python programs +can use MacOS X's Cocoa libraries. See the documentation that comes with the Mac +port. + +`Pythonwin `_ by Mark Hammond includes an +interface to the Microsoft Foundation Classes and a Python programming +environment using it that's written mostly in Python. Tkinter questions -===================== +================= How do I freeze Tkinter applications? ---------------------------------------------- +------------------------------------- -Freeze is a tool to create stand-alone applications. When freezing -Tkinter applications, the applications will not be truly stand-alone, -as the application will still need the Tcl and Tk libraries. +Freeze is a tool to create stand-alone applications. When freezing Tkinter +applications, the applications will not be truly stand-alone, as the application +will still need the Tcl and Tk libraries. -One solution is to ship the application with the tcl and tk libraries, -and point to them at run-time using the TCL_LIBRARY and TK_LIBRARY +One solution is to ship the application with the tcl and tk libraries, and point +to them at run-time using the :envvar:`TCL_LIBRARY` and :envvar:`TK_LIBRARY` environment variables. -To get truly stand-alone applications, the Tcl scripts that form -the library have to be integrated into the application as well. One -tool supporting that is SAM (stand-alone modules), which is part -of the Tix distribution (http://tix.mne.com). Build Tix with SAM -enabled, perform the appropriate call to Tclsam_init etc inside -Python's Modules/tkappinit.c, and link with libtclsam +To get truly stand-alone applications, the Tcl scripts that form the library +have to be integrated into the application as well. One tool supporting that is +SAM (stand-alone modules), which is part of the Tix distribution +(http://tix.mne.com). Build Tix with SAM enabled, perform the appropriate call +to Tclsam_init etc inside Python's Modules/tkappinit.c, and link with libtclsam and libtksam (you might include the Tix libraries as well). Can I have Tk events handled while waiting for I/O? ------------------------------------------------------------ -Yes, and you don't even need threads! But you'll have to -restructure your I/O code a bit. Tk has the equivalent of Xt's -XtAddInput() call, which allows you to register a callback function -which will be called from the Tk mainloop when I/O is possible on a -file descriptor. Here's what you need:: - - from Tkinter import tkinter - tkinter.createfilehandler(file, mask, callback) - -The file may be a Python file or socket object (actually, anything -with a fileno() method), or an integer file descriptor. The mask is -one of the constants tkinter.READABLE or tkinter.WRITABLE. The -callback is called as follows:: +--------------------------------------------------- + +Yes, and you don't even need threads! But you'll have to restructure your I/O +code a bit. Tk has the equivalent of Xt's XtAddInput() call, which allows you +to register a callback function which will be called from the Tk mainloop when +I/O is possible on a file descriptor. Here's what you need:: + + from Tkinter import tkinter + tkinter.createfilehandler(file, mask, callback) + +The file may be a Python file or socket object (actually, anything with a +fileno() method), or an integer file descriptor. The mask is one of the +constants tkinter.READABLE or tkinter.WRITABLE. The callback is called as +follows:: - callback(file, mask) + callback(file, mask) You must unregister the callback when you're done, using :: - tkinter.deletefilehandler(file) + tkinter.deletefilehandler(file) -Note: since you don't know *how many bytes* are available for reading, -you can't use the Python file object's read or readline methods, since -these will insist on reading a predefined number of bytes. For -sockets, the recv() or recvfrom() methods will work fine; for other -files, use os.read(file.fileno(), maxbytecount). +Note: since you don't know *how many bytes* are available for reading, you can't +use the Python file object's read or readline methods, since these will insist +on reading a predefined number of bytes. For sockets, the :meth:`recv` or +:meth:`recvfrom` methods will work fine; for other files, use +``os.read(file.fileno(), maxbytecount)``. I can't get key bindings to work in Tkinter: why? ---------------------------------------------------- -An often-heard complaint is that event handlers bound to events -with the bind() method don't get handled even when the appropriate -key is pressed. - -The most common cause is that the widget to which the binding applies -doesn't have "keyboard focus". Check out the Tk documentation -for the focus command. Usually a widget is given the keyboard -focus by clicking in it (but not for labels; see the takefocus -option). +------------------------------------------------- + +An often-heard complaint is that event handlers bound to events with the +:meth:`bind` method don't get handled even when the appropriate key is pressed. + +The most common cause is that the widget to which the binding applies doesn't +have "keyboard focus". Check out the Tk documentation for the focus command. +Usually a widget is given the keyboard focus by clicking in it (but not for +labels; see the takefocus option). Modified: sandbox/trunk/faq/index.rst ============================================================================== --- sandbox/trunk/faq/index.rst (original) +++ sandbox/trunk/faq/index.rst Sun Oct 11 20:12:15 2009 @@ -1,4 +1,3 @@ - ################################### Python Frequently Asked Questions ################################### Modified: sandbox/trunk/faq/installed.rst ============================================================================== --- sandbox/trunk/faq/installed.rst (original) +++ sandbox/trunk/faq/installed.rst Sun Oct 11 20:12:15 2009 @@ -1,59 +1,53 @@ - -===================================================== +============================================= "Why is Python Installed on my Computer?" FAQ -===================================================== +============================================= What is Python? ----------------------- +--------------- -Python is a programming language. It's used for many different -applications. It's used in some high schools and colleges as an -introductory programming language because Python is easy to learn, but -it's also used by professional software developers at places such as Google, -NASA, and Lucasfilm Ltd. +Python is a programming language. It's used for many different applications. +It's used in some high schools and colleges as an introductory programming +language because Python is easy to learn, but it's also used by professional +software developers at places such as Google, NASA, and Lucasfilm Ltd. -If you wish to learn more about Python, start with the -`Beginner's Guide to Python `_. +If you wish to learn more about Python, start with the `Beginner's Guide to +Python `_. Why is Python installed on my machine? --------------------------------------------------- +-------------------------------------- + +If you find Python installed on your system but don't remember installing it, +there are several possible ways it could have gotten there. -If you find Python installed on your system but don't remember -installing it, there are several possible ways it could have gotten -there. - -* Perhaps another user on the computer wanted to learn programming - and installed it; you'll have to figure out who's been using the machine - and might have installed it. -* A third-party application installed on the machine might have been written - in Python and included a Python installation. For a home computer, - the most common such application is - `PySol `_, - a solitaire game that includes over 1000 different games and variations. -* Some Windows machines also have Python installed. At this writing we're - aware of computers from Hewlett-Packard and Compaq that include Python. - Apparently some of HP/Compaq's administrative tools are written in Python. -* All Apple computers running Mac OS X have Python installed; it's included - in the base installation. +* Perhaps another user on the computer wanted to learn programming and installed + it; you'll have to figure out who's been using the machine and might have + installed it. +* A third-party application installed on the machine might have been written in + Python and included a Python installation. For a home computer, the most + common such application is `PySol `_, a + solitaire game that includes over 1000 different games and variations. +* Some Windows machines also have Python installed. At this writing we're aware + of computers from Hewlett-Packard and Compaq that include Python. Apparently + some of HP/Compaq's administrative tools are written in Python. +* All Apple computers running Mac OS X have Python installed; it's included in + the base installation. Can I delete Python? ----------------------------- +-------------------- That depends on where Python came from. -If someone installed it deliberately, you can remove it without -hurting anything. On Windows, use the Add/Remove Programs icon in the -Control Panel. - -If Python was installed by a third-party application, you can also -remove it, but that application will no longer work. You should -use that application's uninstaller rather than removing Python directly. - -If Python came with your operating system, removing it is not -recommended. If you remove it, whatever tools were written in Python -will no longer run, and some of them might be important to you. -Reinstalling the whole system would then be required to fix things -again. +If someone installed it deliberately, you can remove it without hurting +anything. On Windows, use the Add/Remove Programs icon in the Control Panel. + +If Python was installed by a third-party application, you can also remove it, +but that application will no longer work. You should use that application's +uninstaller rather than removing Python directly. + +If Python came with your operating system, removing it is not recommended. If +you remove it, whatever tools were written in Python will no longer run, and +some of them might be important to you. Reinstalling the whole system would +then be required to fix things again. Modified: sandbox/trunk/faq/library.rst ============================================================================== --- sandbox/trunk/faq/library.rst (original) +++ sandbox/trunk/faq/library.rst Sun Oct 11 20:12:15 2009 @@ -1,658 +1,642 @@ +:tocdepth: 2 -==================================== +========================= Library and Extension FAQ -==================================== +========================= .. contents:: General Library Questions -=============================== +========================= How do I find a module or application to perform task X? -------------------------------------------------------------- +-------------------------------------------------------- -Check `the Library Reference `_ to see -if there's a relevant standard library module. (Eventually you'll -learn what's in the standard library and will able to skip this step.) +Check :ref:`the Library Reference ` to see if there's a relevant +standard library module. (Eventually you'll learn what's in the standard +library and will able to skip this step.) Search the `Python Package Index `_. -Next, check the `Vaults of Parnassus `_, -an older index of packages. +Next, check the `Vaults of Parnassus `_, an older +index of packages. -Finally, try `Google `_ or other Web search -engine. Searching for "Python" plus a keyword or two for your topic -of interest will usually find something helpful. +Finally, try `Google `_ or other Web search engine. +Searching for "Python" plus a keyword or two for your topic of interest will +usually find something helpful. Where is the math.py (socket.py, regex.py, etc.) source file? ---------------------------------------------------------------------- -If you can't find a source file for a module it may be a builtin -or dynamically loaded module implemented in C, C++ or other -compiled language. In this case you may not have the source -file or it may be something like mathmodule.c, somewhere in -a C source directory (not on the Python Path). +------------------------------------------------------------- + +If you can't find a source file for a module it may be a builtin or dynamically +loaded module implemented in C, C++ or other compiled language. In this case +you may not have the source file or it may be something like mathmodule.c, +somewhere in a C source directory (not on the Python Path). There are (at least) three kinds of modules in Python: 1) modules written in Python (.py); 2) modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc); -3) modules written in C and linked with the interpreter; to get a list - of these, type:: +3) modules written in C and linked with the interpreter; to get a list of these, + type:: + + import sys + print sys.builtin_module_names - import sys - print sys.builtin_module_names How do I make a Python script executable on Unix? ---------------------------------------------------------- +------------------------------------------------- -You need to do two things: the script file's mode must be executable -and the first line must begin with ``#!`` followed by the path of -the Python interpreter. +You need to do two things: the script file's mode must be executable and the +first line must begin with ``#!`` followed by the path of the Python +interpreter. -The first is done by executing ``chmod +x scriptfile`` or perhaps -``chmod 755 scriptfile``. +The first is done by executing ``chmod +x scriptfile`` or perhaps ``chmod 755 +scriptfile``. -The second can be done in a number of ways. The most straightforward -way is to write :: +The second can be done in a number of ways. The most straightforward way is to +write :: #!/usr/local/bin/python -as the very first line of your file, using the pathname for where the -Python interpreter is installed on your platform. +as the very first line of your file, using the pathname for where the Python +interpreter is installed on your platform. -If you would like the script to be independent of where the Python -interpreter lives, you can use the "env" program. Almost all -Unix variants support the following, assuming the python interpreter -is in a directory on the user's $PATH:: - - #! /usr/bin/env python - -*Don't* do this for CGI scripts. The $PATH variable for -CGI scripts is often very minimal, so you need to use the actual -absolute pathname of the interpreter. - -Occasionally, a user's environment is so full that the /usr/bin/env -program fails; or there's no env program at all. -In that case, you can try the following hack (due to Alex Rezinsky):: - - #! /bin/sh - """:" - exec python $0 ${1+"$@"} - """ +If you would like the script to be independent of where the Python interpreter +lives, you can use the "env" program. Almost all Unix variants support the +following, assuming the python interpreter is in a directory on the user's +$PATH:: + + #!/usr/bin/env python + +*Don't* do this for CGI scripts. The $PATH variable for CGI scripts is often +very minimal, so you need to use the actual absolute pathname of the +interpreter. + +Occasionally, a user's environment is so full that the /usr/bin/env program +fails; or there's no env program at all. In that case, you can try the +following hack (due to Alex Rezinsky):: + + #! /bin/sh + """:" + exec python $0 ${1+"$@"} + """ The minor disadvantage is that this defines the script's __doc__ string. However, you can fix that by adding :: - __doc__ = """...Whatever...""" + __doc__ = """...Whatever...""" Is there a curses/termcap package for Python? ----------------------------------------------------- +--------------------------------------------- -For Unix variants: The standard Python source distribution comes with -a curses module in the Modules/ subdirectory, though it's not compiled -by default (note that this is not available in the Windows -distribution -- there is no curses module for Windows). - -The curses module supports basic curses features as well as many -additional functions from ncurses and SYSV curses such as colour, -alternative character set support, pads, and mouse support. This means -the module isn't compatible with operating systems that only -have BSD curses, but there don't seem to be any currently maintained -OSes that fall into this category. +.. XXX curses *is* built by default, isn't it? -For Windows: use `the consolelib module `_. +For Unix variants: The standard Python source distribution comes with a curses +module in the ``Modules/`` subdirectory, though it's not compiled by default +(note that this is not available in the Windows distribution -- there is no +curses module for Windows). + +The curses module supports basic curses features as well as many additional +functions from ncurses and SYSV curses such as colour, alternative character set +support, pads, and mouse support. This means the module isn't compatible with +operating systems that only have BSD curses, but there don't seem to be any +currently maintained OSes that fall into this category. +For Windows: use `the consolelib module +`_. -Is there an equivalent to C's onexit() in Python? --------------------------------------------------------- -`The atexit module -`_ provides a -register function that is similar to C's onexit. - -Why don't my signal handlers work? --------------------------------------------- -The most common problem is that the signal handler is declared -with the wrong argument list. It is called as :: +Is there an equivalent to C's onexit() in Python? +------------------------------------------------- - handler(signum, frame) +The :mod:`atexit` module provides a register function that is similar to C's +onexit. -so it should be declared with two arguments:: - def handler(signum, frame): - ... +Why don't my signal handlers work? +---------------------------------- +The most common problem is that the signal handler is declared with the wrong +argument list. It is called as :: + handler(signum, frame) +so it should be declared with two arguments:: + def handler(signum, frame): + ... Common tasks -================= +============ How do I test a Python program or component? ----------------------------------------------------- +-------------------------------------------- -Python comes with two testing frameworks. The `doctest module -`_ finds examples -in the docstrings for a module and runs them, comparing the output -with the expected output given in the docstring. - -The `unittest module -`_ is a fancier -testing framework modelled on Java and Smalltalk testing frameworks. - -For testing, it helps to write the program so that it may be easily -tested by using good modular design. Your program should have almost -all functionality encapsulated in either functions or class methods -- -and this sometimes has the surprising and delightful effect of making -the program run faster (because local variable accesses are faster -than global accesses). Furthermore the program should avoid depending -on mutating global variables, since this makes testing much more -difficult to do. +Python comes with two testing frameworks. The :mod:`doctest` module finds +examples in the docstrings for a module and runs them, comparing the output with +the expected output given in the docstring. + +The :mod:`unittest` module is a fancier testing framework modelled on Java and +Smalltalk testing frameworks. + +For testing, it helps to write the program so that it may be easily tested by +using good modular design. Your program should have almost all functionality +encapsulated in either functions or class methods -- and this sometimes has the +surprising and delightful effect of making the program run faster (because local +variable accesses are faster than global accesses). Furthermore the program +should avoid depending on mutating global variables, since this makes testing +much more difficult to do. -The "global main logic" of your program may be as simple -as :: +The "global main logic" of your program may be as simple as :: - if __name__=="__main__": + if __name__ == "__main__": main_logic() at the bottom of the main module of your program. -Once your program is organized as a tractable collection -of functions and class behaviours you should write test -functions that exercise the behaviours. A test suite -can be associated with each module which automates -a sequence of tests. This sounds like a lot of work, but -since Python is so terse and flexible it's surprisingly easy. -You can make coding much more pleasant and fun by -writing your test functions in parallel with the "production -code", since this makes it easy to find bugs and even -design flaws earlier. +Once your program is organized as a tractable collection of functions and class +behaviours you should write test functions that exercise the behaviours. A test +suite can be associated with each module which automates a sequence of tests. +This sounds like a lot of work, but since Python is so terse and flexible it's +surprisingly easy. You can make coding much more pleasant and fun by writing +your test functions in parallel with the "production code", since this makes it +easy to find bugs and even design flaws earlier. -"Support modules" that are not intended to be the main module of a -program may include a self-test of the module. :: +"Support modules" that are not intended to be the main module of a program may +include a self-test of the module. :: if __name__ == "__main__": - self_test() + self_test() + +Even programs that interact with complex external interfaces may be tested when +the external interfaces are unavailable by using "fake" interfaces implemented +in Python. -Even programs that interact with complex external interfaces may be -tested when the external interfaces are unavailable by using "fake" -interfaces implemented in Python. How do I create documentation from doc strings? -------------------------------------------------------- +----------------------------------------------- -The `pydoc module `_ -can create HTML from the doc strings in your Python source code. An -alternative is `pythondoc +.. XXX mention Sphinx/epydoc + +The :mod:`pydoc` module can create HTML from the doc strings in your Python +source code. An alternative is `pythondoc `_. How do I get a single keypress at a time? ------------------------------------------------ +----------------------------------------- -For Unix variants:There are several solutions. -It's straightforward to do this using curses, but curses is a -fairly large module to learn. Here's a solution without curses:: - - import termios, fcntl, sys, os - fd = sys.stdin.fileno() - - oldterm = termios.tcgetattr(fd) - newattr = termios.tcgetattr(fd) - newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO - termios.tcsetattr(fd, termios.TCSANOW, newattr) - - oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) - fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) - - try: - while 1: - try: - c = sys.stdin.read(1) - print "Got character", `c` - except IOError: pass - finally: - termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) - fcntl.fcntl(fd, fcntl.F_SETFL, oldflags) - -You need the ``termios`` and the ``fcntl`` module for any of this to work, -and I've only tried it on Linux, though it should work elsewhere. -In this code, characters are read and printed one at a time. - -``termios.tcsetattr()`` turns off stdin's echoing and disables canonical -mode. ``fcntl.fnctl()`` is used to obtain stdin's file descriptor flags -and modify them for non-blocking mode. Since reading stdin when it is -empty results in an ``IOError``, this error is caught and ignored. +For Unix variants: There are several solutions. It's straightforward to do this +using curses, but curses is a fairly large module to learn. Here's a solution +without curses:: + + import termios, fcntl, sys, os + fd = sys.stdin.fileno() + + oldterm = termios.tcgetattr(fd) + newattr = termios.tcgetattr(fd) + newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO + termios.tcsetattr(fd, termios.TCSANOW, newattr) + + oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) + fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) + + try: + while 1: + try: + c = sys.stdin.read(1) + print "Got character", `c` + except IOError: pass + finally: + termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) + fcntl.fcntl(fd, fcntl.F_SETFL, oldflags) + +You need the :mod:`termios` and the :mod:`fcntl` module for any of this to work, +and I've only tried it on Linux, though it should work elsewhere. In this code, +characters are read and printed one at a time. + +:func:`termios.tcsetattr` turns off stdin's echoing and disables canonical mode. +:func:`fcntl.fnctl` is used to obtain stdin's file descriptor flags and modify +them for non-blocking mode. Since reading stdin when it is empty results in an +:exc:`IOError`, this error is caught and ignored. Threads -============= +======= How do I program using threads? ---------------------------------- +------------------------------- -Be sure to use `the threading module -`_ and not the -``thread`` module. The ``threading`` module builds convenient -abstractions on top of the low-level primitives provided by the -``thread`` module. +.. XXX it's _thread in py3k -Aahz has a set of slides from his threading tutorial that are helpful; -see http://starship.python.net/crew/aahz/OSCON2001/. +Be sure to use the :mod:`threading` module and not the :mod:`thread` module. +The :mod:`threading` module builds convenient abstractions on top of the +low-level primitives provided by the :mod:`thread` module. +Aahz has a set of slides from his threading tutorial that are helpful; see +http://starship.python.net/crew/aahz/OSCON2001/. -None of my threads seem to run: why? -------------------------------------------- -As soon as the main thread exits, all threads are killed. Your main -thread is running too quickly, giving the threads no time to do any work. +None of my threads seem to run: why? +------------------------------------ -A simple fix is to add a sleep to the end of the program -that's long enough for all the threads to finish:: +As soon as the main thread exits, all threads are killed. Your main thread is +running too quickly, giving the threads no time to do any work. - import threading, time +A simple fix is to add a sleep to the end of the program that's long enough for +all the threads to finish:: - def thread_task(name, n): - for i in range(n): print name, i + import threading, time - for i in range(10): - T = threading.Thread(target=thread_task, args=(str(i), i)) - T.start() + def thread_task(name, n): + for i in range(n): print name, i - time.sleep(10) # <----------------------------! + for i in range(10): + T = threading.Thread(target=thread_task, args=(str(i), i)) + T.start() -But now (on many platforms) the threads don't run in parallel, -but appear to run sequentially, one at a time! The reason is -that the OS thread scheduler doesn't start a new thread until -the previous thread is blocked. + time.sleep(10) # <----------------------------! -A simple fix is to add a tiny sleep to the start of the run -function:: +But now (on many platforms) the threads don't run in parallel, but appear to run +sequentially, one at a time! The reason is that the OS thread scheduler doesn't +start a new thread until the previous thread is blocked. - def thread_task(name, n): - time.sleep(0.001) # <---------------------! - for i in range(n): print name, i +A simple fix is to add a tiny sleep to the start of the run function:: - for i in range(10): - T = threading.Thread(target=thread_task, args=(str(i), i)) - T.start() + def thread_task(name, n): + time.sleep(0.001) # <---------------------! + for i in range(n): print name, i - time.sleep(10) + for i in range(10): + T = threading.Thread(target=thread_task, args=(str(i), i)) + T.start() -Instead of trying to guess how long a ``time.sleep()`` delay will be -enough, it's better to use some kind of semaphore mechanism. One idea -is to use the `Queue module -`_ to create a queue -object, let each thread append a token to the queue when it finishes, -and let the main thread read as many tokens from the queue as there -are threads. + time.sleep(10) +Instead of trying to guess how long a :func:`time.sleep` delay will be enough, +it's better to use some kind of semaphore mechanism. One idea is to use the +:mod:`Queue` module to create a queue object, let each thread append a token to +the queue when it finishes, and let the main thread read as many tokens from the +queue as there are threads. How do I parcel out work among a bunch of worker threads? ----------------------------------------------------------------- +--------------------------------------------------------- -Use the `Queue module -`_ to create a queue -containing a list of jobs. The ``Queue`` class maintains a list of -objects with ``.put(obj)`` to add an item to the queue and ``.get()`` -to return an item. The class will take care of the locking necessary -to ensure that each job is handed out exactly once. +Use the :mod:`Queue` module to create a queue containing a list of jobs. The +:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +add an item to the queue and ``.get()`` to return an item. The class will take +care of the locking necessary to ensure that each job is handed out exactly +once. Here's a trivial example:: - import threading, Queue, time + import threading, Queue, time - # The worker thread gets jobs off the queue. When the queue is empty, it - # assumes there will be no more work and exits. - # (Realistically workers will run until terminated.) - def worker (): - print 'Running worker' - time.sleep(0.1) - while True: - try: - arg = q.get(block=False) - except Queue.Empty: - print 'Worker', threading.currentThread(), - print 'queue empty' - break - else: - print 'Worker', threading.currentThread(), - print 'running with argument', arg - time.sleep(0.5) - - # Create queue - q = Queue.Queue() - - # Start a pool of 5 workers - for i in range(5): - t = threading.Thread(target=worker, name='worker %i' % (i+1)) - t.start() - - # Begin adding work to the queue - for i in range(50): - q.put(i) - - # Give threads time to run - print 'Main thread sleeping' - time.sleep(5) + # The worker thread gets jobs off the queue. When the queue is empty, it + # assumes there will be no more work and exits. + # (Realistically workers will run until terminated.) + def worker (): + print 'Running worker' + time.sleep(0.1) + while True: + try: + arg = q.get(block=False) + except Queue.Empty: + print 'Worker', threading.currentThread(), + print 'queue empty' + break + else: + print 'Worker', threading.currentThread(), + print 'running with argument', arg + time.sleep(0.5) + + # Create queue + q = Queue.Queue() + + # Start a pool of 5 workers + for i in range(5): + t = threading.Thread(target=worker, name='worker %i' % (i+1)) + t.start() + + # Begin adding work to the queue + for i in range(50): + q.put(i) + + # Give threads time to run + print 'Main thread sleeping' + time.sleep(5) When run, this will produce the following output: - Running worker - Running worker - Running worker - Running worker - Running worker - Main thread sleeping - Worker running with argument 0 - Worker running with argument 1 - Worker running with argument 2 - Worker running with argument 3 - Worker running with argument 4 - Worker running with argument 5 - ... + Running worker + Running worker + Running worker + Running worker + Running worker + Main thread sleeping + Worker running with argument 0 + Worker running with argument 1 + Worker running with argument 2 + Worker running with argument 3 + Worker running with argument 4 + Worker running with argument 5 + ... -Consult the module's documentation for more details; the ``Queue`` -class provides a featureful interface. +Consult the module's documentation for more details; the ``Queue`` class +provides a featureful interface. What kinds of global value mutation are thread-safe? ------------------------------------------------------------- +---------------------------------------------------- -A global interpreter lock (GIL) is used internally to ensure that only -one thread runs in the Python VM at a time. In general, Python offers -to switch among threads only between bytecode instructions; how -frequently it switches can be set via ``sys.setcheckinterval()``. -Each bytecode instruction and therefore all the C implementation code -reached from each instruction is therefore atomic from the point of view of a Python program. - -In theory, this means an exact accounting requires an exact -understanding of the PVM bytecode implementation. In practice, it -means that operations on shared variables of builtin data types (ints, -lists, dicts, etc) that "look atomic" really are. - -For example, the following operations are all atomic (L, L1, L2 are lists, D, D1, D2 are dicts, x, y -are objects, i, j are ints):: - - L.append(x) - L1.extend(L2) - x = L[i] - x = L.pop() - L1[i:j] = L2 - L.sort() - x = y - x.field = y - D[x] = y - D1.update(D2) - D.keys() +A global interpreter lock (GIL) is used internally to ensure that only one +thread runs in the Python VM at a time. In general, Python offers to switch +among threads only between bytecode instructions; how frequently it switches can +be set via :func:`sys.setcheckinterval`. Each bytecode instruction and +therefore all the C implementation code reached from each instruction is +therefore atomic from the point of view of a Python program. + +In theory, this means an exact accounting requires an exact understanding of the +PVM bytecode implementation. In practice, it means that operations on shared +variables of builtin data types (ints, lists, dicts, etc) that "look atomic" +really are. + +For example, the following operations are all atomic (L, L1, L2 are lists, D, +D1, D2 are dicts, x, y are objects, i, j are ints):: + + L.append(x) + L1.extend(L2) + x = L[i] + x = L.pop() + L1[i:j] = L2 + L.sort() + x = y + x.field = y + D[x] = y + D1.update(D2) + D.keys() These aren't:: - i = i+1 - L.append(L[-1]) - L[i] = L[j] - D[x] = D[x] + 1 - -Operations that replace other objects may invoke those other -objects' ``__del__`` method when their reference count reaches zero, and -that can affect things. This is especially true for the mass updates -to dictionaries and lists. When in doubt, use a mutex! + i = i+1 + L.append(L[-1]) + L[i] = L[j] + D[x] = D[x] + 1 + +Operations that replace other objects may invoke those other objects' +:meth:`__del__` method when their reference count reaches zero, and that can +affect things. This is especially true for the mass updates to dictionaries and +lists. When in doubt, use a mutex! + Can't we get rid of the Global Interpreter Lock? --------------------------------------------------------- +------------------------------------------------ + +.. XXX mention multiprocessing + +The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's +deployment on high-end multiprocessor server machines, because a multi-threaded +Python program effectively only uses one CPU, due to the insistence that +(almost) all Python code can only run while the GIL is held. + +Back in the days of Python 1.5, Greg Stein actually implemented a comprehensive +patch set (the "free threading" patches) that removed the GIL and replaced it +with fine-grained locking. Unfortunately, even on Windows (where locks are very +efficient) this ran ordinary Python code about twice as slow as the interpreter +using the GIL. On Linux the performance loss was even worse because pthread +locks aren't as efficient. + +Since then, the idea of getting rid of the GIL has occasionally come up but +nobody has found a way to deal with the expected slowdown, and users who don't +use threads would not be happy if their code ran at half at the speed. Greg's +free threading patch set has not been kept up-to-date for later Python versions. + +This doesn't mean that you can't make good use of Python on multi-CPU machines! +You just have to be creative with dividing the work up between multiple +*processes* rather than multiple *threads*. Judicious use of C extensions will +also help; if you use a C extension to perform a time-consuming task, the +extension can release the GIL while the thread of execution is in the C code and +allow other threads to get some work done. + +It has been suggested that the GIL should be a per-interpreter-state lock rather +than truly global; interpreters then wouldn't be able to share objects. +Unfortunately, this isn't likely to happen either. It would be a tremendous +amount of work, because many object implementations currently have global state. +For example, small integers and short strings are cached; these caches would +have to be moved to the interpreter state. Other object types have their own +free list; these free lists would have to be moved to the interpreter state. +And so on. + +And I doubt that it can even be done in finite time, because the same problem +exists for 3rd party extensions. It is likely that 3rd party extensions are +being written at a faster rate than you can convert them to store all their +global state in the interpreter state. -The Global Interpreter Lock (GIL) is often seen as a hindrance to -Python's deployment on high-end multiprocessor server machines, -because a multi-threaded Python program effectively only uses one CPU, -due to the insistence that (almost) all Python code can only run while -the GIL is held. - -Back in the days of Python 1.5, Greg Stein actually implemented a -comprehensive patch set (the "free threading" patches) that removed -the GIL and replaced it with fine-grained locking. Unfortunately, even -on Windows (where locks are very efficient) this ran ordinary Python -code about twice as slow as the interpreter using the GIL. On Linux -the performance loss was even worse because pthread locks aren't as -efficient. - -Since then, the idea of getting rid of the GIL has occasionally come -up but nobody has found a way to deal with the expected slowdown, and -users who don't use threads would not be happy if their code ran at -half at the speed. Greg's free threading patch set has not been kept -up-to-date for later Python versions. - -This doesn't mean that you can't make good use of Python on multi-CPU -machines! You just have to be creative with dividing the work up -between multiple *processes* rather than multiple *threads*. -Judicious use of C extensions will also help; if you use a C extension -to perform a time-consuming task, the extension can release the GIL -while the thread of execution is in the C code and allow other threads -to get some work done. - -It has been suggested that the GIL should be a per-interpreter-state -lock rather than truly global; interpreters then wouldn't be able to -share objects. Unfortunately, this isn't likely to happen either. It -would be a tremendous amount of work, because many object -implementations currently have global state. For example, small -integers and short strings are cached; these caches would have to be -moved to the interpreter state. Other object types have their own -free list; these free lists would have to be moved to the interpreter -state. And so on. - -And I doubt that it can even be done in finite time, because the same -problem exists for 3rd party extensions. It is likely that 3rd party -extensions are being written at a faster rate than you can convert -them to store all their global state in the interpreter state. - -And finally, once you have multiple interpreters not sharing any -state, what have you gained over running each interpreter -in a separate process? +And finally, once you have multiple interpreters not sharing any state, what +have you gained over running each interpreter in a separate process? Input and Output -========================= +================ How do I delete a file? (And other file questions...) ---------------------------------------------------------- +----------------------------------------------------- -Use ``os.remove(filename)`` or ``os.unlink(filename)``; for -documentation, see `the POSIX module -`_. The two -functions are identical; ``unlink()`` is simply the name of the Unix -system call for this function. - -To remove a directory, use ``os.rmdir()``; use ``os.mkdir()`` to -create one. ``os.makedirs(path)`` will create any intermediate -directories in ``path`` that don't exist. ``os.removedirs(path)`` will -remove intermediate directories as long as they're empty; if you want -to delete an entire directory tree and its contents, use -``shutil.rmtree()``. +Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, see +the :mod:`os` module. The two functions are identical; :func:`unlink` is simply +the name of the Unix system call for this function. + +To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create one. +``os.makedirs(path)`` will create any intermediate directories in ``path`` that +don't exist. ``os.removedirs(path)`` will remove intermediate directories as +long as they're empty; if you want to delete an entire directory tree and its +contents, use :func:`shutil.rmtree`. To rename a file, use ``os.rename(old_path, new_path)``. To truncate a file, open it using ``f = open(filename, "r+")``, and use -``f.truncate(offset)``; offset defaults to the current seek position. -There's also ```os.ftruncate(fd, offset)`` for files opened with ``os.open()``, -where ``fd`` is the file descriptor (a small integer). +``f.truncate(offset)``; offset defaults to the current seek position. There's +also ```os.ftruncate(fd, offset)`` for files opened with :func:`os.open`, where +``fd`` is the file descriptor (a small integer). + +The :mod:`shutil` module also contains a number of functions to work on files +including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and +:func:`~shutil.rmtree`. -The ``shutil`` module also contains a number of functions to work on files -including ``copyfile``, ``copytree``, and ``rmtree``. How do I copy a file? ------------------------------ +--------------------- -The ``shutil`` module contains a ``copyfile()`` function. Note that -on MacOS 9 it doesn't copy the resource fork and Finder info. +The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note +that on MacOS 9 it doesn't copy the resource fork and Finder info. How do I read (or write) binary data? ---------------------------------------------- +------------------------------------- + +To read or write complex binary data formats, it's best to use the :mod:`struct` +module. It allows you to take a string containing binary data (usually numbers) +and convert it to Python objects; and vice versa. + +For example, the following code reads two 2-byte integers and one 4-byte integer +in big-endian format from a file:: + + import struct + + f = open(filename, "rb") # Open in binary mode for portability + s = f.read(8) + x, y, z = struct.unpack(">hhl", s) -or complex data formats, it's best to use `the struct module -`_. It allows you -to take a string containing binary data (usually numbers) and convert -it to Python objects; and vice versa. - -For example, the following code reads two 2-byte integers -and one 4-byte integer in big-endian format from a file:: - - import struct - - f = open(filename, "rb") # Open in binary mode for portability - s = f.read(8) - x, y, z = struct.unpack(">hhl", s) - -The '>' in the format string forces big-endian data; the letter -'h' reads one "short integer" (2 bytes), and 'l' reads one -"long integer" (4 bytes) from the string. +The '>' in the format string forces big-endian data; the letter 'h' reads one +"short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the +string. + +For data that is more regular (e.g. a homogeneous list of ints or thefloats), +you can also use the :mod:`array` module. -For data that is more regular (e.g. a homogeneous list of ints or -thefloats), you can also use `the array module `_. I can't seem to use os.read() on a pipe created with os.popen(); why? ------------------------------------------------------------------------- +--------------------------------------------------------------------- + +:func:`os.read` is a low-level function which takes a file descriptor, a small +integer representing the opened file. :func:`os.popen` creates a high-level +file object, the same type returned by the builtin :func:`open` function. Thus, +to read n bytes from a pipe p created with :func:`os.popen`, you need to use +``p.read(n)``. -``os.read()`` is a low-level function which takes a file descriptor, a -small integer representing the opened file. ``os.popen()`` creates a -high-level file object, the same type returned by the builtin -``open()`` function. Thus, to read n bytes from a pipe p created with -``os.popen()``, you need to use ``p.read(n)``. How do I run a subprocess with pipes connected to both input and output? --------------------------------------------------------------------------------- -Use `the popen2 module -`_. For example:: - - import popen2 - fromchild, tochild = popen2.popen2("command") - tochild.write("input\n") - tochild.flush() - output = fromchild.readline() - -Warning: in general it is unwise to do this because you can easily -cause a deadlock where your process is blocked waiting for output from -the child while the child is blocked waiting for input from you. This -can be caused because the parent expects the child to output more text -than it does, or it can be caused by data being stuck in stdio buffers -due to lack of flushing. The Python parent can of course explicitly -flush the data it sends to the child before it reads any output, but -if the child is a naive C program it may have been written to never -explicitly flush its output, even if it is interactive, since flushing -is normally automatic. - -Note that a deadlock is also possible if you use ``popen3`` to read -stdout and stderr. If one of the two is too large for the internal -buffer (increasing the buffer size does not help) and you ``read()`` -the other one first, there is a deadlock, too. - -Note on a bug in popen2: unless your program calls ``wait()`` -or ``waitpid()``, finished child processes are never removed, -and eventually calls to popen2 will fail because of a limit on -the number of child processes. Calling ``os.waitpid`` with the -``os.WNOHANG`` option can prevent this; a good place to insert such -a call would be before calling ``popen2`` again. - -In many cases, all you really need is to run some data through a -command and get the result back. Unless the amount of data is very -large, the easiest way to do this is to write it to a temporary file -and run the command with that temporary file as input. The `standard -module tempfile `_ -exports a ``mktemp()`` function to generate unique temporary file names. :: - - import tempfile - import os - class Popen3: - """ - This is a deadlock-safe version of popen that returns - an object with errorlevel, out (a string) and err (a string). - (capturestderr may not work under windows.) - Example: print Popen3('grep spam','\n\nhere spam\n\n').out - """ - def __init__(self,command,input=None,capturestderr=None): - outfile=tempfile.mktemp() - command="( %s ) > %s" % (command,outfile) - if input: - infile=tempfile.mktemp() - open(infile,"w").write(input) - command=command+" <"+infile - if capturestderr: - errfile=tempfile.mktemp() - command=command+" 2>"+errfile - self.errorlevel=os.system(command) >> 8 - self.out=open(outfile,"r").read() - os.remove(outfile) - if input: - os.remove(infile) - if capturestderr: - self.err=open(errfile,"r").read() - os.remove(errfile) - -Note that many interactive programs (e.g. vi) don't work well with -pipes substituted for standard input and output. You will have to use -pseudo ttys ("ptys") instead of pipes. Or you can use a Python -interface to Don Libes' "expect" library. A Python extension that -interfaces to expect is called "expy" and available from -http://expectpy.sourceforge.net. A pure Python solution that works -like expect is ` pexpect `_. +------------------------------------------------------------------------ + +.. XXX update to use subprocess + +Use the :mod:`popen2` module. For example:: + + import popen2 + fromchild, tochild = popen2.popen2("command") + tochild.write("input\n") + tochild.flush() + output = fromchild.readline() + +Warning: in general it is unwise to do this because you can easily cause a +deadlock where your process is blocked waiting for output from the child while +the child is blocked waiting for input from you. This can be caused because the +parent expects the child to output more text than it does, or it can be caused +by data being stuck in stdio buffers due to lack of flushing. The Python parent +can of course explicitly flush the data it sends to the child before it reads +any output, but if the child is a naive C program it may have been written to +never explicitly flush its output, even if it is interactive, since flushing is +normally automatic. + +Note that a deadlock is also possible if you use :func:`popen3` to read stdout +and stderr. If one of the two is too large for the internal buffer (increasing +the buffer size does not help) and you ``read()`` the other one first, there is +a deadlock, too. + +Note on a bug in popen2: unless your program calls ``wait()`` or ``waitpid()``, +finished child processes are never removed, and eventually calls to popen2 will +fail because of a limit on the number of child processes. Calling +:func:`os.waitpid` with the :data:`os.WNOHANG` option can prevent this; a good +place to insert such a call would be before calling ``popen2`` again. + +In many cases, all you really need is to run some data through a command and get +the result back. Unless the amount of data is very large, the easiest way to do +this is to write it to a temporary file and run the command with that temporary +file as input. The standard module :mod:`tempfile` exports a ``mktemp()`` +function to generate unique temporary file names. :: + + import tempfile + import os + + class Popen3: + """ + This is a deadlock-safe version of popen that returns + an object with errorlevel, out (a string) and err (a string). + (capturestderr may not work under windows.) + Example: print Popen3('grep spam','\n\nhere spam\n\n').out + """ + def __init__(self,command,input=None,capturestderr=None): + outfile=tempfile.mktemp() + command="( %s ) > %s" % (command,outfile) + if input: + infile=tempfile.mktemp() + open(infile,"w").write(input) + command=command+" <"+infile + if capturestderr: + errfile=tempfile.mktemp() + command=command+" 2>"+errfile + self.errorlevel=os.system(command) >> 8 + self.out=open(outfile,"r").read() + os.remove(outfile) + if input: + os.remove(infile) + if capturestderr: + self.err=open(errfile,"r").read() + os.remove(errfile) + +Note that many interactive programs (e.g. vi) don't work well with pipes +substituted for standard input and output. You will have to use pseudo ttys +("ptys") instead of pipes. Or you can use a Python interface to Don Libes' +"expect" library. A Python extension that interfaces to expect is called "expy" +and available from http://expectpy.sourceforge.net. A pure Python solution that +works like expect is ` pexpect `_. How do I access the serial (RS232) port? ------------------------------------------------- +---------------------------------------- + For Win32, POSIX (Linux, BSD, etc.), Jython: - http://pyserial.sourceforge.net + http://pyserial.sourceforge.net For Unix, see a Usenet post by Mitch Chapman: - http://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com + http://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com Why doesn't closing sys.stdout (stdin, stderr) really close it? ------------------------------------------------------------------------ +--------------------------------------------------------------- -Python file objects are a high-level layer of abstraction on top of C -streams, which in turn are a medium-level layer of abstraction on top -of (among other things) low-level C file descriptors. - -For most file objects you create in Python via the builtin ``file`` -constructor, ``f.close()`` marks the Python file object as being closed -from Python's point of view, and also arranges to close the underlying -C stream. This also happens automatically in f's destructor, when f -becomes garbage. - -But stdin, stdout and stderr are treated specially by Python, because -of the special status also given to them by C. Running -``sys.stdout.close()`` marks the Python-level file object as being -closed, but does *not* close the associated C stream. - -To close the underlying C stream for one of these three, you should -first be sure that's what you really want to do (e.g., you may confuse -extension modules trying to do I/O). If it is, use -os.close:: +Python file objects are a high-level layer of abstraction on top of C streams, +which in turn are a medium-level layer of abstraction on top of (among other +things) low-level C file descriptors. + +For most file objects you create in Python via the builtin ``file`` constructor, +``f.close()`` marks the Python file object as being closed from Python's point +of view, and also arranges to close the underlying C stream. This also happens +automatically in f's destructor, when f becomes garbage. + +But stdin, stdout and stderr are treated specially by Python, because of the +special status also given to them by C. Running ``sys.stdout.close()`` marks +the Python-level file object as being closed, but does *not* close the +associated C stream. + +To close the underlying C stream for one of these three, you should first be +sure that's what you really want to do (e.g., you may confuse extension modules +trying to do I/O). If it is, use os.close:: os.close(0) # close C's stdin stream os.close(1) # close C's stdout stream os.close(2) # close C's stderr stream - Network/Internet Programming -======================================= +============================ What WWW tools are there for Python? --------------------------------------------- +------------------------------------ + +See the chapters titled :ref:`internet` and :ref:`netdata` in the Library +Reference Manual. Python has many modules that will help you build server-side +and client-side web systems. -See the chapters titled `"Internet Protocols and Support" -`_ and `"Internet Data -Handling" `_ in the -Library Reference Manual. Python has many modules that will help you -build server-side and client-side web systems. +.. XXX check if wiki page is still up to date A summary of available frameworks is maintained by Paul Boddie at http://wiki.python.org/moin/WebProgramming . @@ -662,37 +646,38 @@ How can I mimic CGI form submission (METHOD=POST)? ----------------------------------------------------------- -I would like to retrieve web pages that are the result of POSTing a -form. Is there existing code that would let me do this easily? +-------------------------------------------------- + +I would like to retrieve web pages that are the result of POSTing a form. Is +there existing code that would let me do this easily? Yes. Here's a simple example that uses httplib:: - #!/usr/local/bin/python + #!/usr/local/bin/python - import httplib, sys, time + import httplib, sys, time - ### build the query string - qs = "First=Josephine&MI=Q&Last=Public" + ### build the query string + qs = "First=Josephine&MI=Q&Last=Public" - ### connect and send the server a path - httpobj = httplib.HTTP('www.some-server.out-there', 80) - httpobj.putrequest('POST', '/cgi-bin/some-cgi-script') - ### now generate the rest of the HTTP headers... - httpobj.putheader('Accept', '*/*') - httpobj.putheader('Connection', 'Keep-Alive') - httpobj.putheader('Content-type', 'application/x-www-form-urlencoded') - httpobj.putheader('Content-length', '%d' % len(qs)) - httpobj.endheaders() - httpobj.send(qs) - ### find out what the server said in response... - reply, msg, hdrs = httpobj.getreply() - if reply != 200: - sys.stdout.write(httpobj.getfile().read()) - -Note that in general for URL-encoded POST operations, query -strings must be quoted by using ``urllib.quote()``. For example to send name="Guy -Steele, Jr.":: + ### connect and send the server a path + httpobj = httplib.HTTP('www.some-server.out-there', 80) + httpobj.putrequest('POST', '/cgi-bin/some-cgi-script') + ### now generate the rest of the HTTP headers... + httpobj.putheader('Accept', '*/*') + httpobj.putheader('Connection', 'Keep-Alive') + httpobj.putheader('Content-type', 'application/x-www-form-urlencoded') + httpobj.putheader('Content-length', '%d' % len(qs)) + httpobj.endheaders() + httpobj.send(qs) + ### find out what the server said in response... + reply, msg, hdrs = httpobj.getreply() + if reply != 200: + sys.stdout.write(httpobj.getfile().read()) + +Note that in general for URL-encoded POST operations, query strings must be +quoted by using :func:`urllib.quote`. For example to send name="Guy Steele, +Jr.":: >>> from urllib import quote >>> x = quote("Guy Steele, Jr.") @@ -704,188 +689,183 @@ What module should I use to help with generating HTML? --------------------------------------------------------------- +------------------------------------------------------ + +.. XXX add modern template languages There are many different modules available: -* HTMLgen is a class library of objects corresponding to all the HTML - 3.2 markup tags. It's used when you are writing in Python and wish - to synthesize HTML pages for generating a web or for CGI forms, etc. -* DocumentTemplate and Zope Page Templates are two different systems that are +* HTMLgen is a class library of objects corresponding to all the HTML 3.2 markup + tags. It's used when you are writing in Python and wish to synthesize HTML + pages for generating a web or for CGI forms, etc. + +* DocumentTemplate and Zope Page Templates are two different systems that are part of Zope. + * Quixote's PTL uses Python syntax to assemble strings of text. -Consult the `Web Programming wiki pages `_ for more links. +Consult the `Web Programming wiki pages +`_ for more links. How do I send mail from a Python script? ------------------------------------------------- +---------------------------------------- -Use `the standard library module smtplib -`_. +Use the standard library module :mod:`smtplib`. -Here's a very simple interactive mail sender that uses it. This -method will work on any host that supports an SMTP listener. :: +Here's a very simple interactive mail sender that uses it. This method will +work on any host that supports an SMTP listener. :: - import sys, smtplib + import sys, smtplib - fromaddr = raw_input("From: ") - toaddrs = raw_input("To: ").split(',') - print "Enter message, end with ^D:" - msg = '' - while 1: - line = sys.stdin.readline() - if not line: - break - msg = msg + line - - # The actual mail send - server = smtplib.SMTP('localhost') - server.sendmail(fromaddr, toaddrs, msg) - server.quit() - -A Unix-only alternative uses sendmail. The location of the -sendmail program varies between systems; sometimes it is -``/usr/lib/sendmail``, sometime ``/usr/sbin/sendmail``. The sendmail -manual page will help you out. Here's some sample code:: - - SENDMAIL = "/usr/sbin/sendmail" # sendmail location - import os - p = os.popen("%s -t -i" % SENDMAIL, "w") - p.write("To: receiver at example.com\n") - p.write("Subject: test\n") - p.write("\n") # blank line separating headers from body - p.write("Some text\n") - p.write("some more text\n") - sts = p.close() - if sts != 0: - print "Sendmail exit status", sts + fromaddr = raw_input("From: ") + toaddrs = raw_input("To: ").split(',') + print "Enter message, end with ^D:" + msg = '' + while True: + line = sys.stdin.readline() + if not line: + break + msg += line + + # The actual mail send + server = smtplib.SMTP('localhost') + server.sendmail(fromaddr, toaddrs, msg) + server.quit() + +A Unix-only alternative uses sendmail. The location of the sendmail program +varies between systems; sometimes it is ``/usr/lib/sendmail``, sometime +``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's +some sample code:: + + SENDMAIL = "/usr/sbin/sendmail" # sendmail location + import os + p = os.popen("%s -t -i" % SENDMAIL, "w") + p.write("To: receiver at example.com\n") + p.write("Subject: test\n") + p.write("\n") # blank line separating headers from body + p.write("Some text\n") + p.write("some more text\n") + sts = p.close() + if sts != 0: + print "Sendmail exit status", sts How do I avoid blocking in the connect() method of a socket? --------------------------------------------------------------------------- -The select module is commonly used to help with asynchronous -I/O on sockets. - -To prevent the TCP connect from blocking, you can set the socket to -non-blocking mode. Then when you do the ``connect()``, you will -either connect immediately (unlikely) or get an exception that -contains the error number as ``.errno``. ``errno.EINPROGRESS`` -indicates that the connection is in progress, but hasn't finished yet. -Different OSes will return different values, so you're going to have -to check what's returned on your system. - -You can use the ``connect_ex()`` method to avoid creating an -exception. It will just return the errno value. To poll, you can -call ``connect_ex()`` again later -- 0 or ``errno.EISCONN`` indicate -that you're connected -- or you can pass this socket to select to -check if it's writable. +------------------------------------------------------------ + +The select module is commonly used to help with asynchronous I/O on sockets. + +To prevent the TCP connect from blocking, you can set the socket to non-blocking +mode. Then when you do the ``connect()``, you will either connect immediately +(unlikely) or get an exception that contains the error number as ``.errno``. +``errno.EINPROGRESS`` indicates that the connection is in progress, but hasn't +finished yet. Different OSes will return different values, so you're going to +have to check what's returned on your system. + +You can use the ``connect_ex()`` method to avoid creating an exception. It will +just return the errno value. To poll, you can call ``connect_ex()`` again later +-- 0 or ``errno.EISCONN`` indicate that you're connected -- or you can pass this +socket to select to check if it's writable. Databases -===================== +========= Are there any interfaces to database packages in Python? ----------------------------------------------------------------- +-------------------------------------------------------- -Yes. +Yes. -Python 2.3 includes the ``bsddb`` package which provides an interface -to the `BerkeleyDB -`_ library. -Interfaces to disk-based hashes such as `DBM -`_ and `GDBM -`_ are also included -with standard Python. +.. XXX remove bsddb in py3k, fix other module names -Support for most relational databases is available. See the `DatabaseProgramming wiki page `_ for details. +Python 2.3 includes the :mod:`bsddb` package which provides an interface to the +BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM ` +and :mod:`GDBM ` are also included with standard Python. +Support for most relational databases is available. See the +`DatabaseProgramming wiki page +`_ for details. -How do you implement persistent objects in Python? ------------------------------------------------------------- -The `pickle library module -`_ solves this in a -very general way (though you still can't store things like open files, -sockets or windows), and the `shelve library module -`_ uses pickle and -(g)dbm to create persistent mappings containing arbitrary Python -objects. For better performance, you can use -`the cPickle module `_. - -A more awkward way of doing things is to use pickle's little sister, -marshal. `The marshal module -`_ provides very -fast ways to store noncircular basic Python types to files and -strings, and back again. Although marshal does not do fancy things -like store instances or handle shared references properly, it does run -extremely fast. For example loading a half megabyte of data may take -less than a third of a second. This often beats doing something more -complex and general such as using gdbm with pickle/shelve. - - -Why is cPickle so slow? --------------------------------- - -The default format used by the pickle module is a slow one that -results in readable pickles. Making it the default, but it would -break backward compatibility:: +How do you implement persistent objects in Python? +-------------------------------------------------- - largeString = 'z' * (100 * 1024) - myPickle = cPickle.dumps(largeString, protocol=1) +The :mod:`pickle` library module solves this in a very general way (though you +still can't store things like open files, sockets or windows), and the +:mod:`shelve` library module uses pickle and (g)dbm to create persistent +mappings containing arbitrary Python objects. For better performance, you can +use the :mod:`cPickle` module. +A more awkward way of doing things is to use pickle's little sister, marshal. +The :mod:`marshal` module provides very fast ways to store noncircular basic +Python types to files and strings, and back again. Although marshal does not do +fancy things like store instances or handle shared references properly, it does +run extremely fast. For example loading a half megabyte of data may take less +than a third of a second. This often beats doing something more complex and +general such as using gdbm with pickle/shelve. +Why is cPickle so slow? +----------------------- + +.. XXX update this, default protocol is 2/3 + +The default format used by the pickle module is a slow one that results in +readable pickles. Making it the default, but it would break backward +compatibility:: + + largeString = 'z' * (100 * 1024) + myPickle = cPickle.dumps(largeString, protocol=1) + If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come? --------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------ -Databases opened for write access with the bsddb module (and often by -the anydbm module, since it will preferentially use bsddb) must -explicitly be closed using the ``.close()`` method of the database. The -underlying library caches database contents which need to be -converted to on-disk form and written. - -If you have initialized a new bsddb database but not written anything to -it before the program crashes, you will often wind up with a zero-length -file and encounter an exception the next time the file is opened. +Databases opened for write access with the bsddb module (and often by the anydbm +module, since it will preferentially use bsddb) must explicitly be closed using +the ``.close()`` method of the database. The underlying library caches database +contents which need to be converted to on-disk form and written. + +If you have initialized a new bsddb database but not written anything to it +before the program crashes, you will often wind up with a zero-length file and +encounter an exception the next time the file is opened. I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data? ------------------------------------------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------------------------------- -Don't panic! Your data is probably intact. The most frequent cause -for the error is that you tried to open an earlier Berkeley DB file -with a later version of the Berkeley DB library. - -Many Linux systems now have all three versions of Berkeley DB -available. If you are migrating from version 1 to a newer version use -db_dump185 to dump a plain text version of the database. -If you are migrating from version 2 to version 3 use db2_dump to create -a plain text version of the database. In either case, use db_load to -create a new native database for the latest version installed on your -computer. If you have version 3 of Berkeley DB installed, you should -be able to use db2_load to create a native version 2 database. +Don't panic! Your data is probably intact. The most frequent cause for the error +is that you tried to open an earlier Berkeley DB file with a later version of +the Berkeley DB library. + +Many Linux systems now have all three versions of Berkeley DB available. If you +are migrating from version 1 to a newer version use db_dump185 to dump a plain +text version of the database. If you are migrating from version 2 to version 3 +use db2_dump to create a plain text version of the database. In either case, +use db_load to create a new native database for the latest version installed on +your computer. If you have version 3 of Berkeley DB installed, you should be +able to use db2_load to create a native version 2 database. -You should move away from Berkeley DB version 1 files because -the hash file code contains known bugs that can corrupt your data. +You should move away from Berkeley DB version 1 files because the hash file code +contains known bugs that can corrupt your data. Mathematics and Numerics -================================ +======================== How do I generate random numbers in Python? ---------------------------------------------------- -The `standard module random `_ implements a random number -generator. Usage is simple:: +------------------------------------------- - import random - random.random() +The standard module :mod:`random` implements a random number generator. Usage +is simple:: + + import random + random.random() This returns a random floating point number in the range [0, 1). -There are also many other specialized generators in this module, such -as: +There are also many other specialized generators in this module, such as: * ``randrange(a, b)`` chooses an integer in the range [a, b). * ``uniform(a, b)`` chooses a floating point number in the range [a, b). @@ -896,6 +876,5 @@ * ``choice(S)`` chooses random element from a given sequence * ``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly -There's also a ``Random`` class you can instantiate -to create independent multiple random number generators. - +There's also a ``Random`` class you can instantiate to create independent +multiple random number generators. Modified: sandbox/trunk/faq/programming.rst ============================================================================== --- sandbox/trunk/faq/programming.rst (original) +++ sandbox/trunk/faq/programming.rst Sun Oct 11 20:12:15 2009 @@ -1,150 +1,146 @@ -==================================== +:tocdepth: 2 + +=============== Programming FAQ -==================================== +=============== .. contents:: General Questions -=========================== +================= Is there a source code level debugger with breakpoints, single-stepping, etc.? -------------------------------------------------------------------------------- -Yes. +------------------------------------------------------------------------------ -The pdb module is a simple but adequate console-mode debugger for -Python. It is part of the standard Python library, and is `documented -in the Library Reference Manual -`_. You can -also write your own debugger by using the code for pdb as an example. - -The IDLE interactive development environment, which is part of the -standard Python distribution (normally available as Tools/scripts/idle), -includes a graphical debugger. There is documentation for the IDLE -debugger at http://www.python.org/idle/doc/idle2.html#Debugger - -PythonWin is a Python IDE that includes a GUI debugger based on pdb. -The Pythonwin debugger colors breakpoints and has quite a few cool -features such as debugging non-Pythonwin programs. Pythonwin -is available as part of the `Python for Windows Extensions -`__ -project and as a part of the ActivePython distribution -(see http://www.activestate.com/Products/ActivePython/index.html). - -`Boa Constructor `_ is an IDE -and GUI builder that uses wxWidgets. It offers visual frame creation -and manipulation, an object -inspector, many views on the source like object browsers, inheritance -hierarchies, doc string generated html documentation, an advanced -debugger, integrated help, and Zope support. - -`Eric3 `_ is an IDE -built on PyQt and the Scintilla editing component. - -Pydb is a version of the standard Python debugger pdb, modified for -use with DDD (Data Display Debugger), a popular graphical debugger -front end. Pydb can be found at http://bashdb.sourceforge.net/pydb/ -and DDD can be found at http://www.gnu.org/software/ddd. +Yes. -There are a number of commercial Python IDEs that include graphical -debuggers. They include: +The pdb module is a simple but adequate console-mode debugger for Python. It is +part of the standard Python library, and is :mod:`documented in the Library +Reference Manual `. You can also write your own debugger by using the code +for pdb as an example. + +The IDLE interactive development environment, which is part of the standard +Python distribution (normally available as Tools/scripts/idle), includes a +graphical debugger. There is documentation for the IDLE debugger at +http://www.python.org/idle/doc/idle2.html#Debugger. + +PythonWin is a Python IDE that includes a GUI debugger based on pdb. The +Pythonwin debugger colors breakpoints and has quite a few cool features such as +debugging non-Pythonwin programs. Pythonwin is available as part of the `Python +for Windows Extensions `__ project and +as a part of the ActivePython distribution (see +http://www.activestate.com/Products/ActivePython/index.html). + +`Boa Constructor `_ is an IDE and GUI +builder that uses wxWidgets. It offers visual frame creation and manipulation, +an object inspector, many views on the source like object browsers, inheritance +hierarchies, doc string generated html documentation, an advanced debugger, +integrated help, and Zope support. + +`Eric `_ is an IDE built on PyQt +and the Scintilla editing component. + +Pydb is a version of the standard Python debugger pdb, modified for use with DDD +(Data Display Debugger), a popular graphical debugger front end. Pydb can be +found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at +http://www.gnu.org/software/ddd. -* Wing IDE (http://wingware.com/) -* Komodo IDE (http://www.activestate.com/Products/Komodo) +There are a number of commercial Python IDEs that include graphical debuggers. +They include: +* Wing IDE (http://wingware.com/) +* Komodo IDE (http://www.activestate.com/Products/Komodo) Is there a tool to help find bugs or perform static analysis? ----------------------------------------------------------------------- -Yes. +------------------------------------------------------------- + +Yes. -PyChecker is a static analysis tool that finds bugs in Python source -code and warns about code complexity and style. You can get PyChecker -from http://pychecker.sf.net. - -`Pylint `_ is another tool -that checks if a module satisfies a coding standard, and also makes it -possible to write plug-ins to add a custom feature. In addition to -the bug checking that PyChecker performs, Pylint offers some -additional features such as checking line length, whether variable -names are well-formed according to your coding standard, whether -declared interfaces are fully implemented, and more. -http://www.logilab.org/projects/pylint/documentation provides a full -list of Pylint's features. +PyChecker is a static analysis tool that finds bugs in Python source code and +warns about code complexity and style. You can get PyChecker from +http://pychecker.sf.net. + +`Pylint `_ is another tool that checks +if a module satisfies a coding standard, and also makes it possible to write +plug-ins to add a custom feature. In addition to the bug checking that +PyChecker performs, Pylint offers some additional features such as checking line +length, whether variable names are well-formed according to your coding +standard, whether declared interfaces are fully implemented, and more. +http://www.logilab.org/projects/pylint/documentation provides a full list of +Pylint's features. How can I create a stand-alone binary from a Python script? -------------------------------------------------------------------- -You don't need the ability to compile Python to C code if all you -want is a stand-alone program that users can download and run without -having to install the Python distribution first. There are a number -of tools that determine the set of modules required by a program and -bind these modules together with a Python binary to produce a single -executable. - -One is to use the freeze tool, which is included in the Python -source tree as ``Tools/freeze``. It converts Python byte -code to C arrays; a C compiler you can embed all -your modules into a new program, which is then linked -with the standard Python modules. - -It works by scanning your source recursively for import statements (in -both forms) and looking for the modules in the standard Python path as -well as in the source directory (for built-in modules). It then turns -the bytecode for modules written in Python into C code (array -initializers that can be turned into code objects using the marshal -module) and creates a custom-made config file that only contains those -built-in modules which are actually used in the program. It then -compiles the generated C code and links it with the rest of the Python -interpreter to form a self-contained binary which acts exactly like -your script. +----------------------------------------------------------- + +You don't need the ability to compile Python to C code if all you want is a +stand-alone program that users can download and run without having to install +the Python distribution first. There are a number of tools that determine the +set of modules required by a program and bind these modules together with a +Python binary to produce a single executable. + +One is to use the freeze tool, which is included in the Python source tree as +``Tools/freeze``. It converts Python byte code to C arrays; a C compiler you can +embed all your modules into a new program, which is then linked with the +standard Python modules. + +It works by scanning your source recursively for import statements (in both +forms) and looking for the modules in the standard Python path as well as in the +source directory (for built-in modules). It then turns the bytecode for modules +written in Python into C code (array initializers that can be turned into code +objects using the marshal module) and creates a custom-made config file that +only contains those built-in modules which are actually used in the program. It +then compiles the generated C code and links it with the rest of the Python +interpreter to form a self-contained binary which acts exactly like your script. -Obviously, freeze requires a C compiler. There are several other -utilities which don't. One is Thomas Heller's py2exe (Windows only) at +Obviously, freeze requires a C compiler. There are several other utilities +which don't. One is Thomas Heller's py2exe (Windows only) at http://www.py2exe.org/ -Another is Christian Tismer's `SQFREEZE -`_ which appends the byte code -to a specially-prepared Python interpreter that can find the byte -code in the executable. +Another is Christian Tismer's `SQFREEZE `_ +which appends the byte code to a specially-prepared Python interpreter that can +find the byte code in the executable. Other tools include Fredrik Lundh's `Squeeze -`_ and Anthony -Tuininga's `cx_Freeze -`_. +`_ and Anthony Tuininga's +`cx_Freeze `_. Are there coding standards or a style guide for Python programs? ------------------------------------------------------------------------- -Yes. The coding style required for standard library modules -is documented as `PEP 8 `_. +---------------------------------------------------------------- + +Yes. The coding style required for standard library modules is documented as +:pep:`8`. My program is too slow. How do I speed it up? ----------------------------------------------------- +--------------------------------------------- -That's a tough one, in general. There are many tricks to speed up -Python code; consider rewriting parts in C as a last resort. +That's a tough one, in general. There are many tricks to speed up Python code; +consider rewriting parts in C as a last resort. -In some cases it's possible to automatically translate Python to C or -x86 assembly language, meaning that you don't have to modify your code -to gain increased speed. - -`Pyrex `_ can -compile a slightly modified version of Python code into a C extension, -and can be used on many different platforms. - -`Psyco `_ is a just-in-time compiler -that translates Python code into x86 assembly language. If you can -use it, Psyco can provide dramatic speedups for critical functions. - -The rest of this answer will discuss various tricks for squeezing a -bit more speed out of Python code. *Never* apply any optimization -tricks unless you know you need them, after profiling has indicated -that a particular function is the heavily executed hot spot in the -code. Optimizations almost always make the code less clear, and you -shouldn't pay the costs of reduced clarity (increased development -time, greater likelihood of bugs) unless the resulting performance +In some cases it's possible to automatically translate Python to C or x86 +assembly language, meaning that you don't have to modify your code to gain +increased speed. + +.. XXX seems to have overlap with other questions! + +`Pyrex `_ can compile a +slightly modified version of Python code into a C extension, and can be used on +many different platforms. + +`Psyco `_ is a just-in-time compiler that +translates Python code into x86 assembly language. If you can use it, Psyco can +provide dramatic speedups for critical functions. + +The rest of this answer will discuss various tricks for squeezing a bit more +speed out of Python code. *Never* apply any optimization tricks unless you know +you need them, after profiling has indicated that a particular function is the +heavily executed hot spot in the code. Optimizations almost always make the +code less clear, and you shouldn't pay the costs of reduced clarity (increased +development time, greater likelihood of bugs) unless the resulting performance benefit is worth it. There is a page on the wiki devoted to `performance tips @@ -153,77 +149,71 @@ Guido van Rossum has written up an anecdote related to optimization at http://www.python.org/doc/essays/list2str.html. -One thing to notice is that function and (especially) method calls are -rather expensive; if you have designed a purely OO interface with lots -of tiny functions that don't do much more than get or set an instance -variable or call another method, you might consider using a more -direct way such as directly accessing instance variables. Also see the -standard module "profile" (`described in the Library Reference manual -`_) which -makes it possible to find out where your program is spending most of -its time (if you have some patience -- the profiling itself can slow -your program down by an order of magnitude). - -Remember that many standard optimization heuristics you -may know from other programming experience may well apply -to Python. For example it may be faster to send output to output -devices using larger writes rather than smaller ones in order to -reduce the overhead of kernel system calls. Thus CGI scripts -that write all output in "one shot" may be faster than -those that write lots of small pieces of output. - -Also, be sure to use Python's core features where appropriate. -For example, slicing allows programs to chop up -lists and other sequence objects in a single tick of the interpreter's -mainloop using highly optimized C implementations. Thus to -get the same effect as:: +One thing to notice is that function and (especially) method calls are rather +expensive; if you have designed a purely OO interface with lots of tiny +functions that don't do much more than get or set an instance variable or call +another method, you might consider using a more direct way such as directly +accessing instance variables. Also see the standard module :mod:`profile` which +makes it possible to find out where your program is spending most of its time +(if you have some patience -- the profiling itself can slow your program down by +an order of magnitude). + +Remember that many standard optimization heuristics you may know from other +programming experience may well apply to Python. For example it may be faster +to send output to output devices using larger writes rather than smaller ones in +order to reduce the overhead of kernel system calls. Thus CGI scripts that +write all output in "one shot" may be faster than those that write lots of small +pieces of output. + +Also, be sure to use Python's core features where appropriate. For example, +slicing allows programs to chop up lists and other sequence objects in a single +tick of the interpreter's mainloop using highly optimized C implementations. +Thus to get the same effect as:: - L2 = [] - for i in range[3]: + L2 = [] + for i in range[3]: L2.append(L1[i]) it is much shorter and far faster to use :: - L2 = list(L1[:3]) # "list" is redundant if L1 is a list. + L2 = list(L1[:3]) # "list" is redundant if L1 is a list. -Note that the functionally-oriented builtins such as -``map()``, ``zip()``, and friends can be a convenient -accelerator for loops that perform a single task. For example to pair the elements of two -lists together:: +Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`, +and friends can be a convenient accelerator for loops that perform a single +task. For example to pair the elements of two lists together:: - >>> zip([1,2,3], [4,5,6]) - [(1, 4), (2, 5), (3, 6)] + >>> zip([1,2,3], [4,5,6]) + [(1, 4), (2, 5), (3, 6)] or to compute a number of sines:: - >>> map( math.sin, (1,2,3,4)) - [0.841470984808, 0.909297426826, 0.14112000806, -0.756802495308] + >>> map( math.sin, (1,2,3,4)) + [0.841470984808, 0.909297426826, 0.14112000806, -0.756802495308] The operation completes very quickly in such cases. -Other examples include the ``join()`` and ``split()`` -methods of string objects. For example if s1..s7 are large (10K+) strings then -``"".join([s1,s2,s3,s4,s5,s6,s7])` may be far faster than -the more obvious ``s1+s2+s3+s4+s5+s6+s7``, since the "summation" -will compute many subexpressions, whereas ``join()`` does all the -copying in one pass. For manipulating strings, use -the ``replace()`` method on string objects. Use +Other examples include the ``join()`` and ``split()`` methods of string objects. +For example if s1..s7 are large (10K+) strings then +``"".join([s1,s2,s3,s4,s5,s6,s7])`` may be far faster than the more obvious +``s1+s2+s3+s4+s5+s6+s7``, since the "summation" will compute many +subexpressions, whereas ``join()`` does all the copying in one pass. For +manipulating strings, use the ``replace()`` method on string objects. Use regular expressions only when you're not dealing with constant string patterns. -Consider using the string formatting operations -``string % tuple`` and ``string % dictionary``. +Consider using the string formatting operations ``string % tuple`` and ``string +% dictionary``. -Be sure to use the ``list.sort()`` builtin method to do sorting, and see -the `sorting mini-HOWTO `_ for examples of moderately advanced usage. -``list.sort()`` beats other techniques for sorting in all but the most -extreme circumstances. - -Another common trick is to "push loops into functions or methods." -For example suppose you have a program that runs slowly and you -use the profiler to determine that a Python function ``ff()`` -is being called lots of times. If you notice that ``ff ()``:: +Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the +`sorting mini-HOWTO `_ for examples +of moderately advanced usage. :meth:`list.sort` beats other techniques for +sorting in all but the most extreme circumstances. + +Another common trick is to "push loops into functions or methods." For example +suppose you have a program that runs slowly and you use the profiler to +determine that a Python function ``ff()`` is being called lots of times. If you +notice that ``ff ()``:: def ff(x): - ...do something with x computing result... + ... # do something with x computing result... return result tends to be called in loops like:: @@ -234,248 +224,236 @@ for x in sequence: value = ff(x) - ...do something with value... + ... # do something with value... -then you can often eliminate function call overhead by rewriting -``ff()`` to:: +then you can often eliminate function call overhead by rewriting ``ff()`` to:: def ffseq(seq): resultseq = [] for x in seq: - ...do something with x computing result... + ... # do something with x computing result... resultseq.append(result) return resultseq and rewrite the two examples to ``list = ffseq(oldlist)`` and to:: - for value in ffseq(sequence): - ...do something with value... + for value in ffseq(sequence): + ... # do something with value... -Single calls to ff(x) translate to ffseq([x])[0] with little -penalty. Of course this technique is not always appropriate -and there are other variants which you can figure out. +Single calls to ``ff(x)`` translate to ``ffseq([x])[0]`` with little penalty. +Of course this technique is not always appropriate and there are other variants +which you can figure out. -You can gain some performance by explicitly storing the results of -a function or method lookup into a local variable. A loop like:: +You can gain some performance by explicitly storing the results of a function or +method lookup into a local variable. A loop like:: - for key in token: - dict[key] = dict.get(key, 0) + 1 + for key in token: + dict[key] = dict.get(key, 0) + 1 -resolves dict.get every iteration. If the method isn't going to -change, a slightly faster implementation is:: +resolves ``dict.get`` every iteration. If the method isn't going to change, a +slightly faster implementation is:: - dict_get = dict.get # look up the method once - for key in token: - dict[key] = dict_get(key, 0) + 1 + dict_get = dict.get # look up the method once + for key in token: + dict[key] = dict_get(key, 0) + 1 -Default arguments can be used to determine values once, at -compile time instead of at run time. This can only be done for -functions or objects which will not be changed during program -execution, such as replacing :: +Default arguments can be used to determine values once, at compile time instead +of at run time. This can only be done for functions or objects which will not +be changed during program execution, such as replacing :: - def degree_sin(deg): - return math.sin(deg * math.pi / 180.0) + def degree_sin(deg): + return math.sin(deg * math.pi / 180.0) with :: - def degree_sin(deg, factor=math.pi/180.0, sin=math.sin): - return sin(deg * factor) + def degree_sin(deg, factor=math.pi/180.0, sin=math.sin): + return sin(deg * factor) -Because this trick uses default arguments for terms which should -not be changed, it should only be used when you are not concerned -with presenting a possibly confusing API to your users. +Because this trick uses default arguments for terms which should not be changed, +it should only be used when you are not concerned with presenting a possibly +confusing API to your users. Core Language -================== +============= How do you set a global variable in a function? ----------------------------------------------------------- +----------------------------------------------- + Did you do something like this? :: x = 1 # make a global def f(): - print x # try to print the global - ... - for j in range(100): - if q > 3: - x = 4 - -Any variable assigned in a function is local to that function. -unless it is specifically declared global. Since a value is bound -to ``x`` as the last statement of the function body, the compiler -assumes that ``x`` is local. Consequently the ``print x`` -attempts to print an uninitialized local variable and will -trigger a ``NameError``. + print x # try to print the global + ... + for j in range(100): + if q > 3: + x = 4 + +Any variable assigned in a function is local to that function. unless it is +specifically declared global. Since a value is bound to ``x`` as the last +statement of the function body, the compiler assumes that ``x`` is +local. Consequently the ``print x`` attempts to print an uninitialized local +variable and will trigger a ``NameError``. -The solution is to insert an explicit global declaration at the start -of the function:: +The solution is to insert an explicit global declaration at the start of the +function:: def f(): - global x - print x # try to print the global - ... - for j in range(100): - if q > 3: - x = 4 + global x + print x # try to print the global + ... + for j in range(100): + if q > 3: + x = 4 +In this case, all references to ``x`` are interpreted as references to the ``x`` +from the module namespace. -In this case, all references to ``x`` are interpreted as references -to the ``x`` from the module namespace. What are the rules for local and global variables in Python? --------------------------------------------------------------------------- +------------------------------------------------------------ -In Python, variables that are only referenced inside a function are -implicitly global. If a variable is assigned a new value anywhere -within the function's body, it's assumed to be a local. If a variable -is ever assigned a new value inside the function, the variable is -implicitly local, and you need to explicitly declare it as 'global'. - -Though a bit surprising at first, a moment's consideration explains -this. On one hand, requiring ``global`` for assigned variables provides -a bar against unintended side-effects. On the other hand, if ``global`` -was required for all global references, you'd be using ``global`` all the -time. You'd have to declare as global every reference to a -builtin function or to a component of an imported module. This -clutter would defeat the usefulness of the ``global`` declaration for -identifying side-effects. +In Python, variables that are only referenced inside a function are implicitly +global. If a variable is assigned a new value anywhere within the function's +body, it's assumed to be a local. If a variable is ever assigned a new value +inside the function, the variable is implicitly local, and you need to +explicitly declare it as 'global'. + +Though a bit surprising at first, a moment's consideration explains this. On +one hand, requiring :keyword:`global` for assigned variables provides a bar +against unintended side-effects. On the other hand, if ``global`` was required +for all global references, you'd be using ``global`` all the time. You'd have +to declare as global every reference to a builtin function or to a component of +an imported module. This clutter would defeat the usefulness of the ``global`` +declaration for identifying side-effects. How do I share global variables across modules? ------------------------------------------------ -The canonical way to share information across modules within a single -program is to create a special module (often called config or cfg). -Just import the config module in all modules of your application; the -module then becomes available as a global name. Because there is only -one instance of each module, any changes made to the module object get -reflected everywhere. For example: +The canonical way to share information across modules within a single program is +to create a special module (often called config or cfg). Just import the config +module in all modules of your application; the module then becomes available as +a global name. Because there is only one instance of each module, any changes +made to the module object get reflected everywhere. For example: config.py:: - x = 0 # Default value of the 'x' configuration setting + x = 0 # Default value of the 'x' configuration setting mod.py:: - import config - config.x = 1 + import config + config.x = 1 main.py:: - import config - import mod - print config.x + import config + import mod + print config.x -Note that using a module is also the basis for implementing the -Singleton design pattern, for the same reason. +Note that using a module is also the basis for implementing the Singleton design +pattern, for the same reason. What are the "best practices" for using import in a module? ------------------------------------------------------------------------------- +----------------------------------------------------------- -In general, don't use ``from modulename import *``. -Doing so clutters the importer's namespace. Some people avoid this idiom -even with the few modules that were designed to be imported in this -manner. Modules designed in this manner include ``Tkinter``, -and ``threading``. - -Import modules at the top of a file. Doing so makes it clear what -other modules your code requires and avoids questions of whether the -module name is in scope. Using one import per line makes it easy to -add and delete module imports, but using multiple imports per line -uses less screen space. +In general, don't use ``from modulename import *``. Doing so clutters the +importer's namespace. Some people avoid this idiom even with the few modules +that were designed to be imported in this manner. Modules designed in this +manner include :mod:`Tkinter`, and :mod:`threading`. + +Import modules at the top of a file. Doing so makes it clear what other modules +your code requires and avoids questions of whether the module name is in scope. +Using one import per line makes it easy to add and delete module imports, but +using multiple imports per line uses less screen space. It's good practice if you import modules in the following order: 1. standard library modules -- e.g. ``sys``, ``os``, ``getopt``, ``re``) -2. third-party library modules (anything installed in Python's - site-packages directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc. +2. third-party library modules (anything installed in Python's site-packages + directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc. 3. locally-developed modules -Never use relative package imports. If you're writing code that's -in the ``package.sub.m1`` module and want to import ``package.sub.m2``, -do not just write ``import m2``, even though it's legal. -Write ``from package.sub import m2`` instead. Relative imports can lead to a -module being initialized twice, leading to confusing bugs. - -It is sometimes necessary to move imports to a function or class to -avoid problems with circular imports. Gordon McMillan says: - - Circular imports are fine where both modules use the "import " - form of import. They fail when the 2nd module wants to grab a name - out of the first ("from module import name") and the import is at - the top level. That's because names in the 1st are not yet available, - because the first module is busy importing the 2nd. - -In this case, if the second module is only used in one function, then the -import can easily be moved into that function. By the time the import -is called, the first module will have finished initializing, and the -second module can do its import. - -It may also be necessary to move imports out of the top level of code -if some of the modules are platform-specific. In that case, it may -not even be possible to import all of the modules at the top of the -file. In this case, importing the correct modules in the -corresponding platform-specific code is a good option. - -Only move imports into a local scope, such as inside a function -definition, if it's necessary to solve a problem such as avoiding a -circular import or are trying to reduce the initialization time of a -module. This technique is especially helpful if many of the imports -are unnecessary depending on how the program executes. You may also -want to move imports into a function if the modules are only ever used -in that function. Note that loading a module the first time may be -expensive because of the one time initialization of the module, but -loading a module multiple times is virtually free, costing only a couple of -dictionary lookups. Even if the module name has gone out of scope, -the module is probably available in sys.modules. - -If only instances of a specific class use a module, then it is -reasonable to import the module in the class's ``__init__`` method and -then assign the module to an instance variable so that the module is -always available (via that instance variable) during the life of the -object. Note that to delay an import until the class is instantiated, -the import must be inside a method. Putting the import inside the -class but outside of any method still causes the import to occur when -the module is initialized. +Never use relative package imports. If you're writing code that's in the +``package.sub.m1`` module and want to import ``package.sub.m2``, do not just +write ``import m2``, even though it's legal. Write ``from package.sub import +m2`` instead. Relative imports can lead to a module being initialized twice, +leading to confusing bugs. + +It is sometimes necessary to move imports to a function or class to avoid +problems with circular imports. Gordon McMillan says: + + Circular imports are fine where both modules use the "import " form + of import. They fail when the 2nd module wants to grab a name out of the + first ("from module import name") and the import is at the top level. That's + because names in the 1st are not yet available, because the first module is + busy importing the 2nd. + +In this case, if the second module is only used in one function, then the import +can easily be moved into that function. By the time the import is called, the +first module will have finished initializing, and the second module can do its +import. + +It may also be necessary to move imports out of the top level of code if some of +the modules are platform-specific. In that case, it may not even be possible to +import all of the modules at the top of the file. In this case, importing the +correct modules in the corresponding platform-specific code is a good option. + +Only move imports into a local scope, such as inside a function definition, if +it's necessary to solve a problem such as avoiding a circular import or are +trying to reduce the initialization time of a module. This technique is +especially helpful if many of the imports are unnecessary depending on how the +program executes. You may also want to move imports into a function if the +modules are only ever used in that function. Note that loading a module the +first time may be expensive because of the one time initialization of the +module, but loading a module multiple times is virtually free, costing only a +couple of dictionary lookups. Even if the module name has gone out of scope, +the module is probably available in :data:`sys.modules`. + +If only instances of a specific class use a module, then it is reasonable to +import the module in the class's ``__init__`` method and then assign the module +to an instance variable so that the module is always available (via that +instance variable) during the life of the object. Note that to delay an import +until the class is instantiated, the import must be inside a method. Putting +the import inside the class but outside of any method still causes the import to +occur when the module is initialized. + How can I pass optional or keyword parameters from one function to another? -------------------------------------------------------------------------------- +--------------------------------------------------------------------------- Collect the arguments using the ``*`` and ``**`` specifiers in the function's -parameter list; this gives you the positional arguments as a tuple -and the keyword arguments as a dictionary. You can -then pass these arguments when calling another function by using -``*`` and ``**``:: - - - def f(x, *tup, **kwargs): - ... - kwargs['width'] = '14.3c' - ... - g(x, *tup, **kwargs) - -In the unlikely case that you care about Python -versions older than 2.0, use 'apply':: - - def f(x, *tup, **kwargs): - ... - kwargs['width'] = '14.3c' - ... - apply(g, (x,)+tup, kwargs) - +parameter list; this gives you the positional arguments as a tuple and the +keyword arguments as a dictionary. You can then pass these arguments when +calling another function by using ``*`` and ``**``:: + + def f(x, *args, **kwargs): + ... + kwargs['width'] = '14.3c' + ... + g(x, *args, **kwargs) + +In the unlikely case that you care about Python versions older than 2.0, use +:func:`apply`:: + + def f(x, *args, **kwargs): + ... + kwargs['width'] = '14.3c' + ... + apply(g, (x,)+args, kwargs) How do I write a function with output parameters (call by reference)? ------------------------------------------------------------------------------ +--------------------------------------------------------------------- -Remember that arguments are passed by assignment in Python. Since -assignment just creates references to objects, there's no alias -between an argument name in the caller and callee, and so no -call-by-reference per se. You can achieve the desired effect in a -number of ways. +Remember that arguments are passed by assignment in Python. Since assignment +just creates references to objects, there's no alias between an argument name in +the caller and callee, and so no call-by-reference per se. You can achieve the +desired effect in a number of ways. 1) By returning a tuple of the results:: @@ -490,8 +468,7 @@ This is almost always the clearest solution. -2) By using global variables. This isn't thread-safe, and is not - recommended. +2) By using global variables. This isn't thread-safe, and is not recommended. 3) By passing a mutable (changeable in-place) object:: @@ -535,72 +512,72 @@ How do you make a higher order function in Python? ----------------------------------------------------------- -You have two choices: you can use nested scopes -or you can use callable objects. For example, suppose you wanted to -define ``linear(a,b)`` which returns a function ``f(x)`` that computes the -value ``a*x+b``. Using nested scopes:: - - def linear(a, b): - def result(x): - return a * x + b - return result +-------------------------------------------------- + +You have two choices: you can use nested scopes or you can use callable objects. +For example, suppose you wanted to define ``linear(a,b)`` which returns a +function ``f(x)`` that computes the value ``a*x+b``. Using nested scopes:: + + def linear(a, b): + def result(x): + return a * x + b + return result Or using a callable object:: - class linear: + class linear: - def __init__(self, a, b): - self.a, self.b = a, b + def __init__(self, a, b): + self.a, self.b = a, b - def __call__(self, x): - return self.a * x + self.b + def __call__(self, x): + return self.a * x + self.b -In both cases:: +In both cases, :: - taxes = linear(0.3, 2) + taxes = linear(0.3, 2) gives a callable object where ``taxes(10e6) == 0.3 * 10e6 + 2``. -The callable object approach has the disadvantage that it is a bit -slower and results in slightly longer code. However, note that a -collection of callables can share their signature via inheritance:: - - class exponential(linear): - # __init__ inherited - def __call__(self, x): - return self.a * (x ** self.b) +The callable object approach has the disadvantage that it is a bit slower and +results in slightly longer code. However, note that a collection of callables +can share their signature via inheritance:: + + class exponential(linear): + # __init__ inherited + def __call__(self, x): + return self.a * (x ** self.b) Object can encapsulate state for several methods:: - class counter: + class counter: - value = 0 + value = 0 - def set(self, x): - self.value = x + def set(self, x): + self.value = x - def up(self): - self.value = self.value + 1 + def up(self): + self.value = self.value + 1 - def down(self): - self.value = self.value - 1 + def down(self): + self.value = self.value - 1 - count = counter() - inc, dec, reset = count.up, count.down, count.set + count = counter() + inc, dec, reset = count.up, count.down, count.set Here ``inc()``, ``dec()`` and ``reset()`` act like functions which share the same counting variable. How do I copy an object in Python? ------------------------------------------- +---------------------------------- -In general, try copy.copy() or copy.deepcopy() for the general case. Not all -objects can be copied, but most can. +In general, try :func:`copy.copy` or :func:`copy.deepcopy` for the general case. +Not all objects can be copied, but most can. -Some objects can be copied more easily. -Dictionaries have a ``copy()`` method:: +Some objects can be copied more easily. Dictionaries have a :meth:`~dict.copy` +method:: newdict = olddict.copy() @@ -610,59 +587,57 @@ How can I find the methods or attributes of an object? --------------------------------------------------------------- -For an instance x of a user-defined class, ``dir(x)`` returns an -alphabetized list of the names containing the instance attributes and -methods and attributes defined by its class. +------------------------------------------------------ + +For an instance x of a user-defined class, ``dir(x)`` returns an alphabetized +list of the names containing the instance attributes and methods and attributes +defined by its class. How can my code discover the name of an object? -------------------------------------------------------- +----------------------------------------------- -Generally speaking, it can't, because objects don't really have -names. Essentially, assignment always binds a name to a value; The -same is true of ``def`` and ``class`` statements, but in that case the -value is a callable. Consider the following code:: - - class A: - pass - - B = A - - a = B() - b = a - print b - <__main__.A instance at 016D07CC> - print a - <__main__.A instance at 016D07CC> - - -Arguably the class has a name: even though it is bound to two names -and invoked through the name B the created instance is still reported -as an instance of class A. However, it is impossible to say whether -the instance's name is a or b, since both names are bound to the same -value. - -Generally speaking it should not be necessary for your code to "know -the names" of particular values. Unless you are deliberately writing -introspective programs, this is usually an indication that a change of -approach might be beneficial. - -In comp.lang.python, Fredrik Lundh once gave an excellent analogy in -answer to this question: - - The same way as you get the name of that cat you found on your - porch: the cat (object) itself cannot tell you its name, and it - doesn't really care -- so the only way to find out what it's called - is to ask all your neighbours (namespaces) if it's their cat - (object)... +Generally speaking, it can't, because objects don't really have names. +Essentially, assignment always binds a name to a value; The same is true of +``def`` and ``class`` statements, but in that case the value is a +callable. Consider the following code:: + + class A: + pass + + B = A + + a = B() + b = a + print b + <__main__.A instance at 016D07CC> + print a + <__main__.A instance at 016D07CC> + +Arguably the class has a name: even though it is bound to two names and invoked +through the name B the created instance is still reported as an instance of +class A. However, it is impossible to say whether the instance's name is a or +b, since both names are bound to the same value. + +Generally speaking it should not be necessary for your code to "know the names" +of particular values. Unless you are deliberately writing introspective +programs, this is usually an indication that a change of approach might be +beneficial. + +In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to +this question: + + The same way as you get the name of that cat you found on your porch: the cat + (object) itself cannot tell you its name, and it doesn't really care -- so + the only way to find out what it's called is to ask all your neighbours + (namespaces) if it's their cat (object)... - ....and don't be surprised if you'll find that it's known by many - names, or no name at all! + ....and don't be surprised if you'll find that it's known by many names, or + no name at all! What's up with the comma operator's precedence? ----------------------------------------------------------------------- +----------------------------------------------- Comma is not an operator in Python. Consider this session:: @@ -678,422 +653,418 @@ >>> "a" in ("5", "a") -The same is true of the various assignment operators (``=``, ``+=`` etc). -They are not truly operators but syntactic delimiters in assignment -statements. +The same is true of the various assignment operators (``=``, ``+=`` etc). They +are not truly operators but syntactic delimiters in assignment statements. Is there an equivalent of C's "?:" ternary operator? ----------------------------------------------------------------------- -Yes, this feature was added in python 2.5. The syntax would be as follows:: +---------------------------------------------------- - [on_true] if [expression] else [on_false] +Yes, this feature was added in Python 2.5. The syntax would be as follows:: - x, y = 50,25 + [on_true] if [expression] else [on_false] - small = x if x < y else y + x, y = 50, 25 + + small = x if x < y else y For versions previous to 2.5 the answer would be 'No'. -In many cases you can mimic a?b:c with "a and b or c", but there's a flaw: if b is zero -(or empty, or None -- anything that tests false) then c will be selected -instead. In many cases you can prove by looking at the code that this -can't happen (e.g. because b is a constant or has a type that can never be false), -but in general this can be a problem. - -Tim Peters (who wishes it was Steve Majewski) suggested the following -solution: (a and [b] or [c])[0]. Because [b] is a singleton list it -is never false, so the wrong path is never taken; then applying [0] to -the whole thing gets the b or c that you really wanted. Ugly, but it -gets you there in the rare cases where it is really inconvenient to -rewrite your code using 'if'. - -The best course is usually to write a simple ``if...else`` statement. -Another solution is to implement the "?:" operator as a function:: - - def q(cond, on_true, on_false): - if cond: - if not isfunction(on_true): - return on_true - else: - return apply(on_true) - else: - if not isfunction(on_false): - return on_false - else: - return apply(on_false) - -In most cases you'll pass b and c directly: ``q(a, b, c)``. To avoid -evaluating b or c when they shouldn't be, encapsulate them within a -lambda function, e.g.: ``q(a, lambda: b, lambda: c)``. - -It has been asked *why* Python has no if-then-else expression. -There are several answers: many languages do -just fine without one; it can easily lead to less readable code; -no sufficiently "Pythonic" syntax has been discovered; a search -of the standard library found remarkably few places where using an +.. XXX remove rest? + +In many cases you can mimic ``a ? b : c`` with ``a and b or c``, but there's a +flaw: if *b* is zero (or empty, or ``None`` -- anything that tests false) then +*c* will be selected instead. In many cases you can prove by looking at the +code that this can't happen (e.g. because *b* is a constant or has a type that +can never be false), but in general this can be a problem. + +Tim Peters (who wishes it was Steve Majewski) suggested the following solution: +``(a and [b] or [c])[0]``. Because ``[b]`` is a singleton list it is never +false, so the wrong path is never taken; then applying ``[0]`` to the whole +thing gets the *b* or *c* that you really wanted. Ugly, but it gets you there +in the rare cases where it is really inconvenient to rewrite your code using +'if'. + +The best course is usually to write a simple ``if...else`` statement. Another +solution is to implement the ``?:`` operator as a function:: + + def q(cond, on_true, on_false): + if cond: + if not isfunction(on_true): + return on_true + else: + return apply(on_true) + else: + if not isfunction(on_false): + return on_false + else: + return apply(on_false) + +In most cases you'll pass b and c directly: ``q(a, b, c)``. To avoid evaluating +b or c when they shouldn't be, encapsulate them within a lambda function, e.g.: +``q(a, lambda: b, lambda: c)``. + +It has been asked *why* Python has no if-then-else expression. There are +several answers: many languages do just fine without one; it can easily lead to +less readable code; no sufficiently "Pythonic" syntax has been discovered; a +search of the standard library found remarkably few places where using an if-then-else expression would make the code more understandable. -In 2002, `PEP 308 `_ was -written proposing several possible syntaxes and the community was -asked to vote on the issue. The vote was inconclusive. Most people -liked one of the syntaxes, but also hated other syntaxes; many votes -implied that people preferred no ternary operator -rather than having a syntax they hated. +In 2002, `PEP 308 `_ was written proposing several possible +syntaxes and the community was asked to vote on the issue. The vote was +inconclusive. Most people liked one of the syntaxes, but also hated other +syntaxes; many votes implied that people preferred no ternary operator rather +than having a syntax they hated. Is it possible to write obfuscated one-liners in Python? ----------------------------------------------------------------- -Yes. Usually this is done by nesting `lambda` within `lambda`. -See the following three examples, due to Ulf Bartelt:: +-------------------------------------------------------- - # Primes < 1000 - print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0, - map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000))) - - # First 10 Fibonacci numbers - print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f), - range(10)) - - # Mandelbrot set - print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y, - Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM, - Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro, - i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y - >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr( - 64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy - ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24) - # \___ ___/ \___ ___/ | | |__ lines on screen - # V V | |______ columns on screen - # | | |__________ maximum of "iterations" - # | |_________________ range on y axis - # |____________________________ range on x axis +Yes. Usually this is done by nesting :keyword:`lambda` within +:keyword:`lambda`. See the following three examples, due to Ulf Bartelt:: + + # Primes < 1000 + print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0, + map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000))) + + # First 10 Fibonacci numbers + print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f), + range(10)) + + # Mandelbrot set + print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y, + Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM, + Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro, + i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y + >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr( + 64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy + ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24) + # \___ ___/ \___ ___/ | | |__ lines on screen + # V V | |______ columns on screen + # | | |__________ maximum of "iterations" + # | |_________________ range on y axis + # |____________________________ range on x axis Don't try this at home, kids! Numbers and strings -========================== +=================== How do I specify hexadecimal and octal integers? --------------------------------------------------------- +------------------------------------------------ -To specify an octal digit, precede the octal value with a zero. For -example, to set the variable "a" to the octal value "10" (8 in -decimal), type:: - - >>> a = 010 - >>> a - 8 - -Hexadecimal is just as easy. Simply precede the hexadecimal number with a -zero, and then a lower or uppercase "x". Hexadecimal digits can be specified -in lower or uppercase. For example, in the Python interpreter:: - - >>> a = 0xa5 - >>> a - 165 - >>> b = 0XB2 - >>> b - 178 +To specify an octal digit, precede the octal value with a zero. For example, to +set the variable "a" to the octal value "10" (8 in decimal), type:: + + >>> a = 010 + >>> a + 8 + +Hexadecimal is just as easy. Simply precede the hexadecimal number with a zero, +and then a lower or uppercase "x". Hexadecimal digits can be specified in lower +or uppercase. For example, in the Python interpreter:: + + >>> a = 0xa5 + >>> a + 165 + >>> b = 0XB2 + >>> b + 178 Why does -22 / 10 return -3? ----------------------------------- +---------------------------- -It's primarily driven by the desire that ``i % j`` have the same sign as -``j``. If you want that, and also want:: +It's primarily driven by the desire that ``i % j`` have the same sign as ``j``. +If you want that, and also want:: i == (i / j) * j + (i % j) -then integer division has to return the floor. C also requires that identity -to hold, and then compilers that truncate ``i / j`` need to make ``i % j`` have -the same sign as ``i``. +then integer division has to return the floor. C also requires that identity to +hold, and then compilers that truncate ``i / j`` need to make ``i % j`` have the +same sign as ``i``. There are few real use cases for ``i % j`` when ``j`` is negative. When ``j`` -is positive, there are many, and in virtually all of them it's more useful -for ``i % j`` to be ``>= 0``. If the clock says 10 now, what did it say 200 -hours ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug -waiting to bite. +is positive, there are many, and in virtually all of them it's more useful for +``i % j`` to be ``>= 0``. If the clock says 10 now, what did it say 200 hours +ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to +bite. How do I convert a string to a number? ----------------------------------------------- +-------------------------------------- -For integers, use the built-in ``int()`` type constructor, -e.g. int('144') == 144. Similarly, ``float()`` converts to -floating-point, e.g. ``float('144') == 144.0``. - -By default, these interpret the number as decimal, so that -``int('0144') == 144`` and ``int('0x144')`` raises -``ValueError``. ``int(string, base)`` takes the base to convert from -as a second optional argument, so ``int('0x144', 16) == 324``. If the -base is specified as 0, the number is interpreted using Python's +For integers, use the built-in :func:`int` type constructor, e.g. ``int('144') +== 144``. Similarly, :func:`float` converts to floating-point, +e.g. ``float('144') == 144.0``. + +By default, these interpret the number as decimal, so that ``int('0144') == +144`` and ``int('0x144')`` raises :exc:`ValueError`. ``int(string, base)`` takes +the base to convert from as a second optional argument, so ``int('0x144', 16) == +324``. If the base is specified as 0, the number is interpreted using Python's rules: a leading '0' indicates octal, and '0x' indicates a hex number. -Do not use the built-in function ``eval()`` if all you need is to -convert strings to numbers. ``eval()`` will be significantly slower -and it presents a security risk: someone could pass you a Python -expression that might have unwanted side effects. For example, -someone could pass ``__import__('os').system("rm -rf $HOME")`` which -would erase your home directory. - -``eval()`` also has the effect of interpreting numbers as Python -expressions, so that e.g. eval('09') gives a syntax error because Python -regards numbers starting with '0' as octal (base 8). +Do not use the built-in function :func:`eval` if all you need is to convert +strings to numbers. :func:`eval` will be significantly slower and it presents a +security risk: someone could pass you a Python expression that might have +unwanted side effects. For example, someone could pass +``__import__('os').system("rm -rf $HOME")`` which would erase your home +directory. + +:func:`eval` also has the effect of interpreting numbers as Python expressions, +so that e.g. ``eval('09')`` gives a syntax error because Python regards numbers +starting with '0' as octal (base 8). How do I convert a number to a string? ----------------------------------------------- +-------------------------------------- + +To convert, e.g., the number 144 to the string '144', use the built-in type +constructor :func:`str`. If you want a hexadecimal or octal representation, use +the built-in functions ``hex()`` or ``oct()``. For fancy formatting, use +:ref:`the % operator ` on strings, e.g. ``"%04d" % 144`` +yields ``'0144'`` and ``"%.3f" % (1/3.0)`` yields ``'0.333'``. See the library +reference manual for details. -To convert, e.g., the number 144 to the string '144', use the built-in function -``str()``. If you want a hexadecimal or octal representation, use the built-in -functions ``hex()`` or ``oct()``. For fancy formatting, use `the % operator -`_ on -strings, e.g. ``"%04d" % 144`` yields '0144' and ``"%.3f" % (1/3.0)`` yields -'0.333'. See the library reference manual for details. How do I modify a string in place? ------------------------------------------- +---------------------------------- -You can't, because strings are immutable. If you need an object with -this ability, try converting the string to a list or use the array -module:: - - >>> s = "Hello, world" - >>> a = list(s) - >>> print a - ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] - >>> a[7:] = list("there!") - >>> ''.join(a) - 'Hello, there!' - - >>> import array - >>> a = array.array('c', s) - >>> print a - array('c', 'Hello, world') - >>> a[0] = 'y' ; print a - array('c', 'yello world') - >>> a.tostring() - 'yello, world' +You can't, because strings are immutable. If you need an object with this +ability, try converting the string to a list or use the array module:: + >>> s = "Hello, world" + >>> a = list(s) + >>> print a + ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] + >>> a[7:] = list("there!") + >>> ''.join(a) + 'Hello, there!' + + >>> import array + >>> a = array.array('c', s) + >>> print a + array('c', 'Hello, world') + >>> a[0] = 'y' ; print a + array('c', 'yello world') + >>> a.tostring() + 'yello, world' How do I use strings to call functions/methods? ----------------------------------------------------------- +----------------------------------------------- There are various techniques. -* The best is to use a dictionary that maps strings to functions. The - primary advantage of this technique is that the strings do not need - to match the names of the functions. This is also the primary - technique used to emulate a case construct:: +* The best is to use a dictionary that maps strings to functions. The primary + advantage of this technique is that the strings do not need to match the names + of the functions. This is also the primary technique used to emulate a case + construct:: - def a(): - pass + def a(): + pass - def b(): - pass + def b(): + pass - dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs + dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs - dispatch[get_input()]() # Note trailing parens to call function + dispatch[get_input()]() # Note trailing parens to call function -* Use the built-in function ``getattr()``:: +* Use the built-in function :func:`getattr`:: - import foo - getattr(foo, 'bar')() + import foo + getattr(foo, 'bar')() - Note that getattr() works on any object, including classes, class + Note that :func:`getattr` works on any object, including classes, class instances, modules, and so on. - This is used in several places in the standard library, like - this:: + This is used in several places in the standard library, like this:: - class Foo: - def do_foo(self): - ... + class Foo: + def do_foo(self): + ... - def do_bar(self): - ... + def do_bar(self): + ... f = getattr(foo_instance, 'do_' + opname) f() -* Use ``locals()`` or ``eval()`` to resolve the function name:: +* Use :func:`locals` or :func:`eval` to resolve the function name:: - def myFunc(): - print "hello" + def myFunc(): + print "hello" - fname = "myFunc" + fname = "myFunc" - f = locals()[fname] - f() + f = locals()[fname] + f() - f = eval(fname) - f() + f = eval(fname) + f() - Note: Using ``eval()`` is slow and dangerous. If you don't have absolute control - over the contents of the string, someone could pass a string that + Note: Using :func:`eval` is slow and dangerous. If you don't have absolute + control over the contents of the string, someone could pass a string that resulted in an arbitrary function being executed. Is there an equivalent to Perl's chomp() for removing trailing newlines from strings? --------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------- -Starting with Python 2.2, you can use ``S.rstrip("\r\n")`` to remove -all occurences of any line terminator from the end of the string ``S`` -without removing other trailing whitespace. If the string ``S`` -represents more than one line, with several empty lines at the end, -the line terminators for all the blank lines will be removed:: - - >>> lines = ("line 1 \r\n" - ... "\r\n" - ... "\r\n") - >>> lines.rstrip("\n\r") - "line 1 " +Starting with Python 2.2, you can use ``S.rstrip("\r\n")`` to remove all +occurences of any line terminator from the end of the string ``S`` without +removing other trailing whitespace. If the string ``S`` represents more than +one line, with several empty lines at the end, the line terminators for all the +blank lines will be removed:: + + >>> lines = ("line 1 \r\n" + ... "\r\n" + ... "\r\n") + >>> lines.rstrip("\n\r") + "line 1 " -Since this is typically only desired when reading text one line at a -time, using ``S.rstrip()`` this way works well. +Since this is typically only desired when reading text one line at a time, using +``S.rstrip()`` this way works well. For older versions of Python, There are two partial substitutes: -- If you want to remove all trailing whitespace, use the ``rstrip()`` - method of string objects. This removes all trailing whitespace, not - just a single newline. +- If you want to remove all trailing whitespace, use the ``rstrip()`` method of + string objects. This removes all trailing whitespace, not just a single + newline. - Otherwise, if there is only one line in the string ``S``, use ``S.splitlines()[0]``. Is there a scanf() or sscanf() equivalent? --------------------------------------------------- +------------------------------------------ + Not as such. -For simple input parsing, the easiest approach is usually to split the -line into whitespace-delimited words using the ``split()`` method of -string objects and then convert decimal strings to numeric values using -``int()`` or ``float()``. ``split()`` supports an optional "sep" -parameter which is useful if the line uses something other than -whitespace as a separator. +For simple input parsing, the easiest approach is usually to split the line into +whitespace-delimited words using the :meth:`~str.split` method of string objects +and then convert decimal strings to numeric values using :func:`int` or +:func:`float`. ``split()`` supports an optional "sep" parameter which is useful +if the line uses something other than whitespace as a separator. -For more complicated input parsing, regular expressions -more powerful than C's ``sscanf()`` and better suited for the task. +For more complicated input parsing, regular expressions more powerful than C's +:cfunc:`sscanf` and better suited for the task. What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean? ------------------------------------------------------------------------------------------------------ -This error indicates that your Python installation can handle -only 7-bit ASCII strings. There are a couple ways to fix or -work around the problem. - -If your programs must handle data in arbitrary character set encodings, -the environment the application runs in will generally identify the -encoding of the data it is handing you. You need to convert the input -to Unicode data using that encoding. For example, a program that -handles email or web input will typically find character set encoding -information in Content-Type headers. This can then be used to -properly convert input data to Unicode. Assuming the string referred -to by ``value`` is encoded as UTF-8:: - - value = unicode(value, "utf-8") - -will return a Unicode object. If the data is not correctly encoded as -UTF-8, the above call will raise a ``UnicodeError`` exception. - -If you only want strings converted to Unicode which have non-ASCII -data, you can try converting them first assuming an ASCII encoding, -and then generate Unicode objects if that fails:: - - try: - x = unicode(value, "ascii") - except UnicodeError: - value = unicode(value, "utf-8") - else: - # value was valid ASCII data - pass +------------------------------------------------------------------------------------------ -It's possible to set a default encoding in a file called ``sitecustomize.py`` -that's part of the Python library. However, this isn't recommended because changing the Python-wide default encoding may cause third-party extension modules to fail. +This error indicates that your Python installation can handle only 7-bit ASCII +strings. There are a couple ways to fix or work around the problem. + +If your programs must handle data in arbitrary character set encodings, the +environment the application runs in will generally identify the encoding of the +data it is handing you. You need to convert the input to Unicode data using +that encoding. For example, a program that handles email or web input will +typically find character set encoding information in Content-Type headers. This +can then be used to properly convert input data to Unicode. Assuming the string +referred to by ``value`` is encoded as UTF-8:: + + value = unicode(value, "utf-8") + +will return a Unicode object. If the data is not correctly encoded as UTF-8, +the above call will raise a :exc:`UnicodeError` exception. + +If you only want strings converted to Unicode which have non-ASCII data, you can +try converting them first assuming an ASCII encoding, and then generate Unicode +objects if that fails:: + + try: + x = unicode(value, "ascii") + except UnicodeError: + value = unicode(value, "utf-8") + else: + # value was valid ASCII data + pass -Note that on Windows, there is an encoding known as "mbcs", which uses -an encoding specific to your current locale. In many cases, and -particularly when working with COM, this may be an appropriate default -encoding to use. +It's possible to set a default encoding in a file called ``sitecustomize.py`` +that's part of the Python library. However, this isn't recommended because +changing the Python-wide default encoding may cause third-party extension +modules to fail. + +Note that on Windows, there is an encoding known as "mbcs", which uses an +encoding specific to your current locale. In many cases, and particularly when +working with COM, this may be an appropriate default encoding to use. Sequences (Tuples/Lists) -================================= +======================== How do I convert between tuples and lists? ------------------------------------------------- +------------------------------------------ -The function ``tuple(seq)`` converts any sequence (actually, any +The type constructor ``tuple(seq)`` converts any sequence (actually, any iterable) into a tuple with the same items in the same order. For example, ``tuple([1, 2, 3])`` yields ``(1, 2, 3)`` and ``tuple('abc')`` -yields ``('a', 'b', 'c')``. If the argument is -a tuple, it does not make a copy but returns the same object, so -it is cheap to call ``tuple()`` when you aren't sure that an object -is already a tuple. - -The function ``list(seq)`` converts any sequence or iterable into a list with -the same items in the same order. -For example, ``list((1, 2, 3))`` yields ``[1, 2, 3]`` and ``list('abc')`` -yields ``['a', 'b', 'c']``. If the argument is a list, -it makes a copy just like ``seq[:]`` would. - -What's a negative index? --------------------------------------------------------------------- -Python sequences are indexed with positive numbers and -negative numbers. For positive numbers 0 is the first index -1 is the second index and so forth. For negative indices -1 -is the last index and -2 is the penultimate (next to last) index -and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``. - -Using negative indices can be very convenient. For example ``S[:-1]`` -is all of the string except for its last character, which is useful -for removing the trailing newline from a string. +yields ``('a', 'b', 'c')``. If the argument is a tuple, it does not make a copy +but returns the same object, so it is cheap to call :func:`tuple` when you +aren't sure that an object is already a tuple. + +The type constructor ``list(seq)`` converts any sequence or iterable into a list +with the same items in the same order. For example, ``list((1, 2, 3))`` yields +``[1, 2, 3]`` and ``list('abc')`` yields ``['a', 'b', 'c']``. If the argument +is a list, it makes a copy just like ``seq[:]`` would. + + +What's a negative index? +------------------------ + +Python sequences are indexed with positive numbers and negative numbers. For +positive numbers 0 is the first index 1 is the second index and so forth. For +negative indices -1 is the last index and -2 is the penultimate (next to last) +index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``. + +Using negative indices can be very convenient. For example ``S[:-1]`` is all of +the string except for its last character, which is useful for removing the +trailing newline from a string. How do I iterate over a sequence in reverse order? ---------------------------------------------------------- +-------------------------------------------------- -Use the ``reversed`` builtin function, which is new in Python 2.4:: +Use the :func:`reversed` builtin function, which is new in Python 2.4:: - for x in reversed(sequence): - ...do something with x... + for x in reversed(sequence): + ... # do something with x... -This won't touch your original sequence, but build a new copy with -reversed order to iterate over. +This won't touch your original sequence, but build a new copy with reversed +order to iterate over. With Python 2.3, you can use an extended slice syntax:: - for x in sequence[::-1]: - ...do something with x... + for x in sequence[::-1]: + ... # do something with x... How do you remove duplicates from a list? -------------------------------------------------- +----------------------------------------- + See the Python Cookbook for a long discussion of many ways to do this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 -If you don't mind reordering the list, sort it and then scan from the -end of the list, deleting duplicates as you go:: +If you don't mind reordering the list, sort it and then scan from the end of the +list, deleting duplicates as you go:: - if List: - List.sort() - last = List[-1] - for i in range(len(List)-2, -1, -1): - if last == List[i]: - del List[i] - else: - last = List[i] - -If all elements of the list may be used as -dictionary keys (i.e. they are all hashable) -this is often faster :: + if List: + List.sort() + last = List[-1] + for i in range(len(List)-2, -1, -1): + if last == List[i]: + del List[i] + else: + last = List[i] + +If all elements of the list may be used as dictionary keys (i.e. they are all +hashable) this is often faster :: d = {} for x in List: @@ -1102,84 +1073,87 @@ In Python 2.5 and later, the following is possible instead:: - List = list(set(List)) + List = list(set(List)) + +This converts the list into a set, thereby removing duplicates, and then back +into a list. -This converts the list into a set, thereby removing duplicates, and -then back into a list. How do you make an array in Python? ----------------------------------------------------- +----------------------------------- + Use a list:: - ["this", 1, "is", "an", "array"] + ["this", 1, "is", "an", "array"] + +Lists are equivalent to C or Pascal arrays in their time complexity; the primary +difference is that a Python list can contain objects of many different types. -Lists are equivalent to C or Pascal arrays in their time complexity; -the primary difference is that a Python list can contain objects of -many different types. - -The ``array`` module also provides methods for creating arrays of -fixed types with compact representations, but they are slower to index -than lists. Also note that the Numeric extensions and others define -array-like structures with various characteristics as well. +The ``array`` module also provides methods for creating arrays of fixed types +with compact representations, but they are slower to index than lists. Also +note that the Numeric extensions and others define array-like structures with +various characteristics as well. To get Lisp-style linked lists, you can emulate cons cells using tuples:: - lisp_list = ("like", ("this", ("example", None) ) ) + lisp_list = ("like", ("this", ("example", None) ) ) + +If mutability is desired, you could use lists instead of tuples. Here the +analogue of lisp car is ``lisp_list[0]`` and the analogue of cdr is +``lisp_list[1]``. Only do this if you're sure you really need to, because it's +usually a lot slower than using Python lists. -If mutability is desired, you could use lists instead of tuples. Here -the analogue of lisp car is ``lisp_list[0]`` and the analogue of cdr -is ``lisp_list[1]``. Only do this if you're sure you really need to, -because it's usually a lot slower than using Python lists. How do I create a multidimensional list? ---------------------------------------------------------------- +---------------------------------------- + You probably tried to make a multidimensional array like this:: A = [[None] * 2] * 3 This looks correct if you print it:: - >>> A - [[None, None], [None, None], [None, None]] + >>> A + [[None, None], [None, None], [None, None]] But when you assign a value, it shows up in multiple places: - >>> A[0][0] = 5 - >>> A - [[5, None], [5, None], [5, None]] - -The reason is that replicating a list with ``*`` doesn't create copies, it only creates references to the existing objects. The ``*3`` -creates a list containing 3 references to the same list of length -two. Changes to one row will show in all rows, which is almost certainly -not what you want. + >>> A[0][0] = 5 + >>> A + [[5, None], [5, None], [5, None]] + +The reason is that replicating a list with ``*`` doesn't create copies, it only +creates references to the existing objects. The ``*3`` creates a list +containing 3 references to the same list of length two. Changes to one row will +show in all rows, which is almost certainly not what you want. -The suggested approach is to create a list of the desired length first -and then fill in each element with a newly created list:: +The suggested approach is to create a list of the desired length first and then +fill in each element with a newly created list:: A = [None] * 3 for i in range(3): - A[i] = [None] * 2 + A[i] = [None] * 2 -This generates a list containing 3 different lists of length two. -You can also use a list comprehension:: +This generates a list containing 3 different lists of length two. You can also +use a list comprehension:: w, h = 2, 3 A = [[None] * w for i in range(h)] -Or, you can use an extension that provides a matrix datatype; `Numeric -Python `_ is the best known. +Or, you can use an extension that provides a matrix datatype; `Numeric Python +`_ is the best known. How do I apply a method to a sequence of objects? --------------------------------------------------------------------------- +------------------------------------------------- Use a list comprehension:: - result = [obj.method() for obj in List] + result = [obj.method() for obj in List] More generically, you can try the following function:: - def method_map(objects, method, arguments): + def method_map(objects, method, arguments): """method_map([a,b], "meth", (1,2)) gives [a.meth(1,2), b.meth(1,2)]""" nobjects = len(objects) methods = map(getattr, objects, [method]*nobjects) @@ -1187,65 +1161,63 @@ Dictionaries -================== +============ How can I get a dictionary to display its keys in a consistent order? ------------------------------------------------------------------------------ +--------------------------------------------------------------------- + +You can't. Dictionaries store their keys in an unpredictable order, so the +display order of a dictionary's elements will be similarly unpredictable. + +This can be frustrating if you want to save a printable version to a file, make +some changes and then compare it with some other printed dictionary. In this +case, use the ``pprint`` module to pretty-print the dictionary; the items will +be presented in order sorted by the key. + +A more complicated solution is to subclass ``UserDict.UserDict`` to create a +``SortedDict`` class that prints itself in a predictable order. Here's one +simpleminded implementation of such a class:: + + import UserDict, string + + class SortedDict(UserDict.UserDict): + def __repr__(self): + result = [] + append = result.append + keys = self.data.keys() + keys.sort() + for k in keys: + append("%s: %s" % (`k`, `self.data[k]`)) + return "{%s}" % string.join(result, ", ") + + __str__ = __repr__ + +This will work for many common situations you might encounter, though it's far +from a perfect solution. The largest flaw is that if some values in the +dictionary are also dictionaries, their values won't be presented in any +particular order. -You can't. Dictionaries store their keys in an unpredictable order, -so the display order of a dictionary's elements will be similarly -unpredictable. - -This can be frustrating if you want to save a printable version to a -file, make some changes and then compare it with some other printed -dictionary. In this case, use the ``pprint`` module to pretty-print -the dictionary; the items will be presented in order sorted by the key. - -A more complicated solution is to subclass ``UserDict.UserDict`` -to create a ``SortedDict`` class that prints itself in a predictable order. -Here's one simpleminded implementation of such a class:: - - import UserDict, string - - class SortedDict(UserDict.UserDict): - def __repr__(self): - result = [] - append = result.append - keys = self.data.keys() - keys.sort() - for k in keys: - append("%s: %s" % (`k`, `self.data[k]`)) - return "{%s}" % string.join(result, ", ") - - ___str__ = __repr__ - - -This will work for many common situations you might encounter, though -it's far from a perfect solution. The largest flaw is that if some -values in the dictionary are also dictionaries, their values won't be -presented in any particular order. I want to do a complicated sort: can you do a Schwartzian Transform in Python? --------------------------------------------------------------------------------------- +------------------------------------------------------------------------------ -The technique, attributed to Randal Schwartz of the Perl community, -sorts the elements of a list by a metric which maps each element to -its "sort value". In Python, just use the ``key`` argument for the -``sort()`` method:: +The technique, attributed to Randal Schwartz of the Perl community, sorts the +elements of a list by a metric which maps each element to its "sort value". In +Python, just use the ``key`` argument for the ``sort()`` method:: Isorted = L[:] Isorted.sort(key=lambda s: int(s[10:15])) -The ``key`` argument is new in Python 2.4, for older versions this -kind of sorting is quite simple to do with list comprehensions. -To sort a list of strings by their uppercase values:: +The ``key`` argument is new in Python 2.4, for older versions this kind of +sorting is quite simple to do with list comprehensions. To sort a list of +strings by their uppercase values:: tmp1 = [(x.upper(), x) for x in L] # Schwartzian transform tmp1.sort() Usorted = [x[1] for x in tmp1] -To sort by the integer value of a subfield extending from positions 10-15 -in each string:: +To sort by the integer value of a subfield extending from positions 10-15 in +each string:: tmp2 = [(int(s[10:15]), s) for s in L] # Schwartzian transform tmp2.sort() @@ -1262,432 +1234,427 @@ Isorted = L[:] Isorted.sort(Icmp) -but since this method calls ``intfield()`` many times for each element -of L, it is slower than the Schwartzian Transform. +but since this method calls ``intfield()`` many times for each element of L, it +is slower than the Schwartzian Transform. How can I sort one list by values from another list? ------------------------------------------------------------- +---------------------------------------------------- -Merge them into a single list of tuples, sort the resulting list, -and then pick out the element you want. :: +Merge them into a single list of tuples, sort the resulting list, and then pick +out the element you want. :: - >>> list1 = ["what", "I'm", "sorting", "by"] - >>> list2 = ["something", "else", "to", "sort"] - >>> pairs = zip(list1, list2) - >>> pairs - [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')] - >>> pairs.sort() - >>> result = [ x[1] for x in pairs ] - >>> result - ['else', 'sort', 'to', 'something'] + >>> list1 = ["what", "I'm", "sorting", "by"] + >>> list2 = ["something", "else", "to", "sort"] + >>> pairs = zip(list1, list2) + >>> pairs + [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')] + >>> pairs.sort() + >>> result = [ x[1] for x in pairs ] + >>> result + ['else', 'sort', 'to', 'something'] An alternative for the last step is:: - result = [] - for p in pairs: result.append(p[1]) + result = [] + for p in pairs: result.append(p[1]) -If you find this more legible, you might prefer to use this instead of -the final list comprehension. However, it is almost twice as slow for -long lists. Why? First, the ``append()`` operation has to reallocate -memory, and while it uses some tricks to avoid doing that each time, -it still has to do it occasionally, and that costs quite a bit. -Second, the expression "result.append" requires an extra attribute -lookup, and third, there's a speed reduction from having to make +If you find this more legible, you might prefer to use this instead of the final +list comprehension. However, it is almost twice as slow for long lists. Why? +First, the ``append()`` operation has to reallocate memory, and while it uses +some tricks to avoid doing that each time, it still has to do it occasionally, +and that costs quite a bit. Second, the expression "result.append" requires an +extra attribute lookup, and third, there's a speed reduction from having to make all those function calls. Objects -============= +======= What is a class? ------------------------- -A class is the particular object type created by executing -a class statement. Class objects are used as templates to create -instance objects, which embody both the data -(attributes) and code (methods) specific to a datatype. - -A class can be based on one or more other classes, called its base -class(es). It then inherits the attributes and methods of its base -classes. This allows an object model to be successively refined by -inheritance. You might have a generic ``Mailbox`` class that provides -basic accessor methods for a mailbox, and subclasses such as -``MboxMailbox``, ``MaildirMailbox``, ``OutlookMailbox`` that handle -various specific mailbox formats. +---------------- + +A class is the particular object type created by executing a class statement. +Class objects are used as templates to create instance objects, which embody +both the data (attributes) and code (methods) specific to a datatype. + +A class can be based on one or more other classes, called its base class(es). It +then inherits the attributes and methods of its base classes. This allows an +object model to be successively refined by inheritance. You might have a +generic ``Mailbox`` class that provides basic accessor methods for a mailbox, +and subclasses such as ``MboxMailbox``, ``MaildirMailbox``, ``OutlookMailbox`` +that handle various specific mailbox formats. What is a method? -------------------------- +----------------- A method is a function on some object ``x`` that you normally call as -``x.name(arguments...)``. Methods are defined as functions inside the -class definition:: +``x.name(arguments...)``. Methods are defined as functions inside the class +definition:: + + class C: + def meth (self, arg): + return arg * 2 + self.attribute - class C: - def meth (self, arg): - return arg * 2 + self.attribute What is self? ---------------------- +------------- + +Self is merely a conventional name for the first argument of a method. A method +defined as ``meth(self, a, b, c)`` should be called as ``x.meth(a, b, c)`` for +some instance ``x`` of the class in which the definition occurs; the called +method will think it is called as ``meth(x, a, b, c)``. + +See also :ref:`why-self`. -Self is merely a conventional name for the first argument of a method. -A method defined as ``meth(self, a, b, c)`` should be called as -``x.meth(a, b, c)`` for some instance ``x`` of the class in which the -definition occurs; the called method will think it is called as -``meth(x, a, b, c)``. - -See also -`Why must 'self' be used explicitly in method definitions and calls? -`_ How do I check if an object is an instance of a given class or of a subclass of it? -------------------------------------------------------------------------------------------- +----------------------------------------------------------------------------------- -Use the built-in function ``isinstance(obj, cls)``. You can check if -an object is an instance of any of a number of classes by providing a tuple instead of a single class, e.g. ``isinstance(obj, (class1, class2, ...))``, -and can also check whether an object is one of Python's built-in types, e.g. +Use the built-in function ``isinstance(obj, cls)``. You can check if an object +is an instance of any of a number of classes by providing a tuple instead of a +single class, e.g. ``isinstance(obj, (class1, class2, ...))``, and can also +check whether an object is one of Python's built-in types, e.g. ``isinstance(obj, str)`` or ``isinstance(obj, (int, long, float, complex))``. -Note that most programs do not use ``isinstance()`` on user-defined -classes very often. If you are developing the classes yourself, a -more proper object-oriented style is to define methods on the classes -that encapsulate a particular behaviour, instead of checking the -object's class and doing a different thing based on what class it is. -For example, if you have a function that does something:: - - def search (obj): - if isinstance(obj, Mailbox): - # ... code to search a mailbox - elif isinstance(obj, Document): - # ... code to search a document - elif ... - -A better approach is to define a ``search()`` method on all the -classes and just call it:: - - class Mailbox: - def search(self): - # ... code to search a mailbox - - class Document: - def search(self): - # ... code to search a document +Note that most programs do not use :func:`isinstance` on user-defined classes +very often. If you are developing the classes yourself, a more proper +object-oriented style is to define methods on the classes that encapsulate a +particular behaviour, instead of checking the object's class and doing a +different thing based on what class it is. For example, if you have a function +that does something:: + + def search (obj): + if isinstance(obj, Mailbox): + # ... code to search a mailbox + elif isinstance(obj, Document): + # ... code to search a document + elif ... + +A better approach is to define a ``search()`` method on all the classes and just +call it:: + + class Mailbox: + def search(self): + # ... code to search a mailbox + + class Document: + def search(self): + # ... code to search a document - obj.search() + obj.search() What is delegation? ---------------------------- +------------------- -Delegation is an object oriented technique (also called a design -pattern). Let's say you have an object ``x`` and want to change the -behaviour of just one of its methods. You can create a new class that -provides a new implementation of the method you're interested in changing -and delegates all other methods to the corresponding method of ``x``. +Delegation is an object oriented technique (also called a design pattern). +Let's say you have an object ``x`` and want to change the behaviour of just one +of its methods. You can create a new class that provides a new implementation +of the method you're interested in changing and delegates all other methods to +the corresponding method of ``x``. -Python programmers can easily implement delegation. For example, the -following class implements a class that behaves like a file but -converts all written data to uppercase:: +Python programmers can easily implement delegation. For example, the following +class implements a class that behaves like a file but converts all written data +to uppercase:: - class UpperOut: + class UpperOut: - def __init__(self, outfile): - self.__outfile = outfile + def __init__(self, outfile): + self._outfile = outfile - def write(self, s): - self.__outfile.write(s.upper()) + def write(self, s): + self._outfile.write(s.upper()) - def __getattr__(self, name): - return getattr(self.__outfile, name) + def __getattr__(self, name): + return getattr(self._outfile, name) Here the ``UpperOut`` class redefines the ``write()`` method to convert the argument string to uppercase before calling the underlying ``self.__outfile.write()`` method. All other methods are delegated to the underlying ``self.__outfile`` object. The delegation is accomplished via the -``__getattr__`` method; consult `the language reference -`_ +``__getattr__`` method; consult :ref:`the language reference ` for more information about controlling attribute access. -Note that for more general cases delegation can get trickier. When -attributes must be set as well as retrieved, the class must define a -``__settattr__`` method too, and it must do so carefully. The basic -implementation of __setattr__ is roughly equivalent to the following:: +Note that for more general cases delegation can get trickier. When attributes +must be set as well as retrieved, the class must define a :meth:`__setattr__` +method too, and it must do so carefully. The basic implementation of +:meth:`__setattr__` is roughly equivalent to the following:: class X: - ... - def __setattr__(self, name, value): - self.__dict__[name] = value - ... - -Most __setattr__ implementations must modify -self.__dict__ to store local state for self without -causing an infinite recursion. + ... + def __setattr__(self, name, value): + self.__dict__[name] = value + ... + +Most :meth:`__setattr__` implementations must modify ``self.__dict__`` to store +local state for self without causing an infinite recursion. + How do I call a method defined in a base class from a derived class that overrides it? ----------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------- + +If you're using new-style classes, use the built-in :func:`super` function:: -If you're using new-style classes, use the built-in ``super()`` function:: + class Derived(Base): + def meth (self): + super(Derived, self).meth() + +If you're using classic classes: For a class definition such as ``class +Derived(Base): ...`` you can call method ``meth()`` defined in ``Base`` (or one +of ``Base``'s base classes) as ``Base.meth(self, arguments...)``. Here, +``Base.meth`` is an unbound method, so you need to provide the ``self`` +argument. - class Derived(Base): - def meth (self): - super(Derived, self).meth() - -If you're using classic classes: For a class definition such as -``class Derived(Base): ...`` you can call method ``meth()`` defined in -``Base`` (or one of ``Base``'s base classes) as ``Base.meth(self, -arguments...)``. Here, ``Base.meth`` is an unbound method, so you -need to provide the ``self`` argument. How can I organize my code to make it easier to change the base class? ------------------------------------------------------------------------------- -You could define an alias for the base class, assign the real base -class to it before your class definition, and use the alias throughout -your class. Then all you have to change is the value assigned to the -alias. Incidentally, this trick is also handy if you want to decide -dynamically (e.g. depending on availability of resources) which base -class to use. Example:: - - BaseAlias = - - class Derived(BaseAlias): - def meth(self): - BaseAlias.meth(self) - ... +---------------------------------------------------------------------- +You could define an alias for the base class, assign the real base class to it +before your class definition, and use the alias throughout your class. Then all +you have to change is the value assigned to the alias. Incidentally, this trick +is also handy if you want to decide dynamically (e.g. depending on availability +of resources) which base class to use. Example:: + + BaseAlias = + + class Derived(BaseAlias): + def meth(self): + BaseAlias.meth(self) + ... -How do I create static class data and static class methods? -------------------------------------------------------------------- -Static data (in the sense of C++ or Java) is easy; static methods -(again in the sense of C++ or Java) are not supported directly. +How do I create static class data and static class methods? +----------------------------------------------------------- -For static data, simply define a class attribute. To assign a new -value to the attribute, you have to explicitly use the class name in -the assignment:: +Static data (in the sense of C++ or Java) is easy; static methods (again in the +sense of C++ or Java) are not supported directly. - class C: - count = 0 # number of times C.__init__ called +For static data, simply define a class attribute. To assign a new value to the +attribute, you have to explicitly use the class name in the assignment:: - def __init__(self): - C.count = C.count + 1 + class C: + count = 0 # number of times C.__init__ called - def getcount(self): - return C.count # or return self.count + def __init__(self): + C.count = C.count + 1 -``c.count`` also refers to ``C.count`` for any ``c`` such that -``isinstance(c, C)`` holds, unless overridden by ``c`` itself or by some -class on the base-class search path from ``c.__class__`` back to ``C``. + def getcount(self): + return C.count # or return self.count -Caution: within a method of C, an assignment like ``self.count = 42`` -creates a new and unrelated instance vrbl named "count" in ``self``'s own dict. -Rebinding of a class-static data name must always specify the class -whether inside a method or not:: +``c.count`` also refers to ``C.count`` for any ``c`` such that ``isinstance(c, +C)`` holds, unless overridden by ``c`` itself or by some class on the base-class +search path from ``c.__class__`` back to ``C``. - C.count = 314 +Caution: within a method of C, an assignment like ``self.count = 42`` creates a +new and unrelated instance vrbl named "count" in ``self``'s own dict. Rebinding +of a class-static data name must always specify the class whether inside a +method or not:: + C.count = 314 Static methods are possible since Python 2.2:: - class C: - def static(arg1, arg2, arg3): - # No 'self' parameter! - ... - static = staticmethod(static) + class C: + def static(arg1, arg2, arg3): + # No 'self' parameter! + ... + static = staticmethod(static) With Python 2.4's decorators, this can also be written as :: - class C: - @staticmethod - def static(arg1, arg2, arg3): - # No 'self' parameter! - ... - -However, a far more straightforward way to get the effect of a static -method is via a simple module-level function:: - - def getcount(): - return C.count - -If your code is structured so as to define one class (or tightly -related class hierarchy) per module, this supplies the desired -encapsulation. + class C: + @staticmethod + def static(arg1, arg2, arg3): + # No 'self' parameter! + ... + +However, a far more straightforward way to get the effect of a static method is +via a simple module-level function:: + + def getcount(): + return C.count + +If your code is structured so as to define one class (or tightly related class +hierarchy) per module, this supplies the desired encapsulation. How can I overload constructors (or methods) in Python? ---------------------------------------------------------------- -This answer actually applies to all methods, but the question -usually comes up first in the context of constructors. +------------------------------------------------------- -In C++ you'd write :: +This answer actually applies to all methods, but the question usually comes up +first in the context of constructors. + +In C++ you'd write + +.. code-block:: c class C { C() { cout << "No arguments\n"; } C(int i) { cout << "Argument is " << i << "\n"; } } -in Python you have to write a single constructor that catches all -cases using default arguments. For example:: +In Python you have to write a single constructor that catches all cases using +default arguments. For example:: - class C: - def __init__(self, i=None): - if i is None: - print "No arguments" - else: - print "Argument is", i + class C: + def __init__(self, i=None): + if i is None: + print "No arguments" + else: + print "Argument is", i This is not entirely equivalent, but close enough in practice. You could also try a variable-length argument list, e.g. :: - def __init__(self, *args): - .... + def __init__(self, *args): + ... The same approach works for all method definitions. I try to use __spam and I get an error about _SomeClassName__spam. --------------------------------------------------------------------------- -Variables with double leading underscore are "mangled" to provide a -simple but effective way to define class private variables. Any -identifier of the form ``__spam`` (at least two leading -underscores, at most one trailing underscore) is textually -replaced with ``_classname__spam``, where ``classname`` is the -current class name with any leading underscores stripped. - -This doesn't guarantee privacy: an outside user can still deliberately -access the "_classname__spam" attribute, and private values are visible -in the object's ``__dict__``. Many Python programmers never bother to use -private variable names at all. +------------------------------------------------------------------ + +Variable names with double leading underscores are "mangled" to provide a simple +but effective way to define class private variables. Any identifier of the form +``__spam`` (at least two leading underscores, at most one trailing underscore) +is textually replaced with ``_classname__spam``, where ``classname`` is the +current class name with any leading underscores stripped. + +This doesn't guarantee privacy: an outside user can still deliberately access +the "_classname__spam" attribute, and private values are visible in the object's +``__dict__``. Many Python programmers never bother to use private variable +names at all. My class defines __del__ but it is not called when I delete the object. -------------------------------------------------------------------------------- +----------------------------------------------------------------------- + There are several possible reasons for this. -The del statement does not necessarily call __del__ -- it simply +The del statement does not necessarily call :meth:`__del__` -- it simply decrements the object's reference count, and if this reaches zero -__del__ is called. +:meth:`__del__` is called. -If your data structures contain circular links (e.g. a tree where each -child has a parent reference and each parent has a list of children) -the reference counts will never go back to zero. Once in a while -Python runs an algorithm to detect such cycles, but the garbage -collector might run some time after the last reference to your data -structure vanishes, so your __del__ method may be called at an -inconvenient and random time. This is inconvenient if you're trying to -reproduce a problem. Worse, the order in which object's __del__ -methods are executed is arbitrary. You can run ``gc.collect()`` to -force a collection, but there *are* pathological cases where objects will -never be collected. - -Despite the cycle collector, it's still a good idea to define an -explicit ``close()`` method on objects to be called whenever you're -done with them. The ``close()`` method can then remove attributes -that refer to subobjecs. Don't call ``__del__`` directly -- -``__del__`` should call ``close()`` and ``close()`` should make sure -that it can be called more than once for the same object. - -Another way to avoid cyclical references is to use the "weakref" -module, which allows you to point to objects without incrementing -their reference count. Tree data structures, for instance, should use -weak references for their parent and sibling references (if they need -them!). - -If the object has ever been a local variable in a function that caught -an expression in an except clause, chances are that a reference to the -object still exists in that function's stack frame as contained in the -stack trace. Normally, calling ``sys.exc_clear()`` will take care of -this by clearing the last recorded exception. +If your data structures contain circular links (e.g. a tree where each child has +a parent reference and each parent has a list of children) the reference counts +will never go back to zero. Once in a while Python runs an algorithm to detect +such cycles, but the garbage collector might run some time after the last +reference to your data structure vanishes, so your :meth:`__del__` method may be +called at an inconvenient and random time. This is inconvenient if you're trying +to reproduce a problem. Worse, the order in which object's :meth:`__del__` +methods are executed is arbitrary. You can run :func:`gc.collect` to force a +collection, but there *are* pathological cases where objects will never be +collected. + +Despite the cycle collector, it's still a good idea to define an explicit +``close()`` method on objects to be called whenever you're done with them. The +``close()`` method can then remove attributes that refer to subobjecs. Don't +call :meth:`__del__` directly -- :meth:`__del__` should call ``close()`` and +``close()`` should make sure that it can be called more than once for the same +object. + +Another way to avoid cyclical references is to use the :mod:`weakref` module, +which allows you to point to objects without incrementing their reference count. +Tree data structures, for instance, should use weak references for their parent +and sibling references (if they need them!). + +If the object has ever been a local variable in a function that caught an +expression in an except clause, chances are that a reference to the object still +exists in that function's stack frame as contained in the stack trace. +Normally, calling :func:`sys.exc_clear` will take care of this by clearing the +last recorded exception. -Finally, if your __del__ method raises an exception, a warning message -is printed to sys.stderr. +Finally, if your :meth:`__del__` method raises an exception, a warning message +is printed to :data:`sys.stderr`. How do I get a list of all instances of a given class? --------------------------------------------------------------- +------------------------------------------------------ -Python does not keep track of all instances of a class (or of a -built-in type). You can program the class's constructor to keep track -of all instances by keeping a list of weak references to each -instance. +Python does not keep track of all instances of a class (or of a built-in type). +You can program the class's constructor to keep track of all instances by +keeping a list of weak references to each instance. Modules -============= -How do I create a .pyc file? -------------------------------------- +======= -When a module is imported for the first time (or when the source is -more recent than the current compiled file) a ``.pyc`` file containing -the compiled code should be created in the same directory as the -``.py`` file. - -One reason that a ``.pyc`` file may not be created is permissions -problems with the directory. This can happen, for example, if you -develop as one user but run as another, such as if you are testing -with a web server. Creation of a .pyc file is automatic if you're -importing a module and Python has the ability (permissions, free -space, etc...) to write the compiled module back to the directory. - -Running Python on a top level script is not considered an import and -no ``.pyc`` will be created. For example, if you have a top-level -module ``abc.py`` that imports another module ``xyz.py``, when you run -abc, ``xyz.pyc`` will be created since xyz is imported, but no -``abc.pyc`` file will be created since ``abc.py`` isn't being -imported. - -If you need to create abc.pyc -- that is, to create a .pyc file for a -module that is not imported -- you can, using the py_compile and -compileall modules. - -The ``py_compile`` module can manually compile any module. One way is -to use the ``compile()`` function in that module interactively:: - - >>> import py_compile - >>> py_compile.compile('abc.py') - -This will write the ``.pyc`` to the same location as ``abc.py`` (or -you can override that with the optional parameter ``cfile``). - -You can also automatically compile all files in a directory or -directories using the ``compileall`` module. -You can do it from the shell prompt by running ``compileall.py`` -and providing the path of a directory containing Python files to compile:: +How do I create a .pyc file? +---------------------------- - python compileall.py . +When a module is imported for the first time (or when the source is more recent +than the current compiled file) a ``.pyc`` file containing the compiled code +should be created in the same directory as the ``.py`` file. + +One reason that a ``.pyc`` file may not be created is permissions problems with +the directory. This can happen, for example, if you develop as one user but run +as another, such as if you are testing with a web server. Creation of a .pyc +file is automatic if you're importing a module and Python has the ability +(permissions, free space, etc...) to write the compiled module back to the +directory. + +Running Python on a top level script is not considered an import and no ``.pyc`` +will be created. For example, if you have a top-level module ``abc.py`` that +imports another module ``xyz.py``, when you run abc, ``xyz.pyc`` will be created +since xyz is imported, but no ``abc.pyc`` file will be created since ``abc.py`` +isn't being imported. + +If you need to create abc.pyc -- that is, to create a .pyc file for a module +that is not imported -- you can, using the :mod:`py_compile` and +:mod:`compileall` modules. + +The :mod:`py_compile` module can manually compile any module. One way is to use +the ``compile()`` function in that module interactively:: + + >>> import py_compile + >>> py_compile.compile('abc.py') + +This will write the ``.pyc`` to the same location as ``abc.py`` (or you can +override that with the optional parameter ``cfile``). + +You can also automatically compile all files in a directory or directories using +the :mod:`compileall` module. You can do it from the shell prompt by running +``compileall.py`` and providing the path of a directory containing Python files +to compile:: + python -m compileall . How do I find the current module name? ---------------------------------------------- +-------------------------------------- + +A module can find out its own module name by looking at the predefined global +variable ``__name__``. If this has the value ``'__main__'``, the program is +running as a script. Many modules that are usually used by importing them also +provide a command-line interface or a self-test, and only execute this code +after checking ``__name__``:: + + def main(): + print 'Running test...' + ... -A module can find out its own module name by looking at the predefined -global variable ``__name__``. If this has the value '__main__', the -program is running as a script. Many modules that are usually used by -importing them also provide a command-line interface or a self-test, -and only execute this code after checking ``__name__``:: - - def main(): - print 'Running test...' - ... - - if __name__ == '__main__': - main() + if __name__ == '__main__': + main() How can I have modules that mutually import each other? ---------------------------------------------------------------- +------------------------------------------------------- + Suppose you have the following modules: foo.py:: - from bar import bar_var - foo_var=1 + from bar import bar_var + foo_var = 1 bar.py:: - from foo import foo_var - bar_var=2 + from foo import foo_var + bar_var = 2 The problem is that the interpreter will perform the following steps: @@ -1700,38 +1667,38 @@ * bar imports foo (which is a no-op since there already is a module named foo) * bar.foo_var = foo.foo_var -The last step fails, because Python isn't done with interpreting ``foo`` -yet and the global symbol dictionary for ``foo`` is still empty. +The last step fails, because Python isn't done with interpreting ``foo`` yet and +the global symbol dictionary for ``foo`` is still empty. -The same thing happens when you use ``import foo``, and then try to -access ``foo.foo_var`` in global code. +The same thing happens when you use ``import foo``, and then try to access +``foo.foo_var`` in global code. -There are (at least) three possible workarounds for this problem. +There are (at least) three possible workarounds for this problem. -Guido van Rossum recommends avoiding all uses of ``from -import ...``, and placing all code inside functions. Initializations -of global variables and class variables should use constants or -built-in functions only. This means everything from an imported -module is referenced as ``.``. +Guido van Rossum recommends avoiding all uses of ``from import ...``, +and placing all code inside functions. Initializations of global variables and +class variables should use constants or built-in functions only. This means +everything from an imported module is referenced as ``.``. -Jim Roskind suggests performing steps in the following order in each -module: +Jim Roskind suggests performing steps in the following order in each module: -* exports (globals, functions, and classes that don't need imported base classes) +* exports (globals, functions, and classes that don't need imported base + classes) * ``import`` statements * active code (including globals that are initialized from imported values). -van Rossum doesn't like this approach much because the imports -appear in a strange place, but it does work. +van Rossum doesn't like this approach much because the imports appear in a +strange place, but it does work. -Matthias Urlichs recommends restructuring your code so that the -recursive import is not necessary in the first place. +Matthias Urlichs recommends restructuring your code so that the recursive import +is not necessary in the first place. These solutions are not mutually exclusive. __import__('x.y.z') returns ; how do I get z? ------------------------------------------------------------------------ +--------------------------------------------------------- + Try:: __import__('x.y.z').y.z @@ -1742,41 +1709,44 @@ for i in s.split(".")[1:]: m = getattr(m, i) +See :mod:`importlib` for a convenience function called +:func:`~importlib.import_module`. + When I edit an imported module and reimport it, the changes don't show up. Why does this happen? --------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------- -For reasons of efficiency as well as consistency, Python only reads -the module file on the first time a module is imported. If it didn't, -in a program consisting of many modules where each one imports the -same basic module, the basic module would be parsed and re-parsed many -times. To force rereading of a changed module, do this:: - - import modname - reload(modname) - -Warning: this technique is not 100% fool-proof. In particular, -modules containing statements like :: - - from modname import some_objects - -will continue to work with the old version of the imported objects. -If the module contains class definitions, existing class instances -will *not* be updated to use the new class definition. This can -result in the following paradoxical behaviour:: - - >>> import cls - >>> c = cls.C() # Create an instance of C - >>> reload(cls) - - >>> isinstance(c, cls.C) # isinstance is false?!? - False +For reasons of efficiency as well as consistency, Python only reads the module +file on the first time a module is imported. If it didn't, in a program +consisting of many modules where each one imports the same basic module, the +basic module would be parsed and re-parsed many times. To force rereading of a +changed module, do this:: + + import modname + reload(modname) + +Warning: this technique is not 100% fool-proof. In particular, modules +containing statements like :: + + from modname import some_objects + +will continue to work with the old version of the imported objects. If the +module contains class definitions, existing class instances will *not* be +updated to use the new class definition. This can result in the following +paradoxical behaviour: + + >>> import cls + >>> c = cls.C() # Create an instance of C + >>> reload(cls) + + >>> isinstance(c, cls.C) # isinstance is false?!? + False The nature of the problem is made clear if you print out the class objects: - >>> c.__class__ - - >>> cls.C - + >>> c.__class__ + + >>> cls.C + Modified: sandbox/trunk/faq/windows.rst ============================================================================== --- sandbox/trunk/faq/windows.rst (original) +++ sandbox/trunk/faq/windows.rst Sun Oct 11 20:12:15 2009 @@ -1,68 +1,70 @@ +:tocdepth: 2 -==================================== +.. _windows-faq: + +===================== Python on Windows FAQ -==================================== +===================== .. contents:: How do I run a Python program under Windows? ----------------------------------------------------- - -This is not necessarily a straightforward question. If you are already -familiar with running programs from the Windows command line then everything -will seem obvious; otherwise, you might need a little more guidance. There are -also differences between Windows 95, 98, NT, ME, 2000 and XP which can add to -the confusion. +-------------------------------------------- +This is not necessarily a straightforward question. If you are already familiar +with running programs from the Windows command line then everything will seem +obvious; otherwise, you might need a little more guidance. There are also +differences between Windows 95, 98, NT, ME, 2000 and XP which can add to the +confusion. .. sidebar:: |Python Development on XP|_ :subtitle: `Python Development on XP`_ This series of screencasts aims to get you up and running with Python on Windows XP. The knowledge is distilled into 1.5 hours and will get you up - and running with the right Python distribution, coding in your choice of - IDE, and debugging and writing solid code with unit-tests. - -.. |Python Development on XP| image:: /images/python-video-icon.png -.. _`Python Development on XP`: http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries - + and running with the right Python distribution, coding in your choice of IDE, + and debugging and writing solid code with unit-tests. -Unless you use some sort of integrated development environment, you will end -up *typing* Windows commands into what is variously referred to as a "DOS -window" or "Command prompt window". Usually you can create such a window from -your Start menu; under Windows 2000 the menu selection is "Start | Programs | -Accessories | Command Prompt". You should be able to recognize when you have -started such a window because you will see a Windows "command prompt", which -usually looks like this:: +.. |Python Development on XP| image:: http://python.org/images/python-video-icon.png +.. _`Python Development on XP`: + http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries + +Unless you use some sort of integrated development environment, you will end up +*typing* Windows commands into what is variously referred to as a "DOS window" +or "Command prompt window". Usually you can create such a window from your +Start menu; under Windows 2000 the menu selection is :menuselection:`Start --> +Programs --> Accessories --> Command Prompt`. You should be able to recognize +when you have started such a window because you will see a Windows "command +prompt", which usually looks like this:: - C:\> + C:\> The letter may be different, and there might be other things after it, so you might just as easily see something like:: - D:\Steve\Projects\Python> + D:\Steve\Projects\Python> depending on how your computer has been set up and what else you have recently -done with it. Once you have started such a window, you are well on the way to +done with it. Once you have started such a window, you are well on the way to running Python programs. You need to realize that your Python scripts have to be processed by another -program called the Python interpreter. The interpreter reads your script, +program called the Python interpreter. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program. So, how do you arrange for the interpreter to handle your Python? First, you need to make sure that your command window recognises the word -"python" as an instruction to start the interpreter. If you have opened a +"python" as an instruction to start the interpreter. If you have opened a command window, you should try entering the command ``python`` and hitting return. You should then see something like:: - Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 - Type "help", "copyright", "credits" or "license" for more information. - >>> - -You have started the interpreter in "interactive mode". That means you can -enter Python statements or expressions interactively and have them executed or -evaluated while you wait. This is one of Python's strongest features. Check it + Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 + Type "help", "copyright", "credits" or "license" for more information. + >>> + +You have started the interpreter in "interactive mode". That means you can enter +Python statements or expressions interactively and have them executed or +evaluated while you wait. This is one of Python's strongest features. Check it by entering a few expressions of your choice and seeing the results:: >>> print "Hello" @@ -71,163 +73,160 @@ HelloHelloHello Many people use the interactive mode as a convenient yet highly programmable -calculator. When you want to end your interactive Python session, hold the -Ctrl key down while you enter a Z, then hit the "Enter" key to get back to -your Windows command prompt. - -You may also find that you have a Start-menu entry such as "Start | Programs | -Python 2.2 | Python (command line)" that results in you seeing the ``>>>`` -prompt in a new window. If so, the window will disappear after you enter the -Ctrl-Z character; Windows is running a single "python" command in the window, -and closes it when you terminate the interpreter. +calculator. When you want to end your interactive Python session, hold the Ctrl +key down while you enter a Z, then hit the "Enter" key to get back to your +Windows command prompt. + +You may also find that you have a Start-menu entry such as :menuselection:`Start +--> Programs --> Python 2.2 --> Python (command line)` that results in you +seeing the ``>>>`` prompt in a new window. If so, the window will disappear +after you enter the Ctrl-Z character; Windows is running a single "python" +command in the window, and closes it when you terminate the interpreter. -If the ``python`` command, instead of displaying the interpreter prompt -``>>>``, gives you a message like:: - - 'python' is not recognized as an internal or external command, - operable program or batch file. +If the ``python`` command, instead of displaying the interpreter prompt ``>>>``, +gives you a message like:: + 'python' is not recognized as an internal or external command, + operable program or batch file. .. sidebar:: |Adding Python to DOS Path|_ :subtitle: `Adding Python to DOS Path`_ Python is not added to the DOS path by default. This screencast will walk - you through the steps to add the correct entry to the `System Path`, - allowing Python to be executed from the command-line by all users. + you through the steps to add the correct entry to the `System Path`, allowing + Python to be executed from the command-line by all users. -.. |Adding Python to DOS Path| image:: /images/python-video-icon.png -.. _`Adding Python to DOS Path`: http://showmedo.com/videos/video?name=960000&fromSeriesID=96 +.. |Adding Python to DOS Path| image:: http://python.org/images/python-video-icon.png +.. _`Adding Python to DOS Path`: + http://showmedo.com/videos/video?name=960000&fromSeriesID=96 or:: - Bad command or filename + Bad command or filename then you need to make sure that your computer knows where to find the Python -interpreter. To do this you will have to modify a setting called PATH, which -is a list of directories where Windows will look for programs. +interpreter. To do this you will have to modify a setting called PATH, which is +a list of directories where Windows will look for programs. You should arrange for Python's installation directory to be added to the PATH -of every command window as it starts. If you installed Python fairly recently +of every command window as it starts. If you installed Python fairly recently then the command :: - dir C:\py* + dir C:\py* will probably tell you where it is installed; the usual location is something like ``C:\Python23``. Otherwise you will be reduced to a search of your whole -disk ... use "Tools | Find" or hit the "Search" button and look for -"python.exe". Supposing you discover that Python is installed in the -``C:\Python23`` directory (the default at the time of writing), you should -make sure that entering the command :: - - c:\Python23\python - -starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" -and an "Enter" to get out of it). Once you have verified the directory, you -need to add it to the start-up routines your computer goes through. For older -versions of Windows the easiest way to do this is to edit the -``C:\AUTOEXEC.BAT`` file. You would want to add a line like the following to -``AUTOEXEC.BAT``:: - - PATH C:\Python23;%PATH% - -For Windows NT, 2000 and (I assume) XP, you will need to add a string such as -:: - - ;C:\Python23 - -to the current setting for the PATH environment variable, which you will find -in the properties window of "My Computer" under the "Advanced" tab. Note that -if you have sufficient privilege you might get a choice of installing the -settings either for the Current User or for System. The latter is preferred if -you want everybody to be able to run Python on the machine. - -If you aren't confident doing any of these manipulations yourself, ask for -help! At this stage you may want to reboot your system to make absolutely -sure the new setting has taken effect. You probably won't need to reboot for -Windows NT, XP or 2000. You can also avoid it in earlier versions by editing -the file ``C:\WINDOWS\COMMAND\CMDINIT.BAT`` instead of ``AUTOEXEC.BAT``. +disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` +button and look for "python.exe". Supposing you discover that Python is +installed in the ``C:\Python23`` directory (the default at the time of writing), +you should make sure that entering the command :: + + c:\Python23\python + +starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and +an "Enter" to get out of it). Once you have verified the directory, you need to +add it to the start-up routines your computer goes through. For older versions +of Windows the easiest way to do this is to edit the ``C:\AUTOEXEC.BAT`` +file. You would want to add a line like the following to ``AUTOEXEC.BAT``:: + + PATH C:\Python23;%PATH% + +For Windows NT, 2000 and (I assume) XP, you will need to add a string such as :: + + ;C:\Python23 + +to the current setting for the PATH environment variable, which you will find in +the properties window of "My Computer" under the "Advanced" tab. Note that if +you have sufficient privilege you might get a choice of installing the settings +either for the Current User or for System. The latter is preferred if you want +everybody to be able to run Python on the machine. + +If you aren't confident doing any of these manipulations yourself, ask for help! +At this stage you may want to reboot your system to make absolutely sure the new +setting has taken effect. You probably won't need to reboot for Windows NT, XP +or 2000. You can also avoid it in earlier versions by editing the file +``C:\WINDOWS\COMMAND\CMDINIT.BAT`` instead of ``AUTOEXEC.BAT``. You should now be able to start a new command window, enter ``python`` at the -``C:>`` (or whatever) prompt, and see the ``>>>`` prompt that indicates the +``C:\>`` (or whatever) prompt, and see the ``>>>`` prompt that indicates the Python interpreter is reading interactive commands. Let's suppose you have a program called ``pytest.py`` in directory -``C:\Steve\Projects\Python``. A session to run that program might look like +``C:\Steve\Projects\Python``. A session to run that program might look like this:: - C:\> cd \Steve\Projects\Python - C:\Steve\Projects\Python> python pytest.py + C:\> cd \Steve\Projects\Python + C:\Steve\Projects\Python> python pytest.py Because you added a file name to the command to start the interpreter, when it starts up it reads the Python script in the named file, compiles it, executes it, and terminates, so you see another ``C:\>`` prompt. You might also have entered :: - C:\> python \Steve\Projects\Python\pytest.py + C:\> python \Steve\Projects\Python\pytest.py if you hadn't wanted to change your current directory. Under NT, 2000 and XP you may well find that the installation process has also arranged that the command ``pytest.py`` (or, if the file isn't in the current -directory, ``C:\Steve\Projects\Python\pytest.py``) will automatically -recognize the ".py" extension and run the Python interpreter on the named -file. Using this feature is fine, but *some* versions of Windows have bugs -which mean that this form isn't exactly equivalent to using the interpreter -explicitly, so be careful. +directory, ``C:\Steve\Projects\Python\pytest.py``) will automatically recognize +the ".py" extension and run the Python interpreter on the named file. Using this +feature is fine, but *some* versions of Windows have bugs which mean that this +form isn't exactly equivalent to using the interpreter explicitly, so be +careful. The important things to remember are: 1. Start Python from the Start Menu, or make sure the PATH is set correctly so Windows can find the Python interpreter. :: - python + python - should give you a '>>>" prompt from the Python interpreter. Don't forget - the CTRL-Z and ENTER to terminate the interpreter (and, if you started the - window from the Start Menu, make the window disappear). + should give you a '>>>' prompt from the Python interpreter. Don't forget the + CTRL-Z and ENTER to terminate the interpreter (and, if you started the window + from the Start Menu, make the window disappear). 2. Once this works, you run programs with commands:: - python {program-file} + python {program-file} -3. When you know the commands to use you can build Windows shortcuts to run - the Python interpreter on any of your scripts, naming particular working +3. When you know the commands to use you can build Windows shortcuts to run the + Python interpreter on any of your scripts, naming particular working directories, and adding them to your menus. Take a look at :: - python --help + python --help if your needs are complex. -4. Interactive mode (where you see the ``>>>`` prompt) is best used for - checking that individual statements and expressions do what you think they - will, and for developing code by experiment. +4. Interactive mode (where you see the ``>>>`` prompt) is best used for checking + that individual statements and expressions do what you think they will, and + for developing code by experiment. How do I make python scripts executable? ----------------------------------------------- +---------------------------------------- On Windows 2000, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open -command that runs the interpreter (D:\\Program Files\\Python\\python.exe "%1" -%*). This is enough to make scripts executable from the command prompt as -'foo.py'. If you'd rather be able to execute the script by simple typing -'foo' with no extension you need to add .py to the PATHEXT environment -variable. - -On Windows NT, the steps taken by the installer as described above allow you -to run a script with 'foo.py', but a longtime bug in the NT command processor -prevents you from redirecting the input or output of any script executed in -this way. This is often important. +command that runs the interpreter (``D:\Program Files\Python\python.exe "%1" +%*``). This is enough to make scripts executable from the command prompt as +'foo.py'. If you'd rather be able to execute the script by simple typing 'foo' +with no extension you need to add .py to the PATHEXT environment variable. + +On Windows NT, the steps taken by the installer as described above allow you to +run a script with 'foo.py', but a longtime bug in the NT command processor +prevents you from redirecting the input or output of any script executed in this +way. This is often important. -The incantation for making a Python script executable under WinNT is to give -the file an extension of .cmd and add the following as the first line:: +The incantation for making a Python script executable under WinNT is to give the +file an extension of .cmd and add the following as the first line:: - @setlocal enableextensions & python -x %~f0 %* & goto :EOF + @setlocal enableextensions & python -x %~f0 %* & goto :EOF Why does Python sometimes take so long to start? -------------------------------------------------------- +------------------------------------------------ Usually Python starts very quickly on Windows, but occasionally there are bug reports that Python suddenly begins to take a long time to start up. This is @@ -237,14 +236,14 @@ The problem may be caused by a misconfiguration of virus checking software on the problem machine. Some virus scanners have been known to introduce startup overhead of two orders of magnitude when the scanner is configured to monitor -all reads from the filesystem. Try checking the configuration of virus -scanning software on your systems to ensure that they are indeed configured -identically. McAfee, when configured to scan all file system read activity, -is a particular offender. +all reads from the filesystem. Try checking the configuration of virus scanning +software on your systems to ensure that they are indeed configured identically. +McAfee, when configured to scan all file system read activity, is a particular +offender. Where is Freeze for Windows? ------------------------------------- +---------------------------- "Freeze" is a program that allows you to ship a Python program as a single stand-alone executable file. It is *not* a compiler; your programs don't run @@ -261,49 +260,53 @@ Is a ``*.pyd`` file the same as a DLL? ------------------------------------------- +-------------------------------------- + +.. XXX update for py3k (PyInit_foo) Yes, .pyd files are dll's, but there are a few differences. If you have a DLL -named ``foo.pyd``, then it must have a function initfoo(). You can then write -Python "import foo", and Python will search for foo.pyd (as well as foo.py, -foo.pyc) and if it finds it, will attempt to call initfoo() to initialize it. -You do not link your .exe with foo.lib, as that would cause Windows to require -the DLL to be present. +named ``foo.pyd``, then it must have a function ``initfoo()``. You can then +write Python "import foo", and Python will search for foo.pyd (as well as +foo.py, foo.pyc) and if it finds it, will attempt to call ``initfoo()`` to +initialize it. You do not link your .exe with foo.lib, as that would cause +Windows to require the DLL to be present. Note that the search path for foo.pyd is PYTHONPATH, not the same as the path that Windows uses to search for foo.dll. Also, foo.pyd need not be present to run your program, whereas if you linked your program with a dll, the dll is -required. Of course, foo.pyd is required if you want to say "import foo". In -a DLL, linkage is declared in the source code with __declspec(dllexport). In -a .pyd, linkage is defined in a list of available functions. +required. Of course, foo.pyd is required if you want to say ``import foo``. In +a DLL, linkage is declared in the source code with ``__declspec(dllexport)``. +In a .pyd, linkage is defined in a list of available functions. + How can I embed Python into a Windows application? ----------------------------------------------------------- +-------------------------------------------------- -Embedding the Python interpreter in a Windows app can be summarized as -follows: +Embedding the Python interpreter in a Windows app can be summarized as follows: -1. Do _not_ build Python into your .exe file directly. On Windows, Python - must be a DLL to handle importing modules that are themselves DLL's. (This - is the first key undocumented fact.) Instead, link to pythonNN.dll; it is +1. Do _not_ build Python into your .exe file directly. On Windows, Python must + be a DLL to handle importing modules that are themselves DLL's. (This is the + first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is typically installed in ``C:\Windows\System``. NN is the Python version, a number such as "23" for Python 2.3. You can link to Python statically or dynamically. Linking statically means - linking against pythonNN.lib, while dynamically linking means linking - against pythonNN.dll. The drawback to dynamic linking is that your app - won't run if pythonNN.dll does not exist on your system. (General note: - pythonNN.lib is the so-called "import lib" corresponding to python.dll. It - merely defines symbols for the linker.) + linking against :file:`python{NN}.lib`, while dynamically linking means + linking against :file:`python{NN}.dll`. The drawback to dynamic linking is + that your app won't run if :file:`python{NN}.dll` does not exist on your + system. (General note: :file:`python{NN}.lib` is the so-called "import lib" + corresponding to :file:`python.dll`. It merely defines symbols for the + linker.) Linking dynamically greatly simplifies link options; everything happens at - run time. Your code must load pythonNN.dll using the Windows - LoadLibraryEx() routine. The code must also use access routines and data - in pythonNN.dll (that is, Python's C API's) using pointers obtained by the - Windows GetProcAddress() routine. Macros can make using these pointers - transparent to any C code that calls routines in Python's C API. + run time. Your code must load :file:`python{NN}.dll` using the Windows + ``LoadLibraryEx()`` routine. The code must also use access routines and data + in :file:`python{NN}.dll` (that is, Python's C API's) using pointers obtained + by the Windows ``GetProcAddress()`` routine. Macros can make using these + pointers transparent to any C code that calls routines in Python's C API. - Borland note: convert pythonNN.lib to OMF format using Coff2Omf.exe first. + Borland note: convert :file:`python{NN}.lib` to OMF format using Coff2Omf.exe + first. 2. If you use SWIG, it is easy to create a Python "extension module" that will make the app's data and methods available to Python. SWIG will handle just @@ -312,35 +315,38 @@ also simplifies linking. 3. SWIG will create an init function (a C function) whose name depends on the - name of the extension module. For example, if the name of the module is - leo, the init function will be called initleo(). If you use SWIG shadow - classes, as you should, the init function will be called initleoc(). This - initializes a mostly hidden helper class used by the shadow class. + name of the extension module. For example, if the name of the module is leo, + the init function will be called initleo(). If you use SWIG shadow classes, + as you should, the init function will be called initleoc(). This initializes + a mostly hidden helper class used by the shadow class. The reason you can link the C code in step 2 into your .exe file is that calling the initialization function is equivalent to importing the module into Python! (This is the second key undocumented fact.) -4. In short, you can use the following code to initialize the Python - interpreter with your extension module. :: +4. In short, you can use the following code to initialize the Python interpreter + with your extension module. + + .. code-block:: c - #include "python.h" - ... - Py_Initialize(); // Initialize Python. - initmyAppc(); // Initialize (import) the helper class. - PyRun_SimpleString("import myApp") ; // Import the shadow class. - -5. There are two problems with Python's C API which will become apparent if - you use a compiler other than MSVC, the compiler used to build - pythonNN.dll. + #include "python.h" + ... + Py_Initialize(); // Initialize Python. + initmyAppc(); // Initialize (import) the helper class. + PyRun_SimpleString("import myApp") ; // Import the shadow class. + +5. There are two problems with Python's C API which will become apparent if you + use a compiler other than MSVC, the compiler used to build pythonNN.dll. Problem 1: The so-called "Very High Level" functions that take FILE * arguments will not work in a multi-compiler environment because each - compiler's notion of a struct FILE will be different. From an - implementation standpoint these are very _low_ level functions. + compiler's notion of a struct FILE will be different. From an implementation + standpoint these are very _low_ level functions. + + Problem 2: SWIG generates the following code when generating wrappers to void + functions: - Problem 2: SWIG generates the following code when generating wrappers to - void functions:: + .. code-block:: c Py_INCREF(Py_None); _resultobj = Py_None; @@ -348,25 +354,27 @@ Alas, Py_None is a macro that expands to a reference to a complex data structure called _Py_NoneStruct inside pythonNN.dll. Again, this code will - fail in a mult-compiler environment. Replace such code by:: + fail in a mult-compiler environment. Replace such code by: + + .. code-block:: c return Py_BuildValue(""); - It may be possible to use SWIG's %typemap command to make the change + It may be possible to use SWIG's ``%typemap`` command to make the change automatically, though I have not been able to get this to work (I'm a complete SWIG newbie). -6. Using a Python shell script to put up a Python interpreter window from - inside your Windows app is not a good idea; the resulting window will be - independent of your app's windowing system. Rather, you (or the - wxPythonWindow class) should create a "native" interpreter window. It is - easy to connect that window to the Python interpreter. You can redirect - Python's i/o to _any_ object that supports read and write, so all you need - is a Python object (defined in your extension module) that contains read() - and write() methods. +6. Using a Python shell script to put up a Python interpreter window from inside + your Windows app is not a good idea; the resulting window will be independent + of your app's windowing system. Rather, you (or the wxPythonWindow class) + should create a "native" interpreter window. It is easy to connect that + window to the Python interpreter. You can redirect Python's i/o to _any_ + object that supports read and write, so all you need is a Python object + (defined in your extension module) that contains read() and write() methods. + How do I use Python for CGI? -------------------------------------------------------- +---------------------------- On the Microsoft IIS server or on the Win95 MS Personal Web Server you set up Python in the same way that you would set up any other scripting engine. @@ -375,20 +383,20 @@ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap -and enter the following line (making any specific changes that your system may need):: +and enter the following line (making any specific changes that your system may +need):: .py :REG_SZ: c:\\python.exe -u %s %s This line will allow you to call your script with a simple reference like: http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" directory for your server (which it usually is by default). The "-u" flag -specifies unbuffered and binary mode for stdin - needed when working with -binary data. +specifies unbuffered and binary mode for stdin - needed when working with binary +data. In addition, it is recommended that using ".py" may not be a good idea for the file extensions when used in this context (you might want to reserve ``*.py`` -for support modules and use ``*.cgi`` or ``*.cgp`` for "main program" -scripts). +for support modules and use ``*.cgi`` or ``*.cgp`` for "main program" scripts). In order to set up Internet Information Services 5 to use Python for CGI processing, please see the following links: @@ -401,109 +409,110 @@ ScriptInterpreterSource Registry -Then, give your Python CGI-scripts the extension .py and put them in the -cgi-bin directory. +Then, give your Python CGI-scripts the extension .py and put them in the cgi-bin +directory. How do I keep editors from inserting tabs into my Python source? ------------------------------------------------------------------- +---------------------------------------------------------------- -The FAQ does not recommend using tabs, and `the Python style guide -`_ recommends 4 spaces for -distributed Python code; this is also the Emacs python-mode default. - -Under any editor, mixing tabs and spaces is a bad idea. MSVC is no different -in this respect, and is easily configured to use spaces: Take Tools -> Options --> Tabs, and for file type "Default" set "Tab size" and "Indent size" to 4, -and select the "Insert spaces" radio button. - -If you suspect mixed tabs and spaces are causing problems in leading -whitespace, run Python with the -t switch or run ``Tools/Scripts/tabnanny.py`` -to check a directory tree in batch mode. +The FAQ does not recommend using tabs, and the Python style guide, :pep:`8`, +recommends 4 spaces for distributed Python code; this is also the Emacs +python-mode default. + +Under any editor, mixing tabs and spaces is a bad idea. MSVC is no different in +this respect, and is easily configured to use spaces: Take :menuselection:`Tools +--> Options --> Tabs`, and for file type "Default" set "Tab size" and "Indent +size" to 4, and select the "Insert spaces" radio button. + +If you suspect mixed tabs and spaces are causing problems in leading whitespace, +run Python with the :option:`-t` switch or run ``Tools/Scripts/tabnanny.py`` to +check a directory tree in batch mode. How do I check for a keypress without blocking? ----------------------------------------------------- +----------------------------------------------- Use the msvcrt module. This is a standard Windows-specific extension module. -It defines a function kbhit() which checks whether a keyboard hit is present, -and getch() which gets one character without echoing it. +It defines a function ``kbhit()`` which checks whether a keyboard hit is +present, and ``getch()`` which gets one character without echoing it. How do I emulate os.kill() in Windows? ---------------------------------------------- +-------------------------------------- Use win32api:: - def kill(pid): - """kill function for Win32""" - import win32api - handle = win32api.OpenProcess(1, 0, pid) - return (0 != win32api.TerminateProcess(handle, 0)) + def kill(pid): + """kill function for Win32""" + import win32api + handle = win32api.OpenProcess(1, 0, pid) + return (0 != win32api.TerminateProcess(handle, 0)) Why does os.path.isdir() fail on NT shared directories? --------------------------------------------------------------- +------------------------------------------------------- The solution appears to be always append the "\\" on the end of shared -drives. :: +drives. - >>> import os - >>> os.path.isdir( '\\\\rorschach\\public') - 0 - >>> os.path.isdir( '\\\\rorschach\\public\\') - 1 + >>> import os + >>> os.path.isdir( '\\\\rorschach\\public') + 0 + >>> os.path.isdir( '\\\\rorschach\\public\\') + 1 It helps to think of share points as being like drive letters. Example:: - k: is not a directory - k:\ is a directory - k:\media is a directory - k:\media\ is not a directory + k: is not a directory + k:\ is a directory + k:\media is a directory + k:\media\ is not a directory The same rules apply if you substitute "k:" with "\\conky\foo":: - \\conky\foo is not a directory - \\conky\foo\ is a directory - \\conky\foo\media is a directory - \\conky\foo\media\ is not a directory + \\conky\foo is not a directory + \\conky\foo\ is a directory + \\conky\foo\media is a directory + \\conky\foo\media\ is not a directory cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! ------------------------------------------------------------------------------ +------------------------------------------------------------------------ Be sure you have the latest python.exe, that you are using python.exe rather -than a GUI version of Python and that you have configured the server to -execute :: +than a GUI version of Python and that you have configured the server to execute +:: - "...\python.exe -u ..." + "...\python.exe -u ..." -for the CGI execution. The -u (unbuffered) option on NT and Win95 prevents -the interpreter from altering newlines in the standard input and output. -Without it post/multipart requests will seem to have the wrong length and -binary (e.g. GIF) responses may get garbled (resulting in broken images, PDF +for the CGI execution. The :option:`-u` (unbuffered) option on NT and Win95 +prevents the interpreter from altering newlines in the standard input and +output. Without it post/multipart requests will seem to have the wrong length +and binary (e.g. GIF) responses may get garbled (resulting in broken images, PDF files, and other binary downloads failing). + Why doesn't os.popen() work in PythonWin on NT? -------------------------------------------------------- +----------------------------------------------- -The reason that os.popen() doesn't work from within PythonWin is due to a bug -in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 -console attached to the process. +The reason that os.popen() doesn't work from within PythonWin is due to a bug in +Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console +attached to the process. You should use the win32pipe module's popen() instead which doesn't depend on having an attached Win32 console. Example:: - import win32pipe - f = win32pipe.popen('dir /c c:\\') - print f.readlines() - f.close() + import win32pipe + f = win32pipe.popen('dir /c c:\\') + print f.readlines() + f.close() Why doesn't os.popen()/win32pipe.popen() work on Win9x? ---------------------------------------------------------------- +------------------------------------------------------- There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. The @@ -512,83 +521,87 @@ PyRun_SimpleFile() crashes on Windows but not on Unix; why? ------------------------------------------------------------- +----------------------------------------------------------- This is very sensitive to the compiler vendor, version and (perhaps) even -options. If the FILE* structure in your embedding program isn't the same as -is assumed by the Python interpreter it won't work. +options. If the FILE* structure in your embedding program isn't the same as is +assumed by the Python interpreter it won't work. The Python 1.5.* DLLs (``python15.dll``) are all compiled with MS VC++ 5.0 and with multithreading-DLL options (``/MD``). -If you can't change compilers or flags, try using Py_RunSimpleString(). A -trick to get it to run an arbitrary file is to construct a call to execfile() -with the name of your file as argument. +If you can't change compilers or flags, try using :cfunc:`Py_RunSimpleString`. +A trick to get it to run an arbitrary file is to construct a call to +:func:`execfile` with the name of your file as argument. Also note that you can not mix-and-match Debug and Release versions. If you -wish to use the Debug Multithreaded DLL, then your module _must_ have an "_d" +wish to use the Debug Multithreaded DLL, then your module *must* have an "_d" appended to the base name. Importing _tkinter fails on Windows 95/98: why? ------------------------------------------------ -Sometimes, the import of _tkinter fails on Windows 95 or 98, complaining with -a message like the following:: +Sometimes, the import of _tkinter fails on Windows 95 or 98, complaining with a +message like the following:: - ImportError: DLL load failed: One of the library files needed - to run this application cannot be found. + ImportError: DLL load failed: One of the library files needed + to run this application cannot be found. It could be that you haven't installed Tcl/Tk, but if you did install Tcl/Tk, -and the Wish application works correctly, the problem may be that its -installer didn't manage to edit the autoexec.bat file correctly. It tries to -add a statement that changes the PATH environment variable to include the -Tcl/Tk 'bin' subdirectory, but sometimes this edit doesn't quite work. -Opening it with notepad usually reveals what the problem is. +and the Wish application works correctly, the problem may be that its installer +didn't manage to edit the autoexec.bat file correctly. It tries to add a +statement that changes the PATH environment variable to include the Tcl/Tk 'bin' +subdirectory, but sometimes this edit doesn't quite work. Opening it with +notepad usually reveals what the problem is. (One additional hint, noted by David Szafranski: you can't use long filenames -here; e.g. use ``C:\PROGRA~1\Tcl\bin`` instead of ``C:\Program -Files\Tcl\bin``.) +here; e.g. use ``C:\PROGRA~1\Tcl\bin`` instead of ``C:\Program Files\Tcl\bin``.) + How do I extract the downloaded documentation on Windows? ------------------------------------------------------------- +--------------------------------------------------------- Sometimes, when you download the documentation package to a Windows machine using a web browser, the file extension of the saved file ends up being .EXE. This is a mistake; the extension should be .TGZ. -Simply rename the downloaded file to have the .TGZ extension, and WinZip will -be able to handle it. (If your copy of WinZip doesn't, get a newer one from +Simply rename the downloaded file to have the .TGZ extension, and WinZip will be +able to handle it. (If your copy of WinZip doesn't, get a newer one from http://www.winzip.com.) + Missing cw3215mt.dll (or missing cw3215.dll) ----------------------------------------------------- +-------------------------------------------- -Sometimes, when using Tkinter on Windows, you get an error that cw3215mt.dll -or cw3215.dll is missing. +Sometimes, when using Tkinter on Windows, you get an error that cw3215mt.dll or +cw3215.dll is missing. Cause: you have an old Tcl/Tk DLL built with cygwin in your path (probably ``C:\Windows``). You must use the Tcl/Tk DLLs from the standard Tcl/Tk installation (Python 1.5.2 comes with one). + Warning about CTL3D32 version from installer ----------------------------------------------------- +-------------------------------------------- The Python installer issues a warning like this:: - This version uses ``CTL3D32.DLL`` which is not the correct version. - This version is used for windows NT applications only. + This version uses ``CTL3D32.DLL`` which is not the correct version. + This version is used for windows NT applications only. + +Tim Peters: -[Tim Peters] This is a Microsoft DLL, and a notorious source of problems. The -message means what it says: you have the wrong version of this DLL for your -operating system. The Python installation did not cause this -- something -else you installed previous to this overwrote the DLL that came with your OS -(probably older shareware of some sort, but there's no way to tell now). If -you search for "CTL3D32" using any search engine (AltaVista, for example), -you'll find hundreds and hundreds of web pages complaining about the same -problem with all sorts of installation programs. They'll point you to ways to -get the correct version reinstalled on your system (since Python doesn't cause -this, we can't fix it). + This is a Microsoft DLL, and a notorious source of problems. The message + means what it says: you have the wrong version of this DLL for your operating + system. The Python installation did not cause this -- something else you + installed previous to this overwrote the DLL that came with your OS (probably + older shareware of some sort, but there's no way to tell now). If you search + for "CTL3D32" using any search engine (AltaVista, for example), you'll find + hundreds and hundreds of web pages complaining about the same problem with + all sorts of installation programs. They'll point you to ways to get the + correct version reinstalled on your system (since Python doesn't cause this, + we can't fix it). David A Burton has written a little program to fix this. Go to -http://www.burtonsys.com/download.html and click on "ctl3dfix.zip" +http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". From python-checkins at python.org Sun Oct 11 20:17:31 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 18:17:31 -0000 Subject: [Python-checkins] r75361 - in sandbox/trunk/faq: design.rst extending.rst general.rst gui.rst programming.rst Message-ID: Author: georg.brandl Date: Sun Oct 11 20:17:31 2009 New Revision: 75361 Log: Fix remaining links that either are now internal or now must be external. Modified: sandbox/trunk/faq/design.rst sandbox/trunk/faq/extending.rst sandbox/trunk/faq/general.rst sandbox/trunk/faq/gui.rst sandbox/trunk/faq/programming.rst Modified: sandbox/trunk/faq/design.rst ============================================================================== --- sandbox/trunk/faq/design.rst (original) +++ sandbox/trunk/faq/design.rst Sun Oct 11 20:17:31 2009 @@ -91,9 +91,8 @@ if expected_result-epsilon <= computation() <= expected_result+epsilon: ... -Please see the chapter on `floating point arithmetic -`_ in the Python tutorial for -more information. +Please see the chapter on :ref:`floating point arithmetic ` in +the Python tutorial for more information. Why are Python strings immutable? @@ -322,9 +321,8 @@ You can do this easily enough with a sequence of ``if... elif... elif... else``. There have been some proposals for switch statement syntax, but there is no -consensus (yet) on whether and how to do range tests. See `PEP 275 -`_ for complete details and the current -status. +consensus (yet) on whether and how to do range tests. See :pep:`275` for +complete details and the current status. For cases where you need to choose from a very large number of possibilities, you can create a dictionary mapping case values to functions to call. For @@ -398,12 +396,12 @@ ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this approach is feasible, +conferences `_ have shown that this approach is feasible, although the speedups reached so far are only modest (e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated that in combination with whole-program analysis, speedups of 1000x are feasible for small demo programs. See the proceedings from the `1997 Python conference -`_ for more information.) +`_ for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual Modified: sandbox/trunk/faq/extending.rst ============================================================================== --- sandbox/trunk/faq/extending.rst (original) +++ sandbox/trunk/faq/extending.rst Sun Oct 11 20:17:31 2009 @@ -11,8 +11,8 @@ ----------------------------------- Yes, you can create built-in modules containing functions, variables, exceptions -and even new types in C. This is explained in the document "Extending and -Embedding the Python Interpreter" (http://docs.python.org/ext/ext.html). +and even new types in C. This is explained in the document +:ref:`extending-index`. Most intermediate or advanced Python books will also cover this topic. Modified: sandbox/trunk/faq/general.rst ============================================================================== --- sandbox/trunk/faq/general.rst (original) +++ sandbox/trunk/faq/general.rst Sun Oct 11 20:17:31 2009 @@ -50,8 +50,8 @@ unmodified), or to sell products that incorporate Python in some form. We would still like to know about all commercial use of Python, of course. -See `the PSF license page `_ to find further explanations and a -link to the full text of the license. +See `the PSF license page `_ to find further +explanations and a link to the full text of the license. The Python logo is trademarked, and in certain cases permission is required to use it. Consult `the Trademark Usage Policy @@ -124,8 +124,8 @@ Python versions are numbered A.B.C or A.B. A is the major version number -- it is only incremented for really major changes in the language. B is the minor version number, incremented for less earth-shattering changes. C is the -micro-level -- it is incremented for each bugfix release. See `PEP 6 -`_ for more information about bugfix releases. +micro-level -- it is incremented for each bugfix release. See :pep:`6` for more +information about bugfix releases. Not all releases are bugfix releases. In the run-up to a new major release, a series of development releases are made, denoted as alpha, beta, or release @@ -239,7 +239,7 @@ .. XXX adapt link to dev guide For more information on how Python is developed, consult `the Python Developer's -Guide `_. +Guide `_. Are there any published articles about Python that I can reference? @@ -306,11 +306,13 @@ guaranteed that interfaces will remain the same throughout a series of bugfix releases. -The `2.6.2 release `_ is recommended production-ready version at -this point in time. Python 3.1 is also considered production-ready, but may be -less useful, since currently there is more third party software available for -Python 2 than for Python 3. Python 2 code will generally not run unchanged in -Python 3. +.. XXX this gets out of date pretty often + +The `2.6.4 release `_ is recommended +production-ready version at this point in time. Python 3.1 is also considered +production-ready, but may be less useful, since currently there is more third +party software available for Python 2 than for Python 3. Python 2 code will +generally not run unchanged in Python 3. How many people are using Python? @@ -367,9 +369,8 @@ all at a single stroke. Providing a gradual upgrade path is necessary if a feature has to be changed. -`PEP 5 `_ describes the procedure followed -for introducing backward-incompatible changes while minimizing disruption for -users. +:pep:`5` describes the procedure followed for introducing backward-incompatible +changes while minimizing disruption for users. Is Python Y2K (Year 2000) Compliant? Modified: sandbox/trunk/faq/gui.rst ============================================================================== --- sandbox/trunk/faq/gui.rst (original) +++ sandbox/trunk/faq/gui.rst Sun Oct 11 20:17:31 2009 @@ -89,9 +89,9 @@ can use MacOS X's Cocoa libraries. See the documentation that comes with the Mac port. -`Pythonwin `_ by Mark Hammond includes an -interface to the Microsoft Foundation Classes and a Python programming -environment using it that's written mostly in Python. +:ref:`Pythonwin ` by Mark Hammond includes an interface to the +Microsoft Foundation Classes and a Python programming environment using it +that's written mostly in Python. Tkinter questions Modified: sandbox/trunk/faq/programming.rst ============================================================================== --- sandbox/trunk/faq/programming.rst (original) +++ sandbox/trunk/faq/programming.rst Sun Oct 11 20:17:31 2009 @@ -710,11 +710,11 @@ search of the standard library found remarkably few places where using an if-then-else expression would make the code more understandable. -In 2002, `PEP 308 `_ was written proposing several possible -syntaxes and the community was asked to vote on the issue. The vote was -inconclusive. Most people liked one of the syntaxes, but also hated other -syntaxes; many votes implied that people preferred no ternary operator rather -than having a syntax they hated. +In 2002, :pep:`308` was written proposing several possible syntaxes and the +community was asked to vote on the issue. The vote was inconclusive. Most +people liked one of the syntaxes, but also hated other syntaxes; many votes +implied that people preferred no ternary operator rather than having a syntax +they hated. Is it possible to write obfuscated one-liners in Python? From python-checkins at python.org Sun Oct 11 20:28:48 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 11 Oct 2009 18:28:48 -0000 Subject: [Python-checkins] r75362 - python/branches/py3k/Lib/test/test_descr.py Message-ID: Author: benjamin.peterson Date: Sun Oct 11 20:28:48 2009 New Revision: 75362 Log: actually test a method that will be lookup in py3 Modified: python/branches/py3k/Lib/test/test_descr.py Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Sun Oct 11 20:28:48 2009 @@ -1022,8 +1022,8 @@ import sys,gc if hasattr(gc, 'get_objects'): class G(object): - def __cmp__(self, other): - return 0 + def __eq__(self, other): + return False g = G() orig_objects = len(gc.get_objects()) for i in range(10): From python-checkins at python.org Sun Oct 11 20:31:24 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 18:31:24 -0000 Subject: [Python-checkins] r75363 - in python/trunk/Doc: contents.rst faq faq/design.rst faq/extending.rst faq/general.rst faq/gui.rst faq/index.rst faq/installed.rst faq/library.rst faq/programming.rst faq/python-video-icon.png faq/windows.rst tools/sphinxext/indexcontent.html Message-ID: Author: georg.brandl Date: Sun Oct 11 20:31:23 2009 New Revision: 75363 Log: Add the Python FAQ lists to the documentation. Copied from sandbox/faq. Many thanks to AMK for the preparation work. Added: python/trunk/Doc/faq/ python/trunk/Doc/faq/design.rst (contents, props changed) python/trunk/Doc/faq/extending.rst (contents, props changed) python/trunk/Doc/faq/general.rst (contents, props changed) python/trunk/Doc/faq/gui.rst (contents, props changed) python/trunk/Doc/faq/index.rst (contents, props changed) python/trunk/Doc/faq/installed.rst (contents, props changed) python/trunk/Doc/faq/library.rst (contents, props changed) python/trunk/Doc/faq/programming.rst (contents, props changed) python/trunk/Doc/faq/python-video-icon.png (contents, props changed) python/trunk/Doc/faq/windows.rst (contents, props changed) Modified: python/trunk/Doc/contents.rst python/trunk/Doc/tools/sphinxext/indexcontent.html Modified: python/trunk/Doc/contents.rst ============================================================================== --- python/trunk/Doc/contents.rst (original) +++ python/trunk/Doc/contents.rst Sun Oct 11 20:31:23 2009 @@ -15,6 +15,7 @@ install/index.rst documenting/index.rst howto/index.rst + faq/index.rst glossary.rst about.rst Added: python/trunk/Doc/faq/design.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/design.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,924 @@ +====================== +Design and History FAQ +====================== + +Why does Python use indentation for grouping of statements? +----------------------------------------------------------- + +Guido van Rossum believes that using indentation for grouping is extremely +elegant and contributes a lot to the clarity of the average Python program. +Most people learn to love this feature after awhile. + +Since there are no begin/end brackets there cannot be a disagreement between +grouping perceived by the parser and the human reader. Occasionally C +programmers will encounter a fragment of code like this:: + + if (x <= y) + x++; + y--; + z++; + +Only the ``x++`` statement is executed if the condition is true, but the +indentation leads you to believe otherwise. Even experienced C programmers will +sometimes stare at it a long time wondering why ``y`` is being decremented even +for ``x > y``. + +Because there are no begin/end brackets, Python is much less prone to +coding-style conflicts. In C there are many different ways to place the braces. +If you're used to reading and writing code that uses one style, you will feel at +least slightly uneasy when reading (or being required to write) another style. + +Many coding styles place begin/end brackets on a line by themself. This makes +programs considerably longer and wastes valuable screen space, making it harder +to get a good overview of a program. Ideally, a function should fit on one +screen (say, 20-30 lines). 20 lines of Python can do a lot more work than 20 +lines of C. This is not solely due to the lack of begin/end brackets -- the +lack of declarations and the high-level data types are also responsible -- but +the indentation-based syntax certainly helps. + + +Why am I getting strange results with simple arithmetic operations? +------------------------------------------------------------------- + +See the next question. + + +Why are floating point calculations so inaccurate? +-------------------------------------------------- + +People are often very surprised by results like this:: + + >>> 1.2-1.0 + 0.199999999999999996 + +and think it is a bug in Python. It's not. This has nothing to do with Python, +but with how the underlying C platform handles floating point numbers, and +ultimately with the inaccuracies introduced when writing down numbers as a +string of a fixed number of digits. + +The internal representation of floating point numbers uses a fixed number of +binary digits to represent a decimal number. Some decimal numbers can't be +represented exactly in binary, resulting in small roundoff errors. + +In decimal math, there are many numbers that can't be represented with a fixed +number of decimal digits, e.g. 1/3 = 0.3333333333....... + +In base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. .2 equals 2/10 equals 1/5, +resulting in the binary fractional number 0.001100110011001... + +Floating point numbers only have 32 or 64 bits of precision, so the digits are +cut off at some point, and the resulting number is 0.199999999999999996 in +decimal, not 0.2. + +A floating point number's ``repr()`` function prints as many digits are +necessary to make ``eval(repr(f)) == f`` true for any float f. The ``str()`` +function prints fewer digits and this often results in the more sensible number +that was probably intended:: + + >>> 0.2 + 0.20000000000000001 + >>> print 0.2 + 0.2 + +One of the consequences of this is that it is error-prone to compare the result +of some computation to a float with ``==``. Tiny inaccuracies may mean that +``==`` fails. Instead, you have to check that the difference between the two +numbers is less than a certain threshold:: + + epsilon = 0.0000000000001 # Tiny allowed error + expected_result = 0.4 + + if expected_result-epsilon <= computation() <= expected_result+epsilon: + ... + +Please see the chapter on :ref:`floating point arithmetic ` in +the Python tutorial for more information. + + +Why are Python strings immutable? +--------------------------------- + +There are several advantages. + +One is performance: knowing that a string is immutable means we can allocate +space for it at creation time, and the storage requirements are fixed and +unchanging. This is also one of the reasons for the distinction between tuples +and lists. + +Another advantage is that strings in Python are considered as "elemental" as +numbers. No amount of activity will change the value 8 to anything else, and in +Python, no amount of activity will change the string "eight" to anything else. + + +.. _why-self: + +Why must 'self' be used explicitly in method definitions and calls? +------------------------------------------------------------------- + +The idea was borrowed from Modula-3. It turns out to be very useful, for a +variety of reasons. + +First, it's more obvious that you are using a method or instance attribute +instead of a local variable. Reading ``self.x`` or ``self.meth()`` makes it +absolutely clear that an instance variable or method is used even if you don't +know the class definition by heart. In C++, you can sort of tell by the lack of +a local variable declaration (assuming globals are rare or easily recognizable) +-- but in Python, there are no local variable declarations, so you'd have to +look up the class definition to be sure. Some C++ and Java coding standards +call for instance attributes to have an ``m_`` prefix, so this explicitness is +still useful in those languages, too. + +Second, it means that no special syntax is necessary if you want to explicitly +reference or call the method from a particular class. In C++, if you want to +use a method from a base class which is overridden in a derived class, you have +to use the ``::`` operator -- in Python you can write baseclass.methodname(self, +). This is particularly useful for :meth:`__init__` methods, and +in general in cases where a derived class method wants to extend the base class +method of the same name and thus has to call the base class method somehow. + +Finally, for instance variables it solves a syntactic problem with assignment: +since local variables in Python are (by definition!) those variables to which a +value assigned in a function body (and that aren't explicitly declared global), +there has to be some way to tell the interpreter that an assignment was meant to +assign to an instance variable instead of to a local variable, and it should +preferably be syntactic (for efficiency reasons). C++ does this through +declarations, but Python doesn't have declarations and it would be a pity having +to introduce them just for this purpose. Using the explicit "self.var" solves +this nicely. Similarly, for using instance variables, having to write +"self.var" means that references to unqualified names inside a method don't have +to search the instance's directories. To put it another way, local variables +and instance variables live in two different namespaces, and you need to tell +Python which namespace to use. + + +Why can't I use an assignment in an expression? +----------------------------------------------- + +Many people used to C or Perl complain that they want to use this C idiom: + +.. code-block:: c + + while (line = readline(f)) { + // do something with line + } + +where in Python you're forced to write this:: + + while True: + line = f.readline() + if not line: + break + ... # do something with line + +The reason for not allowing assignment in Python expressions is a common, +hard-to-find bug in those other languages, caused by this construct: + +.. code-block:: c + + if (x = 0) { + // error handling + } + else { + // code that only works for nonzero x + } + +The error is a simple typo: ``x = 0``, which assigns 0 to the variable ``x``, +was written while the comparison ``x == 0`` is certainly what was intended. + +Many alternatives have been proposed. Most are hacks that save some typing but +use arbitrary or cryptic syntax or keywords, and fail the simple criterion for +language change proposals: it should intuitively suggest the proper meaning to a +human reader who has not yet been introduced to the construct. + +An interesting phenomenon is that most experienced Python programmers recognize +the ``while True`` idiom and don't seem to be missing the assignment in +expression construct much; it's only newcomers who express a strong desire to +add this to the language. + +There's an alternative way of spelling this that seems attractive but is +generally less robust than the "while True" solution:: + + line = f.readline() + while line: + ... # do something with line... + line = f.readline() + +The problem with this is that if you change your mind about exactly how you get +the next line (e.g. you want to change it into ``sys.stdin.readline()``) you +have to remember to change two places in your program -- the second occurrence +is hidden at the bottom of the loop. + +The best approach is to use iterators, making it possible to loop through +objects using the ``for`` statement. For example, in the current version of +Python file objects support the iterator protocol, so you can now write simply:: + + for line in f: + ... # do something with line... + + + +Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))? +---------------------------------------------------------------------------------------------------------------- + +The major reason is history. Functions were used for those operations that were +generic for a group of types and which were intended to work even for objects +that didn't have methods at all (e.g. tuples). It is also convenient to have a +function that can readily be applied to an amorphous collection of objects when +you use the functional features of Python (``map()``, ``apply()`` et al). + +In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is +actually less code than implementing them as methods for each type. One can +quibble about individual cases but it's a part of Python, and it's too late to +make such fundamental changes now. The functions have to remain to avoid massive +code breakage. + +.. XXX talk about protocols? + +Note that for string operations Python has moved from external functions (the +``string`` module) to methods. However, ``len()`` is still a function. + + +Why is join() a string method instead of a list or tuple method? +---------------------------------------------------------------- + +Strings became much more like other standard types starting in Python 1.6, when +methods were added which give the same functionality that has always been +available using the functions of the string module. Most of these new methods +have been widely accepted, but the one which appears to make some programmers +feel uncomfortable is:: + + ", ".join(['1', '2', '4', '8', '16']) + +which gives the result:: + + "1, 2, 4, 8, 16" + +There are two common arguments against this usage. + +The first runs along the lines of: "It looks really ugly using a method of a +string literal (string constant)", to which the answer is that it might, but a +string literal is just a fixed value. If the methods are to be allowed on names +bound to strings there is no logical reason to make them unavailable on +literals. + +The second objection is typically cast as: "I am really telling a sequence to +join its members together with a string constant". Sadly, you aren't. For some +reason there seems to be much less difficulty with having :meth:`~str.split` as +a string method, since in that case it is easy to see that :: + + "1, 2, 4, 8, 16".split(", ") + +is an instruction to a string literal to return the substrings delimited by the +given separator (or, by default, arbitrary runs of white space). In this case a +Unicode string returns a list of Unicode strings, an ASCII string returns a list +of ASCII strings, and everyone is happy. + +:meth:`~str.join` is a string method because in using it you are telling the +separator string to iterate over a sequence of strings and insert itself between +adjacent elements. This method can be used with any argument which obeys the +rules for sequence objects, including any new classes you might define yourself. + +Because this is a string method it can work for Unicode strings as well as plain +ASCII strings. If ``join()`` were a method of the sequence types then the +sequence types would have to decide which type of string to return depending on +the type of the separator. + +.. XXX remove next paragraph eventually + +If none of these arguments persuade you, then for the moment you can continue to +use the ``join()`` function from the string module, which allows you to write :: + + string.join(['1', '2', '4', '8', '16'], ", ") + + +How fast are exceptions? +------------------------ + +A try/except block is extremely efficient. Actually catching an exception is +expensive. In versions of Python prior to 2.0 it was common to use this idiom:: + + try: + value = dict[key] + except KeyError: + dict[key] = getvalue(key) + value = dict[key] + +This only made sense when you expected the dict to have the key almost all the +time. If that wasn't the case, you coded it like this:: + + if dict.has_key(key): + value = dict[key] + else: + dict[key] = getvalue(key) + value = dict[key] + +(In Python 2.0 and higher, you can code this as ``value = dict.setdefault(key, +getvalue(key))``.) + + +Why isn't there a switch or case statement in Python? +----------------------------------------------------- + +You can do this easily enough with a sequence of ``if... elif... elif... else``. +There have been some proposals for switch statement syntax, but there is no +consensus (yet) on whether and how to do range tests. See :pep:`275` for +complete details and the current status. + +For cases where you need to choose from a very large number of possibilities, +you can create a dictionary mapping case values to functions to call. For +example:: + + def function_1(...): + ... + + functions = {'a': function_1, + 'b': function_2, + 'c': self.method_1, ...} + + func = functions[value] + func() + +For calling methods on objects, you can simplify yet further by using the +:func:`getattr` built-in to retrieve methods with a particular name:: + + def visit_a(self, ...): + ... + ... + + def dispatch(self, value): + method_name = 'visit_' + str(value) + method = getattr(self, method_name) + method() + +It's suggested that you use a prefix for the method names, such as ``visit_`` in +this example. Without such a prefix, if values are coming from an untrusted +source, an attacker would be able to call any method on your object. + + +Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation? +-------------------------------------------------------------------------------------------------------- + +Answer 1: Unfortunately, the interpreter pushes at least one C stack frame for +each Python stack frame. Also, extensions can call back into Python at almost +random moments. Therefore, a complete threads implementation requires thread +support for C. + +Answer 2: Fortunately, there is `Stackless Python `_, +which has a completely redesigned interpreter loop that avoids the C stack. +It's still experimental but looks very promising. Although it is binary +compatible with standard Python, it's still unclear whether Stackless will make +it into the core -- maybe it's just too revolutionary. + + +Why can't lambda forms contain statements? +------------------------------------------ + +Python lambda forms cannot contain statements because Python's syntactic +framework can't handle statements nested inside expressions. However, in +Python, this is not a serious problem. Unlike lambda forms in other languages, +where they add functionality, Python lambdas are only a shorthand notation if +you're too lazy to define a function. + +Functions are already first class objects in Python, and can be declared in a +local scope. Therefore the only advantage of using a lambda form instead of a +locally-defined function is that you don't need to invent a name for the +function -- but that's just a local variable to which the function object (which +is exactly the same type of object that a lambda form yields) is assigned! + + +Can Python be compiled to machine code, C or some other language? +----------------------------------------------------------------- + +Not easily. Python's high level data types, dynamic typing of objects and +run-time invocation of the interpreter (using :func:`eval` or :keyword:`exec`) +together mean that a "compiled" Python program would probably consist mostly of +calls into the Python run-time system, even for seemingly simple operations like +``x+1``. + +Several projects described in the Python newsgroup or at past `Python +conferences `_ have shown that this approach is feasible, +although the speedups reached so far are only modest (e.g. 2x). Jython uses the +same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated +that in combination with whole-program analysis, speedups of 1000x are feasible +for small demo programs. See the proceedings from the `1997 Python conference +`_ for more information.) + +Internally, Python source code is always translated into a bytecode +representation, and this bytecode is then executed by the Python virtual +machine. In order to avoid the overhead of repeatedly parsing and translating +modules that rarely change, this byte code is written into a file whose name +ends in ".pyc" whenever a module is parsed. When the corresponding .py file is +changed, it is parsed and translated again and the .pyc file is rewritten. + +There is no performance difference once the .pyc file has been loaded, as the +bytecode read from the .pyc file is exactly the same as the bytecode created by +direct translation. The only difference is that loading code from a .pyc file +is faster than parsing and translating a .py file, so the presence of +precompiled .pyc files improves the start-up time of Python scripts. If +desired, the Lib/compileall.py module can be used to create valid .pyc files for +a given set of modules. + +Note that the main script executed by Python, even if its filename ends in .py, +is not compiled to a .pyc file. It is compiled to bytecode, but the bytecode is +not saved to a file. Usually main scripts are quite short, so this doesn't cost +much speed. + +.. XXX check which of these projects are still alive + +There are also several programs which make it easier to intermingle Python and C +code in various ways to increase performance. See, for example, `Psyco +`_, `Pyrex +`_, `PyInline +`_, `Py2Cmod +`_, and `Weave +`_. + + +How does Python manage memory? +------------------------------ + +The details of Python memory management depend on the implementation. The +standard C implementation of Python uses reference counting to detect +inaccessible objects, and another mechanism to collect reference cycles, +periodically executing a cycle detection algorithm which looks for inaccessible +cycles and deletes the objects involved. The :mod:`gc` module provides functions +to perform a garbage collection, obtain debugging statistics, and tune the +collector's parameters. + +Jython relies on the Java runtime so the JVM's garbage collector is used. This +difference can cause some subtle porting problems if your Python code depends on +the behavior of the reference counting implementation. + +Sometimes objects get stuck in tracebacks temporarily and hence are not +deallocated when you might expect. Clear the tracebacks with:: + + import sys + sys.exc_clear() + sys.exc_traceback = sys.last_traceback = None + +Tracebacks are used for reporting errors, implementing debuggers and related +things. They contain a portion of the program state extracted during the +handling of an exception (usually the most recent exception). + +In the absence of circularities and tracebacks, Python programs need not +explicitly manage memory. + +Why doesn't Python use a more traditional garbage collection scheme? For one +thing, this is not a C standard feature and hence it's not portable. (Yes, we +know about the Boehm GC library. It has bits of assembler code for *most* +common platforms, not for all of them, and although it is mostly transparent, it +isn't completely transparent; patches are required to get Python to work with +it.) + +Traditional GC also becomes a problem when Python is embedded into other +applications. While in a standalone Python it's fine to replace the standard +malloc() and free() with versions provided by the GC library, an application +embedding Python may want to have its *own* substitute for malloc() and free(), +and may not want Python's. Right now, Python works with anything that +implements malloc() and free() properly. + +In Jython, the following code (which is fine in CPython) will probably run out +of file descriptors long before it runs out of memory:: + + for file in : + f = open(file) + c = f.read(1) + +Using the current reference counting and destructor scheme, each new assignment +to f closes the previous file. Using GC, this is not guaranteed. If you want +to write code that will work with any Python implementation, you should +explicitly close the file; this will work regardless of GC:: + + for file in : + f = open(file) + c = f.read(1) + f.close() + + +Why isn't all memory freed when Python exits? +--------------------------------------------- + +Objects referenced from the global namespaces of Python modules are not always +deallocated when Python exits. This may happen if there are circular +references. There are also certain bits of memory that are allocated by the C +library that are impossible to free (e.g. a tool like Purify will complain about +these). Python is, however, aggressive about cleaning up memory on exit and +does try to destroy every single object. + +If you want to force Python to delete certain things on deallocation use the +:mod:`atexit` module to run a function that will force those deletions. + + +Why are there separate tuple and list data types? +------------------------------------------------- + +Lists and tuples, while similar in many respects, are generally used in +fundamentally different ways. Tuples can be thought of as being similar to +Pascal records or C structs; they're small collections of related data which may +be of different types which are operated on as a group. For example, a +Cartesian coordinate is appropriately represented as a tuple of two or three +numbers. + +Lists, on the other hand, are more like arrays in other languages. They tend to +hold a varying number of objects all of which have the same type and which are +operated on one-by-one. For example, ``os.listdir('.')`` returns a list of +strings representing the files in the current directory. Functions which +operate on this output would generally not break if you added another file or +two to the directory. + +Tuples are immutable, meaning that once a tuple has been created, you can't +replace any of its elements with a new value. Lists are mutable, meaning that +you can always change a list's elements. Only immutable elements can be used as +dictionary keys, and hence only tuples and not lists can be used as keys. + + +How are lists implemented? +-------------------------- + +Python's lists are really variable-length arrays, not Lisp-style linked lists. +The implementation uses a contiguous array of references to other objects, and +keeps a pointer to this array and the array's length in a list head structure. + +This makes indexing a list ``a[i]`` an operation whose cost is independent of +the size of the list or the value of the index. + +When items are appended or inserted, the array of references is resized. Some +cleverness is applied to improve the performance of appending items repeatedly; +when the array must be grown, some extra space is allocated so the next few +times don't require an actual resize. + + +How are dictionaries implemented? +--------------------------------- + +Python's dictionaries are implemented as resizable hash tables. Compared to +B-trees, this gives better performance for lookup (the most common operation by +far) under most circumstances, and the implementation is simpler. + +Dictionaries work by computing a hash code for each key stored in the dictionary +using the :func:`hash` built-in function. The hash code varies widely depending +on the key; for example, "Python" hashes to -539294296 while "python", a string +that differs by a single bit, hashes to 1142331976. The hash code is then used +to calculate a location in an internal array where the value will be stored. +Assuming that you're storing keys that all have different hash values, this +means that dictionaries take constant time -- O(1), in computer science notation +-- to retrieve a key. It also means that no sorted order of the keys is +maintained, and traversing the array as the ``.keys()`` and ``.items()`` do will +output the dictionary's content in some arbitrary jumbled order. + + +Why must dictionary keys be immutable? +-------------------------------------- + +The hash table implementation of dictionaries uses a hash value calculated from +the key value to find the key. If the key were a mutable object, its value +could change, and thus its hash could also change. But since whoever changes +the key object can't tell that it was being used as a dictionary key, it can't +move the entry around in the dictionary. Then, when you try to look up the same +object in the dictionary it won't be found because its hash value is different. +If you tried to look up the old value it wouldn't be found either, because the +value of the object found in that hash bin would be different. + +If you want a dictionary indexed with a list, simply convert the list to a tuple +first; the function ``tuple(L)`` creates a tuple with the same entries as the +list ``L``. Tuples are immutable and can therefore be used as dictionary keys. + +Some unacceptable solutions that have been proposed: + +- Hash lists by their address (object ID). This doesn't work because if you + construct a new list with the same value it won't be found; e.g.:: + + d = {[1,2]: '12'} + print d[[1,2]] + + would raise a KeyError exception because the id of the ``[1,2]`` used in the + second line differs from that in the first line. In other words, dictionary + keys should be compared using ``==``, not using :keyword:`is`. + +- Make a copy when using a list as a key. This doesn't work because the list, + being a mutable object, could contain a reference to itself, and then the + copying code would run into an infinite loop. + +- Allow lists as keys but tell the user not to modify them. This would allow a + class of hard-to-track bugs in programs when you forgot or modified a list by + accident. It also invalidates an important invariant of dictionaries: every + value in ``d.keys()`` is usable as a key of the dictionary. + +- Mark lists as read-only once they are used as a dictionary key. The problem + is that it's not just the top-level object that could change its value; you + could use a tuple containing a list as a key. Entering anything as a key into + a dictionary would require marking all objects reachable from there as + read-only -- and again, self-referential objects could cause an infinite loop. + +There is a trick to get around this if you need to, but use it at your own risk: +You can wrap a mutable structure inside a class instance which has both a +:meth:`__cmp_` and a :meth:`__hash__` method. You must then make sure that the +hash value for all such wrapper objects that reside in a dictionary (or other +hash based structure), remain fixed while the object is in the dictionary (or +other structure). :: + + class ListWrapper: + def __init__(self, the_list): + self.the_list = the_list + def __cmp__(self, other): + return self.the_list == other.the_list + def __hash__(self): + l = self.the_list + result = 98767 - len(l)*555 + for i in range(len(l)): + try: + result = result + (hash(l[i]) % 9999999) * 1001 + i + except: + result = (result % 7777777) + i * 333 + return result + +Note that the hash computation is complicated by the possibility that some +members of the list may be unhashable and also by the possibility of arithmetic +overflow. + +Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1.__cmp__(o2) +== 0``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == o2.__hash__()``), +regardless of whether the object is in a dictionary or not. If you fail to meet +these restrictions dictionaries and other hash based structures will misbehave. + +In the case of ListWrapper, whenever the wrapper object is in a dictionary the +wrapped list must not change to avoid anomalies. Don't do this unless you are +prepared to think hard about the requirements and the consequences of not +meeting them correctly. Consider yourself warned. + + +Why doesn't list.sort() return the sorted list? +----------------------------------------------- + +In situations where performance matters, making a copy of the list just to sort +it would be wasteful. Therefore, :meth:`list.sort` sorts the list in place. In +order to remind you of that fact, it does not return the sorted list. This way, +you won't be fooled into accidentally overwriting a list when you need a sorted +copy but also need to keep the unsorted version around. + +In Python 2.4 a new builtin -- :func:`sorted` -- has been added. This function +creates a new list from a provided iterable, sorts it and returns it. For +example, here's how to iterate over the keys of a dictionary in sorted order:: + + for key in sorted(dict.iterkeys()): + ... # do whatever with dict[key]... + + +How do you specify and enforce an interface spec in Python? +----------------------------------------------------------- + +An interface specification for a module as provided by languages such as C++ and +Java describes the prototypes for the methods and functions of the module. Many +feel that compile-time enforcement of interface specifications helps in the +construction of large programs. + +Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base Classes +(ABCs). You can then use :func:`isinstance` and :func:`issubclass` to check +whether an instance or a class implements a particular ABC. The +:mod:`collections` modules defines a set of useful ABCs such as +:class:`Iterable`, :class:`Container`, and :class:`MutableMapping`. + +For Python, many of the advantages of interface specifications can be obtained +by an appropriate test discipline for components. There is also a tool, +PyChecker, which can be used to find problems due to subclassing. + +A good test suite for a module can both provide a regression test and serve as a +module interface specification and a set of examples. Many Python modules can +be run as a script to provide a simple "self test." Even modules which use +complex external interfaces can often be tested in isolation using trivial +"stub" emulations of the external interface. The :mod:`doctest` and +:mod:`unittest` modules or third-party test frameworks can be used to construct +exhaustive test suites that exercise every line of code in a module. + +An appropriate testing discipline can help build large complex applications in +Python as well as having interface specifications would. In fact, it can be +better because an interface specification cannot test certain properties of a +program. For example, the :meth:`append` method is expected to add new elements +to the end of some internal list; an interface specification cannot test that +your :meth:`append` implementation will actually do this correctly, but it's +trivial to check this property in a test suite. + +Writing test suites is very helpful, and you might want to design your code with +an eye to making it easily tested. One increasingly popular technique, +test-directed development, calls for writing parts of the test suite first, +before you write any of the actual code. Of course Python allows you to be +sloppy and not write test cases at all. + + +Why are default values shared between objects? +---------------------------------------------- + +This type of bug commonly bites neophyte programmers. Consider this function:: + + def foo(D={}): # Danger: shared reference to one dict for all calls + ... compute something ... + D[key] = value + return D + +The first time you call this function, ``D`` contains a single item. The second +time, ``D`` contains two items because when ``foo()`` begins executing, ``D`` +starts out with an item already in it. + +It is often expected that a function call creates new objects for default +values. This is not what happens. Default values are created exactly once, when +the function is defined. If that object is changed, like the dictionary in this +example, subsequent calls to the function will refer to this changed object. + +By definition, immutable objects such as numbers, strings, tuples, and ``None``, +are safe from change. Changes to mutable objects such as dictionaries, lists, +and class instances can lead to confusion. + +Because of this feature, it is good programming practice to not use mutable +objects as default values. Instead, use ``None`` as the default value and +inside the function, check if the parameter is ``None`` and create a new +list/dictionary/whatever if it is. For example, don't write:: + + def foo(dict={}): + ... + +but:: + + def foo(dict=None): + if dict is None: + dict = {} # create a new dict for local namespace + +This feature can be useful. When you have a function that's time-consuming to +compute, a common technique is to cache the parameters and the resulting value +of each call to the function, and return the cached value if the same value is +requested again. This is called "memoizing", and can be implemented like this:: + + # Callers will never provide a third parameter for this function. + def expensive (arg1, arg2, _cache={}): + if _cache.has_key((arg1, arg2)): + return _cache[(arg1, arg2)] + + # Calculate the value + result = ... expensive computation ... + _cache[(arg1, arg2)] = result # Store result in the cache + return result + +You could use a global variable containing a dictionary instead of the default +value; it's a matter of taste. + + +Why is there no goto? +--------------------- + +You can use exceptions to provide a "structured goto" that even works across +function calls. Many feel that exceptions can conveniently emulate all +reasonable uses of the "go" or "goto" constructs of C, Fortran, and other +languages. For example:: + + class label: pass # declare a label + + try: + ... + if (condition): raise label() # goto label + ... + except label: # where to goto + pass + ... + +This doesn't allow you to jump into the middle of a loop, but that's usually +considered an abuse of goto anyway. Use sparingly. + + +Why can't raw strings (r-strings) end with a backslash? +------------------------------------------------------- + +More precisely, they can't end with an odd number of backslashes: the unpaired +backslash at the end escapes the closing quote character, leaving an +unterminated string. + +Raw strings were designed to ease creating input for processors (chiefly regular +expression engines) that want to do their own backslash escape processing. Such +processors consider an unmatched trailing backslash to be an error anyway, so +raw strings disallow that. In return, they allow you to pass on the string +quote character by escaping it with a backslash. These rules work well when +r-strings are used for their intended purpose. + +If you're trying to build Windows pathnames, note that all Windows system calls +accept forward slashes too:: + + f = open("/mydir/file.txt") # works fine! + +If you're trying to build a pathname for a DOS command, try e.g. one of :: + + dir = r"\this\is\my\dos\dir" "\\" + dir = r"\this\is\my\dos\dir\ "[:-1] + dir = "\\this\\is\\my\\dos\\dir\\" + + +Why doesn't Python have a "with" statement for attribute assignments? +--------------------------------------------------------------------- + +Python has a 'with' statement that wraps the execution of a block, calling code +on the entrance and exit from the block. Some language have a construct that +looks like this:: + + with obj: + a = 1 # equivalent to obj.a = 1 + total = total + 1 # obj.total = obj.total + 1 + +In Python, such a construct would be ambiguous. + +Other languages, such as Object Pascal, Delphi, and C++, use static types, so +it's possible to know, in an unambiguous way, what member is being assigned +to. This is the main point of static typing -- the compiler *always* knows the +scope of every variable at compile time. + +Python uses dynamic types. It is impossible to know in advance which attribute +will be referenced at runtime. Member attributes may be added or removed from +objects on the fly. This makes it impossible to know, from a simple reading, +what attribute is being referenced: a local one, a global one, or a member +attribute? + +For instance, take the following incomplete snippet:: + + def foo(a): + with a: + print x + +The snippet assumes that "a" must have a member attribute called "x". However, +there is nothing in Python that tells the interpreter this. What should happen +if "a" is, let us say, an integer? If there is a global variable named "x", +will it be used inside the with block? As you see, the dynamic nature of Python +makes such choices much harder. + +The primary benefit of "with" and similar language features (reduction of code +volume) can, however, easily be achieved in Python by assignment. Instead of:: + + function(args).dict[index][index].a = 21 + function(args).dict[index][index].b = 42 + function(args).dict[index][index].c = 63 + +write this:: + + ref = function(args).dict[index][index] + ref.a = 21 + ref.b = 42 + ref.c = 63 + +This also has the side-effect of increasing execution speed because name +bindings are resolved at run-time in Python, and the second version only needs +to perform the resolution once. If the referenced object does not have a, b and +c attributes, of course, the end result is still a run-time exception. + + +Why are colons required for the if/while/def/class statements? +-------------------------------------------------------------- + +The colon is required primarily to enhance readability (one of the results of +the experimental ABC language). Consider this:: + + if a == b + print a + +versus :: + + if a == b: + print a + +Notice how the second one is slightly easier to read. Notice further how a +colon sets off the example in this FAQ answer; it's a standard usage in English. + +Another minor reason is that the colon makes it easier for editors with syntax +highlighting; they can look for colons to decide when indentation needs to be +increased instead of having to do a more elaborate parsing of the program text. + + +Why does Python allow commas at the end of lists and tuples? +------------------------------------------------------------ + +Python lets you add a trailing comma at the end of lists, tuples, and +dictionaries:: + + [1, 2, 3,] + ('a', 'b', 'c',) + d = { + "A": [1, 5], + "B": [6, 7], # last trailing comma is optional but good style + } + + +There are several reasons to allow this. + +When you have a literal value for a list, tuple, or dictionary spread across +multiple lines, it's easier to add more elements because you don't have to +remember to add a comma to the previous line. The lines can also be sorted in +your editor without creating a syntax error. + +Accidentally omitting the comma can lead to errors that are hard to diagnose. +For example:: + + x = [ + "fee", + "fie" + "foo", + "fum" + ] + +This list looks like it has four elements, but it actually contains three: +"fee", "fiefoo" and "fum". Always adding the comma avoids this source of error. + +Allowing the trailing comma may also make programmatic code generation easier. Added: python/trunk/Doc/faq/extending.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/extending.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,481 @@ +======================= +Extending/Embedding FAQ +======================= + +.. contents:: + +.. highlight:: c + + +Can I create my own functions in C? +----------------------------------- + +Yes, you can create built-in modules containing functions, variables, exceptions +and even new types in C. This is explained in the document +:ref:`extending-index`. + +Most intermediate or advanced Python books will also cover this topic. + + +Can I create my own functions in C++? +------------------------------------- + +Yes, using the C compatibility features found in C++. Place ``extern "C" { +... }`` around the Python include files and put ``extern "C"`` before each +function that is going to be called by the Python interpreter. Global or static +C++ objects with constructors are probably not a good idea. + + +Writing C is hard; are there any alternatives? +---------------------------------------------- + +There are a number of alternatives to writing your own C extensions, depending +on what you're trying to do. + +.. XXX make sure these all work; mention Cython + +If you need more speed, `Psyco `_ generates x86 +assembly code from Python bytecode. You can use Psyco to compile the most +time-critical functions in your code, and gain a significant improvement with +very little effort, as long as you're running on a machine with an +x86-compatible processor. + +`Pyrex `_ is a compiler +that accepts a slightly modified form of Python and generates the corresponding +C code. Pyrex makes it possible to write an extension without having to learn +Python's C API. + +If you need to interface to some C or C++ library for which no Python extension +currently exists, you can try wrapping the library's data types and functions +with a tool such as `SWIG `_. `SIP +`_, `CXX +`_ `Boost +`_, or `Weave +`_ are also alternatives for wrapping +C++ libraries. + + +How can I execute arbitrary Python statements from C? +----------------------------------------------------- + +The highest-level function to do this is :cfunc:`PyRun_SimpleString` which takes +a single string argument to be executed in the context of the module +``__main__`` and returns 0 for success and -1 when an exception occurred +(including ``SyntaxError``). If you want more control, use +:cfunc:`PyRun_String`; see the source for :cfunc:`PyRun_SimpleString` in +``Python/pythonrun.c``. + + +How can I evaluate an arbitrary Python expression from C? +--------------------------------------------------------- + +Call the function :cfunc:`PyRun_String` from the previous question with the +start symbol :cdata:`Py_eval_input`; it parses an expression, evaluates it and +returns its value. + + +How do I extract C values from a Python object? +----------------------------------------------- + +That depends on the object's type. If it's a tuple, :cfunc:`PyTuple_Size` +returns its length and :cfunc:`PyTuple_GetItem` returns the item at a specified +index. Lists have similar functions, :cfunc:`PyListSize` and +:cfunc:`PyList_GetItem`. + +For strings, :cfunc:`PyString_Size` returns its length and +:cfunc:`PyString_AsString` a pointer to its value. Note that Python strings may +contain null bytes so C's :cfunc:`strlen` should not be used. + +To test the type of an object, first make sure it isn't *NULL*, and then use +:cfunc:`PyString_Check`, :cfunc:`PyTuple_Check`, :cfunc:`PyList_Check`, etc. + +There is also a high-level API to Python objects which is provided by the +so-called 'abstract' interface -- read ``Include/abstract.h`` for further +details. It allows interfacing with any kind of Python sequence using calls +like :cfunc:`PySequence_Length`, :cfunc:`PySequence_GetItem`, etc.) as well as +many other useful protocols. + + +How do I use Py_BuildValue() to create a tuple of arbitrary length? +------------------------------------------------------------------- + +You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using +``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of +``o``, so you have to :cfunc:`Py_INCREF` it. Lists have similar functions +``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all +the tuple items to some value before you pass the tuple to Python code -- +``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value. + + +How do I call an object's method from C? +---------------------------------------- + +The :cfunc:`PyObject_CallMethod` function can be used to call an arbitrary +method of an object. The parameters are the object, the name of the method to +call, a format string like that used with :cfunc:`Py_BuildValue`, and the +argument values:: + + PyObject * + PyObject_CallMethod(PyObject *object, char *method_name, + char *arg_format, ...); + +This works for any object that has methods -- whether built-in or user-defined. +You are responsible for eventually :cfunc:`Py_DECREF`\ 'ing the return value. + +To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the +file object pointer is "f"):: + + res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); + if (res == NULL) { + ... an exception occurred ... + } + else { + Py_DECREF(res); + } + +Note that since :cfunc:`PyObject_CallObject` *always* wants a tuple for the +argument list, to call a function without arguments, pass "()" for the format, +and to call a function with one argument, surround the argument in parentheses, +e.g. "(i)". + + +How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? +---------------------------------------------------------------------------------------- + +In Python code, define an object that supports the ``write()`` method. Assign +this object to :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or +just allow the standard traceback mechanism to work. Then, the output will go +wherever your ``write()`` method sends it. + +The easiest way to do this is to use the StringIO class in the standard library. + +Sample code and use for catching stdout: + + >>> class StdoutCatcher: + ... def __init__(self): + ... self.data = '' + ... def write(self, stuff): + ... self.data = self.data + stuff + ... + >>> import sys + >>> sys.stdout = StdoutCatcher() + >>> print 'foo' + >>> print 'hello world!' + >>> sys.stderr.write(sys.stdout.data) + foo + hello world! + + +How do I access a module written in Python from C? +-------------------------------------------------- + +You can get a pointer to the module object as follows:: + + module = PyImport_ImportModule(""); + +If the module hasn't been imported yet (i.e. it is not yet present in +:data:`sys.modules`), this initializes the module; otherwise it simply returns +the value of ``sys.modules[""]``. Note that it doesn't enter the +module into any namespace -- it only ensures it has been initialized and is +stored in :data:`sys.modules`. + +You can then access the module's attributes (i.e. any name defined in the +module) as follows:: + + attr = PyObject_GetAttrString(module, ""); + +Calling :cfunc:`PyObject_SetAttrString` to assign to variables in the module +also works. + + +How do I interface to C++ objects from Python? +---------------------------------------------- + +Depending on your requirements, there are many approaches. To do this manually, +begin by reading :ref:`the "Extending and Embedding" document +`. Realize that for the Python run-time system, there isn't a +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 `_ + + +I added a module using the Setup file and the make fails; why? +-------------------------------------------------------------- + +Setup must end in a newline, if there is no newline there, the build process +fails. (Fixing this requires some ugly shell script hackery, and this bug is so +minor that it doesn't seem worth the effort.) + + +How do I debug an extension? +---------------------------- + +When using GDB with dynamically loaded extensions, you can't set a breakpoint in +your extension until your extension is loaded. + +In your ``.gdbinit`` file (or interactively), add the command:: + + br _PyImport_LoadDynamicModule + +Then, when you run GDB:: + + $ gdb /local/bin/python + gdb) run myscript.py + gdb) continue # repeat until your extension is loaded + gdb) finish # so that your extension is loaded + gdb) br myfunction.c:50 + gdb) continue + +I want to compile a Python module on my Linux system, but some files are missing. Why? +-------------------------------------------------------------------------------------- + +Most packaged versions of Python don't include the +:file:`/usr/lib/python2.{x}/config/` directory, which contains various files +required for compiling Python extensions. + +For Red Hat, install the python-devel RPM to get the necessary files. + +For Debian, run ``apt-get install python-dev``. + + +What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean? +------------------------------------------------------------------------------------- + +This means that you have created an extension module named "yourmodule", but +your module init function does not initialize with that name. + +Every module init function will have a line similar to:: + + module = Py_InitModule("yourmodule", yourmodule_functions); + +If the string passed to this function is not the same name as your extension +module, the :exc:`SystemError` exception will be raised. + + +How do I tell "incomplete input" from "invalid input"? +------------------------------------------------------ + +Sometimes you want to emulate the Python interactive interpreter's behavior, +where it gives you a continuation prompt when the input is incomplete (e.g. you +typed the start of an "if" statement or you didn't close your parentheses or +triple string quotes), but it gives you a syntax error message immediately when +the input is invalid. + +In Python you can use the :mod:`codeop` module, which approximates the parser's +behavior sufficiently. IDLE uses this, for example. + +The easiest way to do it in C is to call :cfunc:`PyRun_InteractiveLoop` (perhaps +in a separate thread) and let the Python interpreter handle the input for +you. You can also set the :cfunc:`PyOS_ReadlineFunctionPointer` to point at your +custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` +for more hints. + +However sometimes you have to run the embedded Python interpreter in the same +thread as your rest application and you can't allow the +:cfunc:`PyRun_InteractiveLoop` to stop while waiting for user input. The one +solution then is to call :cfunc:`PyParser_ParseString` and test for ``e.error`` +equal to ``E_EOF``, which means the input is incomplete). Here's a sample code +fragment, untested, inspired by code from Alex Farber:: + + #include + #include + #include + #include + #include + #include + + int testcomplete(char *code) + /* code should end in \n */ + /* return -1 for error, 0 for incomplete, 1 for complete */ + { + node *n; + perrdetail e; + + n = PyParser_ParseString(code, &_PyParser_Grammar, + Py_file_input, &e); + if (n == NULL) { + if (e.error == E_EOF) + return 0; + return -1; + } + + PyNode_Free(n); + return 1; + } + +Another solution is trying to compile the received string with +:cfunc:`Py_CompileString`. If it compiles without errors, try to execute the +returned code object by calling :cfunc:`PyEval_EvalCode`. Otherwise save the +input for later. If the compilation fails, find out if it's an error or just +more input is required - by extracting the message string from the exception +tuple and comparing it to the string "unexpected EOF while parsing". Here is a +complete example using the GNU readline library (you may want to ignore +**SIGINT** while calling readline()):: + + #include + #include + + #include + #include + #include + #include + + int main (int argc, char* argv[]) + { + int i, j, done = 0; /* lengths of line, code */ + char ps1[] = ">>> "; + char ps2[] = "... "; + char *prompt = ps1; + char *msg, *line, *code = NULL; + PyObject *src, *glb, *loc; + PyObject *exc, *val, *trb, *obj, *dum; + + Py_Initialize (); + loc = PyDict_New (); + glb = PyDict_New (); + PyDict_SetItemString (glb, "__builtins__", PyEval_GetBuiltins ()); + + while (!done) + { + line = readline (prompt); + + if (NULL == line) /* CTRL-D pressed */ + { + done = 1; + } + else + { + i = strlen (line); + + if (i > 0) + add_history (line); /* save non-empty lines */ + + if (NULL == code) /* nothing in code yet */ + j = 0; + else + j = strlen (code); + + code = realloc (code, i + j + 2); + if (NULL == code) /* out of memory */ + exit (1); + + if (0 == j) /* code was empty, so */ + code[0] = '\0'; /* keep strncat happy */ + + strncat (code, line, i); /* append line to code */ + code[i + j] = '\n'; /* append '\n' to code */ + code[i + j + 1] = '\0'; + + src = Py_CompileString (code, "", Py_single_input); + + if (NULL != src) /* compiled just fine - */ + { + if (ps1 == prompt || /* ">>> " or */ + '\n' == code[i + j - 1]) /* "... " and double '\n' */ + { /* so execute it */ + dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc); + Py_XDECREF (dum); + Py_XDECREF (src); + free (code); + code = NULL; + if (PyErr_Occurred ()) + PyErr_Print (); + prompt = ps1; + } + } /* syntax error or E_EOF? */ + else if (PyErr_ExceptionMatches (PyExc_SyntaxError)) + { + PyErr_Fetch (&exc, &val, &trb); /* clears exception! */ + + if (PyArg_ParseTuple (val, "sO", &msg, &obj) && + !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ + { + Py_XDECREF (exc); + Py_XDECREF (val); + Py_XDECREF (trb); + prompt = ps2; + } + else /* some other syntax error */ + { + PyErr_Restore (exc, val, trb); + PyErr_Print (); + free (code); + code = NULL; + prompt = ps1; + } + } + else /* some non-syntax error */ + { + PyErr_Print (); + free (code); + code = NULL; + prompt = ps1; + } + + free (line); + } + } + + Py_XDECREF(glb); + Py_XDECREF(loc); + Py_Finalize(); + exit(0); + } + + +How do I find undefined g++ symbols __builtin_new or __pure_virtual? +-------------------------------------------------------------------- + +To dynamically load g++ extension modules, you must recompile Python, relink it +using g++ (change LINKCC in the python Modules Makefile), and link your +extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``). + + +Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? +---------------------------------------------------------------------------------------------------------------- + +In Python 2.2, you can inherit from builtin classes such as :class:`int`, +:class:`list`, :class:`dict`, etc. + +The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) +provides a way of doing this from C++ (i.e. you can inherit from an extension +class written in C++ using the BPL). + + +When importing module X, why do I get "undefined symbol: PyUnicodeUCS2*"? +------------------------------------------------------------------------- + +You are using a version of Python that uses a 4-byte representation for Unicode +characters, but some C extension module you are importing was compiled using a +Python that uses a 2-byte representation for Unicode characters (the default). + +If instead the name of the undefined symbol starts with ``PyUnicodeUCS4``, the +problem is the reverse: Python was built using 2-byte Unicode characters, and +the extension module was compiled using a Python with 4-byte Unicode characters. + +This can easily occur when using pre-built extension packages. RedHat Linux +7.x, in particular, provided a "python2" binary that is compiled with 4-byte +Unicode. This only causes the link failure if the extension uses any of the +``PyUnicode_*()`` functions. It is also a problem if an extension uses any of +the Unicode-related format specifiers for :cfunc:`Py_BuildValue` (or similar) or +parameter specifications for :cfunc:`PyArg_ParseTuple`. + +You can check the size of the Unicode character a Python interpreter is using by +checking the value of sys.maxunicode: + + >>> import sys + >>> if sys.maxunicode > 65535: + ... print 'UCS4 build' + ... else: + ... print 'UCS2 build' + +The only way to solve this problem is to use extension modules compiled with a +Python binary built using the same size for Unicode characters. + + + Added: python/trunk/Doc/faq/general.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/general.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,510 @@ +:tocdepth: 2 + +================== +General Python FAQ +================== + +.. contents:: + +General Information +=================== + +What is Python? +--------------- + +Python is an interpreted, interactive, object-oriented programming language. It +incorporates modules, exceptions, dynamic typing, very high level dynamic data +types, and classes. Python combines remarkable power with very clear syntax. +It has interfaces to many system calls and libraries, as well as to various +window systems, and is extensible in C or C++. It is also usable as an +extension language for applications that need a programmable interface. +Finally, Python is portable: it runs on many Unix variants, on the Mac, and on +PCs under MS-DOS, Windows, Windows NT, and OS/2. + +To find out more, start with :ref:`tutorial-index`. The `Beginner's Guide to +Python `_ links to other +introductory tutorials and resources for learning Python. + + +What is the Python Software Foundation? +--------------------------------------- + +The Python Software Foundation is an independent non-profit organization that +holds the copyright on Python versions 2.1 and newer. The PSF's mission is to +advance open source technology related to the Python programming language and to +publicize the use of Python. The PSF's home page is at +http://www.python.org/psf/. + +Donations to the PSF are tax-exempt in the US. If you use Python and find it +helpful, please contribute via `the PSF donation page +`_. + + +Are there copyright restrictions on the use of Python? +------------------------------------------------------ + +You can do anything you want with the source, as long as you leave the +copyrights in and display those copyrights in any documentation about Python +that you produce. If you honor the copyright rules, it's OK to use Python for +commercial use, to sell copies of Python in source or binary form (modified or +unmodified), or to sell products that incorporate Python in some form. We would +still like to know about all commercial use of Python, of course. + +See `the PSF license page `_ to find further +explanations and a link to the full text of the license. + +The Python logo is trademarked, and in certain cases permission is required to +use it. Consult `the Trademark Usage Policy +`__ for more information. + + +Why was Python created in the first place? +------------------------------------------ + +Here's a *very* brief summary of what started it all, written by Guido van +Rossum: + + I had extensive experience with implementing an interpreted language in the + ABC group at CWI, and from working with this group I had learned a lot about + language design. This is the origin of many Python features, including the + use of indentation for statement grouping and the inclusion of + very-high-level data types (although the details are all different in + Python). + + I had a number of gripes about the ABC language, but also liked many of its + features. It was impossible to extend the ABC language (or its + implementation) to remedy my complaints -- in fact its lack of extensibility + was one of its biggest problems. I had some experience with using Modula-2+ + and talked with the designers of Modula-3 and read the Modula-3 report. + Modula-3 is the origin of the syntax and semantics used for exceptions, and + some other Python features. + + I was working in the Amoeba distributed operating system group at CWI. We + needed a better way to do system administration than by writing either C + programs or Bourne shell scripts, since Amoeba had its own system call + interface which wasn't easily accessible from the Bourne shell. My + experience with error handling in Amoeba made me acutely aware of the + importance of exceptions as a programming language feature. + + It occurred to me that a scripting language with a syntax like ABC but with + access to the Amoeba system calls would fill the need. I realized that it + would be foolish to write an Amoeba-specific language, so I decided that I + needed a language that was generally extensible. + + During the 1989 Christmas holidays, I had a lot of time on my hand, so I + decided to give it a try. During the next year, while still mostly working + on it in my own time, Python was used in the Amoeba project with increasing + success, and the feedback from colleagues made me add many early + improvements. + + In February 1991, after just over a year of development, I decided to post to + USENET. The rest is in the ``Misc/HISTORY`` file. + + +What is Python good for? +------------------------ + +Python is a high-level general-purpose programming language that can be applied +to many different classes of problems. + +The language comes with a large standard library that covers areas such as +string processing (regular expressions, Unicode, calculating differences between +files), Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, CGI +programming), software engineering (unit testing, logging, profiling, parsing +Python code), and operating system interfaces (system calls, filesystems, TCP/IP +sockets). Look at the table of contents for :ref:`library-index` to get an idea +of what's available. A wide variety of third-party extensions are also +available. Consult `the Python Package Index `_ to +find packages of interest to you. + + +How does the Python version numbering scheme work? +-------------------------------------------------- + +Python versions are numbered A.B.C or A.B. A is the major version number -- it +is only incremented for really major changes in the language. B is the minor +version number, incremented for less earth-shattering changes. C is the +micro-level -- it is incremented for each bugfix release. See :pep:`6` for more +information about bugfix releases. + +Not all releases are bugfix releases. In the run-up to a new major release, a +series of development releases are made, denoted as alpha, beta, or release +candidate. Alphas are early releases in which interfaces aren't yet finalized; +it's not unexpected to see an interface change between two alpha releases. +Betas are more stable, preserving existing interfaces but possibly adding new +modules, and release candidates are frozen, making no changes except as needed +to fix critical bugs. + +Alpha, beta and release candidate versions have an additional suffix. The +suffix for an alpha version is "aN" for some small number N, the suffix for a +beta version is "bN" for some small number N, and the suffix for a release +candidate version is "cN" for some small number N. In other words, all versions +labeled 2.0aN precede the versions labeled 2.0bN, which precede versions labeled +2.0cN, and *those* precede 2.0. + +You may also find version numbers with a "+" suffix, e.g. "2.2+". These are +unreleased versions, built directly from the Subversion trunk. In practice, +after a final minor release is made, the Subversion trunk is incremented to the +next minor version, which becomes the "a0" version, +e.g. "2.4a0". + +See also the documentation for ``sys.version``, ``sys.hexversion``, and +``sys.version_info``. + + +How do I obtain a copy of the Python source? +-------------------------------------------- + +The latest Python source distribution is always available from python.org, at +http://www.python.org/download/. The latest development sources can be obtained +via anonymous Subversion at http://svn.python.org/projects/python/trunk. + +The source distribution is a gzipped tar file containing the complete C source, +Sphinx-formatted documentation, Python library modules, example programs, and +several useful pieces of freely distributable software. The source will compile +and run out of the box on most UNIX platforms. + +Consult the `Developer FAQ +`__ for more information +on getting the source code and compiling it. + + +How do I get documentation on Python? +------------------------------------- + +.. XXX mention py3k + +The standard documentation for the current stable version of Python is available +at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are +also available at http://docs.python.org/download/. + +The documentation is written in reStructuredText and processed by `the Sphinx +documentation tool `__. The reStructuredText source +for the documentation is part of the Python source distribution. + + +I've never programmed before. Is there a Python tutorial? +--------------------------------------------------------- + +There are numerous tutorials and books available. The standard documentation +includes :ref:`tutorial-index`. + +Consult `the Beginner's Guide `_ to +find information for beginning Python programmers, including lists of tutorials. + + +Is there a newsgroup or mailing list devoted to Python? +------------------------------------------------------- + +There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, +`python-list `_. The +newsgroup and mailing list are gatewayed into each other -- if you can read news +it's unnecessary to subscribe to the mailing list. +:newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of postings +every day, and Usenet readers are often more able to cope with this volume. + +Announcements of new software releases and events can be found in +comp.lang.python.announce, a low-traffic moderated list that receives about five +postings per day. It's available as `the python-announce mailing list +`_. + +More info about other mailing lists and newsgroups +can be found at http://www.python.org/community/lists/. + + +How do I get a beta test version of Python? +------------------------------------------- + +Alpha and beta releases are available from http://www.python.org/download/. All +releases are announced on the comp.lang.python and comp.lang.python.announce +newsgroups and on the Python home page at http://www.python.org/; an RSS feed of +news is available. + +You can also access the development version of Python through Subversion. See +http://www.python.org/dev/devfaq.html#subversion-svn for details. + + +How do I submit bug reports and patches for Python? +--------------------------------------------------- + +To report a bug or submit a patch, please use the Roundup installation at +http://bugs.python.org/. + +You must have a Roundup account to report bugs; this makes it possible for us to +contact you if we have follow-up questions. It will also enable Roundup to send +you updates as we act on your bug. If you had previously used SourceForge to +report bugs to Python, you can obtain your Roundup password through Roundup's +`password reset procedure `_. + +.. XXX adapt link to dev guide + +For more information on how Python is developed, consult `the Python Developer's +Guide `_. + + +Are there any published articles about Python that I can reference? +------------------------------------------------------------------- + +It's probably best to cite your favorite book about Python. + +The very first article about Python was written in 1991 and is now quite +outdated. + + Guido van Rossum and Jelke de Boer, "Interactively Testing Remote Servers + Using the Python Programming Language", CWI Quarterly, Volume 4, Issue 4 + (December 1991), Amsterdam, pp 283-303. + + +Are there any books on Python? +------------------------------ + +Yes, there are many, and more are being published. See the python.org wiki at +http://wiki.python.org/moin/PythonBooks for a list. + +You can also search online bookstores for "Python" and filter out the Monty +Python references; or perhaps search for "Python" and "language". + + +Where in the world is www.python.org located? +--------------------------------------------- + +It's currently in Amsterdam, graciously hosted by `XS4ALL +`_. Thanks to Thomas Wouters for his work in arranging +python.org's hosting. + + +Why is it called Python? +------------------------ + +When he began implementing Python, Guido van Rossum was also reading the +published scripts from `"Monty Python's Flying Circus" +`__, a BBC comedy series from the 1970s. Van Rossum +thought he needed a name that was short, unique, and slightly mysterious, so he +decided to call the language Python. + + +Do I have to like "Monty Python's Flying Circus"? +------------------------------------------------- + +No, but it helps. :) + + +Python in the real world +======================== + +How stable is Python? +--------------------- + +Very stable. New, stable releases have been coming out roughly every 6 to 18 +months since 1991, and this seems likely to continue. Currently there are +usually around 18 months between major releases. + +The developers issue "bugfix" releases of older versions, so the stability of +existing releases gradually improves. Bugfix releases, indicated by a third +component of the version number (e.g. 2.5.3, 2.6.2), are managed for stability; +only fixes for known problems are included in a bugfix release, and it's +guaranteed that interfaces will remain the same throughout a series of bugfix +releases. + +.. XXX this gets out of date pretty often + +The `2.6.4 release `_ is recommended +production-ready version at this point in time. Python 3.1 is also considered +production-ready, but may be less useful, since currently there is more third +party software available for Python 2 than for Python 3. Python 2 code will +generally not run unchanged in Python 3. + + +How many people are using Python? +--------------------------------- + +There are probably tens of thousands of users, though it's difficult to obtain +an exact count. + +Python is available for free download, so there are no sales figures, and it's +available from many different sites and packaged with many Linux distributions, +so download statistics don't tell the whole story either. + +The comp.lang.python newsgroup is very active, but not all Python users post to +the group or even read it. + + +Have any significant projects been done in Python? +-------------------------------------------------- + +See http://python.org/about/success for a list of projects that use Python. +Consulting the proceedings for `past Python conferences +`_ will reveal contributions from many +different companies and organizations. + +High-profile Python projects include `the Mailman mailing list manager +`_ and `the Zope application server +`_. Several Linux distributions, most notably `Red Hat +`_, have written part or all of their installer and +system administration software in Python. Companies that use Python internally +include Google, Yahoo, and Lucasfilm Ltd. + + +What new developments are expected for Python in the future? +------------------------------------------------------------ + +See http://www.python.org/dev/peps/ for the Python Enhancement Proposals +(PEPs). PEPs are design documents describing a suggested new feature for Python, +providing a concise technical specification and a rationale. Look for a PEP +titled "Python X.Y Release Schedule", where X.Y is a version that hasn't been +publicly released yet. + +New development is discussed on `the python-dev mailing list +`_. + + +Is it reasonable to propose incompatible changes to Python? +----------------------------------------------------------- + +In general, no. There are already millions of lines of Python code around the +world, so any change in the language that invalidates more than a very small +fraction of existing programs has to be frowned upon. Even if you can provide a +conversion program, there's still the problem of updating all documentation; +many books have been written about Python, and we don't want to invalidate them +all at a single stroke. + +Providing a gradual upgrade path is necessary if a feature has to be changed. +:pep:`5` describes the procedure followed for introducing backward-incompatible +changes while minimizing disruption for users. + + +Is Python Y2K (Year 2000) Compliant? +------------------------------------ + +.. remove this question? + +As of August, 2003 no major problems have been reported and Y2K compliance seems +to be a non-issue. + +Python does very few date calculations and for those it does perform relies on +the C library functions. Python generally represents times either as seconds +since 1970 or as a ``(year, month, day, ...)`` tuple where the year is expressed +with four digits, which makes Y2K bugs unlikely. So as long as your C library +is okay, Python should be okay. Of course, it's possible that a particular +application written in Python makes assumptions about 2-digit years. + +Because Python is available free of charge, there are no absolute guarantees. +If there *are* unforeseen problems, liability is the user's problem rather than +the developers', and there is nobody you can sue for damages. The Python +copyright notice contains the following disclaimer: + + 4. PSF is making Python 2.3 available to Licensee on an "AS IS" + basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY + WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY + REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR + PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT INFRINGE ANY THIRD PARTY + RIGHTS. + + 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON + 2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS + A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, + OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +The good news is that *if* you encounter a problem, you have full source +available to track it down and fix it. This is one advantage of an open source +programming environment. + + +Is Python a good language for beginning programmers? +---------------------------------------------------- + +Yes. + +It is still common to start students with a procedural and statically typed +language such as Pascal, C, or a subset of C++ or Java. Students may be better +served by learning Python as their first language. Python has a very simple and +consistent syntax and a large standard library and, most importantly, using +Python in a beginning programming course lets students concentrate on important +programming skills such as problem decomposition and data type design. With +Python, students can be quickly introduced to basic concepts such as loops and +procedures. They can probably even work with user-defined objects in their very +first course. + +For a student who has never programmed before, using a statically typed language +seems unnatural. It presents additional complexity that the student must master +and slows the pace of the course. The students are trying to learn to think +like a computer, decompose problems, design consistent interfaces, and +encapsulate data. While learning to use a statically typed language is +important in the long term, it is not necessarily the best topic to address in +the students' first programming course. + +Many other aspects of Python make it a good first language. Like Java, Python +has a large standard library so that students can be assigned programming +projects very early in the course that *do* something. Assignments aren't +restricted to the standard four-function calculator and check balancing +programs. By using the standard library, students can gain the satisfaction of +working on realistic applications as they learn the fundamentals of programming. +Using the standard library also teaches students about code reuse. Third-party +modules such as PyGame are also helpful in extending the students' reach. + +Python's interactive interpreter enables students to test language features +while they're programming. They can keep a window with the interpreter running +while they enter their program's source in another window. If they can't +remember the methods for a list, they can do something like this:: + + >>> L = [] + >>> dir(L) + ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', + 'reverse', 'sort'] + >>> help(L.append) + Help on built-in function append: + + append(...) + L.append(object) -- append object to end + >>> L.append(1) + >>> L + [1] + +With the interpreter, documentation is never far from the student as he's +programming. + +There are also good IDEs for Python. IDLE is a cross-platform IDE for Python +that is written in Python using Tkinter. PythonWin is a Windows-specific IDE. +Emacs users will be happy to know that there is a very good Python mode for +Emacs. All of these programming environments provide syntax highlighting, +auto-indenting, and access to the interactive interpreter while coding. Consult +http://www.python.org/editors/ for a full list of Python editing environments. + +If you want to discuss Python's use in education, you may be interested in +joining `the edu-sig mailing list +`_. + + +Upgrading Python +================ + +What is this bsddb185 module my application keeps complaining about? +-------------------------------------------------------------------- + +.. XXX remove this question? + +Starting with Python2.3, the distribution includes the `PyBSDDB package +` as a replacement for the old bsddb module. It +includes functions which provide backward compatibility at the API level, but +requires a newer version of the underlying `Berkeley DB +`_ library. Files created with the older bsddb module +can't be opened directly using the new module. + +Using your old version of Python and a pair of scripts which are part of Python +2.3 (db2pickle.py and pickle2db.py, in the Tools/scripts directory) you can +convert your old database files to the new format. Using your old Python +version, run the db2pickle.py script to convert it to a pickle, e.g.:: + + python2.2 /db2pickley.py database.db database.pck + +Rename your database file:: + + mv database.db olddatabase.db + +Now convert the pickle file to a new format database:: + + python /pickle2db.py database.db database.pck + +The precise commands you use will vary depending on the particulars of your +installation. For full details about operation of these two scripts check the +doc string at the start of each one. Added: python/trunk/Doc/faq/gui.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/gui.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,160 @@ +:tocdepth: 2 + +========================== +Graphic User Interface FAQ +========================== + +.. contents:: + +General GUI Questions +===================== + +What platform-independent GUI toolkits exist for Python? +-------------------------------------------------------- + +Depending on what platform(s) you are aiming at, there are several. + +.. XXX check links + +Tkinter +''''''' + +Standard builds of Python include an object-oriented interface to the Tcl/Tk +widget set, called Tkinter. This is probably the easiest to install and use. +For more info about Tk, including pointers to the source, see the Tcl/Tk home +page at http://www.tcl.tk. Tcl/Tk is fully portable to the MacOS, Windows, and +Unix platforms. + +wxWindows +''''''''' + +wxWindows is a portable GUI class library written in C++ that's a portable +interface to various platform-specific libraries; wxWidgets is a Python +interface to wxWindows. wxWindows supports Windows and MacOS; on Unix variants, +it supports both GTk+ and Motif toolkits. wxWindows preserves the look and feel +of the underlying graphics toolkit, and there is quite a rich widget set and +collection of GDI classes. See `the wxWindows page `_ +for more details. + +`wxWidgets `_ is an extension module that wraps many of +the wxWindows C++ classes, and is quickly gaining popularity amongst Python +developers. You can get wxWidgets as part of the source or CVS distribution of +wxWindows, or directly from its home page. + +Qt +''' + +There are bindings available for the Qt toolkit (`PyQt +`_) and for KDE (PyKDE). If you're +writing open source software, you don't need to pay for PyQt, but if you want to +write proprietary applications, you must buy a PyQt license from `Riverbank +Computing `_ and a Qt license from +`Trolltech `_. + +Gtk+ +'''' + +PyGtk bindings for the `Gtk+ toolkit `_ have been +implemented by by James Henstridge; see ftp://ftp.gtk.org/pub/gtk/python/. + +FLTK +'''' + +Python bindings for `the FLTK toolkit `_, a simple yet +powerful and mature cross-platform windowing system, are available from `the +PyFLTK project `_. + + +FOX +''' + +A wrapper for `the FOX toolkit `_ called `FXpy +`_ is available. FOX supports both Unix variants +and Windows. + + +OpenGL +'''''' + +For OpenGL bindings, see `PyOpenGL `_. + + +What platform-specific GUI toolkits exist for Python? +----------------------------------------------------- + +`The Mac port `_ by Jack Jansen has a rich and +ever-growing set of modules that support the native Mac toolbox calls. The port +includes support for MacOS9 and MacOS X's Carbon libraries. By installing the +`PyObjc Objective-C bridge `_, Python programs +can use MacOS X's Cocoa libraries. See the documentation that comes with the Mac +port. + +:ref:`Pythonwin ` by Mark Hammond includes an interface to the +Microsoft Foundation Classes and a Python programming environment using it +that's written mostly in Python. + + +Tkinter questions +================= + +How do I freeze Tkinter applications? +------------------------------------- + +Freeze is a tool to create stand-alone applications. When freezing Tkinter +applications, the applications will not be truly stand-alone, as the application +will still need the Tcl and Tk libraries. + +One solution is to ship the application with the tcl and tk libraries, and point +to them at run-time using the :envvar:`TCL_LIBRARY` and :envvar:`TK_LIBRARY` +environment variables. + +To get truly stand-alone applications, the Tcl scripts that form the library +have to be integrated into the application as well. One tool supporting that is +SAM (stand-alone modules), which is part of the Tix distribution +(http://tix.mne.com). Build Tix with SAM enabled, perform the appropriate call +to Tclsam_init etc inside Python's Modules/tkappinit.c, and link with libtclsam +and libtksam (you might include the Tix libraries as well). + + +Can I have Tk events handled while waiting for I/O? +--------------------------------------------------- + +Yes, and you don't even need threads! But you'll have to restructure your I/O +code a bit. Tk has the equivalent of Xt's XtAddInput() call, which allows you +to register a callback function which will be called from the Tk mainloop when +I/O is possible on a file descriptor. Here's what you need:: + + from Tkinter import tkinter + tkinter.createfilehandler(file, mask, callback) + +The file may be a Python file or socket object (actually, anything with a +fileno() method), or an integer file descriptor. The mask is one of the +constants tkinter.READABLE or tkinter.WRITABLE. The callback is called as +follows:: + + callback(file, mask) + +You must unregister the callback when you're done, using :: + + tkinter.deletefilehandler(file) + +Note: since you don't know *how many bytes* are available for reading, you can't +use the Python file object's read or readline methods, since these will insist +on reading a predefined number of bytes. For sockets, the :meth:`recv` or +:meth:`recvfrom` methods will work fine; for other files, use +``os.read(file.fileno(), maxbytecount)``. + + +I can't get key bindings to work in Tkinter: why? +------------------------------------------------- + +An often-heard complaint is that event handlers bound to events with the +:meth:`bind` method don't get handled even when the appropriate key is pressed. + +The most common cause is that the widget to which the binding applies doesn't +have "keyboard focus". Check out the Tk documentation for the focus command. +Usually a widget is given the keyboard focus by clicking in it (but not for +labels; see the takefocus option). + + + Added: python/trunk/Doc/faq/index.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/index.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,18 @@ +################################### + Python Frequently Asked Questions +################################### + +:Release: |version| +:Date: |today| + +.. toctree:: + :maxdepth: 1 + + general.rst + programming.rst + design.rst + library.rst + extending.rst + windows.rst + gui.rst + installed.rst Added: python/trunk/Doc/faq/installed.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/installed.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,53 @@ +============================================= +"Why is Python Installed on my Computer?" FAQ +============================================= + +What is Python? +--------------- + +Python is a programming language. It's used for many different applications. +It's used in some high schools and colleges as an introductory programming +language because Python is easy to learn, but it's also used by professional +software developers at places such as Google, NASA, and Lucasfilm Ltd. + +If you wish to learn more about Python, start with the `Beginner's Guide to +Python `_. + + +Why is Python installed on my machine? +-------------------------------------- + +If you find Python installed on your system but don't remember installing it, +there are several possible ways it could have gotten there. + +* Perhaps another user on the computer wanted to learn programming and installed + it; you'll have to figure out who's been using the machine and might have + installed it. +* A third-party application installed on the machine might have been written in + Python and included a Python installation. For a home computer, the most + common such application is `PySol `_, a + solitaire game that includes over 1000 different games and variations. +* Some Windows machines also have Python installed. At this writing we're aware + of computers from Hewlett-Packard and Compaq that include Python. Apparently + some of HP/Compaq's administrative tools are written in Python. +* All Apple computers running Mac OS X have Python installed; it's included in + the base installation. + + +Can I delete Python? +-------------------- + +That depends on where Python came from. + +If someone installed it deliberately, you can remove it without hurting +anything. On Windows, use the Add/Remove Programs icon in the Control Panel. + +If Python was installed by a third-party application, you can also remove it, +but that application will no longer work. You should use that application's +uninstaller rather than removing Python directly. + +If Python came with your operating system, removing it is not recommended. If +you remove it, whatever tools were written in Python will no longer run, and +some of them might be important to you. Reinstalling the whole system would +then be required to fix things again. + Added: python/trunk/Doc/faq/library.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/library.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,880 @@ +:tocdepth: 2 + +========================= +Library and Extension FAQ +========================= + +.. contents:: + +General Library Questions +========================= + +How do I find a module or application to perform task X? +-------------------------------------------------------- + +Check :ref:`the Library Reference ` to see if there's a relevant +standard library module. (Eventually you'll learn what's in the standard +library and will able to skip this step.) + +Search the `Python Package Index `_. + +Next, check the `Vaults of Parnassus `_, an older +index of packages. + +Finally, try `Google `_ or other Web search engine. +Searching for "Python" plus a keyword or two for your topic of interest will +usually find something helpful. + + +Where is the math.py (socket.py, regex.py, etc.) source file? +------------------------------------------------------------- + +If you can't find a source file for a module it may be a builtin or dynamically +loaded module implemented in C, C++ or other compiled language. In this case +you may not have the source file or it may be something like mathmodule.c, +somewhere in a C source directory (not on the Python Path). + +There are (at least) three kinds of modules in Python: + +1) modules written in Python (.py); +2) modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc); +3) modules written in C and linked with the interpreter; to get a list of these, + type:: + + import sys + print sys.builtin_module_names + + +How do I make a Python script executable on Unix? +------------------------------------------------- + +You need to do two things: the script file's mode must be executable and the +first line must begin with ``#!`` followed by the path of the Python +interpreter. + +The first is done by executing ``chmod +x scriptfile`` or perhaps ``chmod 755 +scriptfile``. + +The second can be done in a number of ways. The most straightforward way is to +write :: + + #!/usr/local/bin/python + +as the very first line of your file, using the pathname for where the Python +interpreter is installed on your platform. + +If you would like the script to be independent of where the Python interpreter +lives, you can use the "env" program. Almost all Unix variants support the +following, assuming the python interpreter is in a directory on the user's +$PATH:: + + #!/usr/bin/env python + +*Don't* do this for CGI scripts. The $PATH variable for CGI scripts is often +very minimal, so you need to use the actual absolute pathname of the +interpreter. + +Occasionally, a user's environment is so full that the /usr/bin/env program +fails; or there's no env program at all. In that case, you can try the +following hack (due to Alex Rezinsky):: + + #! /bin/sh + """:" + exec python $0 ${1+"$@"} + """ + +The minor disadvantage is that this defines the script's __doc__ string. +However, you can fix that by adding :: + + __doc__ = """...Whatever...""" + + + +Is there a curses/termcap package for Python? +--------------------------------------------- + +.. XXX curses *is* built by default, isn't it? + +For Unix variants: The standard Python source distribution comes with a curses +module in the ``Modules/`` subdirectory, though it's not compiled by default +(note that this is not available in the Windows distribution -- there is no +curses module for Windows). + +The curses module supports basic curses features as well as many additional +functions from ncurses and SYSV curses such as colour, alternative character set +support, pads, and mouse support. This means the module isn't compatible with +operating systems that only have BSD curses, but there don't seem to be any +currently maintained OSes that fall into this category. + +For Windows: use `the consolelib module +`_. + + +Is there an equivalent to C's onexit() in Python? +------------------------------------------------- + +The :mod:`atexit` module provides a register function that is similar to C's +onexit. + + +Why don't my signal handlers work? +---------------------------------- + +The most common problem is that the signal handler is declared with the wrong +argument list. It is called as :: + + handler(signum, frame) + +so it should be declared with two arguments:: + + def handler(signum, frame): + ... + + +Common tasks +============ + +How do I test a Python program or component? +-------------------------------------------- + +Python comes with two testing frameworks. The :mod:`doctest` module finds +examples in the docstrings for a module and runs them, comparing the output with +the expected output given in the docstring. + +The :mod:`unittest` module is a fancier testing framework modelled on Java and +Smalltalk testing frameworks. + +For testing, it helps to write the program so that it may be easily tested by +using good modular design. Your program should have almost all functionality +encapsulated in either functions or class methods -- and this sometimes has the +surprising and delightful effect of making the program run faster (because local +variable accesses are faster than global accesses). Furthermore the program +should avoid depending on mutating global variables, since this makes testing +much more difficult to do. + +The "global main logic" of your program may be as simple as :: + + if __name__ == "__main__": + main_logic() + +at the bottom of the main module of your program. + +Once your program is organized as a tractable collection of functions and class +behaviours you should write test functions that exercise the behaviours. A test +suite can be associated with each module which automates a sequence of tests. +This sounds like a lot of work, but since Python is so terse and flexible it's +surprisingly easy. You can make coding much more pleasant and fun by writing +your test functions in parallel with the "production code", since this makes it +easy to find bugs and even design flaws earlier. + +"Support modules" that are not intended to be the main module of a program may +include a self-test of the module. :: + + if __name__ == "__main__": + self_test() + +Even programs that interact with complex external interfaces may be tested when +the external interfaces are unavailable by using "fake" interfaces implemented +in Python. + + +How do I create documentation from doc strings? +----------------------------------------------- + +.. XXX mention Sphinx/epydoc + +The :mod:`pydoc` module can create HTML from the doc strings in your Python +source code. An alternative is `pythondoc +`_. + + +How do I get a single keypress at a time? +----------------------------------------- + +For Unix variants: There are several solutions. It's straightforward to do this +using curses, but curses is a fairly large module to learn. Here's a solution +without curses:: + + import termios, fcntl, sys, os + fd = sys.stdin.fileno() + + oldterm = termios.tcgetattr(fd) + newattr = termios.tcgetattr(fd) + newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO + termios.tcsetattr(fd, termios.TCSANOW, newattr) + + oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) + fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) + + try: + while 1: + try: + c = sys.stdin.read(1) + print "Got character", `c` + except IOError: pass + finally: + termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) + fcntl.fcntl(fd, fcntl.F_SETFL, oldflags) + +You need the :mod:`termios` and the :mod:`fcntl` module for any of this to work, +and I've only tried it on Linux, though it should work elsewhere. In this code, +characters are read and printed one at a time. + +:func:`termios.tcsetattr` turns off stdin's echoing and disables canonical mode. +:func:`fcntl.fnctl` is used to obtain stdin's file descriptor flags and modify +them for non-blocking mode. Since reading stdin when it is empty results in an +:exc:`IOError`, this error is caught and ignored. + + +Threads +======= + +How do I program using threads? +------------------------------- + +.. XXX it's _thread in py3k + +Be sure to use the :mod:`threading` module and not the :mod:`thread` module. +The :mod:`threading` module builds convenient abstractions on top of the +low-level primitives provided by the :mod:`thread` module. + +Aahz has a set of slides from his threading tutorial that are helpful; see +http://starship.python.net/crew/aahz/OSCON2001/. + + +None of my threads seem to run: why? +------------------------------------ + +As soon as the main thread exits, all threads are killed. Your main thread is +running too quickly, giving the threads no time to do any work. + +A simple fix is to add a sleep to the end of the program that's long enough for +all the threads to finish:: + + import threading, time + + def thread_task(name, n): + for i in range(n): print name, i + + for i in range(10): + T = threading.Thread(target=thread_task, args=(str(i), i)) + T.start() + + time.sleep(10) # <----------------------------! + +But now (on many platforms) the threads don't run in parallel, but appear to run +sequentially, one at a time! The reason is that the OS thread scheduler doesn't +start a new thread until the previous thread is blocked. + +A simple fix is to add a tiny sleep to the start of the run function:: + + def thread_task(name, n): + time.sleep(0.001) # <---------------------! + for i in range(n): print name, i + + for i in range(10): + T = threading.Thread(target=thread_task, args=(str(i), i)) + T.start() + + time.sleep(10) + +Instead of trying to guess how long a :func:`time.sleep` delay will be enough, +it's better to use some kind of semaphore mechanism. One idea is to use the +:mod:`Queue` module to create a queue object, let each thread append a token to +the queue when it finishes, and let the main thread read as many tokens from the +queue as there are threads. + + +How do I parcel out work among a bunch of worker threads? +--------------------------------------------------------- + +Use the :mod:`Queue` module to create a queue containing a list of jobs. The +:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +add an item to the queue and ``.get()`` to return an item. The class will take +care of the locking necessary to ensure that each job is handed out exactly +once. + +Here's a trivial example:: + + import threading, Queue, time + + # The worker thread gets jobs off the queue. When the queue is empty, it + # assumes there will be no more work and exits. + # (Realistically workers will run until terminated.) + def worker (): + print 'Running worker' + time.sleep(0.1) + while True: + try: + arg = q.get(block=False) + except Queue.Empty: + print 'Worker', threading.currentThread(), + print 'queue empty' + break + else: + print 'Worker', threading.currentThread(), + print 'running with argument', arg + time.sleep(0.5) + + # Create queue + q = Queue.Queue() + + # Start a pool of 5 workers + for i in range(5): + t = threading.Thread(target=worker, name='worker %i' % (i+1)) + t.start() + + # Begin adding work to the queue + for i in range(50): + q.put(i) + + # Give threads time to run + print 'Main thread sleeping' + time.sleep(5) + +When run, this will produce the following output: + + Running worker + Running worker + Running worker + Running worker + Running worker + Main thread sleeping + Worker running with argument 0 + Worker running with argument 1 + Worker running with argument 2 + Worker running with argument 3 + Worker running with argument 4 + Worker running with argument 5 + ... + +Consult the module's documentation for more details; the ``Queue`` class +provides a featureful interface. + + +What kinds of global value mutation are thread-safe? +---------------------------------------------------- + +A global interpreter lock (GIL) is used internally to ensure that only one +thread runs in the Python VM at a time. In general, Python offers to switch +among threads only between bytecode instructions; how frequently it switches can +be set via :func:`sys.setcheckinterval`. Each bytecode instruction and +therefore all the C implementation code reached from each instruction is +therefore atomic from the point of view of a Python program. + +In theory, this means an exact accounting requires an exact understanding of the +PVM bytecode implementation. In practice, it means that operations on shared +variables of builtin data types (ints, lists, dicts, etc) that "look atomic" +really are. + +For example, the following operations are all atomic (L, L1, L2 are lists, D, +D1, D2 are dicts, x, y are objects, i, j are ints):: + + L.append(x) + L1.extend(L2) + x = L[i] + x = L.pop() + L1[i:j] = L2 + L.sort() + x = y + x.field = y + D[x] = y + D1.update(D2) + D.keys() + +These aren't:: + + i = i+1 + L.append(L[-1]) + L[i] = L[j] + D[x] = D[x] + 1 + +Operations that replace other objects may invoke those other objects' +:meth:`__del__` method when their reference count reaches zero, and that can +affect things. This is especially true for the mass updates to dictionaries and +lists. When in doubt, use a mutex! + + +Can't we get rid of the Global Interpreter Lock? +------------------------------------------------ + +.. XXX mention multiprocessing + +The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's +deployment on high-end multiprocessor server machines, because a multi-threaded +Python program effectively only uses one CPU, due to the insistence that +(almost) all Python code can only run while the GIL is held. + +Back in the days of Python 1.5, Greg Stein actually implemented a comprehensive +patch set (the "free threading" patches) that removed the GIL and replaced it +with fine-grained locking. Unfortunately, even on Windows (where locks are very +efficient) this ran ordinary Python code about twice as slow as the interpreter +using the GIL. On Linux the performance loss was even worse because pthread +locks aren't as efficient. + +Since then, the idea of getting rid of the GIL has occasionally come up but +nobody has found a way to deal with the expected slowdown, and users who don't +use threads would not be happy if their code ran at half at the speed. Greg's +free threading patch set has not been kept up-to-date for later Python versions. + +This doesn't mean that you can't make good use of Python on multi-CPU machines! +You just have to be creative with dividing the work up between multiple +*processes* rather than multiple *threads*. Judicious use of C extensions will +also help; if you use a C extension to perform a time-consuming task, the +extension can release the GIL while the thread of execution is in the C code and +allow other threads to get some work done. + +It has been suggested that the GIL should be a per-interpreter-state lock rather +than truly global; interpreters then wouldn't be able to share objects. +Unfortunately, this isn't likely to happen either. It would be a tremendous +amount of work, because many object implementations currently have global state. +For example, small integers and short strings are cached; these caches would +have to be moved to the interpreter state. Other object types have their own +free list; these free lists would have to be moved to the interpreter state. +And so on. + +And I doubt that it can even be done in finite time, because the same problem +exists for 3rd party extensions. It is likely that 3rd party extensions are +being written at a faster rate than you can convert them to store all their +global state in the interpreter state. + +And finally, once you have multiple interpreters not sharing any state, what +have you gained over running each interpreter in a separate process? + + +Input and Output +================ + +How do I delete a file? (And other file questions...) +----------------------------------------------------- + +Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, see +the :mod:`os` module. The two functions are identical; :func:`unlink` is simply +the name of the Unix system call for this function. + +To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create one. +``os.makedirs(path)`` will create any intermediate directories in ``path`` that +don't exist. ``os.removedirs(path)`` will remove intermediate directories as +long as they're empty; if you want to delete an entire directory tree and its +contents, use :func:`shutil.rmtree`. + +To rename a file, use ``os.rename(old_path, new_path)``. + +To truncate a file, open it using ``f = open(filename, "r+")``, and use +``f.truncate(offset)``; offset defaults to the current seek position. There's +also ```os.ftruncate(fd, offset)`` for files opened with :func:`os.open`, where +``fd`` is the file descriptor (a small integer). + +The :mod:`shutil` module also contains a number of functions to work on files +including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and +:func:`~shutil.rmtree`. + + +How do I copy a file? +--------------------- + +The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note +that on MacOS 9 it doesn't copy the resource fork and Finder info. + + +How do I read (or write) binary data? +------------------------------------- + +To read or write complex binary data formats, it's best to use the :mod:`struct` +module. It allows you to take a string containing binary data (usually numbers) +and convert it to Python objects; and vice versa. + +For example, the following code reads two 2-byte integers and one 4-byte integer +in big-endian format from a file:: + + import struct + + f = open(filename, "rb") # Open in binary mode for portability + s = f.read(8) + x, y, z = struct.unpack(">hhl", s) + +The '>' in the format string forces big-endian data; the letter 'h' reads one +"short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the +string. + +For data that is more regular (e.g. a homogeneous list of ints or thefloats), +you can also use the :mod:`array` module. + + +I can't seem to use os.read() on a pipe created with os.popen(); why? +--------------------------------------------------------------------- + +:func:`os.read` is a low-level function which takes a file descriptor, a small +integer representing the opened file. :func:`os.popen` creates a high-level +file object, the same type returned by the builtin :func:`open` function. Thus, +to read n bytes from a pipe p created with :func:`os.popen`, you need to use +``p.read(n)``. + + +How do I run a subprocess with pipes connected to both input and output? +------------------------------------------------------------------------ + +.. XXX update to use subprocess + +Use the :mod:`popen2` module. For example:: + + import popen2 + fromchild, tochild = popen2.popen2("command") + tochild.write("input\n") + tochild.flush() + output = fromchild.readline() + +Warning: in general it is unwise to do this because you can easily cause a +deadlock where your process is blocked waiting for output from the child while +the child is blocked waiting for input from you. This can be caused because the +parent expects the child to output more text than it does, or it can be caused +by data being stuck in stdio buffers due to lack of flushing. The Python parent +can of course explicitly flush the data it sends to the child before it reads +any output, but if the child is a naive C program it may have been written to +never explicitly flush its output, even if it is interactive, since flushing is +normally automatic. + +Note that a deadlock is also possible if you use :func:`popen3` to read stdout +and stderr. If one of the two is too large for the internal buffer (increasing +the buffer size does not help) and you ``read()`` the other one first, there is +a deadlock, too. + +Note on a bug in popen2: unless your program calls ``wait()`` or ``waitpid()``, +finished child processes are never removed, and eventually calls to popen2 will +fail because of a limit on the number of child processes. Calling +:func:`os.waitpid` with the :data:`os.WNOHANG` option can prevent this; a good +place to insert such a call would be before calling ``popen2`` again. + +In many cases, all you really need is to run some data through a command and get +the result back. Unless the amount of data is very large, the easiest way to do +this is to write it to a temporary file and run the command with that temporary +file as input. The standard module :mod:`tempfile` exports a ``mktemp()`` +function to generate unique temporary file names. :: + + import tempfile + import os + + class Popen3: + """ + This is a deadlock-safe version of popen that returns + an object with errorlevel, out (a string) and err (a string). + (capturestderr may not work under windows.) + Example: print Popen3('grep spam','\n\nhere spam\n\n').out + """ + def __init__(self,command,input=None,capturestderr=None): + outfile=tempfile.mktemp() + command="( %s ) > %s" % (command,outfile) + if input: + infile=tempfile.mktemp() + open(infile,"w").write(input) + command=command+" <"+infile + if capturestderr: + errfile=tempfile.mktemp() + command=command+" 2>"+errfile + self.errorlevel=os.system(command) >> 8 + self.out=open(outfile,"r").read() + os.remove(outfile) + if input: + os.remove(infile) + if capturestderr: + self.err=open(errfile,"r").read() + os.remove(errfile) + +Note that many interactive programs (e.g. vi) don't work well with pipes +substituted for standard input and output. You will have to use pseudo ttys +("ptys") instead of pipes. Or you can use a Python interface to Don Libes' +"expect" library. A Python extension that interfaces to expect is called "expy" +and available from http://expectpy.sourceforge.net. A pure Python solution that +works like expect is ` pexpect `_. + + +How do I access the serial (RS232) port? +---------------------------------------- + +For Win32, POSIX (Linux, BSD, etc.), Jython: + + http://pyserial.sourceforge.net + +For Unix, see a Usenet post by Mitch Chapman: + + http://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com + + +Why doesn't closing sys.stdout (stdin, stderr) really close it? +--------------------------------------------------------------- + +Python file objects are a high-level layer of abstraction on top of C streams, +which in turn are a medium-level layer of abstraction on top of (among other +things) low-level C file descriptors. + +For most file objects you create in Python via the builtin ``file`` constructor, +``f.close()`` marks the Python file object as being closed from Python's point +of view, and also arranges to close the underlying C stream. This also happens +automatically in f's destructor, when f becomes garbage. + +But stdin, stdout and stderr are treated specially by Python, because of the +special status also given to them by C. Running ``sys.stdout.close()`` marks +the Python-level file object as being closed, but does *not* close the +associated C stream. + +To close the underlying C stream for one of these three, you should first be +sure that's what you really want to do (e.g., you may confuse extension modules +trying to do I/O). If it is, use os.close:: + + os.close(0) # close C's stdin stream + os.close(1) # close C's stdout stream + os.close(2) # close C's stderr stream + + +Network/Internet Programming +============================ + +What WWW tools are there for Python? +------------------------------------ + +See the chapters titled :ref:`internet` and :ref:`netdata` in the Library +Reference Manual. Python has many modules that will help you build server-side +and client-side web systems. + +.. XXX check if wiki page is still up to date + +A summary of available frameworks is maintained by Paul Boddie at +http://wiki.python.org/moin/WebProgramming . + +Cameron Laird maintains a useful set of pages about Python web technologies at +http://phaseit.net/claird/comp.lang.python/web_python. + + +How can I mimic CGI form submission (METHOD=POST)? +-------------------------------------------------- + +I would like to retrieve web pages that are the result of POSTing a form. Is +there existing code that would let me do this easily? + +Yes. Here's a simple example that uses httplib:: + + #!/usr/local/bin/python + + import httplib, sys, time + + ### build the query string + qs = "First=Josephine&MI=Q&Last=Public" + + ### connect and send the server a path + httpobj = httplib.HTTP('www.some-server.out-there', 80) + httpobj.putrequest('POST', '/cgi-bin/some-cgi-script') + ### now generate the rest of the HTTP headers... + httpobj.putheader('Accept', '*/*') + httpobj.putheader('Connection', 'Keep-Alive') + httpobj.putheader('Content-type', 'application/x-www-form-urlencoded') + httpobj.putheader('Content-length', '%d' % len(qs)) + httpobj.endheaders() + httpobj.send(qs) + ### find out what the server said in response... + reply, msg, hdrs = httpobj.getreply() + if reply != 200: + sys.stdout.write(httpobj.getfile().read()) + +Note that in general for URL-encoded POST operations, query strings must be +quoted by using :func:`urllib.quote`. For example to send name="Guy Steele, +Jr.":: + + >>> from urllib import quote + >>> x = quote("Guy Steele, Jr.") + >>> x + 'Guy%20Steele,%20Jr.' + >>> query_string = "name="+x + >>> query_string + 'name=Guy%20Steele,%20Jr.' + + +What module should I use to help with generating HTML? +------------------------------------------------------ + +.. XXX add modern template languages + +There are many different modules available: + +* HTMLgen is a class library of objects corresponding to all the HTML 3.2 markup + tags. It's used when you are writing in Python and wish to synthesize HTML + pages for generating a web or for CGI forms, etc. + +* DocumentTemplate and Zope Page Templates are two different systems that are + part of Zope. + +* Quixote's PTL uses Python syntax to assemble strings of text. + +Consult the `Web Programming wiki pages +`_ for more links. + + +How do I send mail from a Python script? +---------------------------------------- + +Use the standard library module :mod:`smtplib`. + +Here's a very simple interactive mail sender that uses it. This method will +work on any host that supports an SMTP listener. :: + + import sys, smtplib + + fromaddr = raw_input("From: ") + toaddrs = raw_input("To: ").split(',') + print "Enter message, end with ^D:" + msg = '' + while True: + line = sys.stdin.readline() + if not line: + break + msg += line + + # The actual mail send + server = smtplib.SMTP('localhost') + server.sendmail(fromaddr, toaddrs, msg) + server.quit() + +A Unix-only alternative uses sendmail. The location of the sendmail program +varies between systems; sometimes it is ``/usr/lib/sendmail``, sometime +``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's +some sample code:: + + SENDMAIL = "/usr/sbin/sendmail" # sendmail location + import os + p = os.popen("%s -t -i" % SENDMAIL, "w") + p.write("To: receiver at example.com\n") + p.write("Subject: test\n") + p.write("\n") # blank line separating headers from body + p.write("Some text\n") + p.write("some more text\n") + sts = p.close() + if sts != 0: + print "Sendmail exit status", sts + + +How do I avoid blocking in the connect() method of a socket? +------------------------------------------------------------ + +The select module is commonly used to help with asynchronous I/O on sockets. + +To prevent the TCP connect from blocking, you can set the socket to non-blocking +mode. Then when you do the ``connect()``, you will either connect immediately +(unlikely) or get an exception that contains the error number as ``.errno``. +``errno.EINPROGRESS`` indicates that the connection is in progress, but hasn't +finished yet. Different OSes will return different values, so you're going to +have to check what's returned on your system. + +You can use the ``connect_ex()`` method to avoid creating an exception. It will +just return the errno value. To poll, you can call ``connect_ex()`` again later +-- 0 or ``errno.EISCONN`` indicate that you're connected -- or you can pass this +socket to select to check if it's writable. + + +Databases +========= + +Are there any interfaces to database packages in Python? +-------------------------------------------------------- + +Yes. + +.. XXX remove bsddb in py3k, fix other module names + +Python 2.3 includes the :mod:`bsddb` package which provides an interface to the +BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM ` +and :mod:`GDBM ` are also included with standard Python. + +Support for most relational databases is available. See the +`DatabaseProgramming wiki page +`_ for details. + + +How do you implement persistent objects in Python? +-------------------------------------------------- + +The :mod:`pickle` library module solves this in a very general way (though you +still can't store things like open files, sockets or windows), and the +:mod:`shelve` library module uses pickle and (g)dbm to create persistent +mappings containing arbitrary Python objects. For better performance, you can +use the :mod:`cPickle` module. + +A more awkward way of doing things is to use pickle's little sister, marshal. +The :mod:`marshal` module provides very fast ways to store noncircular basic +Python types to files and strings, and back again. Although marshal does not do +fancy things like store instances or handle shared references properly, it does +run extremely fast. For example loading a half megabyte of data may take less +than a third of a second. This often beats doing something more complex and +general such as using gdbm with pickle/shelve. + + +Why is cPickle so slow? +----------------------- + +.. XXX update this, default protocol is 2/3 + +The default format used by the pickle module is a slow one that results in +readable pickles. Making it the default, but it would break backward +compatibility:: + + largeString = 'z' * (100 * 1024) + myPickle = cPickle.dumps(largeString, protocol=1) + + +If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come? +------------------------------------------------------------------------------------------ + +Databases opened for write access with the bsddb module (and often by the anydbm +module, since it will preferentially use bsddb) must explicitly be closed using +the ``.close()`` method of the database. The underlying library caches database +contents which need to be converted to on-disk form and written. + +If you have initialized a new bsddb database but not written anything to it +before the program crashes, you will often wind up with a zero-length file and +encounter an exception the next time the file is opened. + + +I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data? +---------------------------------------------------------------------------------------------------------------------------- + +Don't panic! Your data is probably intact. The most frequent cause for the error +is that you tried to open an earlier Berkeley DB file with a later version of +the Berkeley DB library. + +Many Linux systems now have all three versions of Berkeley DB available. If you +are migrating from version 1 to a newer version use db_dump185 to dump a plain +text version of the database. If you are migrating from version 2 to version 3 +use db2_dump to create a plain text version of the database. In either case, +use db_load to create a new native database for the latest version installed on +your computer. If you have version 3 of Berkeley DB installed, you should be +able to use db2_load to create a native version 2 database. + +You should move away from Berkeley DB version 1 files because the hash file code +contains known bugs that can corrupt your data. + + +Mathematics and Numerics +======================== + +How do I generate random numbers in Python? +------------------------------------------- + +The standard module :mod:`random` implements a random number generator. Usage +is simple:: + + import random + random.random() + +This returns a random floating point number in the range [0, 1). + +There are also many other specialized generators in this module, such as: + +* ``randrange(a, b)`` chooses an integer in the range [a, b). +* ``uniform(a, b)`` chooses a floating point number in the range [a, b). +* ``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution. + +Some higher-level functions operate on sequences directly, such as: + +* ``choice(S)`` chooses random element from a given sequence +* ``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly + +There's also a ``Random`` class you can instantiate to create independent +multiple random number generators. Added: python/trunk/Doc/faq/programming.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/programming.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,1752 @@ +:tocdepth: 2 + +=============== +Programming FAQ +=============== + +.. contents:: + +General Questions +================= + +Is there a source code level debugger with breakpoints, single-stepping, etc.? +------------------------------------------------------------------------------ + +Yes. + +The pdb module is a simple but adequate console-mode debugger for Python. It is +part of the standard Python library, and is :mod:`documented in the Library +Reference Manual `. You can also write your own debugger by using the code +for pdb as an example. + +The IDLE interactive development environment, which is part of the standard +Python distribution (normally available as Tools/scripts/idle), includes a +graphical debugger. There is documentation for the IDLE debugger at +http://www.python.org/idle/doc/idle2.html#Debugger. + +PythonWin is a Python IDE that includes a GUI debugger based on pdb. The +Pythonwin debugger colors breakpoints and has quite a few cool features such as +debugging non-Pythonwin programs. Pythonwin is available as part of the `Python +for Windows Extensions `__ project and +as a part of the ActivePython distribution (see +http://www.activestate.com/Products/ActivePython/index.html). + +`Boa Constructor `_ is an IDE and GUI +builder that uses wxWidgets. It offers visual frame creation and manipulation, +an object inspector, many views on the source like object browsers, inheritance +hierarchies, doc string generated html documentation, an advanced debugger, +integrated help, and Zope support. + +`Eric `_ is an IDE built on PyQt +and the Scintilla editing component. + +Pydb is a version of the standard Python debugger pdb, modified for use with DDD +(Data Display Debugger), a popular graphical debugger front end. Pydb can be +found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at +http://www.gnu.org/software/ddd. + +There are a number of commercial Python IDEs that include graphical debuggers. +They include: + +* Wing IDE (http://wingware.com/) +* Komodo IDE (http://www.activestate.com/Products/Komodo) + + +Is there a tool to help find bugs or perform static analysis? +------------------------------------------------------------- + +Yes. + +PyChecker is a static analysis tool that finds bugs in Python source code and +warns about code complexity and style. You can get PyChecker from +http://pychecker.sf.net. + +`Pylint `_ is another tool that checks +if a module satisfies a coding standard, and also makes it possible to write +plug-ins to add a custom feature. In addition to the bug checking that +PyChecker performs, Pylint offers some additional features such as checking line +length, whether variable names are well-formed according to your coding +standard, whether declared interfaces are fully implemented, and more. +http://www.logilab.org/projects/pylint/documentation provides a full list of +Pylint's features. + + +How can I create a stand-alone binary from a Python script? +----------------------------------------------------------- + +You don't need the ability to compile Python to C code if all you want is a +stand-alone program that users can download and run without having to install +the Python distribution first. There are a number of tools that determine the +set of modules required by a program and bind these modules together with a +Python binary to produce a single executable. + +One is to use the freeze tool, which is included in the Python source tree as +``Tools/freeze``. It converts Python byte code to C arrays; a C compiler you can +embed all your modules into a new program, which is then linked with the +standard Python modules. + +It works by scanning your source recursively for import statements (in both +forms) and looking for the modules in the standard Python path as well as in the +source directory (for built-in modules). It then turns the bytecode for modules +written in Python into C code (array initializers that can be turned into code +objects using the marshal module) and creates a custom-made config file that +only contains those built-in modules which are actually used in the program. It +then compiles the generated C code and links it with the rest of the Python +interpreter to form a self-contained binary which acts exactly like your script. + +Obviously, freeze requires a C compiler. There are several other utilities +which don't. One is Thomas Heller's py2exe (Windows only) at + + http://www.py2exe.org/ + +Another is Christian Tismer's `SQFREEZE `_ +which appends the byte code to a specially-prepared Python interpreter that can +find the byte code in the executable. + +Other tools include Fredrik Lundh's `Squeeze +`_ and Anthony Tuininga's +`cx_Freeze `_. + + +Are there coding standards or a style guide for Python programs? +---------------------------------------------------------------- + +Yes. The coding style required for standard library modules is documented as +:pep:`8`. + + +My program is too slow. How do I speed it up? +--------------------------------------------- + +That's a tough one, in general. There are many tricks to speed up Python code; +consider rewriting parts in C as a last resort. + +In some cases it's possible to automatically translate Python to C or x86 +assembly language, meaning that you don't have to modify your code to gain +increased speed. + +.. XXX seems to have overlap with other questions! + +`Pyrex `_ can compile a +slightly modified version of Python code into a C extension, and can be used on +many different platforms. + +`Psyco `_ is a just-in-time compiler that +translates Python code into x86 assembly language. If you can use it, Psyco can +provide dramatic speedups for critical functions. + +The rest of this answer will discuss various tricks for squeezing a bit more +speed out of Python code. *Never* apply any optimization tricks unless you know +you need them, after profiling has indicated that a particular function is the +heavily executed hot spot in the code. Optimizations almost always make the +code less clear, and you shouldn't pay the costs of reduced clarity (increased +development time, greater likelihood of bugs) unless the resulting performance +benefit is worth it. + +There is a page on the wiki devoted to `performance tips +`_. + +Guido van Rossum has written up an anecdote related to optimization at +http://www.python.org/doc/essays/list2str.html. + +One thing to notice is that function and (especially) method calls are rather +expensive; if you have designed a purely OO interface with lots of tiny +functions that don't do much more than get or set an instance variable or call +another method, you might consider using a more direct way such as directly +accessing instance variables. Also see the standard module :mod:`profile` which +makes it possible to find out where your program is spending most of its time +(if you have some patience -- the profiling itself can slow your program down by +an order of magnitude). + +Remember that many standard optimization heuristics you may know from other +programming experience may well apply to Python. For example it may be faster +to send output to output devices using larger writes rather than smaller ones in +order to reduce the overhead of kernel system calls. Thus CGI scripts that +write all output in "one shot" may be faster than those that write lots of small +pieces of output. + +Also, be sure to use Python's core features where appropriate. For example, +slicing allows programs to chop up lists and other sequence objects in a single +tick of the interpreter's mainloop using highly optimized C implementations. +Thus to get the same effect as:: + + L2 = [] + for i in range[3]: + L2.append(L1[i]) + +it is much shorter and far faster to use :: + + L2 = list(L1[:3]) # "list" is redundant if L1 is a list. + +Note that the functionally-oriented builtins such as :func:`map`, :func:`zip`, +and friends can be a convenient accelerator for loops that perform a single +task. For example to pair the elements of two lists together:: + + >>> zip([1,2,3], [4,5,6]) + [(1, 4), (2, 5), (3, 6)] + +or to compute a number of sines:: + + >>> map( math.sin, (1,2,3,4)) + [0.841470984808, 0.909297426826, 0.14112000806, -0.756802495308] + +The operation completes very quickly in such cases. + +Other examples include the ``join()`` and ``split()`` methods of string objects. +For example if s1..s7 are large (10K+) strings then +``"".join([s1,s2,s3,s4,s5,s6,s7])`` may be far faster than the more obvious +``s1+s2+s3+s4+s5+s6+s7``, since the "summation" will compute many +subexpressions, whereas ``join()`` does all the copying in one pass. For +manipulating strings, use the ``replace()`` method on string objects. Use +regular expressions only when you're not dealing with constant string patterns. +Consider using the string formatting operations ``string % tuple`` and ``string +% dictionary``. + +Be sure to use the :meth:`list.sort` builtin method to do sorting, and see the +`sorting mini-HOWTO `_ for examples +of moderately advanced usage. :meth:`list.sort` beats other techniques for +sorting in all but the most extreme circumstances. + +Another common trick is to "push loops into functions or methods." For example +suppose you have a program that runs slowly and you use the profiler to +determine that a Python function ``ff()`` is being called lots of times. If you +notice that ``ff ()``:: + + def ff(x): + ... # do something with x computing result... + return result + +tends to be called in loops like:: + + list = map(ff, oldlist) + +or:: + + for x in sequence: + value = ff(x) + ... # do something with value... + +then you can often eliminate function call overhead by rewriting ``ff()`` to:: + + def ffseq(seq): + resultseq = [] + for x in seq: + ... # do something with x computing result... + resultseq.append(result) + return resultseq + +and rewrite the two examples to ``list = ffseq(oldlist)`` and to:: + + for value in ffseq(sequence): + ... # do something with value... + +Single calls to ``ff(x)`` translate to ``ffseq([x])[0]`` with little penalty. +Of course this technique is not always appropriate and there are other variants +which you can figure out. + +You can gain some performance by explicitly storing the results of a function or +method lookup into a local variable. A loop like:: + + for key in token: + dict[key] = dict.get(key, 0) + 1 + +resolves ``dict.get`` every iteration. If the method isn't going to change, a +slightly faster implementation is:: + + dict_get = dict.get # look up the method once + for key in token: + dict[key] = dict_get(key, 0) + 1 + +Default arguments can be used to determine values once, at compile time instead +of at run time. This can only be done for functions or objects which will not +be changed during program execution, such as replacing :: + + def degree_sin(deg): + return math.sin(deg * math.pi / 180.0) + +with :: + + def degree_sin(deg, factor=math.pi/180.0, sin=math.sin): + return sin(deg * factor) + +Because this trick uses default arguments for terms which should not be changed, +it should only be used when you are not concerned with presenting a possibly +confusing API to your users. + + +Core Language +============= + +How do you set a global variable in a function? +----------------------------------------------- + +Did you do something like this? :: + + x = 1 # make a global + + def f(): + print x # try to print the global + ... + for j in range(100): + if q > 3: + x = 4 + +Any variable assigned in a function is local to that function. unless it is +specifically declared global. Since a value is bound to ``x`` as the last +statement of the function body, the compiler assumes that ``x`` is +local. Consequently the ``print x`` attempts to print an uninitialized local +variable and will trigger a ``NameError``. + +The solution is to insert an explicit global declaration at the start of the +function:: + + def f(): + global x + print x # try to print the global + ... + for j in range(100): + if q > 3: + x = 4 + +In this case, all references to ``x`` are interpreted as references to the ``x`` +from the module namespace. + + +What are the rules for local and global variables in Python? +------------------------------------------------------------ + +In Python, variables that are only referenced inside a function are implicitly +global. If a variable is assigned a new value anywhere within the function's +body, it's assumed to be a local. If a variable is ever assigned a new value +inside the function, the variable is implicitly local, and you need to +explicitly declare it as 'global'. + +Though a bit surprising at first, a moment's consideration explains this. On +one hand, requiring :keyword:`global` for assigned variables provides a bar +against unintended side-effects. On the other hand, if ``global`` was required +for all global references, you'd be using ``global`` all the time. You'd have +to declare as global every reference to a builtin function or to a component of +an imported module. This clutter would defeat the usefulness of the ``global`` +declaration for identifying side-effects. + + +How do I share global variables across modules? +------------------------------------------------ + +The canonical way to share information across modules within a single program is +to create a special module (often called config or cfg). Just import the config +module in all modules of your application; the module then becomes available as +a global name. Because there is only one instance of each module, any changes +made to the module object get reflected everywhere. For example: + +config.py:: + + x = 0 # Default value of the 'x' configuration setting + +mod.py:: + + import config + config.x = 1 + +main.py:: + + import config + import mod + print config.x + +Note that using a module is also the basis for implementing the Singleton design +pattern, for the same reason. + + +What are the "best practices" for using import in a module? +----------------------------------------------------------- + +In general, don't use ``from modulename import *``. Doing so clutters the +importer's namespace. Some people avoid this idiom even with the few modules +that were designed to be imported in this manner. Modules designed in this +manner include :mod:`Tkinter`, and :mod:`threading`. + +Import modules at the top of a file. Doing so makes it clear what other modules +your code requires and avoids questions of whether the module name is in scope. +Using one import per line makes it easy to add and delete module imports, but +using multiple imports per line uses less screen space. + +It's good practice if you import modules in the following order: + +1. standard library modules -- e.g. ``sys``, ``os``, ``getopt``, ``re``) +2. third-party library modules (anything installed in Python's site-packages + directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc. +3. locally-developed modules + +Never use relative package imports. If you're writing code that's in the +``package.sub.m1`` module and want to import ``package.sub.m2``, do not just +write ``import m2``, even though it's legal. Write ``from package.sub import +m2`` instead. Relative imports can lead to a module being initialized twice, +leading to confusing bugs. + +It is sometimes necessary to move imports to a function or class to avoid +problems with circular imports. Gordon McMillan says: + + Circular imports are fine where both modules use the "import " form + of import. They fail when the 2nd module wants to grab a name out of the + first ("from module import name") and the import is at the top level. That's + because names in the 1st are not yet available, because the first module is + busy importing the 2nd. + +In this case, if the second module is only used in one function, then the import +can easily be moved into that function. By the time the import is called, the +first module will have finished initializing, and the second module can do its +import. + +It may also be necessary to move imports out of the top level of code if some of +the modules are platform-specific. In that case, it may not even be possible to +import all of the modules at the top of the file. In this case, importing the +correct modules in the corresponding platform-specific code is a good option. + +Only move imports into a local scope, such as inside a function definition, if +it's necessary to solve a problem such as avoiding a circular import or are +trying to reduce the initialization time of a module. This technique is +especially helpful if many of the imports are unnecessary depending on how the +program executes. You may also want to move imports into a function if the +modules are only ever used in that function. Note that loading a module the +first time may be expensive because of the one time initialization of the +module, but loading a module multiple times is virtually free, costing only a +couple of dictionary lookups. Even if the module name has gone out of scope, +the module is probably available in :data:`sys.modules`. + +If only instances of a specific class use a module, then it is reasonable to +import the module in the class's ``__init__`` method and then assign the module +to an instance variable so that the module is always available (via that +instance variable) during the life of the object. Note that to delay an import +until the class is instantiated, the import must be inside a method. Putting +the import inside the class but outside of any method still causes the import to +occur when the module is initialized. + + +How can I pass optional or keyword parameters from one function to another? +--------------------------------------------------------------------------- + +Collect the arguments using the ``*`` and ``**`` specifiers in the function's +parameter list; this gives you the positional arguments as a tuple and the +keyword arguments as a dictionary. You can then pass these arguments when +calling another function by using ``*`` and ``**``:: + + def f(x, *args, **kwargs): + ... + kwargs['width'] = '14.3c' + ... + g(x, *args, **kwargs) + +In the unlikely case that you care about Python versions older than 2.0, use +:func:`apply`:: + + def f(x, *args, **kwargs): + ... + kwargs['width'] = '14.3c' + ... + apply(g, (x,)+args, kwargs) + + +How do I write a function with output parameters (call by reference)? +--------------------------------------------------------------------- + +Remember that arguments are passed by assignment in Python. Since assignment +just creates references to objects, there's no alias between an argument name in +the caller and callee, and so no call-by-reference per se. You can achieve the +desired effect in a number of ways. + +1) By returning a tuple of the results:: + + def func2(a, b): + a = 'new-value' # a and b are local names + b = b + 1 # assigned to new objects + return a, b # return new values + + x, y = 'old-value', 99 + x, y = func2(x, y) + print x, y # output: new-value 100 + + This is almost always the clearest solution. + +2) By using global variables. This isn't thread-safe, and is not recommended. + +3) By passing a mutable (changeable in-place) object:: + + def func1(a): + a[0] = 'new-value' # 'a' references a mutable list + a[1] = a[1] + 1 # changes a shared object + + args = ['old-value', 99] + func1(args) + print args[0], args[1] # output: new-value 100 + +4) By passing in a dictionary that gets mutated:: + + def func3(args): + args['a'] = 'new-value' # args is a mutable dictionary + args['b'] = args['b'] + 1 # change it in-place + + args = {'a':' old-value', 'b': 99} + func3(args) + print args['a'], args['b'] + +5) Or bundle up values in a class instance:: + + class callByRef: + def __init__(self, **args): + for (key, value) in args.items(): + setattr(self, key, value) + + def func4(args): + args.a = 'new-value' # args is a mutable callByRef + args.b = args.b + 1 # change object in-place + + args = callByRef(a='old-value', b=99) + func4(args) + print args.a, args.b + + + There's almost never a good reason to get this complicated. + +Your best choice is to return a tuple containing the multiple results. + + +How do you make a higher order function in Python? +-------------------------------------------------- + +You have two choices: you can use nested scopes or you can use callable objects. +For example, suppose you wanted to define ``linear(a,b)`` which returns a +function ``f(x)`` that computes the value ``a*x+b``. Using nested scopes:: + + def linear(a, b): + def result(x): + return a * x + b + return result + +Or using a callable object:: + + class linear: + + def __init__(self, a, b): + self.a, self.b = a, b + + def __call__(self, x): + return self.a * x + self.b + +In both cases, :: + + taxes = linear(0.3, 2) + +gives a callable object where ``taxes(10e6) == 0.3 * 10e6 + 2``. + +The callable object approach has the disadvantage that it is a bit slower and +results in slightly longer code. However, note that a collection of callables +can share their signature via inheritance:: + + class exponential(linear): + # __init__ inherited + def __call__(self, x): + return self.a * (x ** self.b) + +Object can encapsulate state for several methods:: + + class counter: + + value = 0 + + def set(self, x): + self.value = x + + def up(self): + self.value = self.value + 1 + + def down(self): + self.value = self.value - 1 + + count = counter() + inc, dec, reset = count.up, count.down, count.set + +Here ``inc()``, ``dec()`` and ``reset()`` act like functions which share the +same counting variable. + + +How do I copy an object in Python? +---------------------------------- + +In general, try :func:`copy.copy` or :func:`copy.deepcopy` for the general case. +Not all objects can be copied, but most can. + +Some objects can be copied more easily. Dictionaries have a :meth:`~dict.copy` +method:: + + newdict = olddict.copy() + +Sequences can be copied by slicing:: + + new_l = l[:] + + +How can I find the methods or attributes of an object? +------------------------------------------------------ + +For an instance x of a user-defined class, ``dir(x)`` returns an alphabetized +list of the names containing the instance attributes and methods and attributes +defined by its class. + + +How can my code discover the name of an object? +----------------------------------------------- + +Generally speaking, it can't, because objects don't really have names. +Essentially, assignment always binds a name to a value; The same is true of +``def`` and ``class`` statements, but in that case the value is a +callable. Consider the following code:: + + class A: + pass + + B = A + + a = B() + b = a + print b + <__main__.A instance at 016D07CC> + print a + <__main__.A instance at 016D07CC> + +Arguably the class has a name: even though it is bound to two names and invoked +through the name B the created instance is still reported as an instance of +class A. However, it is impossible to say whether the instance's name is a or +b, since both names are bound to the same value. + +Generally speaking it should not be necessary for your code to "know the names" +of particular values. Unless you are deliberately writing introspective +programs, this is usually an indication that a change of approach might be +beneficial. + +In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to +this question: + + The same way as you get the name of that cat you found on your porch: the cat + (object) itself cannot tell you its name, and it doesn't really care -- so + the only way to find out what it's called is to ask all your neighbours + (namespaces) if it's their cat (object)... + + ....and don't be surprised if you'll find that it's known by many names, or + no name at all! + + +What's up with the comma operator's precedence? +----------------------------------------------- + +Comma is not an operator in Python. Consider this session:: + + >>> "a" in "b", "a" + (False, '1') + +Since the comma is not an operator, but a separator between expressions the +above is evaluated as if you had entered:: + + >>> ("a" in "b"), "a" + +not:: + + >>> "a" in ("5", "a") + +The same is true of the various assignment operators (``=``, ``+=`` etc). They +are not truly operators but syntactic delimiters in assignment statements. + + +Is there an equivalent of C's "?:" ternary operator? +---------------------------------------------------- + +Yes, this feature was added in Python 2.5. The syntax would be as follows:: + + [on_true] if [expression] else [on_false] + + x, y = 50, 25 + + small = x if x < y else y + +For versions previous to 2.5 the answer would be 'No'. + +.. XXX remove rest? + +In many cases you can mimic ``a ? b : c`` with ``a and b or c``, but there's a +flaw: if *b* is zero (or empty, or ``None`` -- anything that tests false) then +*c* will be selected instead. In many cases you can prove by looking at the +code that this can't happen (e.g. because *b* is a constant or has a type that +can never be false), but in general this can be a problem. + +Tim Peters (who wishes it was Steve Majewski) suggested the following solution: +``(a and [b] or [c])[0]``. Because ``[b]`` is a singleton list it is never +false, so the wrong path is never taken; then applying ``[0]`` to the whole +thing gets the *b* or *c* that you really wanted. Ugly, but it gets you there +in the rare cases where it is really inconvenient to rewrite your code using +'if'. + +The best course is usually to write a simple ``if...else`` statement. Another +solution is to implement the ``?:`` operator as a function:: + + def q(cond, on_true, on_false): + if cond: + if not isfunction(on_true): + return on_true + else: + return apply(on_true) + else: + if not isfunction(on_false): + return on_false + else: + return apply(on_false) + +In most cases you'll pass b and c directly: ``q(a, b, c)``. To avoid evaluating +b or c when they shouldn't be, encapsulate them within a lambda function, e.g.: +``q(a, lambda: b, lambda: c)``. + +It has been asked *why* Python has no if-then-else expression. There are +several answers: many languages do just fine without one; it can easily lead to +less readable code; no sufficiently "Pythonic" syntax has been discovered; a +search of the standard library found remarkably few places where using an +if-then-else expression would make the code more understandable. + +In 2002, :pep:`308` was written proposing several possible syntaxes and the +community was asked to vote on the issue. The vote was inconclusive. Most +people liked one of the syntaxes, but also hated other syntaxes; many votes +implied that people preferred no ternary operator rather than having a syntax +they hated. + + +Is it possible to write obfuscated one-liners in Python? +-------------------------------------------------------- + +Yes. Usually this is done by nesting :keyword:`lambda` within +:keyword:`lambda`. See the following three examples, due to Ulf Bartelt:: + + # Primes < 1000 + print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0, + map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000))) + + # First 10 Fibonacci numbers + print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f), + range(10)) + + # Mandelbrot set + print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y, + Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM, + Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro, + i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y + >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr( + 64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy + ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24) + # \___ ___/ \___ ___/ | | |__ lines on screen + # V V | |______ columns on screen + # | | |__________ maximum of "iterations" + # | |_________________ range on y axis + # |____________________________ range on x axis + +Don't try this at home, kids! + + +Numbers and strings +=================== + +How do I specify hexadecimal and octal integers? +------------------------------------------------ + +To specify an octal digit, precede the octal value with a zero. For example, to +set the variable "a" to the octal value "10" (8 in decimal), type:: + + >>> a = 010 + >>> a + 8 + +Hexadecimal is just as easy. Simply precede the hexadecimal number with a zero, +and then a lower or uppercase "x". Hexadecimal digits can be specified in lower +or uppercase. For example, in the Python interpreter:: + + >>> a = 0xa5 + >>> a + 165 + >>> b = 0XB2 + >>> b + 178 + + +Why does -22 / 10 return -3? +---------------------------- + +It's primarily driven by the desire that ``i % j`` have the same sign as ``j``. +If you want that, and also want:: + + i == (i / j) * j + (i % j) + +then integer division has to return the floor. C also requires that identity to +hold, and then compilers that truncate ``i / j`` need to make ``i % j`` have the +same sign as ``i``. + +There are few real use cases for ``i % j`` when ``j`` is negative. When ``j`` +is positive, there are many, and in virtually all of them it's more useful for +``i % j`` to be ``>= 0``. If the clock says 10 now, what did it say 200 hours +ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to +bite. + + +How do I convert a string to a number? +-------------------------------------- + +For integers, use the built-in :func:`int` type constructor, e.g. ``int('144') +== 144``. Similarly, :func:`float` converts to floating-point, +e.g. ``float('144') == 144.0``. + +By default, these interpret the number as decimal, so that ``int('0144') == +144`` and ``int('0x144')`` raises :exc:`ValueError`. ``int(string, base)`` takes +the base to convert from as a second optional argument, so ``int('0x144', 16) == +324``. If the base is specified as 0, the number is interpreted using Python's +rules: a leading '0' indicates octal, and '0x' indicates a hex number. + +Do not use the built-in function :func:`eval` if all you need is to convert +strings to numbers. :func:`eval` will be significantly slower and it presents a +security risk: someone could pass you a Python expression that might have +unwanted side effects. For example, someone could pass +``__import__('os').system("rm -rf $HOME")`` which would erase your home +directory. + +:func:`eval` also has the effect of interpreting numbers as Python expressions, +so that e.g. ``eval('09')`` gives a syntax error because Python regards numbers +starting with '0' as octal (base 8). + + +How do I convert a number to a string? +-------------------------------------- + +To convert, e.g., the number 144 to the string '144', use the built-in type +constructor :func:`str`. If you want a hexadecimal or octal representation, use +the built-in functions ``hex()`` or ``oct()``. For fancy formatting, use +:ref:`the % operator ` on strings, e.g. ``"%04d" % 144`` +yields ``'0144'`` and ``"%.3f" % (1/3.0)`` yields ``'0.333'``. See the library +reference manual for details. + + +How do I modify a string in place? +---------------------------------- + +You can't, because strings are immutable. If you need an object with this +ability, try converting the string to a list or use the array module:: + + >>> s = "Hello, world" + >>> a = list(s) + >>> print a + ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] + >>> a[7:] = list("there!") + >>> ''.join(a) + 'Hello, there!' + + >>> import array + >>> a = array.array('c', s) + >>> print a + array('c', 'Hello, world') + >>> a[0] = 'y' ; print a + array('c', 'yello world') + >>> a.tostring() + 'yello, world' + + +How do I use strings to call functions/methods? +----------------------------------------------- + +There are various techniques. + +* The best is to use a dictionary that maps strings to functions. The primary + advantage of this technique is that the strings do not need to match the names + of the functions. This is also the primary technique used to emulate a case + construct:: + + def a(): + pass + + def b(): + pass + + dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs + + dispatch[get_input()]() # Note trailing parens to call function + +* Use the built-in function :func:`getattr`:: + + import foo + getattr(foo, 'bar')() + + Note that :func:`getattr` works on any object, including classes, class + instances, modules, and so on. + + This is used in several places in the standard library, like this:: + + class Foo: + def do_foo(self): + ... + + def do_bar(self): + ... + + f = getattr(foo_instance, 'do_' + opname) + f() + + +* Use :func:`locals` or :func:`eval` to resolve the function name:: + + def myFunc(): + print "hello" + + fname = "myFunc" + + f = locals()[fname] + f() + + f = eval(fname) + f() + + Note: Using :func:`eval` is slow and dangerous. If you don't have absolute + control over the contents of the string, someone could pass a string that + resulted in an arbitrary function being executed. + +Is there an equivalent to Perl's chomp() for removing trailing newlines from strings? +------------------------------------------------------------------------------------- + +Starting with Python 2.2, you can use ``S.rstrip("\r\n")`` to remove all +occurences of any line terminator from the end of the string ``S`` without +removing other trailing whitespace. If the string ``S`` represents more than +one line, with several empty lines at the end, the line terminators for all the +blank lines will be removed:: + + >>> lines = ("line 1 \r\n" + ... "\r\n" + ... "\r\n") + >>> lines.rstrip("\n\r") + "line 1 " + +Since this is typically only desired when reading text one line at a time, using +``S.rstrip()`` this way works well. + +For older versions of Python, There are two partial substitutes: + +- If you want to remove all trailing whitespace, use the ``rstrip()`` method of + string objects. This removes all trailing whitespace, not just a single + newline. + +- Otherwise, if there is only one line in the string ``S``, use + ``S.splitlines()[0]``. + + +Is there a scanf() or sscanf() equivalent? +------------------------------------------ + +Not as such. + +For simple input parsing, the easiest approach is usually to split the line into +whitespace-delimited words using the :meth:`~str.split` method of string objects +and then convert decimal strings to numeric values using :func:`int` or +:func:`float`. ``split()`` supports an optional "sep" parameter which is useful +if the line uses something other than whitespace as a separator. + +For more complicated input parsing, regular expressions more powerful than C's +:cfunc:`sscanf` and better suited for the task. + + +What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean? +------------------------------------------------------------------------------------------ + +This error indicates that your Python installation can handle only 7-bit ASCII +strings. There are a couple ways to fix or work around the problem. + +If your programs must handle data in arbitrary character set encodings, the +environment the application runs in will generally identify the encoding of the +data it is handing you. You need to convert the input to Unicode data using +that encoding. For example, a program that handles email or web input will +typically find character set encoding information in Content-Type headers. This +can then be used to properly convert input data to Unicode. Assuming the string +referred to by ``value`` is encoded as UTF-8:: + + value = unicode(value, "utf-8") + +will return a Unicode object. If the data is not correctly encoded as UTF-8, +the above call will raise a :exc:`UnicodeError` exception. + +If you only want strings converted to Unicode which have non-ASCII data, you can +try converting them first assuming an ASCII encoding, and then generate Unicode +objects if that fails:: + + try: + x = unicode(value, "ascii") + except UnicodeError: + value = unicode(value, "utf-8") + else: + # value was valid ASCII data + pass + +It's possible to set a default encoding in a file called ``sitecustomize.py`` +that's part of the Python library. However, this isn't recommended because +changing the Python-wide default encoding may cause third-party extension +modules to fail. + +Note that on Windows, there is an encoding known as "mbcs", which uses an +encoding specific to your current locale. In many cases, and particularly when +working with COM, this may be an appropriate default encoding to use. + + +Sequences (Tuples/Lists) +======================== + +How do I convert between tuples and lists? +------------------------------------------ + +The type constructor ``tuple(seq)`` converts any sequence (actually, any +iterable) into a tuple with the same items in the same order. + +For example, ``tuple([1, 2, 3])`` yields ``(1, 2, 3)`` and ``tuple('abc')`` +yields ``('a', 'b', 'c')``. If the argument is a tuple, it does not make a copy +but returns the same object, so it is cheap to call :func:`tuple` when you +aren't sure that an object is already a tuple. + +The type constructor ``list(seq)`` converts any sequence or iterable into a list +with the same items in the same order. For example, ``list((1, 2, 3))`` yields +``[1, 2, 3]`` and ``list('abc')`` yields ``['a', 'b', 'c']``. If the argument +is a list, it makes a copy just like ``seq[:]`` would. + + +What's a negative index? +------------------------ + +Python sequences are indexed with positive numbers and negative numbers. For +positive numbers 0 is the first index 1 is the second index and so forth. For +negative indices -1 is the last index and -2 is the penultimate (next to last) +index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``. + +Using negative indices can be very convenient. For example ``S[:-1]`` is all of +the string except for its last character, which is useful for removing the +trailing newline from a string. + + +How do I iterate over a sequence in reverse order? +-------------------------------------------------- + +Use the :func:`reversed` builtin function, which is new in Python 2.4:: + + for x in reversed(sequence): + ... # do something with x... + +This won't touch your original sequence, but build a new copy with reversed +order to iterate over. + +With Python 2.3, you can use an extended slice syntax:: + + for x in sequence[::-1]: + ... # do something with x... + + +How do you remove duplicates from a list? +----------------------------------------- + +See the Python Cookbook for a long discussion of many ways to do this: + + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 + +If you don't mind reordering the list, sort it and then scan from the end of the +list, deleting duplicates as you go:: + + if List: + List.sort() + last = List[-1] + for i in range(len(List)-2, -1, -1): + if last == List[i]: + del List[i] + else: + last = List[i] + +If all elements of the list may be used as dictionary keys (i.e. they are all +hashable) this is often faster :: + + d = {} + for x in List: + d[x] = x + List = d.values() + +In Python 2.5 and later, the following is possible instead:: + + List = list(set(List)) + +This converts the list into a set, thereby removing duplicates, and then back +into a list. + + +How do you make an array in Python? +----------------------------------- + +Use a list:: + + ["this", 1, "is", "an", "array"] + +Lists are equivalent to C or Pascal arrays in their time complexity; the primary +difference is that a Python list can contain objects of many different types. + +The ``array`` module also provides methods for creating arrays of fixed types +with compact representations, but they are slower to index than lists. Also +note that the Numeric extensions and others define array-like structures with +various characteristics as well. + +To get Lisp-style linked lists, you can emulate cons cells using tuples:: + + lisp_list = ("like", ("this", ("example", None) ) ) + +If mutability is desired, you could use lists instead of tuples. Here the +analogue of lisp car is ``lisp_list[0]`` and the analogue of cdr is +``lisp_list[1]``. Only do this if you're sure you really need to, because it's +usually a lot slower than using Python lists. + + +How do I create a multidimensional list? +---------------------------------------- + +You probably tried to make a multidimensional array like this:: + + A = [[None] * 2] * 3 + +This looks correct if you print it:: + + >>> A + [[None, None], [None, None], [None, None]] + +But when you assign a value, it shows up in multiple places: + + >>> A[0][0] = 5 + >>> A + [[5, None], [5, None], [5, None]] + +The reason is that replicating a list with ``*`` doesn't create copies, it only +creates references to the existing objects. The ``*3`` creates a list +containing 3 references to the same list of length two. Changes to one row will +show in all rows, which is almost certainly not what you want. + +The suggested approach is to create a list of the desired length first and then +fill in each element with a newly created list:: + + A = [None] * 3 + for i in range(3): + A[i] = [None] * 2 + +This generates a list containing 3 different lists of length two. You can also +use a list comprehension:: + + w, h = 2, 3 + A = [[None] * w for i in range(h)] + +Or, you can use an extension that provides a matrix datatype; `Numeric Python +`_ is the best known. + + +How do I apply a method to a sequence of objects? +------------------------------------------------- + +Use a list comprehension:: + + result = [obj.method() for obj in List] + +More generically, you can try the following function:: + + def method_map(objects, method, arguments): + """method_map([a,b], "meth", (1,2)) gives [a.meth(1,2), b.meth(1,2)]""" + nobjects = len(objects) + methods = map(getattr, objects, [method]*nobjects) + return map(apply, methods, [arguments]*nobjects) + + +Dictionaries +============ + +How can I get a dictionary to display its keys in a consistent order? +--------------------------------------------------------------------- + +You can't. Dictionaries store their keys in an unpredictable order, so the +display order of a dictionary's elements will be similarly unpredictable. + +This can be frustrating if you want to save a printable version to a file, make +some changes and then compare it with some other printed dictionary. In this +case, use the ``pprint`` module to pretty-print the dictionary; the items will +be presented in order sorted by the key. + +A more complicated solution is to subclass ``UserDict.UserDict`` to create a +``SortedDict`` class that prints itself in a predictable order. Here's one +simpleminded implementation of such a class:: + + import UserDict, string + + class SortedDict(UserDict.UserDict): + def __repr__(self): + result = [] + append = result.append + keys = self.data.keys() + keys.sort() + for k in keys: + append("%s: %s" % (`k`, `self.data[k]`)) + return "{%s}" % string.join(result, ", ") + + __str__ = __repr__ + +This will work for many common situations you might encounter, though it's far +from a perfect solution. The largest flaw is that if some values in the +dictionary are also dictionaries, their values won't be presented in any +particular order. + + +I want to do a complicated sort: can you do a Schwartzian Transform in Python? +------------------------------------------------------------------------------ + +The technique, attributed to Randal Schwartz of the Perl community, sorts the +elements of a list by a metric which maps each element to its "sort value". In +Python, just use the ``key`` argument for the ``sort()`` method:: + + Isorted = L[:] + Isorted.sort(key=lambda s: int(s[10:15])) + +The ``key`` argument is new in Python 2.4, for older versions this kind of +sorting is quite simple to do with list comprehensions. To sort a list of +strings by their uppercase values:: + + tmp1 = [(x.upper(), x) for x in L] # Schwartzian transform + tmp1.sort() + Usorted = [x[1] for x in tmp1] + +To sort by the integer value of a subfield extending from positions 10-15 in +each string:: + + tmp2 = [(int(s[10:15]), s) for s in L] # Schwartzian transform + tmp2.sort() + Isorted = [x[1] for x in tmp2] + +Note that Isorted may also be computed by :: + + def intfield(s): + return int(s[10:15]) + + def Icmp(s1, s2): + return cmp(intfield(s1), intfield(s2)) + + Isorted = L[:] + Isorted.sort(Icmp) + +but since this method calls ``intfield()`` many times for each element of L, it +is slower than the Schwartzian Transform. + + +How can I sort one list by values from another list? +---------------------------------------------------- + +Merge them into a single list of tuples, sort the resulting list, and then pick +out the element you want. :: + + >>> list1 = ["what", "I'm", "sorting", "by"] + >>> list2 = ["something", "else", "to", "sort"] + >>> pairs = zip(list1, list2) + >>> pairs + [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')] + >>> pairs.sort() + >>> result = [ x[1] for x in pairs ] + >>> result + ['else', 'sort', 'to', 'something'] + +An alternative for the last step is:: + + result = [] + for p in pairs: result.append(p[1]) + +If you find this more legible, you might prefer to use this instead of the final +list comprehension. However, it is almost twice as slow for long lists. Why? +First, the ``append()`` operation has to reallocate memory, and while it uses +some tricks to avoid doing that each time, it still has to do it occasionally, +and that costs quite a bit. Second, the expression "result.append" requires an +extra attribute lookup, and third, there's a speed reduction from having to make +all those function calls. + + +Objects +======= + +What is a class? +---------------- + +A class is the particular object type created by executing a class statement. +Class objects are used as templates to create instance objects, which embody +both the data (attributes) and code (methods) specific to a datatype. + +A class can be based on one or more other classes, called its base class(es). It +then inherits the attributes and methods of its base classes. This allows an +object model to be successively refined by inheritance. You might have a +generic ``Mailbox`` class that provides basic accessor methods for a mailbox, +and subclasses such as ``MboxMailbox``, ``MaildirMailbox``, ``OutlookMailbox`` +that handle various specific mailbox formats. + + +What is a method? +----------------- + +A method is a function on some object ``x`` that you normally call as +``x.name(arguments...)``. Methods are defined as functions inside the class +definition:: + + class C: + def meth (self, arg): + return arg * 2 + self.attribute + + +What is self? +------------- + +Self is merely a conventional name for the first argument of a method. A method +defined as ``meth(self, a, b, c)`` should be called as ``x.meth(a, b, c)`` for +some instance ``x`` of the class in which the definition occurs; the called +method will think it is called as ``meth(x, a, b, c)``. + +See also :ref:`why-self`. + + +How do I check if an object is an instance of a given class or of a subclass of it? +----------------------------------------------------------------------------------- + +Use the built-in function ``isinstance(obj, cls)``. You can check if an object +is an instance of any of a number of classes by providing a tuple instead of a +single class, e.g. ``isinstance(obj, (class1, class2, ...))``, and can also +check whether an object is one of Python's built-in types, e.g. +``isinstance(obj, str)`` or ``isinstance(obj, (int, long, float, complex))``. + +Note that most programs do not use :func:`isinstance` on user-defined classes +very often. If you are developing the classes yourself, a more proper +object-oriented style is to define methods on the classes that encapsulate a +particular behaviour, instead of checking the object's class and doing a +different thing based on what class it is. For example, if you have a function +that does something:: + + def search (obj): + if isinstance(obj, Mailbox): + # ... code to search a mailbox + elif isinstance(obj, Document): + # ... code to search a document + elif ... + +A better approach is to define a ``search()`` method on all the classes and just +call it:: + + class Mailbox: + def search(self): + # ... code to search a mailbox + + class Document: + def search(self): + # ... code to search a document + + obj.search() + + +What is delegation? +------------------- + +Delegation is an object oriented technique (also called a design pattern). +Let's say you have an object ``x`` and want to change the behaviour of just one +of its methods. You can create a new class that provides a new implementation +of the method you're interested in changing and delegates all other methods to +the corresponding method of ``x``. + +Python programmers can easily implement delegation. For example, the following +class implements a class that behaves like a file but converts all written data +to uppercase:: + + class UpperOut: + + def __init__(self, outfile): + self._outfile = outfile + + def write(self, s): + self._outfile.write(s.upper()) + + def __getattr__(self, name): + return getattr(self._outfile, name) + +Here the ``UpperOut`` class redefines the ``write()`` method to convert the +argument string to uppercase before calling the underlying +``self.__outfile.write()`` method. All other methods are delegated to the +underlying ``self.__outfile`` object. The delegation is accomplished via the +``__getattr__`` method; consult :ref:`the language reference ` +for more information about controlling attribute access. + +Note that for more general cases delegation can get trickier. When attributes +must be set as well as retrieved, the class must define a :meth:`__setattr__` +method too, and it must do so carefully. The basic implementation of +:meth:`__setattr__` is roughly equivalent to the following:: + + class X: + ... + def __setattr__(self, name, value): + self.__dict__[name] = value + ... + +Most :meth:`__setattr__` implementations must modify ``self.__dict__`` to store +local state for self without causing an infinite recursion. + + +How do I call a method defined in a base class from a derived class that overrides it? +-------------------------------------------------------------------------------------- + +If you're using new-style classes, use the built-in :func:`super` function:: + + class Derived(Base): + def meth (self): + super(Derived, self).meth() + +If you're using classic classes: For a class definition such as ``class +Derived(Base): ...`` you can call method ``meth()`` defined in ``Base`` (or one +of ``Base``'s base classes) as ``Base.meth(self, arguments...)``. Here, +``Base.meth`` is an unbound method, so you need to provide the ``self`` +argument. + + +How can I organize my code to make it easier to change the base class? +---------------------------------------------------------------------- + +You could define an alias for the base class, assign the real base class to it +before your class definition, and use the alias throughout your class. Then all +you have to change is the value assigned to the alias. Incidentally, this trick +is also handy if you want to decide dynamically (e.g. depending on availability +of resources) which base class to use. Example:: + + BaseAlias = + + class Derived(BaseAlias): + def meth(self): + BaseAlias.meth(self) + ... + + +How do I create static class data and static class methods? +----------------------------------------------------------- + +Static data (in the sense of C++ or Java) is easy; static methods (again in the +sense of C++ or Java) are not supported directly. + +For static data, simply define a class attribute. To assign a new value to the +attribute, you have to explicitly use the class name in the assignment:: + + class C: + count = 0 # number of times C.__init__ called + + def __init__(self): + C.count = C.count + 1 + + def getcount(self): + return C.count # or return self.count + +``c.count`` also refers to ``C.count`` for any ``c`` such that ``isinstance(c, +C)`` holds, unless overridden by ``c`` itself or by some class on the base-class +search path from ``c.__class__`` back to ``C``. + +Caution: within a method of C, an assignment like ``self.count = 42`` creates a +new and unrelated instance vrbl named "count" in ``self``'s own dict. Rebinding +of a class-static data name must always specify the class whether inside a +method or not:: + + C.count = 314 + +Static methods are possible since Python 2.2:: + + class C: + def static(arg1, arg2, arg3): + # No 'self' parameter! + ... + static = staticmethod(static) + +With Python 2.4's decorators, this can also be written as :: + + class C: + @staticmethod + def static(arg1, arg2, arg3): + # No 'self' parameter! + ... + +However, a far more straightforward way to get the effect of a static method is +via a simple module-level function:: + + def getcount(): + return C.count + +If your code is structured so as to define one class (or tightly related class +hierarchy) per module, this supplies the desired encapsulation. + + +How can I overload constructors (or methods) in Python? +------------------------------------------------------- + +This answer actually applies to all methods, but the question usually comes up +first in the context of constructors. + +In C++ you'd write + +.. code-block:: c + + class C { + C() { cout << "No arguments\n"; } + C(int i) { cout << "Argument is " << i << "\n"; } + } + +In Python you have to write a single constructor that catches all cases using +default arguments. For example:: + + class C: + def __init__(self, i=None): + if i is None: + print "No arguments" + else: + print "Argument is", i + +This is not entirely equivalent, but close enough in practice. + +You could also try a variable-length argument list, e.g. :: + + def __init__(self, *args): + ... + +The same approach works for all method definitions. + + +I try to use __spam and I get an error about _SomeClassName__spam. +------------------------------------------------------------------ + +Variable names with double leading underscores are "mangled" to provide a simple +but effective way to define class private variables. Any identifier of the form +``__spam`` (at least two leading underscores, at most one trailing underscore) +is textually replaced with ``_classname__spam``, where ``classname`` is the +current class name with any leading underscores stripped. + +This doesn't guarantee privacy: an outside user can still deliberately access +the "_classname__spam" attribute, and private values are visible in the object's +``__dict__``. Many Python programmers never bother to use private variable +names at all. + + +My class defines __del__ but it is not called when I delete the object. +----------------------------------------------------------------------- + +There are several possible reasons for this. + +The del statement does not necessarily call :meth:`__del__` -- it simply +decrements the object's reference count, and if this reaches zero +:meth:`__del__` is called. + +If your data structures contain circular links (e.g. a tree where each child has +a parent reference and each parent has a list of children) the reference counts +will never go back to zero. Once in a while Python runs an algorithm to detect +such cycles, but the garbage collector might run some time after the last +reference to your data structure vanishes, so your :meth:`__del__` method may be +called at an inconvenient and random time. This is inconvenient if you're trying +to reproduce a problem. Worse, the order in which object's :meth:`__del__` +methods are executed is arbitrary. You can run :func:`gc.collect` to force a +collection, but there *are* pathological cases where objects will never be +collected. + +Despite the cycle collector, it's still a good idea to define an explicit +``close()`` method on objects to be called whenever you're done with them. The +``close()`` method can then remove attributes that refer to subobjecs. Don't +call :meth:`__del__` directly -- :meth:`__del__` should call ``close()`` and +``close()`` should make sure that it can be called more than once for the same +object. + +Another way to avoid cyclical references is to use the :mod:`weakref` module, +which allows you to point to objects without incrementing their reference count. +Tree data structures, for instance, should use weak references for their parent +and sibling references (if they need them!). + +If the object has ever been a local variable in a function that caught an +expression in an except clause, chances are that a reference to the object still +exists in that function's stack frame as contained in the stack trace. +Normally, calling :func:`sys.exc_clear` will take care of this by clearing the +last recorded exception. + +Finally, if your :meth:`__del__` method raises an exception, a warning message +is printed to :data:`sys.stderr`. + + +How do I get a list of all instances of a given class? +------------------------------------------------------ + +Python does not keep track of all instances of a class (or of a built-in type). +You can program the class's constructor to keep track of all instances by +keeping a list of weak references to each instance. + + +Modules +======= + +How do I create a .pyc file? +---------------------------- + +When a module is imported for the first time (or when the source is more recent +than the current compiled file) a ``.pyc`` file containing the compiled code +should be created in the same directory as the ``.py`` file. + +One reason that a ``.pyc`` file may not be created is permissions problems with +the directory. This can happen, for example, if you develop as one user but run +as another, such as if you are testing with a web server. Creation of a .pyc +file is automatic if you're importing a module and Python has the ability +(permissions, free space, etc...) to write the compiled module back to the +directory. + +Running Python on a top level script is not considered an import and no ``.pyc`` +will be created. For example, if you have a top-level module ``abc.py`` that +imports another module ``xyz.py``, when you run abc, ``xyz.pyc`` will be created +since xyz is imported, but no ``abc.pyc`` file will be created since ``abc.py`` +isn't being imported. + +If you need to create abc.pyc -- that is, to create a .pyc file for a module +that is not imported -- you can, using the :mod:`py_compile` and +:mod:`compileall` modules. + +The :mod:`py_compile` module can manually compile any module. One way is to use +the ``compile()`` function in that module interactively:: + + >>> import py_compile + >>> py_compile.compile('abc.py') + +This will write the ``.pyc`` to the same location as ``abc.py`` (or you can +override that with the optional parameter ``cfile``). + +You can also automatically compile all files in a directory or directories using +the :mod:`compileall` module. You can do it from the shell prompt by running +``compileall.py`` and providing the path of a directory containing Python files +to compile:: + + python -m compileall . + + +How do I find the current module name? +-------------------------------------- + +A module can find out its own module name by looking at the predefined global +variable ``__name__``. If this has the value ``'__main__'``, the program is +running as a script. Many modules that are usually used by importing them also +provide a command-line interface or a self-test, and only execute this code +after checking ``__name__``:: + + def main(): + print 'Running test...' + ... + + if __name__ == '__main__': + main() + + +How can I have modules that mutually import each other? +------------------------------------------------------- + +Suppose you have the following modules: + +foo.py:: + + from bar import bar_var + foo_var = 1 + +bar.py:: + + from foo import foo_var + bar_var = 2 + +The problem is that the interpreter will perform the following steps: + +* main imports foo +* Empty globals for foo are created +* foo is compiled and starts executing +* foo imports bar +* Empty globals for bar are created +* bar is compiled and starts executing +* bar imports foo (which is a no-op since there already is a module named foo) +* bar.foo_var = foo.foo_var + +The last step fails, because Python isn't done with interpreting ``foo`` yet and +the global symbol dictionary for ``foo`` is still empty. + +The same thing happens when you use ``import foo``, and then try to access +``foo.foo_var`` in global code. + +There are (at least) three possible workarounds for this problem. + +Guido van Rossum recommends avoiding all uses of ``from import ...``, +and placing all code inside functions. Initializations of global variables and +class variables should use constants or built-in functions only. This means +everything from an imported module is referenced as ``.``. + +Jim Roskind suggests performing steps in the following order in each module: + +* exports (globals, functions, and classes that don't need imported base + classes) +* ``import`` statements +* active code (including globals that are initialized from imported values). + +van Rossum doesn't like this approach much because the imports appear in a +strange place, but it does work. + +Matthias Urlichs recommends restructuring your code so that the recursive import +is not necessary in the first place. + +These solutions are not mutually exclusive. + + +__import__('x.y.z') returns ; how do I get z? +--------------------------------------------------------- + +Try:: + + __import__('x.y.z').y.z + +For more realistic situations, you may have to do something like :: + + m = __import__(s) + for i in s.split(".")[1:]: + m = getattr(m, i) + +See :mod:`importlib` for a convenience function called +:func:`~importlib.import_module`. + + + +When I edit an imported module and reimport it, the changes don't show up. Why does this happen? +------------------------------------------------------------------------------------------------- + +For reasons of efficiency as well as consistency, Python only reads the module +file on the first time a module is imported. If it didn't, in a program +consisting of many modules where each one imports the same basic module, the +basic module would be parsed and re-parsed many times. To force rereading of a +changed module, do this:: + + import modname + reload(modname) + +Warning: this technique is not 100% fool-proof. In particular, modules +containing statements like :: + + from modname import some_objects + +will continue to work with the old version of the imported objects. If the +module contains class definitions, existing class instances will *not* be +updated to use the new class definition. This can result in the following +paradoxical behaviour: + + >>> import cls + >>> c = cls.C() # Create an instance of C + >>> reload(cls) + + >>> isinstance(c, cls.C) # isinstance is false?!? + False + +The nature of the problem is made clear if you print out the class objects: + + >>> c.__class__ + + >>> cls.C + + Added: python/trunk/Doc/faq/python-video-icon.png ============================================================================== Binary file. No diff available. Added: python/trunk/Doc/faq/windows.rst ============================================================================== --- (empty file) +++ python/trunk/Doc/faq/windows.rst Sun Oct 11 20:31:23 2009 @@ -0,0 +1,607 @@ +:tocdepth: 2 + +.. _windows-faq: + +===================== +Python on Windows FAQ +===================== + +.. contents:: + +How do I run a Python program under Windows? +-------------------------------------------- + +This is not necessarily a straightforward question. If you are already familiar +with running programs from the Windows command line then everything will seem +obvious; otherwise, you might need a little more guidance. There are also +differences between Windows 95, 98, NT, ME, 2000 and XP which can add to the +confusion. + +.. sidebar:: |Python Development on XP|_ + :subtitle: `Python Development on XP`_ + + This series of screencasts aims to get you up and running with Python on + Windows XP. The knowledge is distilled into 1.5 hours and will get you up + and running with the right Python distribution, coding in your choice of IDE, + and debugging and writing solid code with unit-tests. + +.. |Python Development on XP| image:: python-video-icon.png +.. _`Python Development on XP`: + http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries + +Unless you use some sort of integrated development environment, you will end up +*typing* Windows commands into what is variously referred to as a "DOS window" +or "Command prompt window". Usually you can create such a window from your +Start menu; under Windows 2000 the menu selection is :menuselection:`Start --> +Programs --> Accessories --> Command Prompt`. You should be able to recognize +when you have started such a window because you will see a Windows "command +prompt", which usually looks like this:: + + C:\> + +The letter may be different, and there might be other things after it, so you +might just as easily see something like:: + + D:\Steve\Projects\Python> + +depending on how your computer has been set up and what else you have recently +done with it. Once you have started such a window, you are well on the way to +running Python programs. + +You need to realize that your Python scripts have to be processed by another +program called the Python interpreter. The interpreter reads your script, +compiles it into bytecodes, and then executes the bytecodes to run your +program. So, how do you arrange for the interpreter to handle your Python? + +First, you need to make sure that your command window recognises the word +"python" as an instruction to start the interpreter. If you have opened a +command window, you should try entering the command ``python`` and hitting +return. You should then see something like:: + + Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 + Type "help", "copyright", "credits" or "license" for more information. + >>> + +You have started the interpreter in "interactive mode". That means you can enter +Python statements or expressions interactively and have them executed or +evaluated while you wait. This is one of Python's strongest features. Check it +by entering a few expressions of your choice and seeing the results:: + + >>> print "Hello" + Hello + >>> "Hello" * 3 + HelloHelloHello + +Many people use the interactive mode as a convenient yet highly programmable +calculator. When you want to end your interactive Python session, hold the Ctrl +key down while you enter a Z, then hit the "Enter" key to get back to your +Windows command prompt. + +You may also find that you have a Start-menu entry such as :menuselection:`Start +--> Programs --> Python 2.2 --> Python (command line)` that results in you +seeing the ``>>>`` prompt in a new window. If so, the window will disappear +after you enter the Ctrl-Z character; Windows is running a single "python" +command in the window, and closes it when you terminate the interpreter. + +If the ``python`` command, instead of displaying the interpreter prompt ``>>>``, +gives you a message like:: + + 'python' is not recognized as an internal or external command, + operable program or batch file. + +.. sidebar:: |Adding Python to DOS Path|_ + :subtitle: `Adding Python to DOS Path`_ + + Python is not added to the DOS path by default. This screencast will walk + you through the steps to add the correct entry to the `System Path`, allowing + Python to be executed from the command-line by all users. + +.. |Adding Python to DOS Path| image:: python-video-icon.png +.. _`Adding Python to DOS Path`: + http://showmedo.com/videos/video?name=960000&fromSeriesID=96 + + +or:: + + Bad command or filename + +then you need to make sure that your computer knows where to find the Python +interpreter. To do this you will have to modify a setting called PATH, which is +a list of directories where Windows will look for programs. + +You should arrange for Python's installation directory to be added to the PATH +of every command window as it starts. If you installed Python fairly recently +then the command :: + + dir C:\py* + +will probably tell you where it is installed; the usual location is something +like ``C:\Python23``. Otherwise you will be reduced to a search of your whole +disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` +button and look for "python.exe". Supposing you discover that Python is +installed in the ``C:\Python23`` directory (the default at the time of writing), +you should make sure that entering the command :: + + c:\Python23\python + +starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and +an "Enter" to get out of it). Once you have verified the directory, you need to +add it to the start-up routines your computer goes through. For older versions +of Windows the easiest way to do this is to edit the ``C:\AUTOEXEC.BAT`` +file. You would want to add a line like the following to ``AUTOEXEC.BAT``:: + + PATH C:\Python23;%PATH% + +For Windows NT, 2000 and (I assume) XP, you will need to add a string such as :: + + ;C:\Python23 + +to the current setting for the PATH environment variable, which you will find in +the properties window of "My Computer" under the "Advanced" tab. Note that if +you have sufficient privilege you might get a choice of installing the settings +either for the Current User or for System. The latter is preferred if you want +everybody to be able to run Python on the machine. + +If you aren't confident doing any of these manipulations yourself, ask for help! +At this stage you may want to reboot your system to make absolutely sure the new +setting has taken effect. You probably won't need to reboot for Windows NT, XP +or 2000. You can also avoid it in earlier versions by editing the file +``C:\WINDOWS\COMMAND\CMDINIT.BAT`` instead of ``AUTOEXEC.BAT``. + +You should now be able to start a new command window, enter ``python`` at the +``C:\>`` (or whatever) prompt, and see the ``>>>`` prompt that indicates the +Python interpreter is reading interactive commands. + +Let's suppose you have a program called ``pytest.py`` in directory +``C:\Steve\Projects\Python``. A session to run that program might look like +this:: + + C:\> cd \Steve\Projects\Python + C:\Steve\Projects\Python> python pytest.py + +Because you added a file name to the command to start the interpreter, when it +starts up it reads the Python script in the named file, compiles it, executes +it, and terminates, so you see another ``C:\>`` prompt. You might also have +entered :: + + C:\> python \Steve\Projects\Python\pytest.py + +if you hadn't wanted to change your current directory. + +Under NT, 2000 and XP you may well find that the installation process has also +arranged that the command ``pytest.py`` (or, if the file isn't in the current +directory, ``C:\Steve\Projects\Python\pytest.py``) will automatically recognize +the ".py" extension and run the Python interpreter on the named file. Using this +feature is fine, but *some* versions of Windows have bugs which mean that this +form isn't exactly equivalent to using the interpreter explicitly, so be +careful. + +The important things to remember are: + +1. Start Python from the Start Menu, or make sure the PATH is set correctly so + Windows can find the Python interpreter. :: + + python + + should give you a '>>>' prompt from the Python interpreter. Don't forget the + CTRL-Z and ENTER to terminate the interpreter (and, if you started the window + from the Start Menu, make the window disappear). + +2. Once this works, you run programs with commands:: + + python {program-file} + +3. When you know the commands to use you can build Windows shortcuts to run the + Python interpreter on any of your scripts, naming particular working + directories, and adding them to your menus. Take a look at :: + + python --help + + if your needs are complex. + +4. Interactive mode (where you see the ``>>>`` prompt) is best used for checking + that individual statements and expressions do what you think they will, and + for developing code by experiment. + + +How do I make python scripts executable? +---------------------------------------- + +On Windows 2000, the standard Python installer already associates the .py +extension with a file type (Python.File) and gives that file type an open +command that runs the interpreter (``D:\Program Files\Python\python.exe "%1" +%*``). This is enough to make scripts executable from the command prompt as +'foo.py'. If you'd rather be able to execute the script by simple typing 'foo' +with no extension you need to add .py to the PATHEXT environment variable. + +On Windows NT, the steps taken by the installer as described above allow you to +run a script with 'foo.py', but a longtime bug in the NT command processor +prevents you from redirecting the input or output of any script executed in this +way. This is often important. + +The incantation for making a Python script executable under WinNT is to give the +file an extension of .cmd and add the following as the first line:: + + @setlocal enableextensions & python -x %~f0 %* & goto :EOF + + +Why does Python sometimes take so long to start? +------------------------------------------------ + +Usually Python starts very quickly on Windows, but occasionally there are bug +reports that Python suddenly begins to take a long time to start up. This is +made even more puzzling because Python will work fine on other Windows systems +which appear to be configured identically. + +The problem may be caused by a misconfiguration of virus checking software on +the problem machine. Some virus scanners have been known to introduce startup +overhead of two orders of magnitude when the scanner is configured to monitor +all reads from the filesystem. Try checking the configuration of virus scanning +software on your systems to ensure that they are indeed configured identically. +McAfee, when configured to scan all file system read activity, is a particular +offender. + + +Where is Freeze for Windows? +---------------------------- + +"Freeze" is a program that allows you to ship a Python program as a single +stand-alone executable file. It is *not* a compiler; your programs don't run +any faster, but they are more easily distributable, at least to platforms with +the same OS and CPU. Read the README file of the freeze program for more +disclaimers. + +You can use freeze on Windows, but you must download the source tree (see +http://www.python.org/download/source). The freeze program is in the +``Tools\freeze`` subdirectory of the source tree. + +You need the Microsoft VC++ compiler, and you probably need to build Python. +The required project files are in the PCbuild directory. + + +Is a ``*.pyd`` file the same as a DLL? +-------------------------------------- + +.. XXX update for py3k (PyInit_foo) + +Yes, .pyd files are dll's, but there are a few differences. If you have a DLL +named ``foo.pyd``, then it must have a function ``initfoo()``. You can then +write Python "import foo", and Python will search for foo.pyd (as well as +foo.py, foo.pyc) and if it finds it, will attempt to call ``initfoo()`` to +initialize it. You do not link your .exe with foo.lib, as that would cause +Windows to require the DLL to be present. + +Note that the search path for foo.pyd is PYTHONPATH, not the same as the path +that Windows uses to search for foo.dll. Also, foo.pyd need not be present to +run your program, whereas if you linked your program with a dll, the dll is +required. Of course, foo.pyd is required if you want to say ``import foo``. In +a DLL, linkage is declared in the source code with ``__declspec(dllexport)``. +In a .pyd, linkage is defined in a list of available functions. + + +How can I embed Python into a Windows application? +-------------------------------------------------- + +Embedding the Python interpreter in a Windows app can be summarized as follows: + +1. Do _not_ build Python into your .exe file directly. On Windows, Python must + be a DLL to handle importing modules that are themselves DLL's. (This is the + first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is + typically installed in ``C:\Windows\System``. NN is the Python version, a + number such as "23" for Python 2.3. + + You can link to Python statically or dynamically. Linking statically means + linking against :file:`python{NN}.lib`, while dynamically linking means + linking against :file:`python{NN}.dll`. The drawback to dynamic linking is + that your app won't run if :file:`python{NN}.dll` does not exist on your + system. (General note: :file:`python{NN}.lib` is the so-called "import lib" + corresponding to :file:`python.dll`. It merely defines symbols for the + linker.) + + Linking dynamically greatly simplifies link options; everything happens at + run time. Your code must load :file:`python{NN}.dll` using the Windows + ``LoadLibraryEx()`` routine. The code must also use access routines and data + in :file:`python{NN}.dll` (that is, Python's C API's) using pointers obtained + by the Windows ``GetProcAddress()`` routine. Macros can make using these + pointers transparent to any C code that calls routines in Python's C API. + + Borland note: convert :file:`python{NN}.lib` to OMF format using Coff2Omf.exe + first. + +2. If you use SWIG, it is easy to create a Python "extension module" that will + make the app's data and methods available to Python. SWIG will handle just + about all the grungy details for you. The result is C code that you link + *into* your .exe file (!) You do _not_ have to create a DLL file, and this + also simplifies linking. + +3. SWIG will create an init function (a C function) whose name depends on the + name of the extension module. For example, if the name of the module is leo, + the init function will be called initleo(). If you use SWIG shadow classes, + as you should, the init function will be called initleoc(). This initializes + a mostly hidden helper class used by the shadow class. + + The reason you can link the C code in step 2 into your .exe file is that + calling the initialization function is equivalent to importing the module + into Python! (This is the second key undocumented fact.) + +4. In short, you can use the following code to initialize the Python interpreter + with your extension module. + + .. code-block:: c + + #include "python.h" + ... + Py_Initialize(); // Initialize Python. + initmyAppc(); // Initialize (import) the helper class. + PyRun_SimpleString("import myApp") ; // Import the shadow class. + +5. There are two problems with Python's C API which will become apparent if you + use a compiler other than MSVC, the compiler used to build pythonNN.dll. + + Problem 1: The so-called "Very High Level" functions that take FILE * + arguments will not work in a multi-compiler environment because each + compiler's notion of a struct FILE will be different. From an implementation + standpoint these are very _low_ level functions. + + Problem 2: SWIG generates the following code when generating wrappers to void + functions: + + .. code-block:: c + + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; + + Alas, Py_None is a macro that expands to a reference to a complex data + structure called _Py_NoneStruct inside pythonNN.dll. Again, this code will + fail in a mult-compiler environment. Replace such code by: + + .. code-block:: c + + return Py_BuildValue(""); + + It may be possible to use SWIG's ``%typemap`` command to make the change + automatically, though I have not been able to get this to work (I'm a + complete SWIG newbie). + +6. Using a Python shell script to put up a Python interpreter window from inside + your Windows app is not a good idea; the resulting window will be independent + of your app's windowing system. Rather, you (or the wxPythonWindow class) + should create a "native" interpreter window. It is easy to connect that + window to the Python interpreter. You can redirect Python's i/o to _any_ + object that supports read and write, so all you need is a Python object + (defined in your extension module) that contains read() and write() methods. + + +How do I use Python for CGI? +---------------------------- + +On the Microsoft IIS server or on the Win95 MS Personal Web Server you set up +Python in the same way that you would set up any other scripting engine. + +Run regedt32 and go to:: + + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap + +and enter the following line (making any specific changes that your system may +need):: + + .py :REG_SZ: c:\\python.exe -u %s %s + +This line will allow you to call your script with a simple reference like: +http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" +directory for your server (which it usually is by default). The "-u" flag +specifies unbuffered and binary mode for stdin - needed when working with binary +data. + +In addition, it is recommended that using ".py" may not be a good idea for the +file extensions when used in this context (you might want to reserve ``*.py`` +for support modules and use ``*.cgi`` or ``*.cgp`` for "main program" scripts). + +In order to set up Internet Information Services 5 to use Python for CGI +processing, please see the following links: + + http://www.e-coli.net/pyiis_server.html (for Win2k Server) + http://www.e-coli.net/pyiis.html (for Win2k pro) + +Configuring Apache is much simpler. In the Apache configuration file +``httpd.conf``, add the following line at the end of the file:: + + ScriptInterpreterSource Registry + +Then, give your Python CGI-scripts the extension .py and put them in the cgi-bin +directory. + + +How do I keep editors from inserting tabs into my Python source? +---------------------------------------------------------------- + +The FAQ does not recommend using tabs, and the Python style guide, :pep:`8`, +recommends 4 spaces for distributed Python code; this is also the Emacs +python-mode default. + +Under any editor, mixing tabs and spaces is a bad idea. MSVC is no different in +this respect, and is easily configured to use spaces: Take :menuselection:`Tools +--> Options --> Tabs`, and for file type "Default" set "Tab size" and "Indent +size" to 4, and select the "Insert spaces" radio button. + +If you suspect mixed tabs and spaces are causing problems in leading whitespace, +run Python with the :option:`-t` switch or run ``Tools/Scripts/tabnanny.py`` to +check a directory tree in batch mode. + + +How do I check for a keypress without blocking? +----------------------------------------------- + +Use the msvcrt module. This is a standard Windows-specific extension module. +It defines a function ``kbhit()`` which checks whether a keyboard hit is +present, and ``getch()`` which gets one character without echoing it. + + +How do I emulate os.kill() in Windows? +-------------------------------------- + +Use win32api:: + + def kill(pid): + """kill function for Win32""" + import win32api + handle = win32api.OpenProcess(1, 0, pid) + return (0 != win32api.TerminateProcess(handle, 0)) + + +Why does os.path.isdir() fail on NT shared directories? +------------------------------------------------------- + +The solution appears to be always append the "\\" on the end of shared +drives. + + >>> import os + >>> os.path.isdir( '\\\\rorschach\\public') + 0 + >>> os.path.isdir( '\\\\rorschach\\public\\') + 1 + +It helps to think of share points as being like drive letters. Example:: + + k: is not a directory + k:\ is a directory + k:\media is a directory + k:\media\ is not a directory + +The same rules apply if you substitute "k:" with "\\conky\foo":: + + \\conky\foo is not a directory + \\conky\foo\ is a directory + \\conky\foo\media is a directory + \\conky\foo\media\ is not a directory + + +cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! +------------------------------------------------------------------------ + +Be sure you have the latest python.exe, that you are using python.exe rather +than a GUI version of Python and that you have configured the server to execute +:: + + "...\python.exe -u ..." + +for the CGI execution. The :option:`-u` (unbuffered) option on NT and Win95 +prevents the interpreter from altering newlines in the standard input and +output. Without it post/multipart requests will seem to have the wrong length +and binary (e.g. GIF) responses may get garbled (resulting in broken images, PDF +files, and other binary downloads failing). + + +Why doesn't os.popen() work in PythonWin on NT? +----------------------------------------------- + +The reason that os.popen() doesn't work from within PythonWin is due to a bug in +Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console +attached to the process. + +You should use the win32pipe module's popen() instead which doesn't depend on +having an attached Win32 console. + +Example:: + + import win32pipe + f = win32pipe.popen('dir /c c:\\') + print f.readlines() + f.close() + + +Why doesn't os.popen()/win32pipe.popen() work on Win9x? +------------------------------------------------------- + +There is a bug in Win9x that prevents os.popen/win32pipe.popen* from +working. The good news is there is a way to work around this problem. The +Microsoft Knowledge Base article that you need to lookup is: Q150956. You will +find links to the knowledge base at: http://www.microsoft.com/kb. + + +PyRun_SimpleFile() crashes on Windows but not on Unix; why? +----------------------------------------------------------- + +This is very sensitive to the compiler vendor, version and (perhaps) even +options. If the FILE* structure in your embedding program isn't the same as is +assumed by the Python interpreter it won't work. + +The Python 1.5.* DLLs (``python15.dll``) are all compiled with MS VC++ 5.0 and +with multithreading-DLL options (``/MD``). + +If you can't change compilers or flags, try using :cfunc:`Py_RunSimpleString`. +A trick to get it to run an arbitrary file is to construct a call to +:func:`execfile` with the name of your file as argument. + +Also note that you can not mix-and-match Debug and Release versions. If you +wish to use the Debug Multithreaded DLL, then your module *must* have an "_d" +appended to the base name. + + +Importing _tkinter fails on Windows 95/98: why? +------------------------------------------------ + +Sometimes, the import of _tkinter fails on Windows 95 or 98, complaining with a +message like the following:: + + ImportError: DLL load failed: One of the library files needed + to run this application cannot be found. + +It could be that you haven't installed Tcl/Tk, but if you did install Tcl/Tk, +and the Wish application works correctly, the problem may be that its installer +didn't manage to edit the autoexec.bat file correctly. It tries to add a +statement that changes the PATH environment variable to include the Tcl/Tk 'bin' +subdirectory, but sometimes this edit doesn't quite work. Opening it with +notepad usually reveals what the problem is. + +(One additional hint, noted by David Szafranski: you can't use long filenames +here; e.g. use ``C:\PROGRA~1\Tcl\bin`` instead of ``C:\Program Files\Tcl\bin``.) + + +How do I extract the downloaded documentation on Windows? +--------------------------------------------------------- + +Sometimes, when you download the documentation package to a Windows machine +using a web browser, the file extension of the saved file ends up being .EXE. +This is a mistake; the extension should be .TGZ. + +Simply rename the downloaded file to have the .TGZ extension, and WinZip will be +able to handle it. (If your copy of WinZip doesn't, get a newer one from +http://www.winzip.com.) + + +Missing cw3215mt.dll (or missing cw3215.dll) +-------------------------------------------- + +Sometimes, when using Tkinter on Windows, you get an error that cw3215mt.dll or +cw3215.dll is missing. + +Cause: you have an old Tcl/Tk DLL built with cygwin in your path (probably +``C:\Windows``). You must use the Tcl/Tk DLLs from the standard Tcl/Tk +installation (Python 1.5.2 comes with one). + + +Warning about CTL3D32 version from installer +-------------------------------------------- + +The Python installer issues a warning like this:: + + This version uses ``CTL3D32.DLL`` which is not the correct version. + This version is used for windows NT applications only. + +Tim Peters: + + This is a Microsoft DLL, and a notorious source of problems. The message + means what it says: you have the wrong version of this DLL for your operating + system. The Python installation did not cause this -- something else you + installed previous to this overwrote the DLL that came with your OS (probably + older shareware of some sort, but there's no way to tell now). If you search + for "CTL3D32" using any search engine (AltaVista, for example), you'll find + hundreds and hundreds of web pages complaining about the same problem with + all sorts of installation programs. They'll point you to ways to get the + correct version reinstalled on your system (since Python doesn't cause this, + we can't fix it). + +David A Burton has written a little program to fix this. Go to +http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". Modified: python/trunk/Doc/tools/sphinxext/indexcontent.html ============================================================================== --- python/trunk/Doc/tools/sphinxext/indexcontent.html (original) +++ python/trunk/Doc/tools/sphinxext/indexcontent.html Sun Oct 11 20:31:23 2009 @@ -26,6 +26,8 @@ sharing modules with others

            + From python-checkins at python.org Sun Oct 11 21:47:10 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 11 Oct 2009 19:47:10 -0000 Subject: [Python-checkins] r75364 - peps/trunk/pep-0376.txt Message-ID: Author: tarek.ziade Date: Sun Oct 11 21:47:09 2009 New Revision: 75364 Log: better wording: installer marker is just a helper Modified: peps/trunk/pep-0376.txt Modified: peps/trunk/pep-0376.txt ============================================================================== --- peps/trunk/pep-0376.txt (original) +++ peps/trunk/pep-0376.txt Sun Oct 11 21:47:09 2009 @@ -534,7 +534,7 @@ >>> uninstall('docutils', installer='cool-pkg-manager') This allows a third-party application to use the ``uninstall`` function -and make sure it's the only program that can remove a distribution it has +and strongly suggest that no other program remove a distribution it has previously installed. This is useful when a third-party program that relies on Distutils APIs does extra steps on the system at installation time, it has to undo at uninstallation time. From python-checkins at python.org Sun Oct 11 22:16:17 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 20:16:17 -0000 Subject: [Python-checkins] r75365 - in python/trunk/Doc: faq/design.rst faq/extending.rst faq/general.rst faq/gui.rst faq/library.rst faq/programming.rst faq/windows.rst howto/unicode.rst howto/webservers.rst install/index.rst library/mailbox.rst library/msilib.rst library/othergui.rst using/windows.rst whatsnew/2.0.rst whatsnew/2.2.rst whatsnew/2.3.rst whatsnew/2.4.rst whatsnew/2.6.rst Message-ID: Author: georg.brandl Date: Sun Oct 11 22:16:16 2009 New Revision: 75365 Log: Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. Modified: python/trunk/Doc/faq/design.rst python/trunk/Doc/faq/extending.rst python/trunk/Doc/faq/general.rst python/trunk/Doc/faq/gui.rst python/trunk/Doc/faq/library.rst python/trunk/Doc/faq/programming.rst python/trunk/Doc/faq/windows.rst python/trunk/Doc/howto/unicode.rst python/trunk/Doc/howto/webservers.rst python/trunk/Doc/install/index.rst python/trunk/Doc/library/mailbox.rst python/trunk/Doc/library/msilib.rst python/trunk/Doc/library/othergui.rst python/trunk/Doc/using/windows.rst python/trunk/Doc/whatsnew/2.0.rst python/trunk/Doc/whatsnew/2.2.rst python/trunk/Doc/whatsnew/2.3.rst python/trunk/Doc/whatsnew/2.4.rst python/trunk/Doc/whatsnew/2.6.rst Modified: python/trunk/Doc/faq/design.rst ============================================================================== --- python/trunk/Doc/faq/design.rst (original) +++ python/trunk/Doc/faq/design.rst Sun Oct 11 22:16:16 2009 @@ -396,12 +396,13 @@ ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this approach is feasible, -although the speedups reached so far are only modest (e.g. 2x). Jython uses the -same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated -that in combination with whole-program analysis, speedups of 1000x are feasible -for small demo programs. See the proceedings from the `1997 Python conference -`_ for more information.) +conferences `_ have shown that this +approach is feasible, although the speedups reached so far are only modest +(e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim +Hugunin has demonstrated that in combination with whole-program analysis, +speedups of 1000x are feasible for small demo programs. See the proceedings +from the `1997 Python conference +`_ for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual Modified: python/trunk/Doc/faq/extending.rst ============================================================================== --- python/trunk/Doc/faq/extending.rst (original) +++ python/trunk/Doc/faq/extending.rst Sun Oct 11 22:16:16 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`_, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping Modified: python/trunk/Doc/faq/general.rst ============================================================================== --- python/trunk/Doc/faq/general.rst (original) +++ python/trunk/Doc/faq/general.rst Sun Oct 11 22:16:16 2009 @@ -164,9 +164,10 @@ several useful pieces of freely distributable software. The source will compile and run out of the box on most UNIX platforms. -Consult the `Developer FAQ -`__ for more information -on getting the source code and compiling it. +.. XXX update link once the dev faq is relocated + +Consult the `Developer FAQ `__ for more +information on getting the source code and compiling it. How do I get documentation on Python? @@ -176,7 +177,7 @@ The standard documentation for the current stable version of Python is available at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are -also available at http://docs.python.org/download/. +also available at http://docs.python.org/download.html. The documentation is written in reStructuredText and processed by `the Sphinx documentation tool `__. The reStructuredText source @@ -220,8 +221,10 @@ newsgroups and on the Python home page at http://www.python.org/; an RSS feed of news is available. +.. XXX update link once the dev faq is relocated + You can also access the development version of Python through Subversion. See -http://www.python.org/dev/devfaq.html#subversion-svn for details. +http://www.python.org/dev/faq/ for details. How do I submit bug reports and patches for Python? Modified: python/trunk/Doc/faq/gui.rst ============================================================================== --- python/trunk/Doc/faq/gui.rst (original) +++ python/trunk/Doc/faq/gui.rst Sun Oct 11 22:16:16 2009 @@ -45,11 +45,12 @@ ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If you're -writing open source software, you don't need to pay for PyQt, but if you want to -write proprietary applications, you must buy a PyQt license from `Riverbank -Computing `_ and a Qt license from -`Trolltech `_. +`_) and for KDE (PyKDE). If +you're writing open source software, you don't need to pay for PyQt, but if you +want to write proprietary applications, you must buy a PyQt license from +`Riverbank Computing `_ and (up to Qt 4.4; +Qt 4.5 upwards is licensed under the LGPL license) a Qt license from `Trolltech +`_. Gtk+ '''' Modified: python/trunk/Doc/faq/library.rst ============================================================================== --- python/trunk/Doc/faq/library.rst (original) +++ python/trunk/Doc/faq/library.rst Sun Oct 11 22:16:16 2009 @@ -16,14 +16,10 @@ standard library module. (Eventually you'll learn what's in the standard library and will able to skip this step.) -Search the `Python Package Index `_. - -Next, check the `Vaults of Parnassus `_, an older -index of packages. - -Finally, try `Google `_ or other Web search engine. -Searching for "Python" plus a keyword or two for your topic of interest will -usually find something helpful. +For third-party packages, search the `Python Package Index +`_ or try `Google `_ or +another Web search engine. Searching for "Python" plus a keyword or two for +your topic of interest will usually find something helpful. Where is the math.py (socket.py, regex.py, etc.) source file? @@ -181,11 +177,10 @@ How do I create documentation from doc strings? ----------------------------------------------- -.. XXX mention Sphinx/epydoc - The :mod:`pydoc` module can create HTML from the doc strings in your Python -source code. An alternative is `pythondoc -`_. +source code. An alternative for creating API documentation purely from +docstrings is `epydoc `_. `Sphinx +`_ can also include docstring content. How do I get a single keypress at a time? @@ -239,7 +234,7 @@ low-level primitives provided by the :mod:`thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see -http://starship.python.net/crew/aahz/OSCON2001/. +http://www.pythoncraft.com/OSCON2001/. None of my threads seem to run: why? @@ -399,6 +394,7 @@ ------------------------------------------------ .. XXX mention multiprocessing +.. XXX link to dbeazley's talk about GIL? The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded @@ -585,7 +581,7 @@ ("ptys") instead of pipes. Or you can use a Python interface to Don Libes' "expect" library. A Python extension that interfaces to expect is called "expy" and available from http://expectpy.sourceforge.net. A pure Python solution that -works like expect is ` pexpect `_. +works like expect is `pexpect `_. How do I access the serial (RS232) port? Modified: python/trunk/Doc/faq/programming.rst ============================================================================== --- python/trunk/Doc/faq/programming.rst (original) +++ python/trunk/Doc/faq/programming.rst Sun Oct 11 22:16:16 2009 @@ -67,8 +67,8 @@ PyChecker performs, Pylint offers some additional features such as checking line length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://www.logilab.org/projects/pylint/documentation provides a full list of -Pylint's features. +http://www.logilab.org/card/pylint_manual provides a full list of Pylint's +features. How can I create a stand-alone binary from a Python script? @@ -1141,7 +1141,7 @@ A = [[None] * w for i in range(h)] Or, you can use an extension that provides a matrix datatype; `Numeric Python -`_ is the best known. +`_ is the best known. How do I apply a method to a sequence of objects? Modified: python/trunk/Doc/faq/windows.rst ============================================================================== --- python/trunk/Doc/faq/windows.rst (original) +++ python/trunk/Doc/faq/windows.rst Sun Oct 11 22:16:16 2009 @@ -389,10 +389,10 @@ .py :REG_SZ: c:\\python.exe -u %s %s This line will allow you to call your script with a simple reference like: -http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" -directory for your server (which it usually is by default). The "-u" flag -specifies unbuffered and binary mode for stdin - needed when working with binary -data. +``http://yourserver/scripts/yourscript.py`` provided "scripts" is an +"executable" directory for your server (which it usually is by default). The +:option:`-u` flag specifies unbuffered and binary mode for stdin - needed when +working with binary data. In addition, it is recommended that using ".py" may not be a good idea for the file extensions when used in this context (you might want to reserve ``*.py`` @@ -517,7 +517,7 @@ There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will -find links to the knowledge base at: http://www.microsoft.com/kb. +find links to the knowledge base at: http://support.microsoft.com/. PyRun_SimpleFile() crashes on Windows but not on Unix; why? @@ -604,4 +604,4 @@ we can't fix it). David A Burton has written a little program to fix this. Go to -http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". +http://www.burtonsys.com/downloads.html and click on "ctl3dfix.zip". Modified: python/trunk/Doc/howto/unicode.rst ============================================================================== --- python/trunk/Doc/howto/unicode.rst (original) +++ python/trunk/Doc/howto/unicode.rst Sun Oct 11 22:16:16 2009 @@ -472,7 +472,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: python/trunk/Doc/howto/webservers.rst ============================================================================== --- python/trunk/Doc/howto/webservers.rst (original) +++ python/trunk/Doc/howto/webservers.rst Sun Oct 11 22:16:16 2009 @@ -270,8 +270,7 @@ * lighttpd ships its own `FastCGI module `_ as well as an `SCGI module `_. -* nginx also supports `FastCGI - `_. +* nginx also supports `FastCGI `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -524,7 +523,7 @@ informations on a web server. Often relational database engines like `MySQL `_ or -`PostgreSQL `_ are used due to their good +`PostgreSQL `_ are used due to their good performance handling very large databases consisting of up to millions of entries. These are *queried* using a language called `SQL `_. Python programmers in general do not like @@ -628,7 +627,7 @@ It has a big, international community which has created many sites using Django. There are also quite a lot of add-on projects which extend Django's normal functionality. This is partly due to Django's well written `online -documentation `_ and the `Django book +documentation `_ and the `Django book `_. Modified: python/trunk/Doc/install/index.rst ============================================================================== --- python/trunk/Doc/install/index.rst (original) +++ python/trunk/Doc/install/index.rst Sun Oct 11 22:16:16 2009 @@ -940,7 +940,8 @@ These compilers require some special libraries. This task is more complex than for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find -a good program for this task at http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html) +a good program for this task at +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) Modified: python/trunk/Doc/library/mailbox.rst ============================================================================== --- python/trunk/Doc/library/mailbox.rst (original) +++ python/trunk/Doc/library/mailbox.rst Sun Oct 11 22:16:16 2009 @@ -602,7 +602,7 @@ `nmh - Message Handling System `_ Home page of :program:`nmh`, an updated version of the original :program:`mh`. - `MH & nmh: Email for Users & Programmers `_ + `MH & nmh: Email for Users & Programmers `_ A GPL-licensed book on :program:`mh` and :program:`nmh`, with some information on the mailbox format. Modified: python/trunk/Doc/library/msilib.rst ============================================================================== --- python/trunk/Doc/library/msilib.rst (original) +++ python/trunk/Doc/library/msilib.rst Sun Oct 11 22:16:16 2009 @@ -396,10 +396,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -424,7 +424,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -518,13 +518,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: @@ -553,5 +553,3 @@ This module contains definitions for the UIText and ActionText tables, for the standard installer actions. - - Modified: python/trunk/Doc/library/othergui.rst ============================================================================== --- python/trunk/Doc/library/othergui.rst (original) +++ python/trunk/Doc/library/othergui.rst Sun Oct 11 22:16:16 2009 @@ -43,7 +43,7 @@ `PythonCAD `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool Modified: python/trunk/Doc/using/windows.rst ============================================================================== --- python/trunk/Doc/using/windows.rst (original) +++ python/trunk/Doc/using/windows.rst Sun Oct 11 22:16:16 2009 @@ -69,7 +69,7 @@ `ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Python Enthought Edition `_ +`Enthought Python Distribution `_ Popular modules (such as PyWin32) with their respective documentation, tool suite for building extensible python applications @@ -223,8 +223,7 @@ * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces `PythonWin `_ + `MingW -- Python extensions `_ by Trent Apted et al, 2007 Modified: python/trunk/Doc/whatsnew/2.0.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.0.rst (original) +++ python/trunk/Doc/whatsnew/2.0.rst Sun Oct 11 22:16:16 2009 @@ -572,8 +572,7 @@ mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still ``'win32'`` on Win64 because it seems that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) PythonWin also supports Windows CE; see the -Python CE page at http://starship.python.net/crew/mhammond/ce/ for more -information. +Python CE page at http://pythonce.sourceforge.net/ for more information. Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify "configure --with-dyld --with-suffix=.x". @@ -1041,8 +1040,8 @@ to include SSL support, which adds an additional function to the :mod:`socket` module: :func:`socket.ssl(socket, keyfile, certfile)`, which takes a socket object and returns an SSL socket. The :mod:`httplib` and :mod:`urllib` modules -were also changed to support "https://" URLs, though no one has implemented FTP -or SMTP over SSL. +were also changed to support ``https://`` URLs, though no one has implemented +FTP or SMTP over SSL. The :mod:`httplib` module has been rewritten by Greg Stein to support HTTP/1.1. Backward compatibility with the 1.5 version of :mod:`httplib` is provided, Modified: python/trunk/Doc/whatsnew/2.2.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.2.rst (original) +++ python/trunk/Doc/whatsnew/2.2.rst Sun Oct 11 22:16:16 2009 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso:: +.. seealso (now defunct) http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and @@ -49,14 +49,14 @@ complicated section of this article, I'll provide an overview of the changes and offer some comments. -A long time ago I wrote a Web page (http://www.amk.ca/python/writing/warts.html) -listing flaws in Python's design. One of the most significant flaws was that -it's impossible to subclass Python types implemented in C. In particular, it's -not possible to subclass built-in types, so you can't just subclass, say, lists -in order to add a single useful method to them. The :mod:`UserList` module -provides a class that supports all of the methods of lists and that can be -subclassed further, but there's lots of C code that expects a regular Python -list and won't accept a :class:`UserList` instance. +A long time ago I wrote a Web page listing flaws in Python's design. One of the +most significant flaws was that it's impossible to subclass Python types +implemented in C. In particular, it's not possible to subclass built-in types, +so you can't just subclass, say, lists in order to add a single useful method to +them. The :mod:`UserList` module provides a class that supports all of the +methods of lists and that can be subclassed further, but there's lots of C code +that expects a regular Python list and won't accept a :class:`UserList` +instance. Python 2.2 fixes this, and in the process adds some exciting new capabilities. A brief summary: Modified: python/trunk/Doc/whatsnew/2.3.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.3.rst (original) +++ python/trunk/Doc/whatsnew/2.3.rst Sun Oct 11 22:16:16 2009 @@ -1855,10 +1855,10 @@ .. seealso:: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c - For the full details of the pymalloc implementation, see the comments at the top - of the file :file:`Objects/obmalloc.c` in the Python source code. The above - link points to the file within the SourceForge CVS browser. + http://svn.python.org/view/python/trunk/Objects/obmalloc.c + For the full details of the pymalloc implementation, see the comments at + the top of the file :file:`Objects/obmalloc.c` in the Python source code. + The above link points to the file within the python.org SVN browser. .. ====================================================================== Modified: python/trunk/Doc/whatsnew/2.4.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.4.rst (original) +++ python/trunk/Doc/whatsnew/2.4.rst Sun Oct 11 22:16:16 2009 @@ -680,9 +680,6 @@ Written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. - http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html - A more detailed overview of the IEEE-754 representation. - http://www.lahey.com/float.htm The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. @@ -756,7 +753,7 @@ :ctype:`double` to an ASCII string. The code for these functions came from the GLib library -(http://developer.gnome.org/arch/gtk/glib.html), whose developers kindly +(http://library.gnome.org/devel/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. Modified: python/trunk/Doc/whatsnew/2.6.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.6.rst (original) +++ python/trunk/Doc/whatsnew/2.6.rst Sun Oct 11 22:16:16 2009 @@ -1824,7 +1824,7 @@ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol available, instead of restricting itself to protocol 1. - (Contributed by W. Barnes; :issue:`1551443`.) + (Contributed by W. Barnes.) * The :mod:`cgi` module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions @@ -2977,7 +2977,7 @@ * The BerkeleyDB module now has a C API object, available as ``bsddb.db.api``. This object can be used by other C extensions that wish to use the :mod:`bsddb` module for their own purposes. - (Contributed by Duncan Grisby; :issue:`1551895`.) + (Contributed by Duncan Grisby.) * The new buffer interface, previously described in `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__, From python-checkins at python.org Sun Oct 11 22:47:36 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 20:47:36 -0000 Subject: [Python-checkins] r75366 - in sandbox/trunk/dev: contributing.rst culture.rst faq.rst index.rst patches.rst process.rst setup.rst tools.rst why.rst workflow.rst Message-ID: Author: georg.brandl Date: Sun Oct 11 22:47:33 2009 New Revision: 75366 Log: Style update and a few actual fixes. Modified: sandbox/trunk/dev/contributing.rst sandbox/trunk/dev/culture.rst sandbox/trunk/dev/faq.rst sandbox/trunk/dev/index.rst sandbox/trunk/dev/patches.rst sandbox/trunk/dev/process.rst sandbox/trunk/dev/setup.rst sandbox/trunk/dev/tools.rst sandbox/trunk/dev/why.rst sandbox/trunk/dev/workflow.rst Modified: sandbox/trunk/dev/contributing.rst ============================================================================== --- sandbox/trunk/dev/contributing.rst (original) +++ sandbox/trunk/dev/contributing.rst Sun Oct 11 22:47:33 2009 @@ -1,12 +1,10 @@ - -============================== +====================== How You Can Contribute -============================== - +====================== There are various ways one can contribute to Python and they do not all involve -knowing the internals of Python. Nor do they necessarily require writing -code! All it takes to contribute is a willing to learn and some free time. +knowing the internals of Python. Nor do they necessarily require writing code! +All it takes to contribute is a willing to learn and some free time. This document assumes you have already read how to get `set up`_ and how the `issue workflow`_ works. @@ -25,66 +23,57 @@ to fix the problem you had. If you want to help with a known issue with the documentation then look at the -`open documentation bugs -`_. -You can comment on documentation issues that have patches or write a patch to -fix an issue. See the `documentation guide -`_ on how Python's -documentation is written. +`open documentation bugs`_. You can comment on documentation issues that have +patches or write a patch to fix an issue. See the `documentation guide`_ on how +Python's documentation is written. .. _documentation: http://docs.python.org/dev/ +.. _documentation guide: http://docs.python.org/dev/documenting/ Writing Unit Tests ================== Python is far from having good coverage (roughly 90% and better) for all of its -code. It is always helpful to increase the coverage by writing more unit tests -to help raise the code coverage. An easy way to see what kind of coverage +code. It is always helpful to increase the coverage by writing more unit tests +to help raise the code coverage. An easy way to see what kind of coverage exists for code is to look `here `_. -Please realize, though, that your patch may not be reviewed immediately! Since +Please realize, though, that your patch may not be reviewed immediately! Since Python is run entirely by open source developers who volunteer their time they -only have so many hours a week to look at issues in the tracker. It might be +only have so many hours a week to look at issues in the tracker. It might be quite some time until someone manages to free up enough time to get to your -patch. But do know that your help is still appreciated no matter how long we +patch. But do know that your help is still appreciated no matter how long we take to get to your work! Fixing Bugs =========== -If you simply look at the `open bugs -`_ -on the `issue tracker`_ you will notice help is always needed. By writing a -solid patch for a bug you make it so that the core developers do not have to -spend what little time they have fixing a bug but instead doing patch reviews -which are almost always a better use of time. Just make sure to follow what is -outlined in the `issue workflow`_ for what is required of a good patch. +If you simply look at the `open bugs`_ on the `issue tracker`_ you will notice +help is always needed. By writing a solid patch for a bug you make it so that +the core developers do not have to spend what little time they have fixing a bug +but instead doing patch reviews which are almost always a better use of time. +Just make sure to follow what is outlined in the `issue workflow`_ for what is +required of a good patch. And you do not need to know C or how Python's intepreter works to contribute! Simply restrict your search in the issue tracker to only a specific *component* -that requires only a certain skill set. For instance, -if you are looking for an explicitly `easy issue -`_ that should take no more -than a day (about the length of a bug day) to work on they are -flagged in the issue tracker as such. If you are comfortable with working in -Python code you can look at issues pertaining to `Lib -`_ -or other components that are inherently only Python code. If you are -comfortable with `extension modules -`_ -you can find issues pertaining to those. -And when you are ready to learn the internal details of Python you can tackle -issues related to the `interpreter core -`_. -There are other components you can narrow your search on as well if you so -choose. Just play around with the search feature of the issue tracker to find a -list of issues you might be interested at looking into. - -Please realize that while your patch is greatly appreciated, it may be some -time before a core developer gets around to looking at your patch. It is simply -an issue of someone having the free time and expertise to look at your work in +that requires only a certain skill set. For instance, if you are looking for an +explicitly `easy issue`_ that should take no more than a day (about the length +of a bug day) to work on they are flagged in the issue tracker as such. If you +are comfortable with working in Python code you can look at issues pertaining to +`the library`_ or other components that are inherently only Python code. If you +are comfortable with `extension modules`_ you can find issues pertaining to +those. And when you are ready to learn the internal details of Python you can +tackle issues related to the `interpreter core`_. There are other components +you can narrow your search on as well if you so choose. Just play around with +the search feature of the issue tracker to find a list of issues you might be +interested at looking into. + +Please realize that while your patch is greatly appreciated, it may be some time +before a core developer gets around to looking at your patch. It is simply an +issue of someone having the free time and expertise to look at your work in order to review it and commit it. @@ -93,17 +82,17 @@ While Python is a very solid piece of software, bugs are found. Plus people are always suggesting new features through patches, improving existing code, etc. -This leads to a lost of issues being created in the `issue tracker`_. Help is +This leads to a lost of issues being created in the `issue tracker`_. Help is always appreciated to go through issues and perform triage by following what is -discussed in the `issue workflow`_. This ranges from helping validate a bug +discussed in the `issue workflow`_. This ranges from helping validate a bug exists in Python's in-development version to reviewing patches. If you have helped out in the issue tracker for a little while or have been a good participant on python-dev you may ask for Developer privileges on the -tracker which allow you to change any and all metadata on an issue. -Please don't be shy about asking for the privilege! We are more liberal with -giving out this ability than with commit privileges so don't feel like you have -to have been contributing for a year to gain this ability. And with Developer +tracker which allow you to change any and all metadata on an issue. Please +don't be shy about asking for the privilege! We are more liberal with giving +out this ability than with commit privileges so don't feel like you have to have +been contributing for a year to gain this ability. And with Developer privileges you can work more autonomously and be an even greater help by narrowing down what issues on the tracker deserve the most attention at any one time. @@ -116,19 +105,40 @@ To become a core developer and gain commit privileges for Python you typically need to have been an active developer on Python through the issue tracker and -shown the ability to develop top-quality patches that require little or no -input or changes from a core developer. Typically people take about a year to -reach this level; some people get there faster, others longer. It can -be short-circuited, though, if a core developer is willing to shepherd you -through the process, but this is typically reserved for special situations like -`GSoC/GHOP `_. Essentially if a core developer is +shown the ability to develop top-quality patches that require little or no input +or changes from a core developer. Typically people take about a year to reach +this level; some people get there faster, others longer. It can be +short-circuited, though, if a core developer is willing to shepherd you through +the process, but this is typically reserved for special situations like +`GSoC/GHOP `_. Essentially if a core developer is willing to vouch for you and initially take personal responsibility for your actions as a developer you can gain commit privileges that way. When you think you have been submitting patches regularly that have not required much feedback from a core developer you can email python-dev requesting commit -privileges. If it is decided you are ready then you mail your SSH 2 key (see -the `dev FAQ`_ on how to do this) to python-dev and you will receive your -commit privileges. +privileges. If it is decided you are ready then you mail your SSH 2 key (see +the `dev FAQ`_ on how to do this) to python-dev and you will receive your commit +privileges. .. _dev FAQ: /dev/faq/ + + +.. here go the ghastly tracker links + +.. _open documentation bugs: + http://bugs.python.org/issue?%40search_text=&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&components=4&versions=&dependencies=&assignee=&keywords=&priority=&%40columns=priority&%40group=priority&status=1&resolution=&nosy_count=&message_count=&%40pagesize=50&%40startwith=0&%40queryname=&%40old-queryname=&%40action=search + +.. _open bugs: + http://bugs.python.org/issue?status=-1,1,3&@sort=-activity&@search_text=&@dispname=Show%20All&@startwith=0&@filter=status&@group=priority&@columns=id,activity,title,creator,assignee,status,type&@pagesize=50 + +.. _easy issue: + http://bugs.python.org/issue?%40search_text=&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&%40columns=type&components=&%40columns=components&versions=&dependencies=&assignee=&%40columns=assignee&keywords=6&priority=&%40group=priority&status=1&resolution=&nosy_count=&message_count=&%40pagesize=50&%40startwith=0&%40queryname=&%40old-queryname=&%40action=search + +.. _the library: + http://bugs.python.org/issue?%40search_text=&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&%40columns=type&components=9&versions=&dependencies=&assignee=&%40columns=assignee&keywords=&priority=&%40group=priority&status=1&resolution=&nosy_count=&message_count=&%40pagesize=50&%40startwith=0&%40queryname=&%40old-queryname=&%40action=search + +.. _extension modules: + http://bugs.python.org/issue?%40search_text=&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&%40columns=type&components=5&versions=&dependencies=&assignee=&%40columns=assignee&keywords=&priority=&%40group=priority&status=1&resolution=&nosy_count=&message_count=&%40pagesize=50&%40startwith=0&%40queryname=&%40old-queryname=&%40action=search + +.. _interpreter core: + http://bugs.python.org/issue?%40search_text=&title=&%40columns=title&id=&%40columns=id&stage=&creation=&creator=&activity=&%40columns=activity&%40sort=activity&actor=&nosy=&type=&%40columns=type&components=8&versions=&dependencies=&assignee=&%40columns=assignee&keywords=&priority=&%40group=priority&status=1&resolution=&nosy_count=&message_count=&%40pagesize=50&%40startwith=0&%40queryname=&%40old-queryname=&%40action=search Modified: sandbox/trunk/dev/culture.rst ============================================================================== --- sandbox/trunk/dev/culture.rst (original) +++ sandbox/trunk/dev/culture.rst Sun Oct 11 22:47:33 2009 @@ -1,39 +1,37 @@ -==================== +============== Python Culture -==================== +============== + +Each software project has its own culture and style, its own approach to solving +problems. Python has its own distinctive style, of course, and if you're a +Python user, that style has probably rubbed off on you to some extent. Python +tries to keep things simple, to be orthogonal but not too much so, and to assist +the programmer as much as possible. + +The first and most important thing is to be friendly, even (I should say +*especially*) with people who disagree with you. Other people are not idiots +just because they disagree with you, so don't call them idiots. Rudeness and +flaming, especially on python-dev, is a fast way to get ignored. Have a sense +of humour, and don't take things too seriously. + +Another useful skill is to know when to give up. If a thread has gone on for +dozens or hundreds of posts with no clear consensus emerging, one of two things +will happen. Either Guido will make a BDFL pronouncement, which consists of him +saying "We'll do it this way", or he's given up on the thread and isn't reading +it at all any more. In either case, there's little point in continuing the +discussion. -Each software project has its own culture and style, its own -approach to solving problems. Python has its own distinctive style, -of course, and if you're a Python user, that style has probably rubbed -off on you to some extent. Python tries to keep things simple, to be -orthogonal but not too much so, and to assist the programmer as much -as possible. - -The first and most important thing is to be friendly, even (I -should say *especially*) with people who disagree with you. -Other people are not idiots just because they disagree with you, so -don't call them idiots. Rudeness and flaming, especially on -python-dev, is a fast way to get ignored. Have a sense of humour, and -don't take things too seriously. - -Another useful skill is to know when to give up. If a thread has -gone on for dozens or hundreds of posts with no clear consensus -emerging, one of two things will happen. Either Guido will make a -BDFL pronouncement, which consists of him saying "We'll do it this -way", or he's given up on the thread and isn't reading it at all any -more. In either case, there's little point in continuing the -discussion. Design Principles ================= +In June 1999, Tim Peters channeled Guido and listed 19 guiding principles for +Python's design in a `comp.lang.python `_ posting. The +principles shouldn't be taken too seriously, as they're not hard-and-fast +constraints and for each rule you can probably list instances where it's been +broken. Still, no one has had much disagreement with this list of design +criteria. (They have also been immortalized as :pep:`20`.) -In June 1999, Tim Peters channeled Guido and listed 19 guiding -principles for Python's design in a `comp.lang.python `_ posting. The -principles shouldn't be taken too seriously, as they're not -hard-and-fast constraints and for each rule you can probably list -instances where it's been broken. Still, no one has had much -disagreement with this list of design criteria. * Beautiful is better than ugly. * Explicit is better than implicit. @@ -55,16 +53,14 @@ * If the implementation is easy to explain, it may be a good idea. * Namespaces are one honking great idea -- let's do more of those! -Don't take these 19 aphorisms too seriously -- tattooing them on your -body is probably a bad idea, for example -- but it's instructive to -contemplate them. Some parallels can be drawn to the guiding -principles of extreme programming, most notably the emphasis on "Do -the simplest thing that can possibly work". - -Another principle is "Correctness and clarity before speed." Most -of the code in the Python interpreter and standard library is written -in a very straightforward style. The developers aren't interested in -making the interpreter run faster at the expense of unreadable or -hard-to-follow tricky code. In the past working patches have been -rejected because they would have made the code too difficult to -maintain. +Don't take these 19 aphorisms too seriously -- tattooing them on your body is +probably a bad idea, for example -- but it's instructive to contemplate them. +Some parallels can be drawn to the guiding principles of extreme programming, +most notably the emphasis on "Do the simplest thing that can possibly work". + +Another principle is "Correctness and clarity before speed." Most of the code +in the Python interpreter and standard library is written in a very +straightforward style. The developers aren't interested in making the +interpreter run faster at the expense of unreadable or hard-to-follow tricky +code. In the past working patches have been rejected because they would have +made the code too difficult to maintain. Modified: sandbox/trunk/dev/faq.rst ============================================================================== --- sandbox/trunk/dev/faq.rst (original) +++ sandbox/trunk/dev/faq.rst Sun Oct 11 22:47:33 2009 @@ -8,22 +8,21 @@ .. sectnum:: General Information -===================================================================== +=================== Where do I start? ----------------- -There are various links of the `dev page`_ to documents to help get you -started. +There are various links of the `dev page`_ to documents to help get you started. .. _dev page: /dev/ How can I become a developer? ---------------------------------------------------------------------------- +----------------------------- -One way to become a developer is through the -`School of Hard Knocks `_. +One way to become a developer is through the `School of Hard Knocks +`_. Otherwise just contribute on a regular basis through patches and just ask for commit privileges once you have helped out enough that other developers tire of @@ -31,20 +30,20 @@ Version Control -================================== +=============== Where can I learn about the version control system used, Subversion (svn)? -------------------------------------------------------------------------------- +-------------------------------------------------------------------------- -`Subversion`_ has its official web site at http://subversion.tigris.org/ (it -is also known as ``svn`` thanks to that being the name of the executable of +`Subversion`_ has its official web site at http://subversion.tigris.org/ (it is +also known as ``svn`` thanks to that being the name of the executable of Subversion itself). A book on Subversion published by `O'Reilly Media`_, `Version Control with Subversion`_, is available for free online. -With Subversion installed, you can run the help tool that comes with -Subversion to get help:: +With Subversion installed, you can run the help tool that comes with Subversion +to get help:: - svn help + svn help This will give you the needed information to use the tool. The man page for ``svn`` is rather scant and thus not worth reading. @@ -55,70 +54,69 @@ What do I need to use Subversion? -------------------------------------------------------------------------------- +--------------------------------- .. _download Subversion: http://subversion.tigris.org/getting.html UNIX -''''''''''''''''''' +'''' First, you need to `download Subversion`_. Most UNIX-based operating systems have binary packages available for Subversion. Also, most package systems also have Subversion available. -If you have checkin rights, you need OpenSSH_. This is needed to verify -your identity when performing commits. +If you have checkin rights, you need OpenSSH_. This is needed to verify your +identity when performing commits. .. _OpenSSH: http://www.openssh.org/ Windows -''''''''''''''''''' +''''''' You have several options on Windows. One is to `download Subversion`_ itself which will give you a command-line version. Another option is to `download TortoiseSVN`_ which integrates with Windows Explorer. -If you have checkin rights, you will also need an SSH client. -`Download PuTTY and friends`_ (PuTTYgen, Pageant, and Plink) for this. All -other questions in this FAQ will assume you are using these tools. - -Once you have both Subversion and PuTTY installed you must tell Subversion -where to find an SSH client. Do this by editing -``%APPDATA%\Subversion\config`` (on Win9x, this might be -``c:\windows\Application Data\Subversionconfig``) to have the following -section:: +If you have checkin rights, you will also need an SSH client. `Download PuTTY +and friends`_ (PuTTYgen, Pageant, and Plink) for this. All other questions in +this FAQ will assume you are using these tools. + +Once you have both Subversion and PuTTY installed you must tell Subversion where +to find an SSH client. Do this by editing ``%APPDATA%\Subversion\config`` (on +Win9x, this might be ``c:\windows\Application Data\Subversionconfig``) to have +the following section:: - [tunnels] - ssh="c:/path/to/putty/plink.exe" -T + [tunnels] + ssh="c:/path/to/putty/plink.exe" -T Obviously change the path to be the proper one for your system. The ``-T`` option prevents a pseudo-terminal from being created. -You can use Pageant to prevent from having to type in your password for your -SSH 2 key constantly. If you prefer not to have another program running, -you need to create a profile in PuTTY. - -Go to Session:Saved Sessions and create a new profile named -``svn.python.org``. In Session:Host Name, enter ``svn.python.org``. In -SSH/Auth:Private key file select your private key. In Connection:Auto-login -username enter ``pythondev``. +You can use Pageant to prevent from having to type in your password for your SSH +2 key constantly. If you prefer not to have another program running, you need +to create a profile in PuTTY. + +Go to Session:Saved Sessions and create a new profile named ``svn.python.org``. +In Session:Host Name, enter ``svn.python.org``. In SSH/Auth:Private key file +select your private key. In Connection:Auto-login username enter ``pythondev``. With this set up, paths are slightly different than most other settings in that -the username is not required. Do take notice of this when choosing to check -out a project! +the username is not required. Do take notice of this when choosing to check out +a project! .. _download TortoiseSVN: http://tortoisesvn.tigris.org/download.html .. _PuTTY: http://www.chiark.greenend.org.uk/~sgtatham/putty/ -.. _download PuTTY and friends: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html +.. _download PuTTY and friends: + http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html How do I get a checkout of the repository (read-only and read-write)? -------------------------------------------------------------------------------- +--------------------------------------------------------------------- Regardless of whether you are checking out a read-only or read-write version of the repository, the basic command is the same:: - svn checkout [PATH] + svn checkout [PATH] ```` is the specified location of the project within the repository that you would like to check out (those paths are discussed later). The optional @@ -127,23 +125,23 @@ For a read-only checkout, the format of ```` is:: - http://svn.python.org/projects/ - + http://svn.python.org/projects/ + with `` representing the path to the project. A list of projects can be -viewed at http://svn.python.org/view/ . Do note that any subdirectory may also +viewed at http://svn.python.org/view/. Do note that any subdirectory may also be checked out individually. For a read-write checkout (with a caveat for Windows users using PuTTY without Pageant), the format for ```` is:: - svn+ssh://pythondev at svn.python.org/ + svn+ssh://pythondev at svn.python.org/ There are three critical differences between a read-only URL and a read-write URL. One is the protocol being specified as ``svn+ssh`` and not ``http``. -Next, notice the addition of the username ``pythondev`` (*note* that for -Windows users using PuTTY without Pageant should leave off ``pythondev@`` if -PuTTY was set up following the instructions in this FAQ). Lastly, note that -``projects`` was removed from the path entirely for a read-write checkout. +Next, notice the addition of the username ``pythondev`` (*note* that for Windows +users using PuTTY without Pageant should leave off ``pythondev@`` if PuTTY was +set up following the instructions in this FAQ). Lastly, note that ``projects`` +was removed from the path entirely for a read-write checkout. The repositories most people will be interested in are: @@ -159,41 +157,42 @@ How do I update my working copy to be in sync with the repository? -------------------------------------------------------------------------------- +------------------------------------------------------------------ -Run:: +Run :: - svn update + svn update from the directory you wish to update (and all subdirectories). How do I browse the source code through a web browser? -------------------------------------------------------------------------------- +------------------------------------------------------ Visit http://svn.python.org/view/ to browse the Subversion repository. Where can I find a downloadable snapshot of the source code? -------------------------------------------------------------------------------- +------------------------------------------------------------ Visit http://svn.python.org/snapshots/ to download a tarball containing a daily snapshot of the repository. Who has commit privileges on the Subversion repository? -------------------------------------------------------------------------------- +------------------------------------------------------- See http://www.python.org/dev/committers for a list of committers. How do I get commit privileges on the svn repository if I had the same privileges on the CVS repository? ---------------------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------------------- + +.. XXX is this still relevant? If you have established commit privileges as listed at -http://sourceforge.net/project/memberlist.php?group_id=5470 but do not have -them yet for the Subversion repository, then there are a few steps you must -take: +http://sourceforge.net/project/memberlist.php?group_id=5470 but do not have them +yet for the Subversion repository, then there are a few steps you must take: #. Generate an SSH 2 public key #. Email key and name (first and last required, middle optional) @@ -202,35 +201,35 @@ How do I verify that my commit privileges are working? -------------------------------------------------------------------------------- +------------------------------------------------------ UNIX -''''''''''''''''''' +'''' -If you are listed as a committer at http://www.python.org/dev/committers , then +If you are listed as a committer at http://www.python.org/dev/committers, then you should be able to execute:: - ssh pythondev at svn.python.org + ssh pythondev at svn.python.org and have the following print out to your terminal:: - ( success ( 1 2 ( ANONYMOUS EXTERNAL ) ( edit-pipeline ) ) ) + ( success ( 1 2 ( ANONYMOUS EXTERNAL ) ( edit-pipeline ) ) ) -If something else is printed, then there is a problem with your SSH 2 public -key and you should contact pydotorg at python.org . +If something else is printed, then there is a problem with your SSH 2 public key +and you should contact pydotorg at python.org. Windows -''''''''''''''''''' +''''''' If you are using Pageant, you can verify that your SSH 2 key is set up properly by running:: - c:\path\to\putty\plink.exe pythondev at svn.python.org + c:\path\to\putty\plink.exe pythondev at svn.python.org -Using the proper path to your PuTTY installation, you should get a response -from the server that says:: +Using the proper path to your PuTTY installation, you should get a response from +the server that says:: - ( success ( 1 2 ( ANONYMOUS EXTERNAL ) ( edit-pipeline ) ) ) + ( success ( 1 2 ( ANONYMOUS EXTERNAL ) ( edit-pipeline ) ) ) If there is a failure, run ``plink`` with ``-v`` to analyse the problem. @@ -239,20 +238,20 @@ What configuration settings should I use? -------------------------------------------------------------------------------- +----------------------------------------- Make sure the following settings are in your Subversion config file (``~/.subversion/config`` under UNIX):: - [miscellany] - enable-auto-props = yes + [miscellany] + enable-auto-props = yes - [auto-props] - * = svn:eol-style=native - *.c = svn:keywords=Id - *.h = svn:keywords=Id - *.py = svn:keywords=Id - *.txt = svn:keywords=Author Date Id Revision + [auto-props] + * = svn:eol-style=native + *.c = svn:keywords=Id + *.h = svn:keywords=Id + *.py = svn:keywords=Id + *.txt = svn:keywords=Author Date Id Revision The ``[auto-props]`` line specifies the beginning of the section in the config file. The ``svn:eol-style`` setting tells Subversion to check out files using @@ -270,112 +269,107 @@ How do I add a file or directory to the repository? -------------------------------------------------------------------------------- +--------------------------------------------------- -Simply specify the path to the file or directory to add and run:: +Simply specify the path to the file or directory to add and run :: - svn add PATH + svn add PATH -Subversion will skip any directories it already knows about. But if -you want new files that exist in any directories specified in ``PATH``, specify +Subversion will skip any directories it already knows about. But if you want +new files that exist in any directories specified in ``PATH``, specify ``--force`` and Subversion will check *all* directories for new files. -You will then need to run ``svn commit`` (as discussed in -`How do I commit a change to a file?`_) to commit the file to the repository. +You will then need to run ``svn commit`` (as discussed in `How do I commit a +change to a file?`_) to commit the file to the repository. How do I commit a change to a file? -------------------------------------------------------------------------------- +----------------------------------- To have any changes to a file (which include adding a new file or deleting an -existing one), you use the command:: +existing one), you use the command :: - svn commit [PATH] + svn commit [PATH] -Although ``[PATH]`` is optional, if PATH is omitted all changes -in your local copy will be committed to the repository. -**DO NOT USE THIS!!!** You should specify the specific files -to be committed unless you are *absolutely* positive that -*all outstanding modifications* are meant to go in this commit. +Although ``[PATH]`` is optional, if PATH is omitted all changes in your local +copy will be committed to the repository. **DO NOT USE THIS!!!** You should +specify the specific files to be committed unless you are *absolutely* positive +that *all outstanding modifications* are meant to go in this commit. To abort a commit that you are in the middle of, perform a commit with no message (i.e., close the text editor without adding any text for the message). Subversion will ask if you want to abort the commit or not at that point. -If you do not like the default text editor Subversion uses for -entering commmit messages, you may specify a different editor -in your Subversion config file with the -``editor-cmd`` option in the ``[helpers]`` section. +If you do not like the default text editor Subversion uses for entering commmit +messages, you may specify a different editor in your Subversion config file with +the ``editor-cmd`` option in the ``[helpers]`` section. How do I delete a file or directory in the repository? -------------------------------------------------------------------------------- +------------------------------------------------------ -Specify the path to be removed with:: +Specify the path to be removed with :: - svn delete PATH + svn delete PATH -Any modified files or files that are not checked in will not be deleted -in the working copy on your machine. +Any modified files or files that are not checked in will not be deleted in the +working copy on your machine. What files are modified locally in my working copy? -------------------------------------------------------------------------------- +--------------------------------------------------- -Running:: +Running :: - svn status [PATH] + svn status [PATH] will list any differences between your working copy and the repository. Some key indicators that can appear in the first column of output are: = =========================== A Scheduled to be added - D Scheduled to be deleted - M Modified locally - ? Not under version control = =========================== How do I find out what Subversions properties are set for a file or directory? -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ :: - svn proplist PATH + svn proplist PATH How do I revert a file I have modified back to the version in the respository? -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ -Running:: +Running :: - svn revert PATH + svn revert PATH will change ``PATH`` to match the version in the repository, throwing away any -changes you made locally. If you run:: +changes you made locally. If you run :: svn revert -R . -from the root of your local repository it will recursively restore everything -to match up with the main server. +from the root of your local repository it will recursively restore everything to +match up with the main server. How do I find out who edited or what revision changed a line last? -------------------------------------------------------------------------------- +------------------------------------------------------------------ You want:: - svn blame PATH + svn blame PATH This will output to stdout every line of the file along with what revision number last touched that line and who committed that revision. Since it is printed to stdout, you probably want to pipe the output to a pager:: - svn blame PATH | less + svn blame PATH | less How can I see a list of log messages for a file or specific revision? @@ -383,144 +377,141 @@ To see the log messages for a specific file, run:: - svn log PATH + svn log PATH That will list all messages that pertain to the file specified in ``PATH``. If you want to view the log message for a specific revision, run:: - svn log --verbose -r REV + svn log --verbose -r REV With ``REV`` substituted with the revision number. The ``--verbose`` flag should be used to get a listing of all files modified in that revision. How can I edit the log message of a committed revision? -------------------------------------------------------------------------------- +------------------------------------------------------- Use:: - svn propedit -r --revprop svn:log + svn propedit -r --revprop svn:log Replace ```` with the revision number of the commit whose log message you wish to change. How do I get a diff between the repository and my working copy for a file? -------------------------------------------------------------------------------- +-------------------------------------------------------------------------- The diff between your working copy and what is in the repository can be had with:: - svn diff PATH + svn diff PATH -This will work off the current revision in the repository. To diff your -working copy with a specific revision, do:: +This will work off the current revision in the repository. To diff your working +copy with a specific revision, do:: - svn diff -r REV PATH + svn diff -r REV PATH Finally, to generate a diff between two specific revisions, use:: - svn diff -r REV1:REV2 PATH + svn diff -r REV1:REV2 PATH Notice the ``:`` between ``REV1`` and ``REV2``. How do I undo the changes made in a recent committal? -------------------------------------------------------------------------------- +----------------------------------------------------- Assuming your bad revision is ``NEW`` and ``OLD`` is the equivalent of ``NEW - 1``, then run:: - svn merge -r NEW:OLD PATH + svn merge -r NEW:OLD PATH -This will revert *all* files back to their state in revision ``OLD``. -The reason that ``OLD`` is just ``NEW - 1`` is you do not want files to be +This will revert *all* files back to their state in revision ``OLD``. The +reason that ``OLD`` is just ``NEW - 1`` is you do not want files to be accidentally reverted to a state older than your changes, just to the point prior. -Note: PATH here refers to the top of the checked out repository, -not the full pathname to a file. PATH can refer to a different -branch when merging from the head, but it must still be the top -and not an individual file or subdirectory. +Note: PATH here refers to the top of the checked out repository, not the full +pathname to a file. PATH can refer to a different branch when merging from the +head, but it must still be the top and not an individual file or subdirectory. How do I update to a specific release tag? -------------------------------------------------------------------------------- +------------------------------------------ Run:: - svn list svn+ssh://pythondev at svn.python.org/python/tags + svn list svn+ssh://pythondev at svn.python.org/python/tags -or visit:: +or visit - http://svn.python.org/view/python/tags/ + http://svn.python.org/view/python/tags/ to get a list of tags. To switch your current sandbox to a specific tag, run:: - svn switch svn+ssh://pythondev at svn.python.org/python/tags/r242 + svn switch svn+ssh://pythondev at svn.python.org/python/tags/r242 -To just update to the revision corresponding to that tag without changing -the metadata for the repository, note the revision number corresponding to -the tag of interest and update to it, e.g.:: +To just update to the revision corresponding to that tag without changing the +metadata for the repository, note the revision number corresponding to the tag +of interest and update to it, e.g.:: - svn update -r 39619 + svn update -r 39619 What you probably want though, is the switch that sandbox to the tag's url:: - svn switch svn+ssh://pythondev at svn.python.org/python/tags/r242 + svn switch svn+ssh://pythondev at svn.python.org/python/tags/r242 Why should I use ``svn switch``? -------------------------------------------------------------------------------- +-------------------------------- -You might find this small treatise by Giovanni Bajo in python-dev on the -``svn switch`` command helpful: +You might find this small treatise by Giovanni Bajo in python-dev on the ``svn +switch`` command helpful: -If you realize that each file/directory in Subversion is uniquely identified -by a 2-space coordinate system [URL, revision] (given a checkout, you can -use "svn info" to get its coordinates), then we can say that "svn up -r N" -(for some revision number N) keeps the url unchanged and changes the -revision to whatever number you specified. In other words, you get the -state of the working copy URL at the time revision N was created. For -instance, if you execute it with revision 39619 within the trunk working -copy, you will get the trunk at the moment 2.4.2 was released. +If you realize that each file/directory in Subversion is uniquely identified by +a 2-space coordinate system [URL, revision] (given a checkout, you can use "svn +info" to get its coordinates), then we can say that "svn up -r N" (for some +revision number N) keeps the url unchanged and changes the revision to whatever +number you specified. In other words, you get the state of the working copy URL +at the time revision N was created. For instance, if you execute it with +revision 39619 within the trunk working copy, you will get the trunk at the +moment 2.4.2 was released. On the other hand, "svn switch" moves the URL: it basically "moves" your -checkout from [old_URL, revision] to [new_URL, HEAD], downloading the -minimal set of diffs to do so. If the new_URL is a tag URL -(e.g. .../tags/r242), it means any revision is good, since nobody is going -to commit into that directory (it will stay unchanged forever). So -[/tags/r242, HEAD] is the same as any other [/tags/r242, revision] (assuming -of course that /tags/r242 was already created at the time the revision was -created). - -If you want to create a sandbox corresponding to a particular release tag, -use svn switch to switch to [/tags/some_tag, HEAD] if you don't plan on -doing modifications. On the other hand if you want to make modifications to -a particular release branch, use svn switch to change to -[/branches/some_branch, HEAD]. +checkout from [old_URL, revision] to [new_URL, HEAD], downloading the minimal +set of diffs to do so. If the new_URL is a tag URL (e.g. .../tags/r242), it +means any revision is good, since nobody is going to commit into that directory +(it will stay unchanged forever). So [/tags/r242, HEAD] is the same as any +other [/tags/r242, revision] (assuming of course that /tags/r242 was already +created at the time the revision was created). + +If you want to create a sandbox corresponding to a particular release tag, use +svn switch to switch to [/tags/some_tag, HEAD] if you don't plan on doing +modifications. On the other hand if you want to make modifications to a +particular release branch, use svn switch to change to [/branches/some_branch, +HEAD]. How do I create a branch? ------------------------- -The best way is to do a server-side copy by specifying the URL for the source -of the branch, and the eventual destination URL for the new branch:: +The best way is to do a server-side copy by specifying the URL for the source of +the branch, and the eventual destination URL for the new branch:: - svn copy SRC_URL DEST_URL + svn copy SRC_URL DEST_URL You can then checkout your branch as normal. You will want to prepare your -branch for future merging from the source branch so as to keep them in sync. -To find out how to do that, read `How do I merge between branches?`_. +branch for future merging from the source branch so as to keep them in sync. To +find out how to do that, read `How do I merge between branches?`_. What tools do I need to merge between branches? ----------------------------------------------- -You need `svnmerge.py -`__. +You need `svnmerge.py `_. How do I prepare a new branch for merging? @@ -529,7 +520,7 @@ You need to initialize a new branch by having ``svnmerge.py`` discover the revision number that the branch was created with. Do this with the command:: - svnmerge.py init + svnmerge.py init Then check in the change to the root of the branch. This is a one-time operation. @@ -539,47 +530,47 @@ -------------------------------- In the current situation for Python there are four branches under development, -meaning that there are three branches to merge into. Assuming a change is -committed into ``trunk`` as revision 0001, you merge into the 2.x maintenance -by doing:: - - # In the 2.x maintenance branch checkout. - svnmerge.py merge -r 0001 - svn commit -F svnmerge-commit-message.txt # r0002 +meaning that there are three branches to merge into. Assuming a change is +committed into ``trunk`` as revision 0001, you merge into the 2.x maintenance by +doing:: + + # In the 2.x maintenance branch checkout. + svnmerge.py merge -r 0001 + svn commit -F svnmerge-commit-message.txt # r0002 To pull into py3k:: - # In a py3k checkout. - svnmerge.py merge -r 0001 - svn commit -F svnmerge-commit-message.txt # r0003 + # In a py3k checkout. + svnmerge.py merge -r 0001 + svn commit -F svnmerge-commit-message.txt # r0003 The 3.x maintenance branch is a special case as you must pull from the py3k branch revision, *not* trunk:: - # In a 3.x maintenance checkout. - svnmerge.py merge -r 0003 # Notice the rev is the one from py3k! - svn resolved . - svn commit -F svnmerge-commit-message.txt + # In a 3.x maintenance checkout. + svnmerge.py merge -r 0003 # Notice the rev is the one from py3k! + svn resolved . + svn commit -F svnmerge-commit-message.txt How do I block a specific revision from being merged into a branch? ------------------------------------------------------------------- -With the revision number that you want to block handy and ``svnmerge.py``, go -to your checkout of the branch where you want to block the revision and run:: +With the revision number that you want to block handy and ``svnmerge.py``, go to +your checkout of the branch where you want to block the revision and run:: - svnmerge.py block -r + svnmerge.py block -r This will modify the repository's top directory (which should be your current -directory) and create ``svnmerge-commit-message.txt`` which contains a -generated log message. +directory) and create ``svnmerge-commit-message.txt`` which contains a generated +log message. If the command says "no available revisions to block", then it means someone already merged the revision. To check in the new metadata, run:: - svn ci -F svnmerge-commit-message.txt + svn ci -F svnmerge-commit-message.txt How do I include an external svn repository (external definition) in the repository? @@ -593,29 +584,29 @@ directory you need to edit the ``svn:externals`` property on the root of the repository you are working with using the format of:: - local_directory remote_repositories_http_address + local_directory remote_repositories_http_address For instance, to include Python's sandbox repository in the 'sandbox' directory of your repository, run ``svn propedit svn:externals .`` while in the root of your repository and enter:: - sandbox http://svn.python.org/projects/sandbox/trunk/ + sandbox http://svn.python.org/projects/sandbox/trunk/ in your text editor. The next time you run ``svn update`` it will pull in the external definition. How can I create a directory in the sandbox? ------------------------------------------------------------------------------- +-------------------------------------------- Assuming you have commit privileges and you do not already have a complete checkout of the sandbox itself, the easiest way is to use svn's ``mkdir`` command:: - svn mkdir svn+ssh://pythondev at svn.python.org/sandbox/trunk/ + svn mkdir svn+ssh://pythondev at svn.python.org/sandbox/trunk/ -That command will create the new directory on the server. To gain access to -the new directory you then checkout it out (substitute ``mkdir`` in the command +That command will create the new directory on the server. To gain access to the +new directory you then checkout it out (substitute ``mkdir`` in the command above with ``checkout``). If you already have a complete checkout of the sandbox then you can just use @@ -623,153 +614,154 @@ SSH -======= +=== How do I generate an SSH 2 public key? -------------------------------------------------------------------------------- +-------------------------------------- All generated SSH keys should be sent to pydotorg for adding to the list of keys. UNIX -''''''''''''''''''' +'''' Run:: - ssh-keygen -t rsa + ssh-keygen -t rsa This will generate a two files; your public key and your private key. Your public key is the file ending in ``.pub``. Windows -''''''''''''''''''' +''''''' Use PuTTYgen to generate your public key. Choose the "SSH2 DSA" radio button, have it create an OpenSSH formatted key, choose a password, and save the private key to a file. Copy the section with the public key (using Alt-P) to a file; that file now has your public key. + Is there a way to prevent from having to enter my password for my SSH 2 public key constantly? ------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------- UNIX -''''''''''''''''''' +'''' -Use ``ssh-agent`` and ``ssh-add`` to register your private key with SSH for -your current session. The simplest solution, though, is to use KeyChain_, -which is a shell script that will handle ``ssh-agent`` and ``ssh-add`` for you -once per login instead of per session. +Use ``ssh-agent`` and ``ssh-add`` to register your private key with SSH for your +current session. The simplest solution, though, is to use KeyChain_, which is a +shell script that will handle ``ssh-agent`` and ``ssh-add`` for you once per +login instead of per session. .. _KeyChain: http://www.gentoo.org/proj/en/keychain/ Windows -''''''''''''''''''' +''''''' Running Pageant will prevent you from having to type your password constantly. If you add a shortcut to Pageant to your Autostart group and edit the shortcut so that the command line includes an argument to your private key then Pageant will load the key every time you log in. + Can I make check-ins from machines other than the one I generated the keys on? ------------------------------------------------------------------------------ -Yes, all you need is to make sure that the machine you want to check -in code from has both the public and private keys in the standard -place that ssh will look for them (i.e. ~/.ssh on Unix machines). -Please note that although the key file ending in .pub contains your -user name and machine name in it, that information is not used by the -verification process, therefore these key files can be moved to a -different computer and used for verification. Please guard your keys -and never share your private key with anyone. If you lose the media -on which your keys are stored or the machine on which your keys are -stored, be sure to report this to pydotorg at python.org at the same time -that you change your keys. +Yes, all you need is to make sure that the machine you want to check in code +from has both the public and private keys in the standard place that ssh will +look for them (i.e. ``~/.ssh`` on Unix machines). Please note that although the +key file ending in ``.pub`` contains your user name and machine name in it, that +information is not used by the verification process, therefore these key files +can be moved to a different computer and used for verification. Please guard +your keys and never share your private key with anyone. If you lose the media +on which your keys are stored or the machine on which your keys are stored, be +sure to report this to pydotorg at python.org at the same time that you change your +keys. Compilation -===================================================================== +=========== How do I create a debug build of Python? ------------------------------------------ +---------------------------------------- A debug build, sometimes called a "pydebug" build, has extra checks and bits of information to help with developing Python. UNIX -''''''''''''''''''''''' +'''' The basic steps for building Python for development is to configuring it and then compile it. Configuration is typically:: - ./configure --prefix=/dev/null --with-pydebug + ./configure --prefix=/dev/null --with-pydebug More flags are available to ``configure``, but this is the minimum you should -do. This will give you a debug version of Python along with a safety measure -to prevent you from accidentally installing your development version over -your system install. If you are developing on OS X for Python 2.x and will not -be working with the OS X-specific modules from the standard library, then -consider using the ``--without-toolbox-glue`` flag to faster compilation time. - -Once ``configure`` is done, you then need to compile Python.:: - - make -s - -This will build Python with only warnings and errors being printed to -stderr. If you running on a multi-core machine you can use the ``-j`` flag -along with the number of cores your machine has to build Python faster -(e.g. with two cores, you would want ``make -s -j2``). - -Once Python is done building you will then have a working build of Python -that can be run in-place; ``./python`` on most machines, ``./python.exe`` -on OS X. +do. This will give you a debug version of Python along with a safety measure to +prevent you from accidentally installing your development version over your +system install. If you are developing on OS X for Python 2.x and will not be +working with the OS X-specific modules from the standard library, then consider +using the ``--without-toolbox-glue`` flag to faster compilation time. + +Once ``configure`` is done, you then need to compile Python. :: + + make -s + +This will build Python with only warnings and errors being printed to stderr. If +you running on a multi-core machine you can use the ``-j`` flag along with the +number of cores your machine has to build Python faster (e.g. with two cores, +you would want ``make -s -j2``). + +Once Python is done building you will then have a working build of Python that +can be run in-place; ``./python`` on most machines, ``./python.exe`` on OS X. + Windows -''''''''''''''''''''''''' +''''''' -For VC 9 and newer, the ``PCbuild`` directory contains build files you will -care about. For older versions of VC, see the ``PC`` directory. For a free -compiler for Windows, go to http://www.microsoft.com/express/ . +For VC 9 and newer, the ``PCbuild`` directory contains build files you will care +about. For older versions of VC, see the ``PC`` directory. For a free compiler +for Windows, go to http://www.microsoft.com/express/. -To build from the GUI, load the project files and press F7. Make sure to +To build from the GUI, load the project files and press :kbd:`F7`. Make sure to choose the Debug build. If you want to build from the command line, run the ``build_env.bat`` file to get a terminal with proper environment variables. From that terminal, run:: - build.bat -c Debug + build.bat -c Debug -Once built you will want to set Python as a startup project. F5 will +Once built you will want to set Python as a startup project. :kbd:`F5` will launch the interpreter as well as double-clicking the binary. Editors and Tools -===================================================================== +================= What support is included in Python's source code for Vim? --------------------------------------------------------- Within the ``Misc/Vim`` directory you will find two files to help you when -editing Python code. One is ``python.vim``, which is a generated syntax -highlight file for Python code. This file is updated much more frequently as it +editing Python code. One is ``python.vim``, which is a generated syntax +highlight file for Python code. This file is updated much more frequently as it contains syntax highlighting for keywords as they are added to the source tree. See the top of the file to find out how to use the file. The other file for Vim is a vimrc file that supports PEP 7 and 8 coding -standards. All settings are specific to Python and C code and thus will not -affect other settings. There are also some settings which are helpful but -turned off by default at the end of the file if one cares to use non-essential -settings. Once again, see the top of the file to learn how to take advantage of +standards. All settings are specific to Python and C code and thus will not +affect other settings. There are also some settings which are helpful but turned +off by default at the end of the file if one cares to use non-essential +settings. Once again, see the top of the file to learn how to take advantage of the file. What support is included in Python's source code for gdb? ---------------------------------------------------------- -The ``Misc/gdbinit`` file contains several helpful commands that can be added -to your gdb session. You can either copy the commands into your own -``.gdbinit`` file or, if you don't have your own version of the file, simply -symlink ``~/.gdbinit`` to ``Misc/gdbinit``. +The ``Misc/gdbinit`` file contains several helpful commands that can be added to +your gdb session. You can either copy the commands into your own ``.gdbinit`` +file or, if you don't have your own version of the file, simply symlink +``~/.gdbinit`` to ``Misc/gdbinit``. Can I run Valgrind against Python? @@ -778,37 +770,36 @@ Because of how Python uses memory, Valgrind requires setting some supression rules to cut down on the false positives (which still come up, suggesting one typically should know how Python uses memory before running Valgrind against -Python). See ``Misc/README.valgrind`` for more details. +Python). See ``Misc/README.valgrind`` for more details. Patches -===================================================================== +======= How to make a patch? -------------------------- - +-------------------- -If you are using subversion (anonymous or developer) you can use -subversion to make the patches for you. Just edit your local copy and -enter the following command:: +If you are using subversion (anonymous or developer) you can use subversion to +make the patches for you. Just edit your local copy and enter the following +command:: - svn diff | tee ~/name_of_the_patch.diff + svn diff | tee ~/name_of_the_patch.diff Else you can use the diff util which comes with most operating systems (a -Windows version is available as part of the cygwin tools). +Windows version is available as part of the cygwin tools). How do I apply a patch? -------------------------- +----------------------- For the general case, to apply a patch go to the directory that the patch was created from (usually /dist/src/) and run:: - patch -p0 < name_of_the_patch.diff + patch -p0 < name_of_the_patch.diff -The ``-p`` option specifies the number of directory separators ("/" in the -case of UNIX) to remove from the paths of the files in the patch. ``-p0`` -leaves the paths alone. +The ``-p`` option specifies the number of directory separators ("/" in the case +of UNIX) to remove from the paths of the files in the patch. ``-p0`` leaves the +paths alone. How do I undo an applied patch? @@ -816,136 +807,129 @@ Undoing a patch differs from applying one by only a command-line option:: - patch -R -p0 < name_of_the_patch.diff + patch -R -p0 < name_of_the_patch.diff Another option is to have 'patch' create backups of all files by using the -``-b`` command-line option. See the man page for 'patch' on the details of -use. +``-b`` command-line option. See the man page for 'patch' on the details of use. How to submit a patch? ---------------------------- +---------------------- -Please consult the patch submission guidelines at -http://www.python.org/patches/ . +Please consult the patch submission guidelines at +http://www.python.org/patches/. How to test a patch? ------------------------------- +-------------------- -Firstly, you'll need to get a checkout of the source tree you wish to -test the patch against and then build python from this source tree. +Firstly, you'll need to get a checkout of the source tree you wish to test the +patch against and then build python from this source tree. -Once you've done that, you can use Python's extensive regression test -suite to check that the patch hasn't broken anything. +Once you've done that, you can use Python's extensive regression test suite to +check that the patch hasn't broken anything. In general, for thorough testing, use:: - python -m test.regrtest -uall + python -m test.regrtest -uall For typical testing use:: - python -m test.regrtest + python -m test.regrtest For running specific test modules:: - python -m test.regrtest test_mod1 test_mod2 + python -m test.regrtest test_mod1 test_mod2 NB: Enabling the relevant test resources via ``-uall`` or something more -specific is especially important when working on things like the -networking code or the audio support - many of the relevant tests are -skipped by default. - -For more thorough documentation, -read the documentation for the ``test`` package at -http://docs.python.org/library/test.html. - -If you suspect the patch may impact other operating systems, test as -many as you have easy access to. You can get help on alternate -platforms by contacting the people listed on -http://www.python.org/moin/PythonTesters, who have -volunteered to support a particular operating system. +specific is especially important when working on things like the networking code +or the audio support - many of the relevant tests are skipped by default. +For more thorough documentation, read the documentation for the ``test`` package +at http://docs.python.org/library/test.html. -How to change the status of a patch? ------------------------------------------ +If you suspect the patch may impact other operating systems, test as many as you +have easy access to. You can get help on alternate platforms by contacting the +people listed on http://www.python.org/moin/PythonTesters, who have volunteered +to support a particular operating system. -To change the status of a patch or assign it to somebody else you have to -have the Developer role in the bug tracker. Contact one of the project +How to change the status of a patch? +------------------------------------ + +To change the status of a patch or assign it to somebody else you have to have +the Developer role in the bug tracker. Contact one of the project administrators if the following does not work for you. -Click on the patch itself. In the screen that comes up, there is a drop-box -for "Assigned To:" and a drop-box for "Status:" where you can select a new -responsible developer or a new status respectively. After selecting the -appropriate victim and status, hit the "Submit Changes" button at the bottom -of the page. +Click on the patch itself. In the screen that comes up, there is a drop-box for +"Assigned To:" and a drop-box for "Status:" where you can select a new +responsible developer or a new status respectively. After selecting the +appropriate victim and status, hit the "Submit Changes" button at the bottom of +the page. -Note: If you are sure that you have the right permissions and a drop-box -does not appear, check that you are actually logged in to Roundup! +Note: If you are sure that you have the right permissions and a drop-box does +not appear, check that you are actually logged in to Roundup! Bugs -===================================================================== +==== Where can I submit/view bugs for Python? ---------------------------------------------- +---------------------------------------- - -The Python project uses Roundup for bug tracking. Go to -http://bugs.python.org/ for all bug management needs. You will need to -create a Roundup account for yourself before submitting the first bug -report; anonymous reports have been disabled since it was too -difficult to get in contact with submitters. If you previously -had used SourceForge to report Python bugs, you can use Roundup's +The Python project uses Roundup for bug tracking. Go to http://bugs.python.org/ +for all bug management needs. You will need to create a Roundup account for +yourself before submitting the first bug report; anonymous reports have been +disabled since it was too difficult to get in contact with submitters. If you +previously had used SourceForge to report Python bugs, you can use Roundup's "Lost your login?" link to obtain your Roundup password. .. XXX this is heavily outdated Appendix A ================ - + Issue Manager Guidelines ------------------------------- - + In general, the Resolution and Status fields should be close to self-explanatory, and the "Assigned to:" field should be the person responsible for taking the next step in the patch process. Both fields are expected to change value over the life of a patch; the normal workflow is detailed below. - + When you've got the time and the ability, feel free to move any patch that catches your eye along, whether or not it's been assigned to you. And if you're assigned to a patch but aren't going to take reasonably quick action (for whatever reason), please assign it to someone else ASAP: at those times you can't actively help, actively get out of the way. - + If you're an expert in some area and know that a patch in that area is both needed and non-controversial, just commit your changes directly -- no need then to get the patch mechanism involved in it. - + You should add a comment to every patch assigned to you at least once a week, if only to say that you realize it's still on your plate. This rule is meant to force your attention periodically: patches get harder & harder to deal with the longer they sit. - - + + Status Open, Resolution None ''''''''''''''''''''''''''''''''' - + The initial state of all patches. The patch is under consideration, but has not been reviewed yet, or s under review but not yet Accepted or Rejected. - + The Resolution will normally change to Accepted or Rejected next. The person submitting the patch should (if they can) assign it to the person they most want to review it. - + Else the patch will be assigned via [xxx a list of expertise areas should be developed] [xxx but since this hasn't happened and volunteers are too few, andom assignment is better than nothing: if you're a Python developer, expect to get assigned out of the blue!] - + Discussion of major patches is carried out on the Python-Dev mailing list. For simple patches, the SourceForge comment mechanism should be sufficient. [xxx an email gateway would be great, ditto Ping's Roundup] @@ -953,69 +937,69 @@ change the Resolution to Accepted and assign it back to the submitter (if possible) for checkin. If you're certain the patch should never be accepted, change the Resolution to Rejected, Status to Closed, and assign it to None. - + If you have specific complaints that would cause you to change your mind, explain them clearly in a comment, leave the status Open, and reassign back to the submitter. If you're uncertain, leave the status Open, explain your uncertainties in a comment, and reassign the patch to someone you believe can address your remaining questions; or leave the status Open and bring it up on Python-Dev. - - + + Status Open, Resolution Accepted ''''''''''''''''''''''''''''''''''''' - + The powers that be accepted the patch, but it hasn't been applied yet. [xxx flesh out -- Guido Bottleneck avoidable here?] - + The Status will normally change to Closed next. - + The person changing the Resolution to Accepted should, at the same time, assign the patch to whoever they believe is most likely to be able & willing to apply it (the submitter if possible). - - + + Status Closed, Resolution Accepted ''''''''''''''''''''''''''''''''''''''''' - + The patch has been accepted and applied. - + The previous Resolution was Accepted, or possibly None if the submitter was Guido (or moral equivalent in some particular area of expertise). - + Status Closed, Resolution Rejected ''''''''''''''''''''''''''''''''''''''''' - + The patch has been reviewed and rejected. - + There are generally no transitions out of this state: the patch is dead. - + The person setting this state should also assign the patch to None. - - + + Status Open, Resolution Out of date '''''''''''''''''''''''''''''''''''''''''' - + Previous Resolution was Accepted or Postponed, but the patch no longer works. - + Please enter a comment when changing the Resolution to "Out of date", to record the nature of the problem and the previous state. - + Also assign it back to the submitter, as they need to upload a new version. - - + + Status Open, Resolution Postponed ''''''''''''''''''''''''''''''''''''''''' - + The previous Resolution was None or Accepted, but for some reason (e.g., pending release) the patch should not be reviewed or applied until further notice. - + The Resolution will normally change to None or Accepted next. - + Please enter a comment when changing the Resolution to Postponed, to record the reason, the previous Resolution, and the conditions under which the patch should revert to Resolution None or Accepted. Also assign the patch to whoever is most likely able and willing to decide when the state should change again. - + Modified: sandbox/trunk/dev/index.rst ============================================================================== --- sandbox/trunk/dev/index.rst (original) +++ sandbox/trunk/dev/index.rst Sun Oct 11 22:47:33 2009 @@ -1,7 +1,7 @@ -################################### +##################### Developer's Guide -################################### +##################### :Release: |version| :Date: |today| Modified: sandbox/trunk/dev/patches.rst ============================================================================== --- sandbox/trunk/dev/patches.rst (original) +++ sandbox/trunk/dev/patches.rst Sun Oct 11 22:47:33 2009 @@ -1,60 +1,53 @@ - .. _patch-guidelines: -======================================== +================================== Python Patch Submission Guidelines -======================================== +================================== + +We're using the Roundup bug/issue tracker to track patches. Here are the main +guidelines: + +* Submit your patch to the `issue tracker `_ interface. + You will need to `register with Roundup + `_. You must login before + submitting a patch, or else the 'Create New' link will not appear. + +* Submit documentation patches in the same way. When adding the patch, be sure + to set the "Category" field to "Documentation". + +* Unified diffs are preferred, so generate the patch using ``diff -u``. This is + what Subversion and most other version control systems produce by default. -We're using the Roundup bug/issue tracker to track patches. Here are the -main guidelines: +* Please use forward diffs. That is, use ``diff -u oldfile newfile``, and not + the other way around. -* Submit your patch to the `issue tracker `_ - interface. - You will need to `register with Roundup `_. You must login - before submitting a patch, or else the 'Create New' - link will not appear. - -* Submit documentation patches in the same way. When adding the - patch, be sure to set the "Category" field to - "Documentation". - -* Unified diffs are preferred, so generate the patch using ``diff -u``. - This is what Subversion and most other version control - systems produce by default. - -* Please use forward diffs. That is, use "diff -u oldfile - newfile", and not the other way around. - -* If you send diffs for multiple files, concatenate all the diffs in - a single text file. Please don't produce a zip file with multiple - patches. +* If you send diffs for multiple files, concatenate all the diffs in a single + text file. Please don't produce a zip file with multiple patches. * We appreciate it if you send patches relative to the `current svn tree - `_. These are our - latest sources. Even a patch relative to the latest alpha or beta - release may be out of date. - -* Please add a succinct message to your Roundup entry that - explains the purpose of the patch and can be used as a checkin - message. Ideally, such a message explains the problem and describes - the fix in a few lines. + `_. + These are our latest sources. Even a patch relative to the latest alpha or + beta release may be out of date. + +* Please add a succinct message to your Roundup entry that explains the purpose + of the patch and can be used as a checkin message. Ideally, such a message + explains the problem and describes the fix in a few lines. * For patches that add or change functionality: please also update the - **documentation** and the **testcases** (the ``Lib/test`` - subdirectory). For new modules, we appreciate a new test module - (typically test/test_spam.py). In this case, do not create a - separate issue for the documentation or test cases; having - everything in one issue makes it easier to verify that the bundle is - complete. + **documentation** and the **testcases** (the ``Lib/test`` subdirectory). For + new modules, we appreciate a new test module (typically test/test_spam.py). + In this case, do not create a separate issue for the documentation or test + cases; having everything in one issue makes it easier to verify that the + bundle is complete. * Patches to C code should follow Python's standard style, described in PEP 7, `"Style Guide for C Code" `_. If you're using Emacs to edit your C code, cc-mode supports Python's standard - style for old source files. Run the ``c-set-style`` command and select the 'python' style. - New source files use 4-space indents, not tabs. + style for old source files. Run the ``c-set-style`` command and select the + 'python' style. New source files use 4-space indents, not tabs. -* Code written in Python should follow the conventions - described in PEP 8, `"Style Guide for Python Code" `_. +* Code written in Python should follow the conventions described in PEP 8, + `"Style Guide for Python Code" `_. Modified: sandbox/trunk/dev/process.rst ============================================================================== --- sandbox/trunk/dev/process.rst (original) +++ sandbox/trunk/dev/process.rst Sun Oct 11 22:47:33 2009 @@ -1,117 +1,108 @@ -============================== +============================ Python's Development Process -============================== +============================ -Guido van Rossum is the project's lead developer. In recognition -of this role, he's sometimes jokingly called the Benevolent Dictator -For Life, or BDFL; the acronym is occasionally used in python-dev -postings, especially in a context such as "making that change will -require a BDFL pronouncement". In theory the BDFL makes all the -decisions about what goes in to Python and what doesn't. In practice, -Guido will often defer to someone else's expertise in a specialized -domain; for example, Tim Peters is the resident master of floating -point arcana, Jeremy Hylton usually wrestles the Python compiler, and -so forth. Modules in the standard library are also often the -responsibility of a particular individual who's the first choice to -review patches or fix bugs in it, but anyone can modify any line of -code at any time, and simple, obviously correct fixes can be applied -by anyone. - -An informal voting process is sometimes followed on python-dev. -People will sometimes post their votes in response to a suggestion, -giving them as +1, -1, +0, or -0. This numbering comes from `the voting scheme used by Apache `_: +Guido van Rossum is the project's lead developer. In recognition of this role, +he's sometimes jokingly called the Benevolent Dictator For Life, or BDFL; the +acronym is occasionally used in python-dev postings, especially in a context +such as "making that change will require a BDFL pronouncement". In theory the +BDFL makes all the decisions about what goes in to Python and what doesn't. In +practice, Guido will often defer to someone else's expertise in a specialized +domain; for example, Tim Peters is the resident master of floating point arcana, +Jeremy Hylton usually wrestles the Python compiler, and so forth. Modules in +the standard library are also often the responsibility of a particular +individual who's the first choice to review patches or fix bugs in it, but +anyone can modify any line of code at any time, and simple, obviously correct +fixes can be applied by anyone. + +An informal voting process is sometimes followed on python-dev. People will +sometimes post their votes in response to a suggestion, giving them as +1, -1, ++0, or -0. This numbering comes from `the voting scheme used by Apache +`_: * +1 indicates that the poster is in favor of the suggestion. * -1 indicates they're against it. * +0 indicates "I don't care, but go ahead". - * -0 means "I don't care, so why bother?". + * -0 means "I don't care, so why bother?". + +In the Apache project, this voting is formalized and is how binding project +decisions are made, but in Python it's just a concise way to express opinions in +a straw poll and the result isn't binding in any way. The BDFL will take note +of the reaction to a proposal, but is free to ignore it. While the BDFL could +completely ignore community reaction, I can't think of an instance where he's +actually done so in the face of united disapproval by the community. The +closest case to that might be the ``print >>`` statement, where everyone turned +out to be divided 50/50 between liking it and hating it. Guido exercised his +right to decide, and the feature was added to the language in Python 2.0. Some +people still hate it; some people who first argued against it have now grown +sneakily fond of it. -In the Apache project, this -voting is formalized and is how binding project decisions are made, -but in -Python it's just a concise way to express opinions in a straw poll -and the result isn't binding in any way. The BDFL will take note of -the reaction to a proposal, but is free to ignore it. While the BDFL -could completely ignore community reaction, I can't think of an instance -where he's actually done so in the face of united disapproval by the -community. The closest case to that might be the ``print >>`` -statement, where everyone turned out to be divided 50/50 between -liking it and hating it. Guido exercised his right to decide, and -the feature was added to the language in Python 2.0. Some people -still hate it; some people who first argued against it have now grown -sneakily fond of it. PEPs -============== +==== +Because Python is a programming language and there are a few million lines of +Python code in the world, the development process has to impose some rigidity +and provide some resistance against accepting changes too easily. Users have +Python code, extension modules written in C, and applications that embed Python, +so it's important that the inconvenience of upgrading to new versions of Python +is minimized. Language changes might also make the language too difficult for +new users to learn. + +As a way to ensure that changes are carefully considered, significant changes +*must* be described in a Python Enhancement Proposal, or PEP. PEPs are modelled +on the Request For Comments documents used by the Internet Engineering Task +Force, and describe a proposed change by giving fairly complete documentation +for it and a design rationale. PEPS also record the community's consensus about +a feature, because the PEP's author must take note of people's comments and +incorporate their feedback. PEPs are especially important if the suggested +feature gets rejected, because the same ideas often come back again and again, +resulting in lengthy discussion threads that always arrive at the same outcome. +(For example, ideas such as not using indentation, adding a *with* statement, or +support for interfaces often come up again and again.) Like a FAQ, which tries +to reduce newsgroup traffic by answering questions before they're asked, PEPs +try to reduce repeated suggestions. + +All the PEPs are available online at http://www.python.org/dev/peps/. PEP 1, +`PEP Purpose and Guidelines `_ explains +the purpose of PEPs, their life cycle, and the prescribed format for a PEP. +Read it before beginning to write a PEP. -Because Python is a programming language and there are a few -million lines of Python code in the world, the development process has -to impose some rigidity and provide some resistance against accepting -changes too easily. Users have Python code, extension modules written -in C, and applications that embed Python, so it's important that the -inconvenience of upgrading to new versions of Python is minimized. -Language changes might also make the language too difficult for new -users to learn. - -As a way to ensure that changes are carefully considered, -significant changes *must* be described in a Python Enhancement -Proposal, or PEP. PEPs are modelled on the Request For Comments -documents used by the Internet Engineering Task Force, and describe a -proposed change by giving fairly complete documentation for it and a -design rationale. PEPS also record the community's consensus about a -feature, because the PEP's author must take note of people's comments -and incorporate their feedback. PEPs are especially important if the -suggested feature gets rejected, because the same ideas often come -back again and again, resulting in lengthy discussion threads that -always arrive at the same outcome. (For example, ideas such as not -using indentation, adding a *with* statement, or support for -interfaces often come up again and again.) Like a FAQ, which tries to -reduce newsgroup traffic by answering questions before they're asked, -PEPs try to reduce repeated suggestions. - -All the PEPs are available online at `http://www.python.org/dev/peps/ `_. -PEP 1, `PEP Purpose and Guidelines `_ explains the purpose of PEPs, their life -cycle, and the prescribed format for a PEP. Read it before beginning -to write a PEP. Documenting Python -============================ - +================== -Any significant additions to the Python core must be accompanied by -supporting patches for the documentation. Python's documentation is, -as of version 2.6, written using `docutils`_\' reStructuredText and an -accompanying builder application that converts the source to -PDF, HTML, or PostScript. Georg Brandl, the author of the builder, -has written the new `"Documenting Python" `_, -containing a quick introduction to reStructuredText and a guide to -the Python-specific markup. - -You should also write helpful docstrings for modules, because the -`pydoc `_ -module provides online help generated from module docstrings. Writing -docstrings is therefore an easy way to make life easier for users. +Any significant additions to the Python core must be accompanied by supporting +patches for the documentation. Python's documentation is, as of version 2.6, +written using `docutils`_\' reStructuredText and an accompanying builder +application that converts the source to PDF, HTML, or PostScript. Georg Brandl, +the author of the builder, has written the new `"Documenting Python" +`_, containing a quick introduction to +reStructuredText and a guide to the Python-specific markup. + +You should also write helpful docstrings for modules, because the `pydoc +`_ module provides online help generated +from module docstrings. Writing docstrings is therefore an easy way to make +life easier for users. .. _docutils: http://docutils.sf.net/ Recording Change -========================== - +================ -The file Misc/NEWS is the traditional place to record all changes to -the Python code. This file is intended to be a complete record of changes -between versions, and therefore useful for (among other purposes) finding -the source of compatibility issues. - -Misc/NEWS is also scanned before each release as the source of the -"What's new in Python X.Y" documents, created from whatsnewXY.tex. -This document is a fuller description of only the more significant -changes to the language. Developers are welcome to add descriptions -of their own changes to whatsnewXY.tex, but not at the expense of -omitting change descriptions in Misc/NEWS. +The file ``Misc/NEWS`` is the traditional place to record all changes to the +Python code. This file is intended to be a complete record of changes between +versions, and therefore useful for (among other purposes) finding the source of +compatibility issues. + +``Misc/NEWS`` is also scanned before each release as the source of the "What's +new in Python X.Y" documents, created from ``Doc/whatsnew/X.Y.rst``. This +document is a fuller description of only the more significant changes to the +language. Developers are welcome to add descriptions of their own changes to +``whatsnew/X.Y.rst``, but not at the expense of omitting change descriptions in +``Misc/NEWS``. -If you only have time to do one thing, record your changes in the -Misc/NEWS file. +If you only have time to do one thing, record your changes in the ``Misc/NEWS`` +file. Modified: sandbox/trunk/dev/setup.rst ============================================================================== --- sandbox/trunk/dev/setup.rst (original) +++ sandbox/trunk/dev/setup.rst Sun Oct 11 22:47:33 2009 @@ -1,14 +1,12 @@ -================================================== +================================ Setting Up for Developing Python -================================================== +================================ - -This document is meant to help you set up your tools, get the source -code to Python, compile it for debugging, and learn the basic -directory structure of the source code. For organizational purposes, -details of the tools needed to work with the Python source code are -kept in the `dev FAQ`_, so you will probably want to have it easily -available as you read this document. +This document is meant to help you set up your tools, get the source code to +Python, compile it for debugging, and learn the basic directory structure of the +source code. For organizational purposes, details of the tools needed to work +with the Python source code are kept in the `dev FAQ`_, so you will probably +want to have it easily available as you read this document. .. contents:: @@ -18,28 +16,28 @@ Checking out the code ===================== -Python always has the in-development version of the current major versions -along with the last minor release of each major version. For instance, if -Python 2.6 was the latest release (and thus has a major version of *2* and a -minor version of *6*), then the in-development 2.7 branch is available along -with the maintenance branch for 2.6. - +Python always has the in-development version of the current major versions along +with the last minor release of each major version. For instance, if Python 2.6 +was the latest release (and thus has a major version of *2* and a minor version +of *6*), then the in-development 2.7 branch is available along with the +maintenance branch for 2.6. + For each branch there is read-only access for the general public and read-write -access for those with commit privileges (called "core developers"). The -location of these branches and the steps to check out the code are listed in -the `dev FAQ`_. +access for those with commit privileges (called "core developers"). The +location of these branches and the steps to check out the code are listed in the +`dev FAQ`_. Compiling for debugging ======================= -Python has two features to aid in developing for it. First, there is a +Python has two features to aid in developing for it. First, there is a ``Py_DEBUG`` compilation flag which turns on some features in the interpreter -which will help with debugging. While this is not the only compilation flag +which will help with debugging. While this is not the only compilation flag available (see ``Misc/SpecialBuilds.txt`` in a checkout for all of them), it is the basic one that you should always use as it tends to catch bugs more often than running a build of Python without the flag. - + The other feature is support for using code directly from a checkout of Python. This is handy as it means you do not need to install your build of Python but can just use the build in-place. It also means that when you edit code in your @@ -51,71 +49,70 @@ Editors and Tools ================== - + Python includes within its source tree some files to help work with various -popular editors and tools. A list of those tools and what is available for them +popular editors and tools. A list of those tools and what is available for them can be found in the `dev FAQ`_. Directory Structure =================== - -There are several top-level directories in the Python source tree. Knowing what + +There are several top-level directories in the Python source tree. Knowing what which one is meant to hold will help you find where a certain piece of -functionality is implemented. Do realize, though, there are always exceptions to -every rule. - +functionality is implemented. Do realize, though, there are always exceptions +to every rule. + ``Demo`` - ??? Example code goes here. This directory is not well-maintained and thus + ??? Example code goes here. This directory is not well-maintained and thus should not be considered best-of-breed in terms how best to accomplish something with the newest version of Python. - + ``Doc`` - ??? The official documentation. This is what http://docs.python.org/ uses. The - tools for building the documentation is kept in another repository. To + ??? The official documentation. This is what http://docs.python.org/ uses. + The tools for building the documentation is kept in another repository. To build the docs, see ``Doc/README.txt``. - + ``Grammar`` ??? Contains the EBNF grammar file for Python. - + ``Include`` ??? Contains all interpreter-wide header files. - + ``Lib`` ??? The part of the standard library implemented in pure Python is here. - + ``Mac`` ??? Mac-specific code for things such as using IDLE as an OS X application. - + ``Misc`` - ??? Things that do not belong elsewhere. Typically this is varying kinds of + ??? Things that do not belong elsewhere. Typically this is varying kinds of documentation. - + ``Modules`` ??? The part of the standard library (plus some other code) that is implemented as extension modules. - + ``Objects`` ??? Code for all built-in types. - + ``PC`` ??? Windows-specific code along with build files for VC 6, 7, & 8 along with OS/2. - + ``PCbuild`` ??? Build files for VC 9 and newer. - + ``Parser`` - ??? Code related to the parser. The definition of the AST nodes is also kept + ??? Code related to the parser. The definition of the AST nodes is also kept here. - + ``Python`` - ??? The code that makes Python run. This includes the compiler, eval loop and + ??? The code that makes Python run. This includes the compiler, eval loop and various built-in modules. - + ``RISCOS`` : Not in Python 3.0 ??? RISC-specific files. - + ``Tools`` Various tools that are (or have been) used to maintain Python. - Modified: sandbox/trunk/dev/tools.rst ============================================================================== --- sandbox/trunk/dev/tools.rst (original) +++ sandbox/trunk/dev/tools.rst Sun Oct 11 22:47:33 2009 @@ -1,152 +1,143 @@ - -==================== +================= Development Tools -==================== - +================= SVN Tree -================== +======== +The Python source code is stored in the Subversion, or SVN, version control +system. -The Python source code is stored in the Subversion, or SVN, version -control system. +Anyone can check out a read-only copy of the source tree by using anonymous SVN. +To check out the tree:: -Anyone can check out a read-only copy of the source tree by using -anonymous SVN. To check out the tree:: + svn co http://svn.python.org/projects/python/trunk python - svn co http://svn.python.org/projects/python/trunk python +Running ``svn update`` will update the tree to the most recent version. Checkin +messages and the accompanying diffs are sent to the `python-checkins +`_ mailing list so that +they can be read and double-checked by the other developers. If you've been +granted write access to the source tree, it's strongly recommended that you +subscribe to this list. -Running ``svn update`` will update the tree to the most recent -version. Checkin messages and the accompanying diffs are sent to the -`python-checkins `_ mailing -list so that they can be read and double-checked by the other -developers. If you've been granted write access to the source tree, -it's strongly recommended that you subscribe to this list. +For information about SVN, see "Version Control with Subversion" at +http://svnbook.red-bean.com/. -For information about SVN, see "Version Control with Subversion" -at http://svnbook.red-bean.com/. Check-in Policies -``````````````````````````` - +----------------- -There's no formal process to gain write access to the Python SVN tree. -If the python-dev team knows who you are, whether through mailing list -discussion, having submitted patches, or some other interaction, then -you may ask for full SVN access and have a reasonable chance of being -accepted. You'll need to have an SSH key and include it with your -request. - -If you're granted SVN write access, you have to follow a few simple -rules. - -* Use the patch manager to submit your first two or three patches for - review before you commit, unless specifically instructed otherwise. - -* Before making a code change, always make sure you've checked out the - most current version. - -* Before checking in a code change, re-run the entire Python test - suite to be sure that you haven't broken anything. To run the - complete test suite, use the following command from the top - directory of the source tree:: - - ./python ./Lib/test/testall.py - -* When fixing a bug, you should add a test case to the test suite - located in ``Lib/test/`` that would have caught this bug. - When adding a whole new class or module, you should add a set of - tests for it. - - If the module you're modifying doesn't have a test suite, create - one, even if it only includes a single test that exercises the - change you're making. Consider writing a larger set of test cases - for the module. - -* If a change affects OS-dependent behavior, run your tests on as - many OSes as you have easy access to. For additional testing, see the - `Python Testers `_ page. - -* When a patch changes behavior or fixes a noteworthy bug, you - should add an entry to the ``Misc/NEWS`` file about the - change. The file is divided into sections for the core and built-ins, - extension modules, the standard library, and accompanying tools, - and a change should be described in the appropriate section. - Optionally you can add a note about the change to the "What's New in - Python" document in ``Doc/whatsnew/``; see the comments at the top - of that file for instructions. - -* Simple or trivial fixes can be just checked in. This is - especially true if it's for code or documentation that you own, but - you can make a change to another person's module; code ownership is - not particularly strict on the Python project. Just be very sure that - your fix is correct and doesn't introduce any incompatibilities. - -* When in doubt, don't commit changes. If you're not sure a - patch is correct or are uncertain about the approach it takes, don't - apply the patch and trust that it'll all get sorted out eventually. - Instead, create a patch in the patch tracker (see below) and discuss - the patch with the other developers until everyone agrees it's - correct. - -* The previous rule applies even more strongly to large patches - that touch many files or make far-reaching changes. The Python source - tree is managed for stability, meaning that if you make a checkout at - a random point in time the tree will almost always compile and be - quite stable. Large sets of changes, such as the 2.2 type/class - rewrite, are usually tested on a branch first and merged into the main - stream of development once they're believed to be complete. - -* Before new releases, code freezes will be announced on - python-dev. Obey them and don't make checkins without getting - approval on the ``python-dev`` list first. +There's no formal process to gain write access to the Python SVN tree. If the +python-dev team knows who you are, whether through mailing list discussion, +having submitted patches, or some other interaction, then you may ask for full +SVN access and have a reasonable chance of being accepted. You'll need to have +an SSH key and include it with your request. + +If you're granted SVN write access, you have to follow a few simple rules. + +* Use the patch manager to submit your first two or three patches for review + before you commit, unless specifically instructed otherwise. + +* Before making a code change, always make sure you've checked out the most + current version. + +* Before checking in a code change, re-run the entire Python test suite to be + sure that you haven't broken anything. To run the complete test suite, use + the following command from the top directory of the source tree :: + + ./python ./Lib/test/regrtest.py + + or just ``make test`` on operating systems that have the ``make`` command. + +* When fixing a bug, you should add a test case to the test suite located in + ``Lib/test/`` that would have caught this bug. When adding a whole new class + or module, you should add a set of tests for it. + + If the module you're modifying doesn't have a test suite, create one, even if + it only includes a single test that exercises the change you're making. + Consider writing a larger set of test cases for the module. + +* If a change affects OS-dependent behavior, run your tests on as many OSes as + you have easy access to. For additional testing, see the `Python Testers + `_ page. + +* When a patch changes behavior or fixes a noteworthy bug, you should add an + entry to the ``Misc/NEWS`` file about the change. The file is divided into + sections for the core and built-ins, extension modules, the standard library, + and accompanying tools, and a change should be described in the appropriate + section. Optionally you can add a note about the change to the "What's New in + Python" document in ``Doc/whatsnew/``; see the comments at the top of that + file for instructions. + +* Simple or trivial fixes can be just checked in. This is especially true if + it's for code or documentation that you own, but you can make a change to + another person's module; code ownership is not particularly strict on the + Python project. Just be very sure that your fix is correct and doesn't + introduce any incompatibilities. + +* When in doubt, don't commit changes. If you're not sure a patch is correct or + are uncertain about the approach it takes, don't apply the patch and trust + that it'll all get sorted out eventually. Instead, create a patch in the + patch tracker (see below) and discuss the patch with the other developers + until everyone agrees it's correct. + +* The previous rule applies even more strongly to large patches that touch many + files or make far-reaching changes. The Python source tree is managed for + stability, meaning that if you make a checkout at a random point in time the + tree will almost always compile and be quite stable. Large sets of changes, + such as the 2.2 type/class rewrite, are usually tested on a branch first and + merged into the main stream of development once they're believed to be + complete. + +* Before new releases, code freezes will be announced on python-dev. Obey them + and don't make checkins without getting approval on the ``python-dev`` list + first. Bug Tracking -====================== +============ -To report a bug in Python, use `the issue tracker -`_. Don't report bugs by posting them to a -mailing list or by sending them to a particular developer as a private -e-mail; most likely the bug will end up buried under later postings -and e-mails and subsequently forgotten. Once a problem is recorded in -the bug tracker, though, it won't get lost. It may sit unchanged for -a while until someone gets around to looking at it, but before -releases someone will go over the outstanding bugs and fix or close -them. PEP 3, -`"Guidelines for Handling Bug Reports" `_ -explains the procedures for handling bugs once they've been reported. +To report a bug in Python, use `the issue tracker `_. +Don't report bugs by posting them to a mailing list or by sending them to a +particular developer as a private e-mail; most likely the bug will end up buried +under later postings and e-mails and subsequently forgotten. Once a problem is +recorded in the bug tracker, though, it won't get lost. It may sit unchanged +for a while until someone gets around to looking at it, but before releases +someone will go over the outstanding bugs and fix or close them. PEP 3, +`"Guidelines for Handling Bug Reports" +`_ explains the procedures for handling +bugs once they've been reported. Patch Tracking -======================== +============== -Just like bugs, and for much the same reasons, patches should be -submitted to the `issue tracker `_, and not posted -to python-dev or e-mailed to people. Often a patch will need some -modification before final acceptance, so be prepared for a -few iterations before the patch is ready to be checked in. +Just like bugs, and for much the same reasons, patches should be submitted to +the `issue tracker `_, and not posted to python-dev or +e-mailed to people. Often a patch will need some modification before final +acceptance, so be prepared for a few iterations before the patch is ready to be +checked in. -For conventions that should be followed when preparing a patch, -see the :ref:`patch-guidelines`. +For conventions that should be followed when preparing a patch, see the +:ref:`patch-guidelines`. URL Redirectors -========================= +=============== The canonical URL of a bug report is - http://bugs.python.org/issue1010 + http://bugs.python.org/issue1010 -This would be the link for bug #1010. A slightly shorter form -is available through a redirect, as simply +This would be the link for bug #1010. A slightly shorter form is available +through a redirect, as simply - http://bugs.python.org/1010 + http://bugs.python.org/1010 -From the time when the issues where tracked at SourceForge, -another redirector is available at +From the time when the issues where tracked at SourceForge, another redirector +is available at - http://www.python.org/sf/1010 + http://www.python.org/sf/1010 -The old URLs using the SF redirector continue to work; URLs -that point at sf.net directly are no longer valid. +The old URLs using the SF redirector continue to work; URLs that point at sf.net +directly are no longer valid. Modified: sandbox/trunk/dev/why.rst ============================================================================== --- sandbox/trunk/dev/why.rst (original) +++ sandbox/trunk/dev/why.rst Sun Oct 11 22:47:33 2009 @@ -1,85 +1,78 @@ -==================== +=================== Why Develop Python? -==================== +=================== Why would you want to work on the Python core interpreter? -* You might be a Python user who wants to make Python more useful - for your purposes. - -* You enjoy hacking on sizable software systems in general, or - perhaps language interpreters in particular. +* You might be a Python user who wants to make Python more useful for your + purposes. -* You want to gain experience as a developer on an open source - project. +* You enjoy hacking on sizable software systems in general, or perhaps language + interpreters in particular. + +* You want to gain experience as a developer on an open source project. From time to time you can see postings in various online forums from - programmers who want to get experience developing a free software - project. Many programmers go off and start their own - project by beginning a new IRC client, mail program, or some similar - application. However, the chances of making a useful contribution - are better if you join an existing sizable project that's already - successful. It'll also be more educational because a - well-established project will teach you skills that aren't called - into play for a smaller project. + programmers who want to get experience developing a free software project. + Many programmers go off and start their own project by beginning a new IRC + client, mail program, or some similar application. However, the chances of + making a useful contribution are better if you join an existing sizable + project that's already successful. It'll also be more educational because a + well-established project will teach you skills that aren't called into play + for a smaller project. Python is an excellent project choice for the following reasons: -* Because Python is a large project, there are many available - tasks suitable for different temperaments and skill levels. If you - enjoy writing prose and explaining things, you can write - documentation. If you can program in Python (and it isn't difficult - to learn), you can work on the library modules, tools, and demo - programs that are included with the Python distribution. If you can - program in C, you can write extension modules or hack on the - interpreter itself. If you'd rather inspect someone else's code - than write your own, you can examine submitted patches or fix bugs. - - You certainly do not have to be a highly skilled wizard who can - rewrite the entire interpreter at the drop of a hat in order to - contribute. There are many things you can do on the spectrum - of tasks ranging from simple to complex ones. - -* First released in 1991, Python's development process is quite mature - at this point. The project has a public Subversion repository, a - coding standard for both C and Python code, a framework for writing - test suites, and infrastructure for tracking bug reports and - submitted patches. A newborn project will have to grow for some - time before it needs such tools, and many projects don't survive - that long. Working on a large project such as Python will show you - how to use these tools effectively in order to work with over 100 - other developers. - -* The most important skill Python can teach is the delicate - skill of working in a diverse group. - - There's a core group of around 115 developers. Roughly 10 of them - are very active, making the majority of commits to the source tree, - and the rest make occasional commits and provide opinions and - advice. Many people outside this core group contribute - significantly, too; bug reports and patches come from core - developers, well-known Python users, and complete strangers. The - list of active members is always shifting because developers have - varying free time, availability, and interests. - - To work with this large and dispersed group, you'll have to learn - who's the right person to answer a question, how to convince the - other developers of the usefulness of a patch, how to offer helpful - criticism, and how to take criticism. - -* C programmers will find that the C source code for the Python - interpreter is clearly written and easy to dive into. It's - straightforward to familiarize yourself with the code, and to begin - writing extensions, making changes, or porting it to a new platform. - -Note that it's possible to do a lot even if you don't know C at all. -Working on the portions of the standard library that are written in -Python is just as valuable for the project and is equally educational -for you. Plus, programming in Python is much more pleasant than -programming in C, because you get nicely formatted tracebacks instead -of crashes and segmentation faults. - -Most of the Python core developers develop on Unix (primarily Linux), -but there are a number of Windows and MacOS programmers. There's -always room for more developers, no matter what platform, so don't -hesitate to jump in. +* Because Python is a large project, there are many available tasks suitable for + different temperaments and skill levels. If you enjoy writing prose and + explaining things, you can write documentation. If you can program in Python + (and it isn't difficult to learn), you can work on the library modules, tools, + and demo programs that are included with the Python distribution. If you can + program in C, you can write extension modules or hack on the interpreter + itself. If you'd rather inspect someone else's code than write your own, you + can examine submitted patches or fix bugs. + + You certainly do not have to be a highly skilled wizard who can rewrite the + entire interpreter at the drop of a hat in order to contribute. There are + many things you can do on the spectrum of tasks ranging from simple to complex + ones. + +* First released in 1991, Python's development process is quite mature at this + point. The project has a public Subversion repository, a coding standard for + both C and Python code, a framework for writing test suites, and + infrastructure for tracking bug reports and submitted patches. A newborn + project will have to grow for some time before it needs such tools, and many + projects don't survive that long. Working on a large project such as Python + will show you how to use these tools effectively in order to work with over + 100 other developers. + +* The most important skill Python can teach is the delicate skill of working in + a diverse group. + + There's a core group of around 115 developers. Roughly 10 of them are very + active, making the majority of commits to the source tree, and the rest make + occasional commits and provide opinions and advice. Many people outside this + core group contribute significantly, too; bug reports and patches come from + core developers, well-known Python users, and complete strangers. The list of + active members is always shifting because developers have varying free time, + availability, and interests. + + To work with this large and dispersed group, you'll have to learn who's the + right person to answer a question, how to convince the other developers of the + usefulness of a patch, how to offer helpful criticism, and how to take + criticism. + +* C programmers will find that the C source code for the Python interpreter is + clearly written and easy to dive into. It's straightforward to familiarize + yourself with the code, and to begin writing extensions, making changes, or + porting it to a new platform. + +Note that it's possible to do a lot even if you don't know C at all. Working on +the portions of the standard library that are written in Python is just as +valuable for the project and is equally educational for you. Plus, programming +in Python is much more pleasant than programming in C, because you get nicely +formatted tracebacks instead of crashes and segmentation faults. + +Most of the Python core developers develop on Unix (primarily Linux), but there +are a number of Windows and MacOS programmers. There's always room for more +developers, no matter what platform, so don't hesitate to jump in. Modified: sandbox/trunk/dev/workflow.rst ============================================================================== --- sandbox/trunk/dev/workflow.rst (original) +++ sandbox/trunk/dev/workflow.rst Sun Oct 11 22:47:33 2009 @@ -1,13 +1,10 @@ - -==================== +============== Issue Workflow -==================== +============== -Below are the typical steps taken to resolve an issue filed on -`issue tracker`_. The section titles match the names -used in the *Stage* field of an issue, -except when in square brackets. It is assumed you have already read -`Getting Set Up`_. +Below are the typical steps taken to resolve an issue filed on `issue tracker`_. +The section titles match the names used in the *Stage* field of an issue, except +when in square brackets. It is assumed you have already read `Getting Set Up`_. .. _issue tracker: http://bugs.python.org/ .. _Getting Set Up: /dev/setup @@ -16,14 +13,14 @@ [New issue] =========== -When you file an issue, the issue should be explained as best as possible. The +When you file an issue, the issue should be explained as best as possible. The more that can be said upfront the faster the issue can be dealt with as there will be less of a chance someone needs more details later on. With the new issue created, emails are sent out to the new-bugs-announce_ and -python-bugs-list_ mailing lists. The former receives a single email for all +python-bugs-list_ mailing lists. The former receives a single email for all created issues while the latter receives an email for any change made to an -issue. This way people who are interested in potentially working on issues are +issue. This way people who are interested in potentially working on issues are quickly and easily notified when issues come in. .. _new-bugs-announce: http://mail.python.org/mailman/listinfo/new-bugs-announce @@ -33,10 +30,9 @@ [triage] ======== -Once a new issue has been created it needs to go through triage. This means all -fields in the issue tracker need to be set properly. Most of the fields -are self-explanatory. The following subsections discuss each field -and its meaning. +Once a new issue has been created it needs to go through triage. This means all +fields in the issue tracker need to be set properly. Most of the fields are +self-explanatory. The following subsections discuss each field and its meaning. Type ---- @@ -67,17 +63,17 @@ Versions -------- -This field represents what versions an issue is known to affect. As -the issue is fixed in various branches, the corresponding version can -be removed from this field in order to make clear what backporting is -still required. +This field represents what versions an issue is known to affect. As the issue +is fixed in various branches, the corresponding version can be removed from this +field in order to make clear what backporting is still required. Priority -------- + release blocker - The next release of Python, whether an alpha or release candidate, - will not happen unless this issue is closed. + The next release of Python, whether an alpha or release candidate, will not + happen unless this issue is closed. deferred blocker While an issue of this priority will not hold up this release, it will hold @@ -95,94 +91,91 @@ In no way critical. low - Simple issues that don't impair usage, - e.g. spelling errors in the documentation. + Simple issues that don't impair usage, e.g. spelling errors in the + documentation. + Nosy list --------- -If a specific developer should look at an issue, it is completely -acceptable to add them to the *Nosy List* without asking for -permission. This is important because not all developers subscribe to -either of the bug announcement lists and thus will not see all updates -to an issue. Adding someone to the nosy list sends them an -email to catch their attention. +If a specific developer should look at an issue, it is completely acceptable to +add them to the *Nosy List* without asking for permission. This is important +because not all developers subscribe to either of the bug announcement lists and +thus will not see all updates to an issue. Adding someone to the nosy list +sends them an email to catch their attention. + Keywords ---------- -For *Keywords*, the **easy** keyword should be set if an issue can be handled -by someone with no deep knowledge of how Python works. Typically this is fixing -shallow bugs, clearing up some semantics, writing tests, etc. These issues can +-------- + +For *Keywords*, the **easy** keyword should be set if an issue can be handled by +someone with no deep knowledge of how Python works. Typically this is fixing +shallow bugs, clearing up some semantics, writing tests, etc. These issues can be solved in a few hours, e.g. within the timespan of a single bug day. -Setting this field is important! Having **easy** issues gives new -developers a way to find issues to work on that will not frustrate -them, and therefore helps provide a gradual introduction to how development -for Python works. +Setting this field is important! Having **easy** issues gives new developers a +way to find issues to work on that will not frustrate them, and therefore helps +provide a gradual introduction to how development for Python works. [Unit] Test needed ================== To help verify an issue is still a problem and have it easily reproduced, an -automated test is needed. The test should be succinct and, if possible, execute -quickly. Every bug fix or semantic change needs some test, whether a completely -new test or a tweak of an existing one. -No new code should ever be committed -without some test to exercise the new code. -Having a test available also makes it easier to verify when a patch fixes -the issue. +automated test is needed. The test should be succinct and, if possible, execute +quickly. Every bug fix or semantic change needs some test, whether a completely +new test or a tweak of an existing one. No new code should ever be committed +without some test to exercise the new code. Having a test available also makes +it easier to verify when a patch fixes the issue. -As with all new code, the style guides of `PEP 8`_ and `PEP 7`_ should be -followed. Tests for modules are in ``Lib/test`` which corresponds to the +As with all new code, the style guides of :pep:`8` and :pep:`7` should be +followed. Tests for modules are in ``Lib/test`` which corresponds to the ``test`` package in Python. For packages, a driver script can be put into ``Lib/test`` that runs tests contained in a subpackage of the package being tested (e.g. tests for the :mod:`email` package are in the `email.test` subpackage). -To run a test, you have two options. One is to execute the test directly -(``./python Lib/test/test_grammar.py``). The other option is to use the +To run a test, you have two options. One is to execute the test directly +(``./python Lib/test/test_grammar.py``). The other option is to use the ``regrtest.py`` test driver which you give the name of the module as contained -in the ``test`` package (``./python Lib/test/regrtest.py test_grammar``). If -you run ``regrtest.py`` without specifying a test then all tests are run. Run +in the ``test`` package (``./python Lib/test/regrtest.py test_grammar``). If +you run ``regrtest.py`` without specifying a test then all tests are run. Run ``regrtest.py`` with the ``-h`` flag to see all of the options it provides, but -the most important is the ``-u`` flag to turn on resource usage. To run +the most important is the ``-u`` flag to turn on resource usage. To run Python's entire test suite, run ``./python Lib/test/regrtest.py -uall``. -Test code can be written using doctest_ or unittest_. Which one is used is left -up to personal preference or what a set of tests for a module is already -written in. For support code beyond what doctest and unittest provide, see -``test.support`` (named ``test.test_support`` in Python 2.x). While not -thoroughly documented on purpose, there is several bits of code in there to -help out with testing. - -.. _PEP 7: http://www.python.org/dev/peps/pep-0007/ -.. _PEP 8: http://www.python.org/dev/peps/pep-0008/ -.. _doctest: http://docs.python.org/dev/library/doctest.html -.. _unittest: http://docs.python.org/dev/library/unittest.html +Test code can be written using doctest_ or unittest_. Which one is used is left +up to personal preference or what a set of tests for a module is already written +in. For support code beyond what doctest and unittest provide, see +``test.support`` (named ``test.test_support`` in Python 2.x). While not +thoroughly documented on purpose, there is several bits of code in there to help +out with testing. + +.. _doctest: http://docs.python.org/library/doctest.html +.. _unittest: http://docs.python.org/library/unittest.html Needs patch =========== -If the issue is a bug, then a patch is needed to fix it. The `PEP 7`_ and -`PEP 8`_ style guides need to be followed. Tests should have already been -written, if needed, by the **test needed** stage. A unified diff is preferred -and should be automatic if you followed the `Getting Set Up`_ docs. +If the issue is a bug, then a patch is needed to fix it. The `PEP 7`_ and `PEP +8`_ style guides need to be followed. Tests should have already been written, +if needed, by the **test needed** stage. A unified diff is preferred and should +be automatic if you followed the `Getting Set Up`_ docs. Any changes need to not only pass their own tests, but also the entire test -suite (``./python Lib/test/regrtest.py -uall``). This makes sure that no +suite (``./python Lib/test/regrtest.py -uall``). This makes sure that no change, no matter how small, does not break other code that may have been relying on old behavior. An issue can end up back at this stage if a pre-existing patch has problems. -Always read the comments on an issue to see what has led to the current state -of the issue. An issue can also seem to belong on this stage if there is a -patch but actually belong to **test needed** because a test is missing. +Always read the comments on an issue to see what has led to the current state of +the issue. An issue can also seem to belong on this stage if there is a patch +but actually belong to **test needed** because a test is missing. -Once a patch is written, it is helpful to also add it to Rietveld_. The code +Once a patch is written, it is helpful to also add it to Rietveld_. The code review tool provides an ``upload.py`` script to help you upload the patch -directly. Simply paste in the link that Rietveld gives you in a message on the +directly. Simply paste in the link that Rietveld gives you in a message on the issue and then reviews of your patch can utilize Rietveld. .. _Rietveld: http://codereview.appspot.com/ @@ -191,38 +184,36 @@ [Docs needed] ============= -If any semantics are changed because of a patch or the issue is to make a -change to the docs then documentation changes are needed. `Documenting Python`_ -specifies how the markup works. How to compile Python's documentation is +If any semantics are changed because of a patch or the issue is to make a change +to the docs then documentation changes are needed. `Documenting Python`_ +specifies how the markup works. How to compile Python's documentation is outlined in the `Getting Set Up` documentation. -.. _Documenting Python: http://docs.python.org/dev/documenting/ +.. _Documenting Python: http://docs.python.org/documenting/ Patch review ============ If an issue reaches this stage then someone believes that the code is ready to -be reviewed for checking. All steps outlined in the other stages should have -been followed: there are tests if needed, all code follows the style -guidelines, the code is of high quality, and any needed docs changes have been -made. There should also be an entry for ``Misc/NEWS`` and ``Misc/ACKS`` as -needed. - -Anyone can comment on an issue that has reached this stage, not just -developers! If you think a change is needed or that the patch looks good then -please say so! +be reviewed for checking. All steps outlined in the other stages should have +been followed: there are tests if needed, all code follows the style guidelines, +the code is of high quality, and any needed docs changes have been made. There +should also be an entry for ``Misc/NEWS`` and ``Misc/ACKS`` as needed. + +Anyone can comment on an issue that has reached this stage, not just developers! +If you think a change is needed or that the patch looks good then please say so! This stage is typically where an issue languishes on the issue tracker. Because there are only so many developers and almost all of them volunteer their free time to work on Python, there is simply not enough collective time to usually -get a patch review done promptly. This does not mean your patch will never be -reviewed or is not appreciated! It simply means people are busy with other -things which include "real life". Please be patient if your patch takes a -while to be reviewed. +get a patch review done promptly. This does not mean your patch will never be +reviewed or is not appreciated! It simply means people are busy with other +things which include "real life". Please be patient if your patch takes a while +to be reviewed. If the OP of the patch didn't do so, feel free to use Rietveld_ for a patch -review. It can greatly simplify the review process for both you and the patch +review. It can greatly simplify the review process for both you and the patch creator. @@ -230,20 +221,20 @@ ============== Setting the stage to this value means that the issue cannot move any forward -without a review by a core developer. This can come up in two situations. +without a review by a core developer. This can come up in two situations. When the next release of Python is a release candidate or a final release, issues need to reviewed by two core developers before being checked in, as this -stage represents. If a patch was written by a core developer than the issue can -skip over the `patch review`_ stage directly to this . But if a patch was done -be a non-core developer it must first pass through the `patch review` stage and -be reviewed by a core developer at that stage as well. This guarantees all new +stage represents. If a patch was written by a core developer than the issue can +skip over the `patch review`_ stage directly to this. But if a patch was done +be a non-core developer it must first pass through the `patch review`_ stage and +be reviewed by a core developer at that stage as well. This guarantees all new code is reviewed by at least two core developers before being committed, preventing any new bugs from slipping into an RC or final release. Another situation is that someone performing triage on an issue notices that a patch has already been properly reviewed by a non-core developer and thus is -ready to be seriously looked at for being applied. By setting a stage to this +ready to be seriously looked at for being applied. By setting a stage to this value should act as a flag to core developers that a patch is as ready as it's going to be for a commit review. @@ -251,5 +242,5 @@ Committed/rejected ================== -At this point the issue is closed. Either it was accepted/fixed or rejected for +At this point the issue is closed. Either it was accepted/fixed or rejected for some reason. From python-checkins at python.org Sun Oct 11 23:03:27 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 11 Oct 2009 21:03:27 -0000 Subject: [Python-checkins] r75367 - in python/trunk: Misc/ACKS Misc/NEWS Objects/listobject.c Message-ID: Author: antoine.pitrou Date: Sun Oct 11 23:03:26 2009 New Revision: 75367 Log: Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. Modified: python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Objects/listobject.c Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Sun Oct 11 23:03:26 2009 @@ -175,6 +175,7 @@ Erik Demaine Roger Dev Raghuram Devarakonda +Scott Dial Toby Dickenson Mark Dickinson Jack Diederich Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 11 23:03:26 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7084: Fix a (very unlikely) crash when printing a list from one + thread, and mutating it from another one. Patch by Scott Dial. + - Issue #1571184: The Unicode database contains properties for more characters. The tables for code points representing numeric values, white spaces or line breaks are now generated from the official Unicode Character Database files, Modified: python/trunk/Objects/listobject.c ============================================================================== --- python/trunk/Objects/listobject.c (original) +++ python/trunk/Objects/listobject.c Sun Oct 11 23:03:26 2009 @@ -319,6 +319,7 @@ { int rc; Py_ssize_t i; + PyObject *item; rc = Py_ReprEnter((PyObject*)op); if (rc != 0) { @@ -333,15 +334,19 @@ fprintf(fp, "["); Py_END_ALLOW_THREADS for (i = 0; i < Py_SIZE(op); i++) { + item = op->ob_item[i]; + Py_INCREF(item); if (i > 0) { Py_BEGIN_ALLOW_THREADS fprintf(fp, ", "); Py_END_ALLOW_THREADS } - if (PyObject_Print(op->ob_item[i], fp, 0) != 0) { + if (PyObject_Print(item, fp, 0) != 0) { + Py_DECREF(item); Py_ReprLeave((PyObject *)op); return -1; } + Py_DECREF(item); } Py_BEGIN_ALLOW_THREADS fprintf(fp, "]"); From python-checkins at python.org Sun Oct 11 23:05:04 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:05:04 -0000 Subject: [Python-checkins] r75368 - in sandbox/trunk/dev: Makefile _templates conf.py faq.rst index.rst workflow.rst Message-ID: Author: georg.brandl Date: Sun Oct 11 23:05:04 2009 New Revision: 75368 Log: Make this a Sphinx project. Added: sandbox/trunk/dev/Makefile (contents, props changed) sandbox/trunk/dev/_templates/ sandbox/trunk/dev/conf.py (contents, props changed) Modified: sandbox/trunk/dev/ (props changed) sandbox/trunk/dev/faq.rst sandbox/trunk/dev/index.rst sandbox/trunk/dev/workflow.rst Added: sandbox/trunk/dev/Makefile ============================================================================== --- (empty file) +++ sandbox/trunk/dev/Makefile Sun Oct 11 23:05:04 2009 @@ -0,0 +1,89 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Pythondeveloper.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Pythondeveloper.qhc" + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." Added: sandbox/trunk/dev/conf.py ============================================================================== --- (empty file) +++ sandbox/trunk/dev/conf.py Sun Oct 11 23:05:04 2009 @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# Python developer documentation build configuration file, created by +# sphinx-quickstart on Sun Oct 11 22:57:56 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Python developer' +copyright = u'2009, Brett Cannon, A.M. Kuchling, Georg Brandl' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.1' +# The full version, including alpha/beta/rc tags. +release = '0.1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +html_title = "Python Developer's Guide" + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Pythondeveloperdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index_', 'Pythondeveloper.tex', u'Python developer Documentation', + u'Brett Cannon, A.M. Kuchling, Georg Brandl', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True Modified: sandbox/trunk/dev/faq.rst ============================================================================== --- sandbox/trunk/dev/faq.rst (original) +++ sandbox/trunk/dev/faq.rst Sun Oct 11 23:05:04 2009 @@ -1,11 +1,7 @@ +================================================ +Frequently Asked Questions for Python Developers +================================================ -:Title: Frequently Asked Questions for Python Developers -:Date: $Date: 2009-07-23 06:21:27 -0400 (Thu, 23 Jul 2009) $ -:Version: $Revision: 10931 $ -:Web site: http://www.python.org/dev/faq/ - -.. contents:: :depth: 3 -.. sectnum:: General Information =================== Modified: sandbox/trunk/dev/index.rst ============================================================================== --- sandbox/trunk/dev/index.rst (original) +++ sandbox/trunk/dev/index.rst Sun Oct 11 23:05:04 2009 @@ -1,13 +1,15 @@ - -##################### - Developer's Guide -##################### +############################ + Python Developer's Guide +############################ :Release: |version| :Date: |today| +XXX introductory blurb XXX + .. toctree:: - :maxdepth: 1 + :maxdepth: 2 + :numbered: why.rst tools.rst Modified: sandbox/trunk/dev/workflow.rst ============================================================================== --- sandbox/trunk/dev/workflow.rst (original) +++ sandbox/trunk/dev/workflow.rst Sun Oct 11 23:05:04 2009 @@ -158,10 +158,10 @@ Needs patch =========== -If the issue is a bug, then a patch is needed to fix it. The `PEP 7`_ and `PEP -8`_ style guides need to be followed. Tests should have already been written, -if needed, by the **test needed** stage. A unified diff is preferred and should -be automatic if you followed the `Getting Set Up`_ docs. +If the issue is a bug, then a patch is needed to fix it. The :pep:`7` and +:pep:`8` style guides need to be followed. Tests should have already been +written, if needed, by the **test needed** stage. A unified diff is preferred +and should be automatic if you followed the `Getting Set Up`_ docs. Any changes need to not only pass their own tests, but also the entire test suite (``./python Lib/test/regrtest.py -uall``). This makes sure that no @@ -218,7 +218,7 @@ Commit review -============== +============= Setting the stage to this value means that the issue cannot move any forward without a review by a core developer. This can come up in two situations. From python-checkins at python.org Sun Oct 11 23:07:02 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 11 Oct 2009 21:07:02 -0000 Subject: [Python-checkins] r75369 - python/branches/py3k Message-ID: Author: antoine.pitrou Date: Sun Oct 11 23:07:02 2009 New Revision: 75369 Log: Blocked revisions 75367 via svnmerge ........ r75367 | antoine.pitrou | 2009-10-11 23:03:26 +0200 (dim., 11 oct. 2009) | 4 lines Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 11 23:10:08 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:10:08 -0000 Subject: [Python-checkins] r75370 - in python/trunk: Misc/HISTORY Misc/NEWS Misc/README Misc/find_recursionlimit.py Tools/scripts/find_recursionlimit.py Message-ID: Author: georg.brandl Date: Sun Oct 11 23:10:07 2009 New Revision: 75370 Log: Move find_recursionlimit.py to Tools/scripts; it is out of place in Misc. Added: python/trunk/Tools/scripts/find_recursionlimit.py - copied unchanged from r75369, /python/trunk/Misc/find_recursionlimit.py Removed: python/trunk/Misc/find_recursionlimit.py Modified: python/trunk/Misc/HISTORY python/trunk/Misc/NEWS python/trunk/Misc/README Modified: python/trunk/Misc/HISTORY ============================================================================== --- python/trunk/Misc/HISTORY (original) +++ python/trunk/Misc/HISTORY Sun Oct 11 23:10:07 2009 @@ -9050,7 +9050,7 @@ Python code. The limit exists to prevent infinite recursion from overflowing the C stack and causing a core dump. The default value is 1000. The maximum safe value for a particular platform can be found -by running Misc/find_recursionlimit.py. +by running Tools/scripts/find_recursionlimit.py. New Modules and Packages ------------------------ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 11 23:10:07 2009 @@ -1566,7 +1566,7 @@ Tools/Demos ----------- -- Issue #3850: recursion tests in Misc/find_recursion_limit.py can raise +- Issue #3850: recursion tests in Tools/scripts/find_recursion_limit.py can raise AttributeError instead of RuntimeError, depending in which C API call exactly the recursion limit is exceeded. Consequently, both exception types are caught and silenced. Modified: python/trunk/Misc/README ============================================================================== --- python/trunk/Misc/README (original) +++ python/trunk/Misc/README Sun Oct 11 23:10:07 2009 @@ -12,7 +12,6 @@ BeOS-NOTES Notes for building on BeOS BeOS-setup.py setup.py replacement for BeOS, see BeOS-NOTES cheatsheet Quick summary of Python by Ken Manheimer -find_recursionlimit.py Script to find a value for sys.maxrecursionlimit gdbinit Handy stuff to put in your .gdbinit file, if you use gdb HISTORY News from previous releases -- oldest last HPUX-NOTES Notes about dynamic loading under HP-UX Deleted: python/trunk/Misc/find_recursionlimit.py ============================================================================== --- python/trunk/Misc/find_recursionlimit.py Sun Oct 11 23:10:07 2009 +++ (empty file) @@ -1,117 +0,0 @@ -#! /usr/bin/env python -"""Find the maximum recursion limit that prevents interpreter termination. - -This script finds the maximum safe recursion limit on a particular -platform. If you need to change the recursion limit on your system, -this script will tell you a safe upper bound. To use the new limit, -call sys.setrecursionlimit(). - -This module implements several ways to create infinite recursion in -Python. Different implementations end up pushing different numbers of -C stack frames, depending on how many calls through Python's abstract -C API occur. - -After each round of tests, it prints a message: -"Limit of NNNN is fine". - -The highest printed value of "NNNN" is therefore the highest potentially -safe limit for your system (which depends on the OS, architecture, but also -the compilation flags). Please note that it is practically impossible to -test all possible recursion paths in the interpreter, so the results of -this test should not be trusted blindly -- although they give a good hint -of which values are reasonable. - -NOTE: When the C stack space allocated by your system is exceeded due -to excessive recursion, exact behaviour depends on the platform, although -the interpreter will always fail in a likely brutal way: either a -segmentation fault, a MemoryError, or just a silent abort. - -NB: A program that does not use __methods__ can set a higher limit. -""" - -import sys -import itertools - -class RecursiveBlowup1: - def __init__(self): - self.__init__() - -def test_init(): - return RecursiveBlowup1() - -class RecursiveBlowup2: - def __repr__(self): - return repr(self) - -def test_repr(): - return repr(RecursiveBlowup2()) - -class RecursiveBlowup4: - def __add__(self, x): - return x + self - -def test_add(): - return RecursiveBlowup4() + RecursiveBlowup4() - -class RecursiveBlowup5: - def __getattr__(self, attr): - return getattr(self, attr) - -def test_getattr(): - return RecursiveBlowup5().attr - -class RecursiveBlowup6: - def __getitem__(self, item): - return self[item - 2] + self[item - 1] - -def test_getitem(): - return RecursiveBlowup6()[5] - -def test_recurse(): - return test_recurse() - -def test_cpickle(_cache={}): - try: - import cPickle - except ImportError: - print "cannot import cPickle, skipped!" - return - l = None - for n in itertools.count(): - try: - l = _cache[n] - continue # Already tried and it works, let's save some time - except KeyError: - for i in range(100): - l = [l] - cPickle.dumps(l, protocol=-1) - _cache[n] = l - -def check_limit(n, test_func_name): - sys.setrecursionlimit(n) - if test_func_name.startswith("test_"): - print test_func_name[5:] - else: - print test_func_name - test_func = globals()[test_func_name] - try: - test_func() - # AttributeError can be raised because of the way e.g. PyDict_GetItem() - # silences all exceptions and returns NULL, which is usually interpreted - # as "missing attribute". - except (RuntimeError, AttributeError): - pass - else: - print "Yikes!" - -limit = 1000 -while 1: - check_limit(limit, "test_recurse") - check_limit(limit, "test_add") - check_limit(limit, "test_repr") - check_limit(limit, "test_init") - check_limit(limit, "test_getattr") - check_limit(limit, "test_getitem") - check_limit(limit, "test_cpickle") - print "Limit of %d is fine" % limit - limit = limit + 100 From python-checkins at python.org Sun Oct 11 23:14:37 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:14:37 -0000 Subject: [Python-checkins] r75371 - python/trunk/Tools/scripts/README Message-ID: Author: georg.brandl Date: Sun Oct 11 23:14:37 2009 New Revision: 75371 Log: Add find_recursionlimit.py to README. Modified: python/trunk/Tools/scripts/README Modified: python/trunk/Tools/scripts/README ============================================================================== --- python/trunk/Tools/scripts/README (original) +++ python/trunk/Tools/scripts/README Sun Oct 11 23:14:37 2009 @@ -19,7 +19,8 @@ diff.py Print file diffs in context, unified, or ndiff formats dutree.py Format du(1) output as a tree sorted by size eptags.py Create Emacs TAGS file for Python modules -finddiv.py A grep-like tool that looks for division operators. +find_recursionlimit.py Find the maximum recursion limit on this machine +finddiv.py A grep-like tool that looks for division operators findlinksto.py Recursively find symbolic links to a given path prefix findnocoding.py Find source files which need an encoding declaration fixcid.py Massive identifier substitution on C source files @@ -28,8 +29,8 @@ fixnotice.py Fix the copyright notice in source files fixps.py Fix Python scripts' first line (if #!) ftpmirror.py FTP mirror script -google.py Open a webbrowser with Google. -gprof2html.py Transform gprof(1) output into useful HTML. +google.py Open a webbrowser with Google +gprof2html.py Transform gprof(1) output into useful HTML h2py.py Translate #define's into Python assignments hotshotmain.py Main program to run script under control of hotshot idle Main program to start IDLE @@ -56,9 +57,9 @@ redemo.py Basic regular expression demonstration facility reindent.py Change .py files to use 4-space indents. rgrep.py Reverse grep through a file (useful for big logfiles) -setup.py Install all scripts listed here. +setup.py Install all scripts listed here suff.py Sort a list of files by suffix -svneol.py Sets svn:eol-style on all files in directory. +svneol.py Sets svn:eol-style on all files in directory texcheck.py Validate Python LaTeX formatting (Raymond Hettinger) texi2html.py Convert GNU texinfo files into HTML treesync.py Synchronize source trees (very ideosyncratic) From python-checkins at python.org Sun Oct 11 23:17:14 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:17:14 -0000 Subject: [Python-checkins] r75372 - python/trunk/Misc/README Message-ID: Author: georg.brandl Date: Sun Oct 11 23:17:14 2009 New Revision: 75372 Log: Update Misc/README. Modified: python/trunk/Misc/README Modified: python/trunk/Misc/README ============================================================================== --- python/trunk/Misc/README (original) +++ python/trunk/Misc/README Sun Oct 11 23:17:14 2009 @@ -11,23 +11,31 @@ AIX-NOTES Notes for building Python on AIX BeOS-NOTES Notes for building on BeOS BeOS-setup.py setup.py replacement for BeOS, see BeOS-NOTES +build.sh Script to build and test latest Python from the repository cheatsheet Quick summary of Python by Ken Manheimer +developers.txt A history of who got developer permissions, and why gdbinit Handy stuff to put in your .gdbinit file, if you use gdb HISTORY News from previous releases -- oldest last -HPUX-NOTES Notes about dynamic loading under HP-UX indent.pro GNU indent profile approximating my C style NEWS News for this release (for some meaning of "this") +NEWS.help How to edit NEWS Porting Mini-FAQ on porting to new platforms PURIFY.README Information for Purify users pymemcompat.h Memory interface compatibility file. python.man UNIX man page for the python interpreter python-mode.el Emacs mode for editing Python programs +python.pc.in Package configuration info template for pkg-config python-wing.wpr Wing IDE project file README The file you're reading now +README.coverity Information about running Coverity's Prevent on Python +README.klocwork Information about running Klocwork's K7 on Python +README.OpenBSD Help for building problems on OpenBSD README.valgrind Information for Valgrind users, see valgrind-python.supp RFD Request For Discussion about a Python newsgroup RPM (Old) tools to build RPMs -SpecialBuilds.txt Describes extra symbols you can set for debug builds setuid-prog.c C helper program for set-uid Python scripts +SpecialBuilds.txt Describes extra symbols you can set for debug builds +TextMate A TextMate bundle for Python development +valgrind-python.supp Valgrind suppression file, see README.valgrind vgrindefs Python configuration for vgrind (a generic pretty printer) -valgrind-python.supp Valgrind suppression file, see README.valgrind +Vim Python development utilities for the Vim editor \ No newline at end of file From python-checkins at python.org Sun Oct 11 23:24:35 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:24:35 -0000 Subject: [Python-checkins] r75373 - in python/branches/py3k: Misc/HISTORY Misc/README Misc/find_recursionlimit.py Tools/scripts/README Tools/scripts/find_recursionlimit.py Message-ID: Author: georg.brandl Date: Sun Oct 11 23:24:34 2009 New Revision: 75373 Log: Merged revisions 75370-75372 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75370 | georg.brandl | 2009-10-11 23:10:07 +0200 (So, 11 Okt 2009) | 1 line Move find_recursionlimit.py to Tools/scripts; it is out of place in Misc. ........ r75371 | georg.brandl | 2009-10-11 23:14:37 +0200 (So, 11 Okt 2009) | 1 line Add find_recursionlimit.py to README. ........ r75372 | georg.brandl | 2009-10-11 23:17:14 +0200 (So, 11 Okt 2009) | 1 line Update Misc/README. ........ Added: python/branches/py3k/Tools/scripts/find_recursionlimit.py - copied, changed from r75372, /python/trunk/Tools/scripts/find_recursionlimit.py Removed: python/branches/py3k/Misc/find_recursionlimit.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/HISTORY python/branches/py3k/Misc/README python/branches/py3k/Tools/scripts/README Modified: python/branches/py3k/Misc/HISTORY ============================================================================== --- python/branches/py3k/Misc/HISTORY (original) +++ python/branches/py3k/Misc/HISTORY Sun Oct 11 23:24:34 2009 @@ -10435,7 +10435,7 @@ Python code. The limit exists to prevent infinite recursion from overflowing the C stack and causing a core dump. The default value is 1000. The maximum safe value for a particular platform can be found -by running Misc/find_recursionlimit.py. +by running Tools/scripts/find_recursionlimit.py. New Modules and Packages ------------------------ Modified: python/branches/py3k/Misc/README ============================================================================== --- python/branches/py3k/Misc/README (original) +++ python/branches/py3k/Misc/README Sun Oct 11 23:24:34 2009 @@ -9,24 +9,32 @@ ACKS Acknowledgements AIX-NOTES Notes for building Python on AIX +build.sh Script to build and test latest Python from the repository cheatsheet Quick summary of Python by Ken Manheimer -find_recursionlimit.py Script to find a value for sys.maxrecursionlimit +developers.txt A history of who got developer permissions, and why gdbinit Handy stuff to put in your .gdbinit file, if you use gdb HISTORY News from previous releases -- oldest last -HPUX-NOTES Notes about dynamic loading under HP-UX indent.pro GNU indent profile approximating my C style +maintainers.txt A list of maintainers for library modules NEWS News for this release (for some meaning of "this") +NEWS.help How to edit NEWS Porting Mini-FAQ on porting to new platforms PURIFY.README Information for Purify users pymemcompat.h Memory interface compatibility file. python.man UNIX man page for the python interpreter python-mode.el Emacs mode for editing Python programs +python.pc.in Package configuration info template for pkg-config python-wing.wpr Wing IDE project file README The file you're reading now +README.coverity Information about running Coverity's Prevent on Python +README.klocwork Information about running Klocwork's K7 on Python +README.OpenBSD Help for building problems on OpenBSD README.valgrind Information for Valgrind users, see valgrind-python.supp RFD Request For Discussion about a Python newsgroup RPM (Old) tools to build RPMs -SpecialBuilds.txt Describes extra symbols you can set for debug builds setuid-prog.c C helper program for set-uid Python scripts +SpecialBuilds.txt Describes extra symbols you can set for debug builds +TextMate A TextMate bundle for Python development +valgrind-python.supp Valgrind suppression file, see README.valgrind vgrindefs Python configuration for vgrind (a generic pretty printer) -valgrind-python.supp Valgrind suppression file, see README.valgrind +Vim Python development utilities for the Vim editor \ No newline at end of file Deleted: python/branches/py3k/Misc/find_recursionlimit.py ============================================================================== --- python/branches/py3k/Misc/find_recursionlimit.py Sun Oct 11 23:24:34 2009 +++ (empty file) @@ -1,118 +0,0 @@ -#! /usr/bin/env python -"""Find the maximum recursion limit that prevents interpreter termination. - -This script finds the maximum safe recursion limit on a particular -platform. If you need to change the recursion limit on your system, -this script will tell you a safe upper bound. To use the new limit, -call sys.setrecursionlimit(). - -This module implements several ways to create infinite recursion in -Python. Different implementations end up pushing different numbers of -C stack frames, depending on how many calls through Python's abstract -C API occur. - -After each round of tests, it prints a message: -"Limit of NNNN is fine". - -The highest printed value of "NNNN" is therefore the highest potentially -safe limit for your system (which depends on the OS, architecture, but also -the compilation flags). Please note that it is practically impossible to -test all possible recursion paths in the interpreter, so the results of -this test should not be trusted blindly -- although they give a good hint -of which values are reasonable. - -NOTE: When the C stack space allocated by your system is exceeded due -to excessive recursion, exact behaviour depends on the platform, although -the interpreter will always fail in a likely brutal way: either a -segmentation fault, a MemoryError, or just a silent abort. - -NB: A program that does not use __methods__ can set a higher limit. -""" - -import sys -import itertools - -class RecursiveBlowup1: - def __init__(self): - self.__init__() - -def test_init(): - return RecursiveBlowup1() - -class RecursiveBlowup2: - def __repr__(self): - return repr(self) - -def test_repr(): - return repr(RecursiveBlowup2()) - -class RecursiveBlowup4: - def __add__(self, x): - return x + self - -def test_add(): - return RecursiveBlowup4() + RecursiveBlowup4() - -class RecursiveBlowup5: - def __getattr__(self, attr): - return getattr(self, attr) - -def test_getattr(): - return RecursiveBlowup5().attr - -class RecursiveBlowup6: - def __getitem__(self, item): - return self[item - 2] + self[item - 1] - -def test_getitem(): - return RecursiveBlowup6()[5] - -def test_recurse(): - return test_recurse() - -def test_cpickle(_cache={}): - import io - try: - import _pickle - except ImportError: - print("cannot import _pickle, skipped!") - return - l = None - for n in itertools.count(): - try: - l = _cache[n] - continue # Already tried and it works, let's save some time - except KeyError: - for i in range(100): - l = [l] - _pickle.Pickler(io.BytesIO(), protocol=-1).dump(l) - _cache[n] = l - -def check_limit(n, test_func_name): - sys.setrecursionlimit(n) - if test_func_name.startswith("test_"): - print(test_func_name[5:]) - else: - print(test_func_name) - test_func = globals()[test_func_name] - try: - test_func() - # AttributeError can be raised because of the way e.g. PyDict_GetItem() - # silences all exceptions and returns NULL, which is usually interpreted - # as "missing attribute". - except (RuntimeError, AttributeError): - pass - else: - print("Yikes!") - -limit = 1000 -while 1: - check_limit(limit, "test_recurse") - check_limit(limit, "test_add") - check_limit(limit, "test_repr") - check_limit(limit, "test_init") - check_limit(limit, "test_getattr") - check_limit(limit, "test_getitem") - check_limit(limit, "test_cpickle") - print("Limit of %d is fine" % limit) - limit = limit + 100 Modified: python/branches/py3k/Tools/scripts/README ============================================================================== --- python/branches/py3k/Tools/scripts/README (original) +++ python/branches/py3k/Tools/scripts/README Sun Oct 11 23:24:34 2009 @@ -19,7 +19,8 @@ diff.py Print file diffs in context, unified, or ndiff formats dutree.py Format du(1) output as a tree sorted by size eptags.py Create Emacs TAGS file for Python modules -finddiv.py A grep-like tool that looks for division operators. +find_recursionlimit.py Find the maximum recursion limit on this machine +finddiv.py A grep-like tool that looks for division operators findlinksto.py Recursively find symbolic links to a given path prefix findnocoding.py Find source files which need an encoding declaration fixcid.py Massive identifier substitution on C source files @@ -28,8 +29,8 @@ fixnotice.py Fix the copyright notice in source files fixps.py Fix Python scripts' first line (if #!) ftpmirror.py FTP mirror script -google.py Open a webbrowser with Google. -gprof2html.py Transform gprof(1) output into useful HTML. +google.py Open a webbrowser with Google +gprof2html.py Transform gprof(1) output into useful HTML h2py.py Translate #define's into Python assignments idle Main program to start IDLE ifdef.py Remove #if(n)def groups from C sources @@ -55,9 +56,9 @@ redemo.py Basic regular expression demonstration facility reindent.py Change .py files to use 4-space indents. rgrep.py Reverse grep through a file (useful for big logfiles) -setup.py Install all scripts listed here. +setup.py Install all scripts listed here suff.py Sort a list of files by suffix -svneol.py Sets svn:eol-style on all files in directory. +svneol.py Sets svn:eol-style on all files in directory texcheck.py Validate Python LaTeX formatting (Raymond Hettinger) texi2html.py Convert GNU texinfo files into HTML treesync.py Synchronize source trees (very ideosyncratic) Copied: python/branches/py3k/Tools/scripts/find_recursionlimit.py (from r75372, /python/trunk/Tools/scripts/find_recursionlimit.py) ============================================================================== --- /python/trunk/Tools/scripts/find_recursionlimit.py (original) +++ python/branches/py3k/Tools/scripts/find_recursionlimit.py Sun Oct 11 23:24:34 2009 @@ -71,10 +71,11 @@ return test_recurse() def test_cpickle(_cache={}): + import io try: - import cPickle + import _pickle except ImportError: - print "cannot import cPickle, skipped!" + print("cannot import _pickle, skipped!") return l = None for n in itertools.count(): @@ -84,15 +85,15 @@ except KeyError: for i in range(100): l = [l] - cPickle.dumps(l, protocol=-1) + _pickle.Pickler(io.BytesIO(), protocol=-1).dump(l) _cache[n] = l def check_limit(n, test_func_name): sys.setrecursionlimit(n) if test_func_name.startswith("test_"): - print test_func_name[5:] + print(test_func_name[5:]) else: - print test_func_name + print(test_func_name) test_func = globals()[test_func_name] try: test_func() @@ -102,7 +103,7 @@ except (RuntimeError, AttributeError): pass else: - print "Yikes!" + print("Yikes!") limit = 1000 while 1: @@ -113,5 +114,5 @@ check_limit(limit, "test_getattr") check_limit(limit, "test_getitem") check_limit(limit, "test_cpickle") - print "Limit of %d is fine" % limit + print("Limit of %d is fine" % limit) limit = limit + 100 From python-checkins at python.org Sun Oct 11 23:25:27 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 11 Oct 2009 21:25:27 -0000 Subject: [Python-checkins] r75374 - in python/branches/py3k: Doc/contents.rst Doc/faq Doc/tools/sphinxext/indexcontent.html Message-ID: Author: georg.brandl Date: Sun Oct 11 23:25:26 2009 New Revision: 75374 Log: Merged revisions 75363 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75363 | georg.brandl | 2009-10-11 20:31:23 +0200 (So, 11 Okt 2009) | 1 line Add the Python FAQ lists to the documentation. Copied from sandbox/faq. Many thanks to AMK for the preparation work. ........ Added: python/branches/py3k/Doc/faq/ - copied from r75363, /python/trunk/Doc/faq/ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/contents.rst python/branches/py3k/Doc/tools/sphinxext/indexcontent.html Modified: python/branches/py3k/Doc/contents.rst ============================================================================== --- python/branches/py3k/Doc/contents.rst (original) +++ python/branches/py3k/Doc/contents.rst Sun Oct 11 23:25:26 2009 @@ -15,6 +15,7 @@ install/index.rst documenting/index.rst howto/index.rst + faq/index.rst glossary.rst about.rst Modified: python/branches/py3k/Doc/tools/sphinxext/indexcontent.html ============================================================================== --- python/branches/py3k/Doc/tools/sphinxext/indexcontent.html (original) +++ python/branches/py3k/Doc/tools/sphinxext/indexcontent.html Sun Oct 11 23:25:26 2009 @@ -26,6 +26,8 @@ sharing modules with others

            + From python-checkins at python.org Mon Oct 12 00:46:05 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 11 Oct 2009 22:46:05 -0000 Subject: [Python-checkins] r75375 - peps/trunk/pep-0390.txt Message-ID: Author: tarek.ziade Date: Mon Oct 12 00:46:05 2009 New Revision: 75375 Log: typo Modified: peps/trunk/pep-0390.txt Modified: peps/trunk/pep-0390.txt ============================================================================== --- peps/trunk/pep-0390.txt (original) +++ peps/trunk/pep-0390.txt Mon Oct 12 00:46:05 2009 @@ -142,8 +142,8 @@ called. Getting ``UNKNOWN`` values will mean that it might be necessary to run the ``setup.py`` command line interface to get the whole set of metadata. -Aknowledgments -============== +Acknowledgments +=============== The Distutils-SIG. From python-checkins at python.org Mon Oct 12 03:26:08 2009 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 12 Oct 2009 01:26:08 -0000 Subject: [Python-checkins] r75376 - python/trunk/Doc/library/pty.rst Message-ID: Author: benjamin.peterson Date: Mon Oct 12 03:26:07 2009 New Revision: 75376 Log: platform we don't care about Modified: python/trunk/Doc/library/pty.rst Modified: python/trunk/Doc/library/pty.rst ============================================================================== --- python/trunk/Doc/library/pty.rst (original) +++ python/trunk/Doc/library/pty.rst Mon Oct 12 03:26:07 2009 @@ -3,8 +3,8 @@ ======================================== .. module:: pty - :platform: IRIX, Linux - :synopsis: Pseudo-Terminal Handling for SGI and Linux. + :platform: Linux + :synopsis: Pseudo-Terminal Handling for Linux. .. moduleauthor:: Steen Lumholt .. sectionauthor:: Moshe Zadka @@ -14,8 +14,8 @@ controlling terminal programmatically. Because pseudo-terminal handling is highly platform dependent, there is code to -do it only for SGI and Linux. (The Linux code is supposed to work on other -platforms, but hasn't been tested yet.) +do it only for Linux. (The Linux code is supposed to work on other platforms, +but hasn't been tested yet.) The :mod:`pty` module defines the following functions: @@ -32,8 +32,8 @@ .. function:: openpty() Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or - emulation code for SGI and generic Unix systems. Return a pair of file - descriptors ``(master, slave)``, for the master and the slave end, respectively. + emulation code for generic Unix systems. Return a pair of file descriptors + ``(master, slave)``, for the master and the slave end, respectively. .. function:: spawn(argv[, master_read[, stdin_read]]) From nnorwitz at gmail.com Mon Oct 12 11:45:57 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 12 Oct 2009 05:45:57 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091012094557.GA22828@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [0, 0, 270] references, sum=270 Less important issues: ---------------------- test_file2k leaked [80, -80, 0] references, sum=0 test_smtplib leaked [-123, 0, 0] references, sum=-123 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Mon Oct 12 16:59:50 2009 From: python-checkins at python.org (tarek.ziade) Date: Mon, 12 Oct 2009 14:59:50 -0000 Subject: [Python-checkins] r75382 - peps/trunk/pep-0390.txt Message-ID: Author: tarek.ziade Date: Mon Oct 12 16:59:50 2009 New Revision: 75382 Log: updated after some feedback from distutils-SIG and MAL Modified: peps/trunk/pep-0390.txt Modified: peps/trunk/pep-0390.txt ============================================================================== --- peps/trunk/pep-0390.txt (original) +++ peps/trunk/pep-0390.txt Mon Oct 12 16:59:50 2009 @@ -31,7 +31,7 @@ 0.6.4 Where ``name`` and ``version`` are metadata fields. This is working fine but -as soon as the developers add more code in ``setup.py``, this feature might +as soon as the developers add more code in ``setup.py``, this feature might break or in worst cases might do unwanted things on the target system. Moreover, when an OS packager wants to get the metadata of a distribution @@ -46,7 +46,7 @@ Adding a ``metadata`` section in ``setup.cfg`` ============================================== -The first thing we want to introduce is a ``[metadata]`` section, in the +The first thing we want to introduce is a ``[metadata]`` section, in the ``setup.cfg`` file, that may contain any field from the Metadata:: [metadata] @@ -62,6 +62,24 @@ ``setup()``, it will override the value that was possibly present in ``setup.cfg``. +Notice that ``setup.py`` is still used and can be required to define some +options that are not part of the Metadata fields. For instance, the +``sdist`` command can use options like ``packages`` or ``scripts``. + + +Multi-lines values +================== + +Some Metadata fields can have multiple values. To keep ``setup.cfg`` compatible +with ``ConfigParser`` and the RFC 822 ``LONG HEADER FIELDS`` (see section 3.1.1), +these are expressed with ``,``-separated values:: + + requires = pywin32, bar > 1.0, foo + +When this variable is read, the values are parsed and transformed into a list: +``['pywin32', 'bar > 1.0', 'foo']``. + + Context-dependant sections ========================== @@ -75,8 +93,8 @@ version = 0.6.4 [metadata:sys_platform == 'win32'] - requires = pywin32 - requires = bar > 1.0 + requires = pywin32, bar > 1.0 + obsoletes = pywin31 [metadata:os_machine == 'i386'] requires = foo @@ -90,12 +108,12 @@ Every ``[metadata:condition]`` section will be used only if the condition is met when the file is read. The background motivation for these context-dependant sections is to be able to define requirements that varies -depending on the platform the distribution might be installed on. +depending on the platform the distribution might be installed on. (see PEP 314). The micro-language behind this is the simplest possible: it compares only -strings, with the ``==`` and ``in`` operators (and their opposites), and -with the ability to combine expressions. It makes it also easy to understand +strings, with the ``==`` and ``in`` operators (and their opposites), and +with the ability to combine expressions. It makes it also easy to understand to non-pythoneers. The pseudo-grammar is :: @@ -107,11 +125,14 @@ - python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - os_name = os.name - sys_platform = sys.platform -- os_version = os.uname()[3] -- os_machine = os.uname()[4] +- platform_version = platform.version() +- platform_machine = platform.machine() - a free string, like ``2.4``, or ``win32`` -Distutils will provide a function that is able to read the metadata +Notice that ``in`` is restricted to strings, meaning that it is not possible +to use other sequences like tuples or lists on the left side. + +Distutils will provide a function that is able to generate the metadata of a distribution, given a ``setup.cfg`` file, for the execution environment:: >>> from distutils.util import local_metadata @@ -121,11 +142,66 @@ This means that a vanilla Python will be able to read the metadata of a package without running any third party code. +Notice that this feature is not restricted to the ``metadata`` namespace. +Consequently, any other section can be extended with such context-dependant +sections. + +Impact on PKG-INFO generation and PEP 314 +========================================= + +When ``PKG-INFO`` is generated by Distutils, every field that relies on a +condition will have that condition written at the end of the line, after a `;` +separator:: + + Metadata-Version: 1.2 + Name: distribute + Version: 0.6.4 + ... + Requires: pywin32, bar > 1.0; sys_platform == 'win32' + Requires: foo; os_machine == 'i386' + Requires: bar; python_version == '2.4' or python_version == '2.5' + Requires: baz; 'linux' in sys_platform + Obsoletes = pywin31; sys_platform == 'win32' + ... + Classifier: Development Status :: 5 - Production/Stable + Classifier: Intended Audience :: Developers + Classifier: License :: OSI Approved :: Python Software Foundation License + +Notice that this file can be opened with the ``DistributionMetadata`` class. +This class will be able to use the micro-language using the execution +environment. + +Let's run in on a ``Python 2.5 i386 Linux``:: + + >>> from distutils.dist import DistributionMetadata + >>> metadata = DistributionMetadata('PKG_INFO') + >>> metadata.get_requires() + ['foo', 'bar', 'baz'] + +The execution environment can be overriden in case we want to get the meyadata +for another environment:: + + >>> env = {'python_version': '2.4', + ... 'os_name': 'nt', + ... 'sys_platform': 'win32', + ... 'platform_version': 'MVCC++ 6.0' + ... 'platform_machine': 'i386'} + ... + >>> metadata = DistributionMetadata('PKG_INFO', environment=env) + >>> metadata.get_requires() + ['bar > 1.0', 'foo', 'bar'] + +PEP 314 is changed accordingly, meaning that each field will be able to +have that extra condition marker. + Compatiblity ============ -This change is fully backward compatible since it just adds a section in the -``ConfigParser``-compatible ``setup.cfg`` file. +This change is is based on a new metadata ``1.2`` format meaning that +Distutils will be able to distinguish old PKG-INFO files from new ones. + +The ``setup.cfg`` file change will stay ``ConfigParser``-compatible and +will not break existing ``setup.cfg`` files. Limitations =========== @@ -134,12 +210,12 @@ ``python_version`` is a regular string. This implies using ``or`` operators when a section needs to be restricted to a couple of Python versions. Although, if PEP 386 is accepted, ``python_version`` could be changed -internally into something comparable with strings, and +internally into something comparable with strings, and ``<`` and ``>`` operators introduced. Last, if a distribution is unable to set all metadata fields in ``setup.cfg``, that's fine, the fields will be set to ``UNKNOWN`` when ``local_metadata`` is -called. Getting ``UNKNOWN`` values will mean that it might be necessary to +called. Getting ``UNKNOWN`` values will mean that it might be necessary to run the ``setup.py`` command line interface to get the whole set of metadata. Acknowledgments From eric at trueblade.com Mon Oct 12 18:57:46 2009 From: eric at trueblade.com (Eric Smith) Date: Mon, 12 Oct 2009 12:57:46 -0400 Subject: [Python-checkins] r75382 - peps/trunk/pep-0390.txt In-Reply-To: <20091012150003.F18CC181824E@tok.trueblade.com> References: <20091012150003.F18CC181824E@tok.trueblade.com> Message-ID: <4AD3600A.5080509@trueblade.com> tarek.ziade wrote: > +Notice that ``in`` is restricted to strings, meaning that it is not possible > +to use other sequences like tuples or lists on the left side. Shouldn't this be "on the right side", not left side? Eric. From ziade.tarek at gmail.com Mon Oct 12 19:23:04 2009 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Mon, 12 Oct 2009 19:23:04 +0200 Subject: [Python-checkins] r75382 - peps/trunk/pep-0390.txt In-Reply-To: <4AD3600A.5080509@trueblade.com> References: <20091012150003.F18CC181824E@tok.trueblade.com> <4AD3600A.5080509@trueblade.com> Message-ID: <94bdd2610910121023t34f73f18t55e3c8066283f9b1@mail.gmail.com> On Mon, Oct 12, 2009 at 6:57 PM, Eric Smith wrote: > tarek.ziade wrote: >> >> +Notice that ``in`` is restricted to strings, meaning that it is not >> possible >> +to use other sequences like tuples or lists on the left side. > > Shouldn't this be "on the right side", not left side? Good catch Eric, thanks. I am fixing it. From python-checkins at python.org Mon Oct 12 19:24:09 2009 From: python-checkins at python.org (tarek.ziade) Date: Mon, 12 Oct 2009 17:24:09 -0000 Subject: [Python-checkins] r75383 - peps/trunk/pep-0390.txt Message-ID: Author: tarek.ziade Date: Mon Oct 12 19:24:09 2009 New Revision: 75383 Log: fixed typo Modified: peps/trunk/pep-0390.txt Modified: peps/trunk/pep-0390.txt ============================================================================== --- peps/trunk/pep-0390.txt (original) +++ peps/trunk/pep-0390.txt Mon Oct 12 19:24:09 2009 @@ -130,7 +130,7 @@ - a free string, like ``2.4``, or ``win32`` Notice that ``in`` is restricted to strings, meaning that it is not possible -to use other sequences like tuples or lists on the left side. +to use other sequences like tuples or lists on the right side. Distutils will provide a function that is able to generate the metadata of a distribution, given a ``setup.cfg`` file, for the execution environment:: From python-checkins at python.org Mon Oct 12 21:58:46 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 19:58:46 -0000 Subject: [Python-checkins] r75384 - in sandbox/trunk/setuptools: EasyInstall.txt pkg_resources.py pkg_resources.txt setup.py setuptools.egg-info/entry_points.txt setuptools.txt setuptools/command/alias.py setuptools/command/bdist_egg.py setuptools/command/build_ext.py setuptools/command/easy_install.py setuptools/command/egg_info.py setuptools/command/sdist.py setuptools/command/test.py setuptools/depends.py setuptools/dist.py setuptools/package_index.py setuptools/sandbox.py setuptools/tests/api_tests.txt Message-ID: Author: phillip.eby Date: Mon Oct 12 21:58:46 2009 New Revision: 75384 Log: Major updates and fixes include: * Fix for the Python 2.6.3 build_ext API change * Support for the most recent Sourceforge download link insanity * Support for SVN 1.6 * Stop crashing on certain types of HTTP error * Stop re-trying URLs that already failed retrieval once * Fixes for various dependency management problems such as looping builds, re-downloading packages already present on sys.path (but not in a registered "site" directory), and randomly preferring local -f packages over local installed packages * Prevent lots of spurious "already imported from another path" warnings (e.g. when pkg_resources is imported late) * Ensure C libraries (as opposed to extensions) are also built when doing bdist_egg * Fixed running the "test" command under Python 2.6+ Other changes: * Misc. documentation fixes * Improved Jython support * Fewer warnings under Python 2.6+ * Warn when 'packages' uses paths instead of package names (because it causes other problems, like spurious "already imported" warnings) * Stop using /usr/bin/sw_vers on Mac OS (replaced w/'platform' module calls) Note: This is NOT a merge from Distribute; upon review, many of the tracker-submitted patches used as a basis for forking were incorrect, incomplete, introduced new bugs, or were not addressing the root causes. (E.g., one of the changes in this patch fixes three superficially unrelated issues in the setuptools bug tracker.) Careful review will be required if you want to merge this work back into Distribute. Modified: sandbox/trunk/setuptools/EasyInstall.txt sandbox/trunk/setuptools/pkg_resources.py sandbox/trunk/setuptools/pkg_resources.txt sandbox/trunk/setuptools/setup.py sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt sandbox/trunk/setuptools/setuptools.txt sandbox/trunk/setuptools/setuptools/command/alias.py sandbox/trunk/setuptools/setuptools/command/bdist_egg.py sandbox/trunk/setuptools/setuptools/command/build_ext.py sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/command/egg_info.py sandbox/trunk/setuptools/setuptools/command/sdist.py sandbox/trunk/setuptools/setuptools/command/test.py sandbox/trunk/setuptools/setuptools/depends.py sandbox/trunk/setuptools/setuptools/dist.py sandbox/trunk/setuptools/setuptools/package_index.py sandbox/trunk/setuptools/setuptools/sandbox.py sandbox/trunk/setuptools/setuptools/tests/api_tests.txt Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Mon Oct 12 21:58:46 2009 @@ -256,7 +256,7 @@ If you want to delete the currently installed version of a package (or all versions of a package), you should first run:: - easy_install -m PackageName + easy_install -mxN PackageName This will ensure that Python doesn't continue to search for a package you're planning to remove. After you've done this, you can safely delete the .egg @@ -427,7 +427,7 @@ Password-Protected Sites ------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~ If a site you want to download from is password-protected using HTTP "Basic" authentication, you can specify your credentials in the URL, like so:: Modified: sandbox/trunk/setuptools/pkg_resources.py ============================================================================== --- sandbox/trunk/setuptools/pkg_resources.py (original) +++ sandbox/trunk/setuptools/pkg_resources.py Mon Oct 12 21:58:46 2009 @@ -13,7 +13,7 @@ method. """ -import sys, os, zipimport, time, re, imp, new, pkgutil # XXX +import sys, os, zipimport, time, re, imp, pkgutil # XXX try: frozenset @@ -39,6 +39,47 @@ +_state_vars = {} + +def _declare_state(vartype, **kw): + g = globals() + for name, val in kw.iteritems(): + g[name] = val + _state_vars[name] = vartype + +def __getstate__(): + state = {} + g = globals() + for k, v in _state_vars.iteritems(): + state[k] = g['_sget_'+v](g[k]) + return state + +def __setstate__(state): + g = globals() + for k, v in state.iteritems(): + g['_sset_'+_state_vars[k]](k, g[k], v) + return state + +def _sget_dict(val): + return val.copy() + +def _sset_dict(key, ob, state): + ob.clear() + ob.update(state) + +def _sget_object(val): + return val.__getstate__() + +def _sset_object(key, ob, state): + ob.__setstate__(state) + +_sget_none = _sset_none = lambda *args: None + + + + + + def get_supported_platform(): """Return this platform's maximum compatible version. @@ -166,14 +207,8 @@ def _macosx_vers(_cache=[]): if not _cache: - info = os.popen('/usr/bin/sw_vers').read().splitlines() - for line in info: - key, value = line.split(None, 1) - if key == 'ProductVersion:': - _cache.append(value.strip().split(".")) - break - else: - raise ValueError, "What?!" + from platform import mac_ver + _cache.append(mac_ver()[0].split('.')) return _cache[0] def _macosx_arch(machine): @@ -203,6 +238,12 @@ darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)") get_platform = get_build_platform # XXX backward compat + + + + + + def compatible_platforms(provided,required): """Can code for the `provided` platform run on the `required` platform? @@ -387,7 +428,7 @@ def add_entry(self, entry): """Add a path item to ``.entries``, finding any distributions on it - ``find_distributions(entry,False)`` is used to find distributions + ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than @@ -622,7 +663,6 @@ activated to fulfill the requirements; all relevant distributions are included, even if they were already activated in this working set. """ - needed = self.resolve(parse_requirements(requirements)) for dist in needed: @@ -630,7 +670,6 @@ return needed - def subscribe(self, callback): """Invoke `callback` for all distributions (including existing ones)""" if callback in self.callbacks: @@ -639,19 +678,21 @@ for dist in self: callback(dist) - def _added_new(self, dist): for callback in self.callbacks: callback(dist) + def __getstate__(self): + return ( + self.entries[:], self.entry_keys.copy(), self.by_key.copy(), + self.callbacks[:] + ) - - - - - - - + def __setstate__(self, (entries, keys, by_key, callbacks)): + self.entries = entries[:] + self.entry_keys = keys.copy() + self.by_key = by_key.copy() + self.callbacks = callbacks[:] class Environment(object): @@ -1515,7 +1556,7 @@ -_distribution_finders = {} +_declare_state('dict', _distribution_finders = {}) def register_finder(importer_type, distribution_finder): """Register `distribution_finder` to find distributions in sys.path items @@ -1564,7 +1605,7 @@ """Yield distributions accessible on a sys.path directory""" path_item = _normalize_cached(path_item) - if os.path.isdir(path_item): + if os.path.isdir(path_item) and os.access(path_item, os.R_OK): if path_item.lower().endswith('.egg'): # unpacked egg yield Distribution.from_filename( @@ -1597,8 +1638,8 @@ break register_finder(pkgutil.ImpImporter, find_on_path) -_namespace_handlers = {} -_namespace_packages = {} +_declare_state('dict', _namespace_handlers = {}) +_declare_state('dict', _namespace_packages = {}) def register_namespace_handler(importer_type, namespace_handler): """Register `namespace_handler` to declare namespace packages @@ -1627,7 +1668,7 @@ return None module = sys.modules.get(packageName) if module is None: - module = sys.modules[packageName] = new.module(packageName) + module = sys.modules[packageName] = imp.new_module(packageName) module.__path__ = []; _set_parent_ns(packageName) elif not hasattr(module,'__path__'): raise TypeError("Not a package:", packageName) @@ -2138,12 +2179,9 @@ if not loc: return - if path is sys.path: - self.check_version_conflict() - nloc = _normalize_cached(loc) bdir = os.path.dirname(nloc) - npath= map(_normalize_cached, path) + npath= [(p and _normalize_cached(p) or p) for p in path] bp = None for p, item in enumerate(npath): @@ -2151,10 +2189,14 @@ break elif item==bdir and self.precedence==EGG_DIST: # if it's an .egg, give it precedence over its directory + if path is sys.path: + self.check_version_conflict() path.insert(p, loc) npath.insert(p, nloc) break else: + if path is sys.path: + self.check_version_conflict() path.append(loc) return @@ -2171,7 +2213,6 @@ return - def check_version_conflict(self): if self.key=='setuptools': return # ignore the inevitable setuptools self-conflicts :( @@ -2185,7 +2226,7 @@ continue fn = getattr(sys.modules[modname], '__file__', None) - if fn and normalize_path(fn).startswith(loc): + if fn and (normalize_path(fn).startswith(loc) or fn.startswith(loc)): continue issue_warning( "Module %s was already imported from %s, but %s is being added" @@ -2362,7 +2403,7 @@ def __contains__(self,item): if isinstance(item,Distribution): - if item.key <> self.key: return False + if item.key != self.key: return False if self.index: item = item.parsed_version # only get if we need it elif isinstance(item,basestring): item = parse_version(item) @@ -2459,7 +2500,7 @@ os.open = old_open # and then put it back -# Set up global resource manager +# Set up global resource manager (deliberately not state-saved) _manager = ResourceManager() def _initialize(g): for name in dir(_manager): @@ -2468,7 +2509,7 @@ _initialize(globals()) # Prepare the master working set and make the ``require()`` API available -working_set = WorkingSet() +_declare_state('object', working_set = WorkingSet()) try: # Does the main program list any requirements? from __main__ import __requires__ Modified: sandbox/trunk/setuptools/pkg_resources.txt ============================================================================== --- sandbox/trunk/setuptools/pkg_resources.txt (original) +++ sandbox/trunk/setuptools/pkg_resources.txt Mon Oct 12 21:58:46 2009 @@ -275,7 +275,7 @@ the global ``working_set`` to reflect the change. This method is also called by the ``WorkingSet()`` constructor during initialization. - This method uses ``find_distributions(entry,False)`` to find distributions + This method uses ``find_distributions(entry, True)`` to find distributions corresponding to the path entry, and then ``add()`` them. `entry` is always appended to the ``entries`` attribute, even if it is already present, however. (This is because ``sys.path`` can contain the same value @@ -1667,10 +1667,13 @@ for obtaining an "importer" object. It first checks for an importer for the path item in ``sys.path_importer_cache``, and if not found it calls each of the ``sys.path_hooks`` and caches the result if a good importer is - found. If no importer is found, this routine returns an ``ImpWrapper`` - instance that wraps the builtin import machinery as a PEP 302-compliant - "importer" object. This ``ImpWrapper`` is *not* cached; instead a new - instance is returned each time. + found. If no importer is found, this routine returns a wrapper object + that wraps the builtin import machinery as a PEP 302-compliant "importer" + object. This wrapper object is *not* cached; instead a new instance is + returned each time. + + (Note: When run under Python 2.5, this function is simply an alias for + ``pkgutil.get_importer()``.) File/Path Utilities Modified: sandbox/trunk/setuptools/setup.py ============================================================================== --- sandbox/trunk/setuptools/setup.py (original) +++ sandbox/trunk/setuptools/setup.py Mon Oct 12 21:58:46 2009 @@ -54,6 +54,7 @@ "dependency_links = setuptools.dist:assert_string_list", "test_loader = setuptools.dist:check_importable", "test_runner = setuptools.dist:check_importable", + "packages = setuptools.dist:check_packages", ], "egg_info.writers": [ "PKG-INFO = setuptools.command.egg_info:write_pkg_info", @@ -79,8 +80,6 @@ }, - - classifiers = [f.strip() for f in """ Development Status :: 3 - Alpha Intended Audience :: Developers Modified: sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt (original) +++ sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt Mon Oct 12 21:58:46 2009 @@ -50,6 +50,7 @@ eager_resources = setuptools.dist:assert_string_list zip_safe = setuptools.dist:assert_bool test_loader = setuptools.dist:check_importable +packages = setuptools.dist:check_packages tests_require = setuptools.dist:check_requirements [setuptools.installation] Modified: sandbox/trunk/setuptools/setuptools.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools.txt (original) +++ sandbox/trunk/setuptools/setuptools.txt Mon Oct 12 21:58:46 2009 @@ -2562,6 +2562,27 @@ inform the user of the missing program(s). +A Note Regarding Dependencies +----------------------------- + +If the project *containing* your distutils/setuptools extension(s) depends on +any projects other than setuptools, you *must* also declare those dependencies +as part of your project's ``setup_requires`` keyword, so that they will +already be built (and at least temprorarily installed) before your extension +project is built. + +So, if for example you create a project Foo that includes a new file finder +plugin, and Foo depends on Bar, then you *must* list Bar in both the +``install_requires`` **and** ``setup_requires`` arguments to ``setup()``. + +If you don't do this, then in certain edge cases you may cause setuptools to +try to go into infinite recursion, trying to build your dependencies to resolve +your dependencies, while still building your dependencies. (It probably won't +happen on your development machine, but it *will* happen in a full build +pulling everything from revision control on a clean machine, and then you or +your users will be scratching their heads trying to figure it out!) + + Subclassing ``Command`` ----------------------- Modified: sandbox/trunk/setuptools/setuptools/command/alias.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/alias.py (original) +++ sandbox/trunk/setuptools/setuptools/command/alias.py Mon Oct 12 21:58:46 2009 @@ -9,7 +9,7 @@ """Quote an argument for later parsing by shlex.split()""" for c in '"', "'", "\\", "#": if c in arg: return repr(arg) - if arg.split()<>[arg]: + if arg.split()!=[arg]: return repr(arg) return arg @@ -33,7 +33,7 @@ def finalize_options(self): option_base.finalize_options(self) - if self.remove and len(self.args)<>1: + if self.remove and len(self.args)!=1: raise DistutilsOptionError( "Must specify exactly one argument (the alias name) when " "using --remove" Modified: sandbox/trunk/setuptools/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_egg.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Mon Oct 12 21:58:46 2009 @@ -165,12 +165,13 @@ def run(self): # Generate metadata first self.run_command("egg_info") - # We run install_lib before install_data, because some data hacks # pull their data path from the install_lib command. log.info("installing library code to %s" % self.bdist_dir) instcmd = self.get_finalized_command('install') old_root = instcmd.root; instcmd.root = None + if self.distribution.has_c_libraries() and not self.skip_build: + self.run_command('build_clib') cmd = self.call_command('install_lib', warn_dir=0) instcmd.root = old_root @@ -190,7 +191,6 @@ to_compile.extend(self.make_init_files()) if to_compile: cmd.byte_compile(to_compile) - if self.distribution.data_files: self.do_install_data() @@ -398,7 +398,7 @@ for flag,fn in safety_flags.items(): fn = os.path.join(egg_dir, fn) if os.path.exists(fn): - if safe is None or bool(safe)<>flag: + if safe is None or bool(safe)!=flag: os.unlink(fn) elif safe is not None and bool(safe)==flag: f=open(fn,'wb'); f.write('\n'); f.close() Modified: sandbox/trunk/setuptools/setuptools/command/build_ext.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/build_ext.py (original) +++ sandbox/trunk/setuptools/setuptools/command/build_ext.py Mon Oct 12 21:58:46 2009 @@ -82,15 +82,15 @@ def get_ext_filename(self, fullname): filename = _build_ext.get_ext_filename(self,fullname) - ext = self.ext_map[fullname] - if isinstance(ext,Library): - fn, ext = os.path.splitext(filename) - return self.shlib_compiler.library_filename(fn,libtype) - elif use_stubs and ext._links_to_dynamic: - d,fn = os.path.split(filename) - return os.path.join(d,'dl-'+fn) - else: - return filename + if fullname in self.ext_map: + ext = self.ext_map[fullname] + if isinstance(ext,Library): + fn, ext = os.path.splitext(filename) + return self.shlib_compiler.library_filename(fn,libtype) + elif use_stubs and ext._links_to_dynamic: + d,fn = os.path.split(filename) + return os.path.join(d,'dl-'+fn) + return filename def initialize_options(self): _build_ext.initialize_options(self) Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Mon Oct 12 21:58:46 2009 @@ -204,7 +204,7 @@ self.outputs = [] def run(self): - if self.verbose<>self.distribution.verbose: + if self.verbose!=self.distribution.verbose: log.set_verbosity(self.verbose) try: for spec in self.args: @@ -252,7 +252,7 @@ # Is it a configured, PYTHONPATH, implicit, or explicit site dir? is_site_dir = instdir in self.all_site_dirs - if not is_site_dir: + if not is_site_dir and not self.multi_version: # No? Then directly test whether it does .pth file processing is_site_dir = self.check_pth_processing() else: @@ -430,9 +430,9 @@ self.check_editable(spec) dist = self.package_index.fetch_distribution( - spec, tmpdir, self.upgrade, self.editable, not self.always_copy + spec, tmpdir, self.upgrade, self.editable, not self.always_copy, + self.local_index ) - if dist is None: msg = "Could not find suitable distribution for %r" % spec if self.always_copy: @@ -722,7 +722,7 @@ f = open(pkg_inf,'w') f.write('Metadata-Version: 1.0\n') for k,v in cfg.items('metadata'): - if k<>'target_version': + if k!='target_version': f.write('%s: %s\n' % (k.replace('_','-').title(), v)) f.close() script_dir = os.path.join(egg_info,'scripts') @@ -988,7 +988,6 @@ def pf(src,dst): if dst.endswith('.py') and not src.startswith('EGG-INFO/'): to_compile.append(dst) - to_chmod.append(dst) elif dst.endswith('.dll') or dst.endswith('.so'): to_chmod.append(dst) self.unpack_progress(src,dst) @@ -1023,6 +1022,7 @@ + def no_default_version_msg(self): return """bad install directory or PYTHONPATH @@ -1286,7 +1286,7 @@ if parts[1].endswith('.egg-info'): prefixes.insert(0,('/'.join(parts[:2]), 'EGG-INFO/')) break - if len(parts)<>2 or not name.endswith('.pth'): + if len(parts)!=2 or not name.endswith('.pth'): continue if name.endswith('-nspkg.pth'): continue Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/egg_info.py (original) +++ sandbox/trunk/setuptools/setuptools/command/egg_info.py Mon Oct 12 21:58:46 2009 @@ -217,18 +217,21 @@ data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): + if data.startswith('9 and d[9]]+[0]) - elif data.startswith('=6 and record[5]=="delete": continue # skip deleted yield joinpath(dirname, record[0]) - elif data.startswith('"unknown" and version >= self.requested_version + str(version)!="unknown" and version >= self.requested_version def get_version(self, paths=None, default="unknown"): Modified: sandbox/trunk/setuptools/setuptools/dist.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/dist.py (original) +++ sandbox/trunk/setuptools/setuptools/dist.py Mon Oct 12 21:58:46 2009 @@ -8,7 +8,7 @@ from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.errors import DistutilsSetupError import setuptools, pkg_resources, distutils.core, distutils.dist, distutils.cmd -import os, distutils.log +import os, distutils.log, re def _get_unpatched(cls): """Protect against re-patching the distutils if reloaded @@ -61,8 +61,8 @@ parent = '.'.join(nsp.split('.')[:-1]) if parent not in value: distutils.log.warn( - "%r is declared as a package namespace, but %r is not:" - " please correct this in setup.py", nsp, parent + "WARNING: %r is declared as a package namespace, but %r" + " is not: please correct this in setup.py", nsp, parent ) def check_extras(dist, attr, value): @@ -121,6 +121,47 @@ "wildcard patterns" ) +def check_packages(dist, attr, value): + for pkgname in value: + if not re.match(r'\w+(\.\w+)*', pkgname): + distutils.log.warn( + "WARNING: %r not a valid package name; please use only" + ".-separated package names in setup.py", pkgname + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class Distribution(_Distribution): """Distribution with support for features, tests, and package data @@ -415,19 +456,19 @@ if self.packages: self.packages = [ p for p in self.packages - if p<>package and not p.startswith(pfx) + if p!=package and not p.startswith(pfx) ] if self.py_modules: self.py_modules = [ p for p in self.py_modules - if p<>package and not p.startswith(pfx) + if p!=package and not p.startswith(pfx) ] if self.ext_modules: self.ext_modules = [ p for p in self.ext_modules - if p.name<>package and not p.name.startswith(pfx) + if p.name!=package and not p.name.startswith(pfx) ] @@ -796,3 +837,25 @@ " doesn't contain any packages or modules under %s" % (self.description, item, item) ) + + + + + + + + + + + + + + + + + + + + + + Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Mon Oct 12 21:58:46 2009 @@ -1,5 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO +import httplib from pkg_resources import * from distutils import log from distutils.errors import DistutilsError @@ -8,7 +9,6 @@ except ImportError: from md5 import md5 from fnmatch import translate - EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.]+)$') HREF = re.compile("""href\\s*=\\s*['"]?([^'"> ]+)""", re.I) # this is here to fix emacs' cruddy broken syntax highlighting @@ -42,6 +42,8 @@ def egg_info_for_url(url): scheme, server, path, parameters, query, fragment = urlparse.urlparse(url) base = urllib2.unquote(path.split('/')[-1]) + if server=='sourceforge.net' and base=='download': # XXX Yuck + base = urllib2.unquote(path.split('/')[-2]) if '#' in base: base, fragment = base.split('#',1) return base,fragment @@ -64,14 +66,12 @@ if basename.endswith('.egg') and '-' in basename: # only one, unambiguous interpretation return [Distribution.from_location(location, basename, metadata)] - if basename.endswith('.exe'): win_base, py_ver = parse_bdist_wininst(basename) if win_base is not None: return interpret_distro_name( location, win_base, metadata, py_ver, BINARY_DIST, "win32" ) - # Try source distro extensions (.zip, .tgz, etc.) # for ext in EXTENSIONS: @@ -186,10 +186,10 @@ return self.info("Reading %s", url) + self.fetched_urls[url] = True # prevent multiple fetch attempts f = self.open_url(url, "Download error: %s -- Some packages may not be found!") if f is None: return - self.fetched_urls[url] = self.fetched_urls[f.url] = True - + self.fetched_urls[f.url] = True if 'html' not in f.headers.get('content-type', '').lower(): f.close() # not html, we can't process it return @@ -329,7 +329,7 @@ def check_md5(self, cs, info, filename, tfp): if re.match('md5=[0-9a-f]{32}$', info): self.debug("Validating md5 checksum for %s", filename) - if cs.hexdigest()<>info[4:]: + if cs.hexdigest()!=info[4:]: tfp.close() os.unlink(filename) raise DistutilsError( @@ -409,7 +409,8 @@ def fetch_distribution(self, - requirement, tmpdir, force_scan=False, source=False, develop_ok=False + requirement, tmpdir, force_scan=False, source=False, develop_ok=False, + local_index=None, ): """Obtain a distribution suitable for fulfilling `requirement` @@ -427,15 +428,15 @@ set, development and system eggs (i.e., those using the ``.egg-info`` format) will be ignored. """ - # process a Requirement self.info("Searching for %s", requirement) skipped = {} + dist = None - def find(req): + def find(env, req): # Find a matching distribution; may be called more than once - for dist in self[req.key]: + for dist in env[req.key]: if dist.precedence==DEVELOP_DIST and not develop_ok: if dist not in skipped: @@ -444,23 +445,25 @@ continue if dist in req and (dist.precedence<=SOURCE_DIST or not source): - self.info("Best match: %s", dist) - return dist.clone( - location=self.download(dist.location, tmpdir) - ) + return dist + + if force_scan: self.prescan() self.find_packages(requirement) + dist = find(self, requirement) + + if local_index is not None: + dist = dist or find(local_index, requirement) - dist = find(requirement) if dist is None and self.to_scan is not None: self.prescan() - dist = find(requirement) + dist = find(self, requirement) if dist is None and not force_scan: self.find_packages(requirement) - dist = find(requirement) + dist = find(self, requirement) if dist is None: self.warn( @@ -468,7 +471,9 @@ (source and "a source distribution of " or ""), requirement, ) - return dist + self.info("Best match: %s", dist) + return dist.clone(location=self.download(dist.location, tmpdir)) + def fetch(self, requirement, tmpdir, force_scan=False, source=False): """Obtain a file suitable for fulfilling `requirement` @@ -485,11 +490,6 @@ - - - - - def gen_setup(self, filename, fragment, tmpdir): match = EGG_FRAGMENT.match(fragment) dists = match and [d for d in @@ -573,17 +573,19 @@ def open_url(self, url, warning=None): - if url.startswith('file:'): - return local_open(url) + if url.startswith('file:'): return local_open(url) try: return open_with_auth(url) except urllib2.HTTPError, v: return v except urllib2.URLError, v: - if warning: self.warn(warning, v.reason) - else: - raise DistutilsError("Download error for %s: %s" - % (url, v.reason)) + reason = v.reason + except httplib.HTTPException, v: + reason = "%s: %s" % (v.__doc__ or v.__class__.__name__, v) + if warning: + self.warn(warning, reason) + else: + raise DistutilsError("Download error for %s: %s" % (url, reason)) def _download_url(self, scheme, url, tmpdir): # Determine download filename @@ -611,8 +613,6 @@ self.url_ok(url, True) # raises error if not allowed return self._attempt_download(url, filename) - - def scan_url(self, url): self.process_url(url, True) Modified: sandbox/trunk/setuptools/setuptools/sandbox.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/sandbox.py (original) +++ sandbox/trunk/setuptools/setuptools/sandbox.py Mon Oct 12 21:58:46 2009 @@ -1,10 +1,44 @@ -import os, sys, __builtin__, tempfile, operator +import os, sys, __builtin__, tempfile, operator, pkg_resources _os = sys.modules[os.name] _open = open +_file = file + from distutils.errors import DistutilsError +from pkg_resources import working_set + __all__ = [ "AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup", ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + def run_setup(setup_script, args): """Run a distutils setup script, sandboxed in its directory""" old_dir = os.getcwd() @@ -15,11 +49,15 @@ if not os.path.isdir(temp_dir): os.makedirs(temp_dir) save_tmp = tempfile.tempdir save_modules = sys.modules.copy() + pr_state = pkg_resources.__getstate__() try: tempfile.tempdir = temp_dir; os.chdir(setup_dir) try: sys.argv[:] = [setup_script]+list(args) sys.path.insert(0, setup_dir) + # reset to include setup dir, w/clean callback list + working_set.__init__() + working_set.callbacks.append(lambda dist:dist.activate()) DirectorySandbox(setup_dir).run( lambda: execfile( "setup.py", @@ -31,6 +69,7 @@ raise # Normal exit, just return finally: + pkg_resources.__setstate__(pr_state) sys.modules.update(save_modules) for key in list(sys.modules): if key not in save_modules: del sys.modules[key] @@ -39,6 +78,8 @@ sys.argv[:] = save_argv tempfile.tempdir = save_tmp + + class AbstractSandbox: """Wrap 'os' module and 'open()' builtin for virtualizing setup scripts""" @@ -58,15 +99,16 @@ """Run 'func' under os sandboxing""" try: self._copy(self) - __builtin__.open = __builtin__.file = self._open + __builtin__.file = self._file + __builtin__.open = self._open self._active = True return func() finally: self._active = False - __builtin__.open = __builtin__.file = _open + __builtin__.open = _file + __builtin__.file = _open self._copy(_os) - def _mk_dual_path_wrapper(name): original = getattr(_os,name) def wrap(self,src,dst,*args,**kw): @@ -75,7 +117,6 @@ return original(src,dst,*args,**kw) return wrap - for name in ["rename", "link", "symlink"]: if hasattr(_os,name): locals()[name] = _mk_dual_path_wrapper(name) @@ -88,7 +129,8 @@ return original(path,*args,**kw) return wrap - _open = _mk_single_path_wrapper('file', _open) + _open = _mk_single_path_wrapper('open', _open) + _file = _mk_single_path_wrapper('file', _file) for name in [ "stat", "listdir", "chdir", "open", "chmod", "chown", "mkdir", "remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat", @@ -96,7 +138,6 @@ ]: if hasattr(_os,name): locals()[name] = _mk_single_path_wrapper(name) - def _mk_single_with_return(name): original = getattr(_os,name) def wrap(self,path,*args,**kw): @@ -187,22 +228,22 @@ self._violation(operation, src, dst, *args, **kw) return (src,dst) + def _file(self, path, mode='r', *args, **kw): + if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): + self._violation("file", path, mode, *args, **kw) + return _file(path,mode,*args,**kw) + def open(self, file, flags, mode=0777): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode) return _os.open(file,flags,mode) - WRITE_FLAGS = reduce( - operator.or_, - [getattr(_os, a, 0) for a in + operator.or_, [getattr(_os, a, 0) for a in "O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARY".split()] ) - - - class SandboxViolation(DistutilsError): """A setup script attempted to modify the filesystem outside the sandbox""" Modified: sandbox/trunk/setuptools/setuptools/tests/api_tests.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools/tests/api_tests.txt (original) +++ sandbox/trunk/setuptools/setuptools/tests/api_tests.txt Mon Oct 12 21:58:46 2009 @@ -170,8 +170,8 @@ >>> ws.entries ['http://example.com/something'] >>> ws.add_entry(pkg_resources.__file__) - >>> ws.entries - ['http://example.com/something', '...pkg_resources.py...'] + >>> ws.entries == ['http://example.com/something', pkg_resources.__file__] + True Multiple additions result in multiple entries, even if the entry is already in the working set (because ``sys.path`` can contain the same entry more than From python-checkins at python.org Mon Oct 12 22:00:03 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 20:00:03 -0000 Subject: [Python-checkins] r75385 - in sandbox/branches/setuptools-0.6: EasyInstall.txt ez_setup.py pkg_resources.py pkg_resources.txt release.sh setup.py setuptools.egg-info/entry_points.txt setuptools.txt setuptools/__init__.py setuptools/command/alias.py setuptools/command/bdist_egg.py setuptools/command/build_ext.py setuptools/command/easy_install.py setuptools/command/egg_info.py setuptools/command/sdist.py setuptools/depends.py setuptools/dist.py setuptools/package_index.py setuptools/sandbox.py version.dat Message-ID: Author: phillip.eby Date: Mon Oct 12 22:00:02 2009 New Revision: 75385 Log: Major updates and fixes include: * Fix for the Python 2.6.3 build_ext API change * Support for the most recent Sourceforge download link insanity * Support for SVN 1.6 * Stop crashing on certain types of HTTP error * Stop re-trying URLs that already failed retrieval once * Fixes for various dependency management problems such as looping builds, re-downloading packages already present on sys.path (but not in a registered "site" directory), and randomly preferring local -f packages over local installed packages * Prevent lots of spurious "already imported from another path" warnings (e.g. when pkg_resources is imported late) * Ensure C libraries (as opposed to extensions) are also built when doing bdist_egg Other changes: * Misc. documentation fixes * Improved Jython support * Fewer warnings under Python 2.6+ * Warn when 'packages' uses paths instead of package names (because it causes other problems, like spurious "already imported" warnings) * Stop using /usr/bin/sw_vers on Mac OS (replaced w/'platform' module calls) Note: This is NOT a merge from Distribute; upon review, many of the tracker-submitted patches used as a basis for forking were incorrect, incomplete, introduced new bugs, or were not addressing the root causes. (E.g., one of the changes in this patch fixes three superficially unrelated issues in the setuptools bug tracker.) Careful review will be required if you want to merge this work back into Distribute. Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/pkg_resources.py sandbox/branches/setuptools-0.6/pkg_resources.txt sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/setuptools/command/alias.py sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py sandbox/branches/setuptools-0.6/setuptools/command/build_ext.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py sandbox/branches/setuptools-0.6/setuptools/command/sdist.py sandbox/branches/setuptools-0.6/setuptools/depends.py sandbox/branches/setuptools-0.6/setuptools/dist.py sandbox/branches/setuptools-0.6/setuptools/package_index.py sandbox/branches/setuptools-0.6/setuptools/sandbox.py sandbox/branches/setuptools-0.6/version.dat Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Mon Oct 12 22:00:02 2009 @@ -256,7 +256,7 @@ If you want to delete the currently installed version of a package (or all versions of a package), you should first run:: - easy_install -m PackageName + easy_install -mxN PackageName This will ensure that Python doesn't continue to search for a package you're planning to remove. After you've done this, you can safely delete the .egg @@ -427,7 +427,7 @@ Password-Protected Sites ------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~ If a site you want to download from is password-protected using HTTP "Basic" authentication, you can specify your credentials in the URL, like so:: @@ -1217,7 +1217,19 @@ Release Notes/Change History ============================ -0.6final +0.6c10 + * Support for the most recent Sourceforge download link insanity + + * Stop crashing on certain types of HTTP error + + * Stop re-trying URLs that already failed retrieval once + + * Fixes for various dependency management problems such as looping builds, + re-downloading packages already present on sys.path (but not in a registered + "site" directory), and semi-randomly preferring local "-f" packages over + local installed packages + +0.6c9 * Fixed ``win32.exe`` support for .pth files, so unnecessary directory nesting is flattened out in the resulting egg. (There was a case-sensitivity problem that affected some distributions, notably ``pywin32``.) Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Mon Oct 12 22:00:02 2009 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6c9" +DEFAULT_VERSION = "0.6c10" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { Modified: sandbox/branches/setuptools-0.6/pkg_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.py (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.py Mon Oct 12 22:00:02 2009 @@ -13,7 +13,7 @@ method. """ -import sys, os, zipimport, time, re, imp, new +import sys, os, zipimport, time, re, imp try: frozenset @@ -39,6 +39,47 @@ +_state_vars = {} + +def _declare_state(vartype, **kw): + g = globals() + for name, val in kw.iteritems(): + g[name] = val + _state_vars[name] = vartype + +def __getstate__(): + state = {} + g = globals() + for k, v in _state_vars.iteritems(): + state[k] = g['_sget_'+v](g[k]) + return state + +def __setstate__(state): + g = globals() + for k, v in state.iteritems(): + g['_sset_'+_state_vars[k]](k, g[k], v) + return state + +def _sget_dict(val): + return val.copy() + +def _sset_dict(key, ob, state): + ob.clear() + ob.update(state) + +def _sget_object(val): + return val.__getstate__() + +def _sset_object(key, ob, state): + ob.__setstate__(state) + +_sget_none = _sset_none = lambda *args: None + + + + + + def get_supported_platform(): """Return this platform's maximum compatible version. @@ -164,14 +205,8 @@ def _macosx_vers(_cache=[]): if not _cache: - info = os.popen('/usr/bin/sw_vers').read().splitlines() - for line in info: - key, value = line.split(None, 1) - if key == 'ProductVersion:': - _cache.append(value.strip().split(".")) - break - else: - raise ValueError, "What?!" + from platform import mac_ver + _cache.append(mac_ver()[0].split('.')) return _cache[0] def _macosx_arch(machine): @@ -203,6 +238,12 @@ + + + + + + def compatible_platforms(provided,required): """Can code for the `provided` platform run on the `required` platform? @@ -387,7 +428,7 @@ def add_entry(self, entry): """Add a path item to ``.entries``, finding any distributions on it - ``find_distributions(entry,False)`` is used to find distributions + ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than @@ -622,7 +663,6 @@ activated to fulfill the requirements; all relevant distributions are included, even if they were already activated in this working set. """ - needed = self.resolve(parse_requirements(requirements)) for dist in needed: @@ -630,7 +670,6 @@ return needed - def subscribe(self, callback): """Invoke `callback` for all distributions (including existing ones)""" if callback in self.callbacks: @@ -639,19 +678,21 @@ for dist in self: callback(dist) - def _added_new(self, dist): for callback in self.callbacks: callback(dist) + def __getstate__(self): + return ( + self.entries[:], self.entry_keys.copy(), self.by_key.copy(), + self.callbacks[:] + ) - - - - - - - + def __setstate__(self, (entries, keys, by_key, callbacks)): + self.entries = entries[:] + self.entry_keys = keys.copy() + self.by_key = by_key.copy() + self.callbacks = callbacks[:] class Environment(object): @@ -1597,7 +1638,7 @@ -_distribution_finders = {} +_declare_state('dict', _distribution_finders = {}) def register_finder(importer_type, distribution_finder): """Register `distribution_finder` to find distributions in sys.path items @@ -1646,7 +1687,7 @@ """Yield distributions accessible on a sys.path directory""" path_item = _normalize_cached(path_item) - if os.path.isdir(path_item): + if os.path.isdir(path_item) and os.access(path_item, os.R_OK): if path_item.lower().endswith('.egg'): # unpacked egg yield Distribution.from_filename( @@ -1679,8 +1720,8 @@ break register_finder(ImpWrapper,find_on_path) -_namespace_handlers = {} -_namespace_packages = {} +_declare_state('dict', _namespace_handlers = {}) +_declare_state('dict', _namespace_packages = {}) def register_namespace_handler(importer_type, namespace_handler): """Register `namespace_handler` to declare namespace packages @@ -1709,7 +1750,7 @@ return None module = sys.modules.get(packageName) if module is None: - module = sys.modules[packageName] = new.module(packageName) + module = sys.modules[packageName] = imp.new_module(packageName) module.__path__ = []; _set_parent_ns(packageName) elif not hasattr(module,'__path__'): raise TypeError("Not a package:", packageName) @@ -2220,12 +2261,9 @@ if not loc: return - if path is sys.path: - self.check_version_conflict() - nloc = _normalize_cached(loc) bdir = os.path.dirname(nloc) - npath= map(_normalize_cached, path) + npath= [(p and _normalize_cached(p) or p) for p in path] bp = None for p, item in enumerate(npath): @@ -2233,10 +2271,14 @@ break elif item==bdir and self.precedence==EGG_DIST: # if it's an .egg, give it precedence over its directory + if path is sys.path: + self.check_version_conflict() path.insert(p, loc) npath.insert(p, nloc) break else: + if path is sys.path: + self.check_version_conflict() path.append(loc) return @@ -2253,7 +2295,6 @@ return - def check_version_conflict(self): if self.key=='setuptools': return # ignore the inevitable setuptools self-conflicts :( @@ -2267,7 +2308,7 @@ continue fn = getattr(sys.modules[modname], '__file__', None) - if fn and normalize_path(fn).startswith(loc): + if fn and (normalize_path(fn).startswith(loc) or fn.startswith(loc)): continue issue_warning( "Module %s was already imported from %s, but %s is being added" @@ -2444,7 +2485,7 @@ def __contains__(self,item): if isinstance(item,Distribution): - if item.key <> self.key: return False + if item.key != self.key: return False if self.index: item = item.parsed_version # only get if we need it elif isinstance(item,basestring): item = parse_version(item) @@ -2541,7 +2582,7 @@ os.open = old_open # and then put it back -# Set up global resource manager +# Set up global resource manager (deliberately not state-saved) _manager = ResourceManager() def _initialize(g): for name in dir(_manager): @@ -2550,7 +2591,7 @@ _initialize(globals()) # Prepare the master working set and make the ``require()`` API available -working_set = WorkingSet() +_declare_state('object', working_set = WorkingSet()) try: # Does the main program list any requirements? from __main__ import __requires__ Modified: sandbox/branches/setuptools-0.6/pkg_resources.txt ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.txt (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.txt Mon Oct 12 22:00:02 2009 @@ -269,7 +269,7 @@ the global ``working_set`` to reflect the change. This method is also called by the ``WorkingSet()`` constructor during initialization. - This method uses ``find_distributions(entry,False)`` to find distributions + This method uses ``find_distributions(entry, True)`` to find distributions corresponding to the path entry, and then ``add()`` them. `entry` is always appended to the ``entries`` attribute, even if it is already present, however. (This is because ``sys.path`` can contain the same value @@ -1661,14 +1661,10 @@ for obtaining an "importer" object. It first checks for an importer for the path item in ``sys.path_importer_cache``, and if not found it calls each of the ``sys.path_hooks`` and caches the result if a good importer is - found. If no importer is found, this routine returns an ``ImpWrapper`` - instance that wraps the builtin import machinery as a PEP 302-compliant - "importer" object. This ``ImpWrapper`` is *not* cached; instead a new - instance is returned each time. - - (Note: When run under Python 2.5, this function is simply an alias for - ``pkgutil.get_importer()``, and instead of ``pkg_resources.ImpWrapper`` - instances, it may return ``pkgutil.ImpImporter`` instances.) + found. If no importer is found, this routine returns a wrapper object + that wraps the builtin import machinery as a PEP 302-compliant "importer" + object. This wrapper object is *not* cached; instead a new instance is + returned each time. File/Path Utilities @@ -1692,7 +1688,11 @@ Release Notes/Change History ---------------------------- -0.6final +0.6c10 + * Prevent lots of spurious "already imported from another path" warnings (e.g. + when pkg_resources is imported late). + +0.6c9 * Fix ``resource_listdir('')`` always returning an empty list for zipped eggs. 0.6c7 Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Mon Oct 12 22:00:02 2009 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6c9" +export VERSION="0.6c10" python2.3 setup.py -q release source --target-version=2.3 upload && \ python2.4 setup.py -q release binary --target-version=2.4 upload && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Mon Oct 12 22:00:02 2009 @@ -7,7 +7,7 @@ execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6c9" +VERSION = "0.6c10" from setuptools import setup, find_packages import sys @@ -53,8 +53,8 @@ "include_package_data = setuptools.dist:assert_bool", "dependency_links = setuptools.dist:assert_string_list", "test_loader = setuptools.dist:check_importable", + "packages = setuptools.dist:check_packages", ], - "egg_info.writers": [ "PKG-INFO = setuptools.command.egg_info:write_pkg_info", "requires.txt = setuptools.command.egg_info:write_requirements", Modified: sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt Mon Oct 12 22:00:02 2009 @@ -49,6 +49,7 @@ eager_resources = setuptools.dist:assert_string_list zip_safe = setuptools.dist:assert_bool test_loader = setuptools.dist:check_importable +packages = setuptools.dist:check_packages tests_require = setuptools.dist:check_requirements [setuptools.installation] Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Mon Oct 12 22:00:02 2009 @@ -2569,6 +2569,27 @@ inform the user of the missing program(s). +A Note Regarding Dependencies +----------------------------- + +If the project *containing* your distutils/setuptools extension(s) depends on +any projects other than setuptools, you *must* also declare those dependencies +as part of your project's ``setup_requires`` keyword, so that they will +already be built (and at least temprorarily installed) before your extension +project is built. + +So, if for example you create a project Foo that includes a new file finder +plugin, and Foo depends on Bar, then you *must* list Bar in both the +``install_requires`` **and** ``setup_requires`` arguments to ``setup()``. + +If you don't do this, then in certain edge cases you may cause setuptools to +try to go into infinite recursion, trying to build your dependencies to resolve +your dependencies, while still building your dependencies. (It probably won't +happen on your development machine, but it *will* happen in a full build +pulling everything from revision control on a clean machine, and then you or +your users will be scratching their heads trying to figure it out!) + + Subclassing ``Command`` ----------------------- @@ -2611,7 +2632,15 @@ Release Notes/Change History ---------------------------- -0.6final +0.6c10 + * Fix for the Python 2.6.3 build_ext API change + + * Ensure C libraries (as opposed to extensions) are also built when doing + bdist_egg + + * Support for SVN 1.6 + +0.6c9 * Fixed a missing files problem when using Windows source distributions on non-Windows platforms, due to distutils not handling manifest file line endings correctly. Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Mon Oct 12 22:00:02 2009 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6c9' +__version__ = '0.6c10' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/setuptools/command/alias.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/alias.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/alias.py Mon Oct 12 22:00:02 2009 @@ -9,7 +9,7 @@ """Quote an argument for later parsing by shlex.split()""" for c in '"', "'", "\\", "#": if c in arg: return repr(arg) - if arg.split()<>[arg]: + if arg.split()!=[arg]: return repr(arg) return arg @@ -33,7 +33,7 @@ def finalize_options(self): option_base.finalize_options(self) - if self.remove and len(self.args)<>1: + if self.remove and len(self.args)!=1: raise DistutilsOptionError( "Must specify exactly one argument (the alias name) when " "using --remove" Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Mon Oct 12 22:00:02 2009 @@ -165,12 +165,13 @@ def run(self): # Generate metadata first self.run_command("egg_info") - # We run install_lib before install_data, because some data hacks # pull their data path from the install_lib command. log.info("installing library code to %s" % self.bdist_dir) instcmd = self.get_finalized_command('install') old_root = instcmd.root; instcmd.root = None + if self.distribution.has_c_libraries() and not self.skip_build: + self.run_command('build_clib') cmd = self.call_command('install_lib', warn_dir=0) instcmd.root = old_root @@ -190,7 +191,6 @@ to_compile.extend(self.make_init_files()) if to_compile: cmd.byte_compile(to_compile) - if self.distribution.data_files: self.do_install_data() @@ -398,7 +398,7 @@ for flag,fn in safety_flags.items(): fn = os.path.join(egg_dir, fn) if os.path.exists(fn): - if safe is None or bool(safe)<>flag: + if safe is None or bool(safe)!=flag: os.unlink(fn) elif safe is not None and bool(safe)==flag: f=open(fn,'wb'); f.write('\n'); f.close() Modified: sandbox/branches/setuptools-0.6/setuptools/command/build_ext.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/build_ext.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/build_ext.py Mon Oct 12 22:00:02 2009 @@ -82,15 +82,15 @@ def get_ext_filename(self, fullname): filename = _build_ext.get_ext_filename(self,fullname) - ext = self.ext_map[fullname] - if isinstance(ext,Library): - fn, ext = os.path.splitext(filename) - return self.shlib_compiler.library_filename(fn,libtype) - elif use_stubs and ext._links_to_dynamic: - d,fn = os.path.split(filename) - return os.path.join(d,'dl-'+fn) - else: - return filename + if fullname in self.ext_map: + ext = self.ext_map[fullname] + if isinstance(ext,Library): + fn, ext = os.path.splitext(filename) + return self.shlib_compiler.library_filename(fn,libtype) + elif use_stubs and ext._links_to_dynamic: + d,fn = os.path.split(filename) + return os.path.join(d,'dl-'+fn) + return filename def initialize_options(self): _build_ext.initialize_options(self) Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Mon Oct 12 22:00:02 2009 @@ -204,7 +204,7 @@ self.outputs = [] def run(self): - if self.verbose<>self.distribution.verbose: + if self.verbose!=self.distribution.verbose: log.set_verbosity(self.verbose) try: for spec in self.args: @@ -252,7 +252,7 @@ # Is it a configured, PYTHONPATH, implicit, or explicit site dir? is_site_dir = instdir in self.all_site_dirs - if not is_site_dir: + if not is_site_dir and not self.multi_version: # No? Then directly test whether it does .pth file processing is_site_dir = self.check_pth_processing() else: @@ -430,9 +430,9 @@ self.check_editable(spec) dist = self.package_index.fetch_distribution( - spec, tmpdir, self.upgrade, self.editable, not self.always_copy + spec, tmpdir, self.upgrade, self.editable, not self.always_copy, + self.local_index ) - if dist is None: msg = "Could not find suitable distribution for %r" % spec if self.always_copy: @@ -722,7 +722,7 @@ f = open(pkg_inf,'w') f.write('Metadata-Version: 1.0\n') for k,v in cfg.items('metadata'): - if k<>'target_version': + if k!='target_version': f.write('%s: %s\n' % (k.replace('_','-').title(), v)) f.close() script_dir = os.path.join(egg_info,'scripts') @@ -988,7 +988,6 @@ def pf(src,dst): if dst.endswith('.py') and not src.startswith('EGG-INFO/'): to_compile.append(dst) - to_chmod.append(dst) elif dst.endswith('.dll') or dst.endswith('.so'): to_chmod.append(dst) self.unpack_progress(src,dst) @@ -1023,6 +1022,7 @@ + def no_default_version_msg(self): return """bad install directory or PYTHONPATH @@ -1286,7 +1286,7 @@ if parts[1].endswith('.egg-info'): prefixes.insert(0,('/'.join(parts[:2]), 'EGG-INFO/')) break - if len(parts)<>2 or not name.endswith('.pth'): + if len(parts)!=2 or not name.endswith('.pth'): continue if name.endswith('-nspkg.pth'): continue Modified: sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py Mon Oct 12 22:00:02 2009 @@ -217,18 +217,21 @@ data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): + if data.startswith('9 and d[9]]+[0]) - elif data.startswith('=6 and record[5]=="delete": continue # skip deleted yield joinpath(dirname, record[0]) - elif data.startswith('"unknown" and version >= self.requested_version + str(version)!="unknown" and version >= self.requested_version def get_version(self, paths=None, default="unknown"): Modified: sandbox/branches/setuptools-0.6/setuptools/dist.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/dist.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/dist.py Mon Oct 12 22:00:02 2009 @@ -8,7 +8,7 @@ from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.errors import DistutilsSetupError import setuptools, pkg_resources, distutils.core, distutils.dist, distutils.cmd -import os, distutils.log +import os, distutils.log, re def _get_unpatched(cls): """Protect against re-patching the distutils if reloaded @@ -61,8 +61,8 @@ parent = '.'.join(nsp.split('.')[:-1]) if parent not in value: distutils.log.warn( - "%r is declared as a package namespace, but %r is not:" - " please correct this in setup.py", nsp, parent + "WARNING: %r is declared as a package namespace, but %r" + " is not: please correct this in setup.py", nsp, parent ) def check_extras(dist, attr, value): @@ -121,6 +121,47 @@ "wildcard patterns" ) +def check_packages(dist, attr, value): + for pkgname in value: + if not re.match(r'\w+(\.\w+)*', pkgname): + distutils.log.warn( + "WARNING: %r not a valid package name; please use only" + ".-separated package names in setup.py", pkgname + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class Distribution(_Distribution): """Distribution with support for features, tests, and package data @@ -415,19 +456,19 @@ if self.packages: self.packages = [ p for p in self.packages - if p<>package and not p.startswith(pfx) + if p!=package and not p.startswith(pfx) ] if self.py_modules: self.py_modules = [ p for p in self.py_modules - if p<>package and not p.startswith(pfx) + if p!=package and not p.startswith(pfx) ] if self.ext_modules: self.ext_modules = [ p for p in self.ext_modules - if p.name<>package and not p.name.startswith(pfx) + if p.name!=package and not p.name.startswith(pfx) ] Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Mon Oct 12 22:00:02 2009 @@ -1,5 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO +import httplib from pkg_resources import * from distutils import log from distutils.errors import DistutilsError @@ -8,7 +9,6 @@ except ImportError: from md5 import md5 from fnmatch import translate - EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.]+)$') HREF = re.compile("""href\\s*=\\s*['"]?([^'"> ]+)""", re.I) # this is here to fix emacs' cruddy broken syntax highlighting @@ -42,6 +42,8 @@ def egg_info_for_url(url): scheme, server, path, parameters, query, fragment = urlparse.urlparse(url) base = urllib2.unquote(path.split('/')[-1]) + if server=='sourceforge.net' and base=='download': # XXX Yuck + base = urllib2.unquote(path.split('/')[-2]) if '#' in base: base, fragment = base.split('#',1) return base,fragment @@ -64,14 +66,12 @@ if basename.endswith('.egg') and '-' in basename: # only one, unambiguous interpretation return [Distribution.from_location(location, basename, metadata)] - if basename.endswith('.exe'): win_base, py_ver = parse_bdist_wininst(basename) if win_base is not None: return interpret_distro_name( location, win_base, metadata, py_ver, BINARY_DIST, "win32" ) - # Try source distro extensions (.zip, .tgz, etc.) # for ext in EXTENSIONS: @@ -186,10 +186,10 @@ return self.info("Reading %s", url) + self.fetched_urls[url] = True # prevent multiple fetch attempts f = self.open_url(url, "Download error: %s -- Some packages may not be found!") if f is None: return - self.fetched_urls[url] = self.fetched_urls[f.url] = True - + self.fetched_urls[f.url] = True if 'html' not in f.headers.get('content-type', '').lower(): f.close() # not html, we can't process it return @@ -329,7 +329,7 @@ def check_md5(self, cs, info, filename, tfp): if re.match('md5=[0-9a-f]{32}$', info): self.debug("Validating md5 checksum for %s", filename) - if cs.hexdigest()<>info[4:]: + if cs.hexdigest()!=info[4:]: tfp.close() os.unlink(filename) raise DistutilsError( @@ -409,7 +409,8 @@ def fetch_distribution(self, - requirement, tmpdir, force_scan=False, source=False, develop_ok=False + requirement, tmpdir, force_scan=False, source=False, develop_ok=False, + local_index=None, ): """Obtain a distribution suitable for fulfilling `requirement` @@ -427,15 +428,15 @@ set, development and system eggs (i.e., those using the ``.egg-info`` format) will be ignored. """ - # process a Requirement self.info("Searching for %s", requirement) skipped = {} + dist = None - def find(req): + def find(env, req): # Find a matching distribution; may be called more than once - for dist in self[req.key]: + for dist in env[req.key]: if dist.precedence==DEVELOP_DIST and not develop_ok: if dist not in skipped: @@ -444,23 +445,25 @@ continue if dist in req and (dist.precedence<=SOURCE_DIST or not source): - self.info("Best match: %s", dist) - return dist.clone( - location=self.download(dist.location, tmpdir) - ) + return dist + + if force_scan: self.prescan() self.find_packages(requirement) + dist = find(self, requirement) + + if local_index is not None: + dist = dist or find(local_index, requirement) - dist = find(requirement) if dist is None and self.to_scan is not None: self.prescan() - dist = find(requirement) + dist = find(self, requirement) if dist is None and not force_scan: self.find_packages(requirement) - dist = find(requirement) + dist = find(self, requirement) if dist is None: self.warn( @@ -468,7 +471,9 @@ (source and "a source distribution of " or ""), requirement, ) - return dist + self.info("Best match: %s", dist) + return dist.clone(location=self.download(dist.location, tmpdir)) + def fetch(self, requirement, tmpdir, force_scan=False, source=False): """Obtain a file suitable for fulfilling `requirement` @@ -485,11 +490,6 @@ - - - - - def gen_setup(self, filename, fragment, tmpdir): match = EGG_FRAGMENT.match(fragment) dists = match and [d for d in @@ -573,17 +573,19 @@ def open_url(self, url, warning=None): - if url.startswith('file:'): - return local_open(url) + if url.startswith('file:'): return local_open(url) try: return open_with_auth(url) except urllib2.HTTPError, v: return v except urllib2.URLError, v: - if warning: self.warn(warning, v.reason) - else: - raise DistutilsError("Download error for %s: %s" - % (url, v.reason)) + reason = v.reason + except httplib.HTTPException, v: + reason = "%s: %s" % (v.__doc__ or v.__class__.__name__, v) + if warning: + self.warn(warning, reason) + else: + raise DistutilsError("Download error for %s: %s" % (url, reason)) def _download_url(self, scheme, url, tmpdir): # Determine download filename @@ -611,8 +613,6 @@ self.url_ok(url, True) # raises error if not allowed return self._attempt_download(url, filename) - - def scan_url(self, url): self.process_url(url, True) Modified: sandbox/branches/setuptools-0.6/setuptools/sandbox.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/sandbox.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/sandbox.py Mon Oct 12 22:00:02 2009 @@ -1,14 +1,46 @@ -import os, sys, __builtin__, tempfile, operator +import os, sys, __builtin__, tempfile, operator, pkg_resources _os = sys.modules[os.name] _open = open +_file = file + from distutils.errors import DistutilsError +from pkg_resources import working_set + __all__ = [ "AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup", ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + def run_setup(setup_script, args): """Run a distutils setup script, sandboxed in its directory""" - old_dir = os.getcwd() save_argv = sys.argv[:] save_path = sys.path[:] @@ -16,13 +48,16 @@ temp_dir = os.path.join(setup_dir,'temp') if not os.path.isdir(temp_dir): os.makedirs(temp_dir) save_tmp = tempfile.tempdir - + save_modules = sys.modules.copy() + pr_state = pkg_resources.__getstate__() try: - tempfile.tempdir = temp_dir - os.chdir(setup_dir) + tempfile.tempdir = temp_dir; os.chdir(setup_dir) try: sys.argv[:] = [setup_script]+list(args) sys.path.insert(0, setup_dir) + # reset to include setup dir, w/clean callback list + working_set.__init__() + working_set.callbacks.append(lambda dist:dist.activate()) DirectorySandbox(setup_dir).run( lambda: execfile( "setup.py", @@ -34,11 +69,17 @@ raise # Normal exit, just return finally: + pkg_resources.__setstate__(pr_state) + sys.modules.update(save_modules) + for key in list(sys.modules): + if key not in save_modules: del sys.modules[key] os.chdir(old_dir) sys.path[:] = save_path sys.argv[:] = save_argv tempfile.tempdir = save_tmp + + class AbstractSandbox: """Wrap 'os' module and 'open()' builtin for virtualizing setup scripts""" @@ -58,15 +99,16 @@ """Run 'func' under os sandboxing""" try: self._copy(self) - __builtin__.open = __builtin__.file = self._open + __builtin__.file = self._file + __builtin__.open = self._open self._active = True return func() finally: self._active = False - __builtin__.open = __builtin__.file = _open + __builtin__.open = _file + __builtin__.file = _open self._copy(_os) - def _mk_dual_path_wrapper(name): original = getattr(_os,name) def wrap(self,src,dst,*args,**kw): @@ -75,7 +117,6 @@ return original(src,dst,*args,**kw) return wrap - for name in ["rename", "link", "symlink"]: if hasattr(_os,name): locals()[name] = _mk_dual_path_wrapper(name) @@ -88,7 +129,8 @@ return original(path,*args,**kw) return wrap - _open = _mk_single_path_wrapper('file', _open) + _open = _mk_single_path_wrapper('open', _open) + _file = _mk_single_path_wrapper('file', _file) for name in [ "stat", "listdir", "chdir", "open", "chmod", "chown", "mkdir", "remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat", @@ -96,7 +138,6 @@ ]: if hasattr(_os,name): locals()[name] = _mk_single_path_wrapper(name) - def _mk_single_with_return(name): original = getattr(_os,name) def wrap(self,path,*args,**kw): @@ -187,22 +228,22 @@ self._violation(operation, src, dst, *args, **kw) return (src,dst) + def _file(self, path, mode='r', *args, **kw): + if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): + self._violation("file", path, mode, *args, **kw) + return _file(path,mode,*args,**kw) + def open(self, file, flags, mode=0777): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode) return _os.open(file,flags,mode) - WRITE_FLAGS = reduce( - operator.or_, - [getattr(_os, a, 0) for a in + operator.or_, [getattr(_os, a, 0) for a in "O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARY".split()] ) - - - class SandboxViolation(DistutilsError): """A setup script attempted to modify the filesystem outside the sandbox""" Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Mon Oct 12 22:00:02 2009 @@ -1,6 +1,6 @@ [setuptools] status = 'release candidate' major = 0 -build = 9 +build = 10 minor = 6 From python-checkins at python.org Mon Oct 12 22:05:56 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 20:05:56 -0000 Subject: [Python-checkins] r75386 - in sandbox/branches/setuptools-0.6: pkg_resources.py setuptools/archive_util.py Message-ID: Author: phillip.eby Date: Mon Oct 12 22:05:56 2009 New Revision: 75386 Log: Backport fixes for issues 16 & 23 from trunk Modified: sandbox/branches/setuptools-0.6/pkg_resources.py sandbox/branches/setuptools-0.6/setuptools/archive_util.py Modified: sandbox/branches/setuptools-0.6/pkg_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.py (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.py Mon Oct 12 22:05:56 2009 @@ -20,18 +20,18 @@ except NameError: from sets import ImmutableSet as frozenset -from os import utime, rename, unlink # capture these to bypass sandboxing +# capture these to bypass sandboxing +from os import utime, rename, unlink, mkdir from os import open as os_open +from os.path import isdir, split - - - - - - - - +def _bypass_ensure_directory(name, mode=0777): + # Sandbox-bypassing version of ensure_directory() + dirname, filename = split(name) + if dirname and filename and not isdir(dirname): + _bypass_ensure_directory(dirname) + mkdir(dirname, mode) @@ -957,7 +957,7 @@ extract_path = self.extraction_path or get_default_cache() target_path = os.path.join(extract_path, archive_name+'-tmp', *names) try: - ensure_directory(target_path) + _bypass_ensure_directory(target_path) except: self.extraction_error() Modified: sandbox/branches/setuptools-0.6/setuptools/archive_util.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/archive_util.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/archive_util.py Mon Oct 12 22:05:56 2009 @@ -189,7 +189,10 @@ if dst: if dst.endswith(os.sep): dst = dst[:-1] - tarobj._extract_member(member,dst) # XXX Ugh + try: + tarobj._extract_member(member,dst) # XXX Ugh + except tarfile.ExtractError: + pass # chown/chmod/mkfifo/mknode/makedev failed return True finally: tarobj.close() @@ -200,6 +203,3 @@ extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile - - - From python-checkins at python.org Mon Oct 12 22:20:34 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 20:20:34 -0000 Subject: [Python-checkins] r75387 - in sandbox/trunk/setuptools/setuptools: cli.exe command/easy_install.py gui.exe Message-ID: Author: phillip.eby Date: Mon Oct 12 22:20:33 2009 New Revision: 75387 Log: Fixes for Windwos 64 and Vista UAC errors Modified: sandbox/trunk/setuptools/setuptools/cli.exe sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/gui.exe Modified: sandbox/trunk/setuptools/setuptools/cli.exe ============================================================================== Binary files. No diff available. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Mon Oct 12 22:20:33 2009 @@ -1590,13 +1590,54 @@ yield (name+ext, hdr+script_text, 't', [name+x for x in old]) yield ( name+'.exe', resource_string('setuptools', launcher), - 'b' # write in binary mode - ) + 'b') # write in binary mode + yield (name+'.exe.manifest', _launcher_manifest % (name,), 't') else: # On other platforms, we assume the right thing to do is to # just write the stub with no extension. yield (name, header+script_text) +_launcher_manifest = """ + + + + + + + + + + + + +""" + + + + + + + + + + + + + + + + + + + + + + + + def rmtree(path, ignore_errors=False, onerror=auto_chmod): """Recursively delete a directory tree. Modified: sandbox/trunk/setuptools/setuptools/gui.exe ============================================================================== Binary files. No diff available. From python-checkins at python.org Mon Oct 12 22:21:44 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 20:21:44 -0000 Subject: [Python-checkins] r75388 - in sandbox/branches/setuptools-0.6/setuptools: cli.exe command/easy_install.py gui.exe Message-ID: Author: phillip.eby Date: Mon Oct 12 22:21:43 2009 New Revision: 75388 Log: Windows 64/Vista UAC fixes Modified: sandbox/branches/setuptools-0.6/setuptools/cli.exe sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/gui.exe Modified: sandbox/branches/setuptools-0.6/setuptools/cli.exe ============================================================================== Binary files. No diff available. Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Mon Oct 12 22:21:43 2009 @@ -1590,13 +1590,54 @@ yield (name+ext, hdr+script_text, 't', [name+x for x in old]) yield ( name+'.exe', resource_string('setuptools', launcher), - 'b' # write in binary mode - ) + 'b') # write in binary mode + yield (name+'.exe.manifest', _launcher_manifest % (name,), 't') else: # On other platforms, we assume the right thing to do is to # just write the stub with no extension. yield (name, header+script_text) +_launcher_manifest = """ + + + + + + + + + + + + +""" + + + + + + + + + + + + + + + + + + + + + + + + def rmtree(path, ignore_errors=False, onerror=auto_chmod): """Recursively delete a directory tree. Modified: sandbox/branches/setuptools-0.6/setuptools/gui.exe ============================================================================== Binary files. No diff available. From python-checkins at python.org Mon Oct 12 22:23:55 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 12 Oct 2009 20:23:55 -0000 Subject: [Python-checkins] r75389 - sandbox/branches/setuptools-0.6/EasyInstall.txt Message-ID: Author: phillip.eby Date: Mon Oct 12 22:23:55 2009 New Revision: 75389 Log: Update change log Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Mon Oct 12 22:23:55 2009 @@ -1218,6 +1218,10 @@ ============================ 0.6c10 + * Fix easy_install.exe giving UAC errors on Windows Vista + + * Fix installed script .exe files not working with 64-bit Python on Windows + * Support for the most recent Sourceforge download link insanity * Stop crashing on certain types of HTTP error From nnorwitz at gmail.com Mon Oct 12 23:45:50 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 12 Oct 2009 17:45:50 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091012214550.GA17899@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [0, 0, 291] references, sum=291 Less important issues: ---------------------- test_smtplib leaked [-160, 0, 0] references, sum=-160 test_sys leaked [-21, -21, 0] references, sum=-42 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Tue Oct 13 00:38:35 2009 From: python-checkins at python.org (tarek.ziade) Date: Mon, 12 Oct 2009 22:38:35 -0000 Subject: [Python-checkins] r75390 - in python/branches/release26-maint: Lib/distutils/command/build_ext.py Lib/distutils/tests/test_build_ext.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Tue Oct 13 00:38:34 2009 New Revision: 75390 Log: Fixed #7115: using paths instead of dotted name for extensions works too in distutils.command.build_ext Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/command/build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/command/build_ext.py Tue Oct 13 00:38:34 2009 @@ -628,6 +628,8 @@ The file is located in `build_lib` or directly in the package (inplace option). """ + if os.sep in ext_name: + ext_name = ext_name.replace(os.sep, '.') fullname = self.get_ext_fullname(ext_name) modpath = fullname.split('.') filename = self.get_ext_filename(ext_name) Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Tue Oct 13 00:38:34 2009 @@ -363,6 +363,16 @@ path = cmd.get_ext_fullpath('lxml.etree') self.assertEquals(wanted, path) + def test_build_ext_path_with_os_sep(self): + dist = Distribution({'name': 'UpdateManager'}) + cmd = build_ext(dist) + cmd.ensure_finalized() + ext = sysconfig.get_config_var("SO") + ext_name = os.path.join('UpdateManager', 'fdsend') + ext_path = cmd.get_ext_fullpath(ext_name) + wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext) + self.assertEquals(ext_path, wanted) + def test_suite(): if not sysconfig.python_build: if test_support.verbose: Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 13 00:38:34 2009 @@ -18,6 +18,9 @@ Library ------- +- Issue #7115: Fixed the extension module builds that is failing when using + paths in the extension name instead of dotted names. + - Issue #7068: Fixed the partial renaming that occured in r72594. - Issue #7064: Fixed the incompatibility with Setuptools in distutils From nnorwitz at gmail.com Tue Oct 13 11:51:06 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 13 Oct 2009 05:51:06 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091013095106.GA28899@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 Less important issues: ---------------------- test_asynchat leaked [-130, 0, 0] references, sum=-130 test_distutils leaked [0, 25, -25] references, sum=0 test_smtplib leaked [-188, 0, 7] references, sum=-181 test_socketserver leaked [83, -83, 82] references, sum=82 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Tue Oct 13 17:49:33 2009 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 13 Oct 2009 15:49:33 -0000 Subject: [Python-checkins] r75391 - python/trunk/Doc/whatsnew/2.7.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 13 17:49:33 2009 New Revision: 75391 Log: Link to PEP Modified: python/trunk/Doc/whatsnew/2.7.rst Modified: python/trunk/Doc/whatsnew/2.7.rst ============================================================================== --- python/trunk/Doc/whatsnew/2.7.rst (original) +++ python/trunk/Doc/whatsnew/2.7.rst Tue Oct 13 17:49:33 2009 @@ -171,6 +171,11 @@ an *object_pairs_hook* to allow OrderedDicts to be built by the decoder. Support was also added for third-party tools like `PyYAML `_. +.. seealso:: + + :pep:`372` - Adding an ordered dictionary to collections + PEP written by Armin Ronacher and Raymond Hettinger; + implemented by Raymond Hettinger. .. _pep-0378: From python-checkins at python.org Tue Oct 13 18:11:49 2009 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 13 Oct 2009 16:11:49 -0000 Subject: [Python-checkins] r75392 - python/trunk/Doc/faq/gui.rst Message-ID: Author: andrew.kuchling Date: Tue Oct 13 18:11:49 2009 New Revision: 75392 Log: Various link, textual, and markup fixes Modified: python/trunk/Doc/faq/gui.rst Modified: python/trunk/Doc/faq/gui.rst ============================================================================== --- python/trunk/Doc/faq/gui.rst (original) +++ python/trunk/Doc/faq/gui.rst Tue Oct 13 18:11:49 2009 @@ -25,27 +25,26 @@ page at http://www.tcl.tk. Tcl/Tk is fully portable to the MacOS, Windows, and Unix platforms. -wxWindows +wxWidgets ''''''''' -wxWindows is a portable GUI class library written in C++ that's a portable -interface to various platform-specific libraries; wxWidgets is a Python -interface to wxWindows. wxWindows supports Windows and MacOS; on Unix variants, -it supports both GTk+ and Motif toolkits. wxWindows preserves the look and feel -of the underlying graphics toolkit, and there is quite a rich widget set and -collection of GDI classes. See `the wxWindows page `_ -for more details. - -`wxWidgets `_ is an extension module that wraps many of -the wxWindows C++ classes, and is quickly gaining popularity amongst Python -developers. You can get wxWidgets as part of the source or CVS distribution of -wxWindows, or directly from its home page. +wxWidgets is a GUI class library written in C++ that's a portable +interface to various platform-specific libraries, and that has a +Python interface called `wxPython `__. + +wxWidgets preserves the look and feel of the +underlying graphics toolkit, and has a large set of widgets and +collection of GDI classes. See `the wxWidgets page +`_ for more details. + +wxWidgets supports Windows and MacOS; on Unix variants, +it supports both GTk+ and Motif toolkits. Qt ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If +`_) and for KDE (`PyKDE `__). If you're writing open source software, you don't need to pay for PyQt, but if you want to write proprietary applications, you must buy a PyQt license from `Riverbank Computing `_ and (up to Qt 4.4; @@ -56,7 +55,7 @@ '''' PyGtk bindings for the `Gtk+ toolkit `_ have been -implemented by by James Henstridge; see ftp://ftp.gtk.org/pub/gtk/python/. +implemented by James Henstridge; see . FLTK '''' @@ -85,14 +84,15 @@ `The Mac port `_ by Jack Jansen has a rich and ever-growing set of modules that support the native Mac toolbox calls. The port -includes support for MacOS9 and MacOS X's Carbon libraries. By installing the -`PyObjc Objective-C bridge `_, Python programs -can use MacOS X's Cocoa libraries. See the documentation that comes with the Mac -port. +supports MacOS X's Carbon libraries. + +By installing the `PyObjc Objective-C bridge +`_, Python programs can use MacOS X's +Cocoa libraries. See the documentation that comes with the Mac port. :ref:`Pythonwin ` by Mark Hammond includes an interface to the -Microsoft Foundation Classes and a Python programming environment using it -that's written mostly in Python. +Microsoft Foundation Classes and a Python programming environment +that's written mostly in Python using the MFC classes. Tkinter questions @@ -105,23 +105,26 @@ applications, the applications will not be truly stand-alone, as the application will still need the Tcl and Tk libraries. -One solution is to ship the application with the tcl and tk libraries, and point +One solution is to ship the application with the Tcl and Tk libraries, and point to them at run-time using the :envvar:`TCL_LIBRARY` and :envvar:`TK_LIBRARY` environment variables. To get truly stand-alone applications, the Tcl scripts that form the library have to be integrated into the application as well. One tool supporting that is SAM (stand-alone modules), which is part of the Tix distribution -(http://tix.mne.com). Build Tix with SAM enabled, perform the appropriate call -to Tclsam_init etc inside Python's Modules/tkappinit.c, and link with libtclsam -and libtksam (you might include the Tix libraries as well). +(http://tix.sourceforge.net/). + +Build Tix with SAM enabled, perform the appropriate call to +:cfunc:`Tclsam_init`, etc. inside Python's +:file:`Modules/tkappinit.c`, and link with libtclsam and libtksam (you +might include the Tix libraries as well). Can I have Tk events handled while waiting for I/O? --------------------------------------------------- Yes, and you don't even need threads! But you'll have to restructure your I/O -code a bit. Tk has the equivalent of Xt's XtAddInput() call, which allows you +code a bit. Tk has the equivalent of Xt's :cfunc:`XtAddInput()` call, which allows you to register a callback function which will be called from the Tk mainloop when I/O is possible on a file descriptor. Here's what you need:: From python-checkins at python.org Tue Oct 13 18:55:12 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 13 Oct 2009 16:55:12 -0000 Subject: [Python-checkins] r75393 - in python/branches/py3k/Doc/faq: library.rst programming.rst Message-ID: Author: georg.brandl Date: Tue Oct 13 18:55:12 2009 New Revision: 75393 Log: Update module names in references in the FAQ. Modified: python/branches/py3k/Doc/faq/library.rst python/branches/py3k/Doc/faq/programming.rst Modified: python/branches/py3k/Doc/faq/library.rst ============================================================================== --- python/branches/py3k/Doc/faq/library.rst (original) +++ python/branches/py3k/Doc/faq/library.rst Tue Oct 13 18:55:12 2009 @@ -232,11 +232,9 @@ How do I program using threads? ------------------------------- -.. XXX it's _thread in py3k - -Be sure to use the :mod:`threading` module and not the :mod:`thread` module. +Be sure to use the :mod:`threading` module and not the :mod:`_thread` module. The :mod:`threading` module builds convenient abstractions on top of the -low-level primitives provided by the :mod:`thread` module. +low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see http://starship.python.net/crew/aahz/OSCON2001/. @@ -280,7 +278,7 @@ Instead of trying to guess how long a :func:`time.sleep` delay will be enough, it's better to use some kind of semaphore mechanism. One idea is to use the -:mod:`Queue` module to create a queue object, let each thread append a token to +:mod:`queue` module to create a queue object, let each thread append a token to the queue when it finishes, and let the main thread read as many tokens from the queue as there are threads. @@ -288,8 +286,8 @@ How do I parcel out work among a bunch of worker threads? --------------------------------------------------------- -Use the :mod:`Queue` module to create a queue containing a list of jobs. The -:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +Use the :mod:`queue` module to create a queue containing a list of jobs. The +:class:`~queue.Queue` class maintains a list of objects with ``.put(obj)`` to add an item to the queue and ``.get()`` to return an item. The class will take care of the locking necessary to ensure that each job is handed out exactly once. @@ -777,11 +775,10 @@ Yes. -.. XXX remove bsddb in py3k, fix other module names - -Python 2.3 includes the :mod:`bsddb` package which provides an interface to the -BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM ` -and :mod:`GDBM ` are also included with standard Python. +Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM +` are also included with standard Python. There is also the +:mod:`sqlite3` module, which provides a lightweight disk-based relational +database. Support for most relational databases is available. See the `DatabaseProgramming wiki page @@ -794,8 +791,7 @@ The :mod:`pickle` library module solves this in a very general way (though you still can't store things like open files, sockets or windows), and the :mod:`shelve` library module uses pickle and (g)dbm to create persistent -mappings containing arbitrary Python objects. For better performance, you can -use the :mod:`cPickle` module. +mappings containing arbitrary Python objects. A more awkward way of doing things is to use pickle's little sister, marshal. The :mod:`marshal` module provides very fast ways to store noncircular basic Modified: python/branches/py3k/Doc/faq/programming.rst ============================================================================== --- python/branches/py3k/Doc/faq/programming.rst (original) +++ python/branches/py3k/Doc/faq/programming.rst Tue Oct 13 18:55:12 2009 @@ -364,7 +364,7 @@ In general, don't use ``from modulename import *``. Doing so clutters the importer's namespace. Some people avoid this idiom even with the few modules that were designed to be imported in this manner. Modules designed in this -manner include :mod:`Tkinter`, and :mod:`threading`. +manner include :mod:`tkinter`, and :mod:`threading`. Import modules at the top of a file. Doing so makes it clear what other modules your code requires and avoids questions of whether the module name is in scope. From python-checkins at python.org Tue Oct 13 20:11:00 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 13 Oct 2009 18:11:00 -0000 Subject: [Python-checkins] r75394 - python/trunk/Doc/library/datetime.rst Message-ID: Author: georg.brandl Date: Tue Oct 13 20:10:59 2009 New Revision: 75394 Log: Fix markup. Modified: python/trunk/Doc/library/datetime.rst Modified: python/trunk/Doc/library/datetime.rst ============================================================================== --- python/trunk/Doc/library/datetime.rst (original) +++ python/trunk/Doc/library/datetime.rst Tue Oct 13 20:10:59 2009 @@ -235,7 +235,7 @@ | | (-*t1.days*, -*t1.seconds*, | | | -*t1.microseconds*), and to *t1*\* -1. (1)(4) | +--------------------------------+-----------------------------------------------+ -| ``abs(t)`` | equivalent to +*t* when ``t.days >= 0``, and | +| ``abs(t)`` | equivalent to +\ *t* when ``t.days >= 0``, and| | | to -*t* when ``t.days < 0``. (2) | +--------------------------------+-----------------------------------------------+ From python-checkins at python.org Tue Oct 13 23:17:34 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 13 Oct 2009 21:17:34 -0000 Subject: [Python-checkins] r75395 - in python/branches/release26-maint/Lib/distutils: command/build_ext.py tests/test_build_ext.py Message-ID: Author: tarek.ziade Date: Tue Oct 13 23:17:34 2009 New Revision: 75395 Log: complementary fix for #7115 Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/command/build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/command/build_ext.py Tue Oct 13 23:17:34 2009 @@ -628,8 +628,10 @@ The file is located in `build_lib` or directly in the package (inplace option). """ - if os.sep in ext_name: - ext_name = ext_name.replace(os.sep, '.') + # makes sure the extension name is only using dots + all_dots = string.maketrans('/'+os.sep, '..') + ext_name = ext_name.translate(all_dots) + fullname = self.get_ext_fullname(ext_name) modpath = fullname.split('.') filename = self.get_ext_filename(ext_name) Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py Tue Oct 13 23:17:34 2009 @@ -373,6 +373,19 @@ wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext) self.assertEquals(ext_path, wanted) + def test_build_ext_path_cross_platform(self): + if sys.platform != 'win32': + return + dist = Distribution({'name': 'UpdateManager'}) + cmd = build_ext(dist) + cmd.ensure_finalized() + ext = sysconfig.get_config_var("SO") + # this needs to work even under win32 + ext_name = 'UpdateManager/fdsend' + ext_path = cmd.get_ext_fullpath(ext_name) + wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext) + self.assertEquals(ext_path, wanted) + def test_suite(): if not sysconfig.python_build: if test_support.verbose: From python-checkins at python.org Tue Oct 13 23:29:35 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Tue, 13 Oct 2009 21:29:35 -0000 Subject: [Python-checkins] r75396 - in python/trunk: Objects/unicodetype_db.h Tools/unicode/makeunicodedata.py Message-ID: Author: amaury.forgeotdarc Date: Tue Oct 13 23:29:34 2009 New Revision: 75396 Log: #7112: Fix compilation warning in unicodetype_db.h makeunicodedata now generates double literals Modified: python/trunk/Objects/unicodetype_db.h python/trunk/Tools/unicode/makeunicodedata.py Modified: python/trunk/Objects/unicodetype_db.h ============================================================================== --- python/trunk/Objects/unicodetype_db.h (original) +++ python/trunk/Objects/unicodetype_db.h Tue Oct 13 23:29:34 2009 @@ -1818,7 +1818,7 @@ { switch (ch) { case 0x0F33: - return (double) -1/2; + return (double) -1.0/2.0; case 0x0030: case 0x0660: case 0x06F0: @@ -1868,7 +1868,7 @@ case 0x1D7EC: case 0x1D7F6: #endif - return (double) 0; + return (double) 0.0; case 0x0031: case 0x00B9: case 0x0661: @@ -1951,7 +1951,7 @@ case 0x1D7F7: case 0x2092A: #endif - return (double) 1; + return (double) 1.0; case 0x00BD: case 0x0D74: case 0x0F2A: @@ -1961,13 +1961,13 @@ case 0x10175: case 0x10176: #endif - return (double) 1/2; + return (double) 1.0/2.0; case 0x2153: #ifdef Py_UNICODE_WIDE case 0x1245A: case 0x1245D: #endif - return (double) 1/3; + return (double) 1.0/3.0; case 0x00BC: case 0x0D73: #ifdef Py_UNICODE_WIDE @@ -1975,19 +1975,19 @@ case 0x12460: case 0x12462: #endif - return (double) 1/4; + return (double) 1.0/4.0; case 0x2155: - return (double) 1/5; + return (double) 1.0/5.0; case 0x2159: #ifdef Py_UNICODE_WIDE case 0x12461: #endif - return (double) 1/6; + return (double) 1.0/6.0; case 0x215B: #ifdef Py_UNICODE_WIDE case 0x1245F: #endif - return (double) 1/8; + return (double) 1.0/8.0; case 0x0BF0: case 0x0D70: case 0x1372: @@ -2024,7 +2024,7 @@ case 0x10A44: case 0x1D369: #endif - return (double) 10; + return (double) 10.0; case 0x0BF1: case 0x0D71: case 0x137B: @@ -2042,7 +2042,7 @@ case 0x10919: case 0x10A46: #endif - return (double) 100; + return (double) 100.0; case 0x0BF2: case 0x0D72: case 0x216F: @@ -2058,7 +2058,7 @@ case 0x10171: case 0x10A47: #endif - return (double) 1000; + return (double) 1000.0; case 0x137C: case 0x2182: case 0x4E07: @@ -2067,75 +2067,75 @@ case 0x1012B: case 0x10155: #endif - return (double) 10000; + return (double) 10000.0; case 0x2188: - return (double) 100000; + return (double) 100000.0; case 0x4EBF: case 0x5104: - return (double) 100000000; + return (double) 100000000.0; case 0x5146: - return (double) 1000000000000; + return (double) 1000000000000.0; case 0x216A: case 0x217A: case 0x246A: case 0x247E: case 0x2492: case 0x24EB: - return (double) 11; + return (double) 11.0; case 0x0F2F: - return (double) 11/2; + return (double) 11.0/2.0; case 0x216B: case 0x217B: case 0x246B: case 0x247F: case 0x2493: case 0x24EC: - return (double) 12; + return (double) 12.0; case 0x246C: case 0x2480: case 0x2494: case 0x24ED: - return (double) 13; + return (double) 13.0; case 0x0F30: - return (double) 13/2; + return (double) 13.0/2.0; case 0x246D: case 0x2481: case 0x2495: case 0x24EE: - return (double) 14; + return (double) 14.0; case 0x246E: case 0x2482: case 0x2496: case 0x24EF: - return (double) 15; + return (double) 15.0; case 0x0F31: - return (double) 15/2; + return (double) 15.0/2.0; case 0x09F9: case 0x246F: case 0x2483: case 0x2497: case 0x24F0: - return (double) 16; + return (double) 16.0; case 0x16EE: case 0x2470: case 0x2484: case 0x2498: case 0x24F1: - return (double) 17; + return (double) 17.0; case 0x0F32: - return (double) 17/2; + return (double) 17.0/2.0; case 0x16EF: case 0x2471: case 0x2485: case 0x2499: case 0x24F2: - return (double) 18; + return (double) 18.0; case 0x16F0: case 0x2472: case 0x2486: case 0x249A: case 0x24F3: - return (double) 19; + return (double) 19.0; case 0x0032: case 0x00B2: case 0x0662: @@ -2222,16 +2222,16 @@ case 0x1D7F8: case 0x22390: #endif - return (double) 2; + return (double) 2.0; case 0x2154: #ifdef Py_UNICODE_WIDE case 0x10177: case 0x1245B: case 0x1245E: #endif - return (double) 2/3; + return (double) 2.0/3.0; case 0x2156: - return (double) 2/5; + return (double) 2.0/5.0; case 0x1373: case 0x2473: case 0x2487: @@ -2247,37 +2247,37 @@ case 0x10A45: case 0x1D36A: #endif - return (double) 20; + return (double) 20.0; #ifdef Py_UNICODE_WIDE case 0x1011A: - return (double) 200; + return (double) 200.0; #endif #ifdef Py_UNICODE_WIDE case 0x10123: - return (double) 2000; + return (double) 2000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012C: - return (double) 20000; + return (double) 20000.0; #endif case 0x3251: - return (double) 21; + return (double) 21.0; case 0x3252: - return (double) 22; + return (double) 22.0; case 0x3253: - return (double) 23; + return (double) 23.0; case 0x3254: - return (double) 24; + return (double) 24.0; case 0x3255: - return (double) 25; + return (double) 25.0; case 0x3256: - return (double) 26; + return (double) 26.0; case 0x3257: - return (double) 27; + return (double) 27.0; case 0x3258: - return (double) 28; + return (double) 28.0; case 0x3259: - return (double) 29; + return (double) 29.0; case 0x0033: case 0x00B3: case 0x0663: @@ -2366,19 +2366,19 @@ case 0x22998: case 0x23B1B: #endif - return (double) 3; + return (double) 3.0; case 0x0F2B: - return (double) 3/2; + return (double) 3.0/2.0; case 0x00BE: case 0x0D75: #ifdef Py_UNICODE_WIDE case 0x10178: #endif - return (double) 3/4; + return (double) 3.0/4.0; case 0x2157: - return (double) 3/5; + return (double) 3.0/5.0; case 0x215C: - return (double) 3/8; + return (double) 3.0/8.0; case 0x1374: case 0x303A: case 0x325A: @@ -2389,38 +2389,38 @@ case 0x1D36B: case 0x20983: #endif - return (double) 30; + return (double) 30.0; #ifdef Py_UNICODE_WIDE case 0x1011B: case 0x1016B: - return (double) 300; + return (double) 300.0; #endif #ifdef Py_UNICODE_WIDE case 0x10124: - return (double) 3000; + return (double) 3000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012D: - return (double) 30000; + return (double) 30000.0; #endif case 0x325B: - return (double) 31; + return (double) 31.0; case 0x325C: - return (double) 32; + return (double) 32.0; case 0x325D: - return (double) 33; + return (double) 33.0; case 0x325E: - return (double) 34; + return (double) 34.0; case 0x325F: - return (double) 35; + return (double) 35.0; case 0x32B1: - return (double) 36; + return (double) 36.0; case 0x32B2: - return (double) 37; + return (double) 37.0; case 0x32B3: - return (double) 38; + return (double) 38.0; case 0x32B4: - return (double) 39; + return (double) 39.0; case 0x0034: case 0x0664: case 0x06F4: @@ -2502,9 +2502,9 @@ case 0x200E2: case 0x2626D: #endif - return (double) 4; + return (double) 4.0; case 0x2158: - return (double) 4/5; + return (double) 4.0/5.0; case 0x1375: case 0x32B5: case 0x534C: @@ -2514,37 +2514,37 @@ case 0x2098C: case 0x2099C: #endif - return (double) 40; + return (double) 40.0; #ifdef Py_UNICODE_WIDE case 0x1011C: - return (double) 400; + return (double) 400.0; #endif #ifdef Py_UNICODE_WIDE case 0x10125: - return (double) 4000; + return (double) 4000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012E: - return (double) 40000; + return (double) 40000.0; #endif case 0x32B6: - return (double) 41; + return (double) 41.0; case 0x32B7: - return (double) 42; + return (double) 42.0; case 0x32B8: - return (double) 43; + return (double) 43.0; case 0x32B9: - return (double) 44; + return (double) 44.0; case 0x32BA: - return (double) 45; + return (double) 45.0; case 0x32BB: - return (double) 46; + return (double) 46.0; case 0x32BC: - return (double) 47; + return (double) 47.0; case 0x32BD: - return (double) 48; + return (double) 48.0; case 0x32BE: - return (double) 49; + return (double) 49.0; case 0x0035: case 0x0665: case 0x06F5: @@ -2624,16 +2624,16 @@ case 0x1D7FB: case 0x20121: #endif - return (double) 5; + return (double) 5.0; case 0x0F2C: - return (double) 5/2; + return (double) 5.0/2.0; case 0x215A: #ifdef Py_UNICODE_WIDE case 0x1245C: #endif - return (double) 5/6; + return (double) 5.0/6.0; case 0x215D: - return (double) 5/8; + return (double) 5.0/8.0; case 0x1376: case 0x216C: case 0x217C: @@ -2652,7 +2652,7 @@ case 0x10323: case 0x1D36D: #endif - return (double) 50; + return (double) 50.0; case 0x216E: case 0x217E: #ifdef Py_UNICODE_WIDE @@ -2666,7 +2666,7 @@ case 0x1016F: case 0x10170: #endif - return (double) 500; + return (double) 500.0; case 0x2181: #ifdef Py_UNICODE_WIDE case 0x10126: @@ -2674,14 +2674,14 @@ case 0x1014E: case 0x10172: #endif - return (double) 5000; + return (double) 5000.0; case 0x2187: #ifdef Py_UNICODE_WIDE case 0x1012F: case 0x10147: case 0x10156: #endif - return (double) 50000; + return (double) 50000.0; case 0x0036: case 0x0666: case 0x06F6: @@ -2753,24 +2753,24 @@ case 0x1D7FC: case 0x20AEA: #endif - return (double) 6; + return (double) 6.0; case 0x1377: #ifdef Py_UNICODE_WIDE case 0x10115: case 0x1D36E: #endif - return (double) 60; + return (double) 60.0; #ifdef Py_UNICODE_WIDE case 0x1011E: - return (double) 600; + return (double) 600.0; #endif #ifdef Py_UNICODE_WIDE case 0x10127: - return (double) 6000; + return (double) 6000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10130: - return (double) 60000; + return (double) 60000.0; #endif case 0x0037: case 0x0667: @@ -2842,28 +2842,28 @@ case 0x1D7FD: case 0x20001: #endif - return (double) 7; + return (double) 7.0; case 0x0F2D: - return (double) 7/2; + return (double) 7.0/2.0; case 0x215E: - return (double) 7/8; + return (double) 7.0/8.0; case 0x1378: #ifdef Py_UNICODE_WIDE case 0x10116: case 0x1D36F: #endif - return (double) 70; + return (double) 70.0; #ifdef Py_UNICODE_WIDE case 0x1011F: - return (double) 700; + return (double) 700.0; #endif #ifdef Py_UNICODE_WIDE case 0x10128: - return (double) 7000; + return (double) 7000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10131: - return (double) 70000; + return (double) 70000.0; #endif case 0x0038: case 0x0668: @@ -2931,24 +2931,24 @@ case 0x1D7F4: case 0x1D7FE: #endif - return (double) 8; + return (double) 8.0; case 0x1379: #ifdef Py_UNICODE_WIDE case 0x10117: case 0x1D370: #endif - return (double) 80; + return (double) 80.0; #ifdef Py_UNICODE_WIDE case 0x10120: - return (double) 800; + return (double) 800.0; #endif #ifdef Py_UNICODE_WIDE case 0x10129: - return (double) 8000; + return (double) 8000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10132: - return (double) 80000; + return (double) 80000.0; #endif case 0x0039: case 0x0669: @@ -3020,28 +3020,28 @@ case 0x1D7FF: case 0x2F890: #endif - return (double) 9; + return (double) 9.0; case 0x0F2E: - return (double) 9/2; + return (double) 9.0/2.0; case 0x137A: #ifdef Py_UNICODE_WIDE case 0x10118: case 0x10341: case 0x1D371: #endif - return (double) 90; + return (double) 90.0; #ifdef Py_UNICODE_WIDE case 0x10121: case 0x1034A: - return (double) 900; + return (double) 900.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012A: - return (double) 9000; + return (double) 9000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10133: - return (double) 90000; + return (double) 90000.0; #endif } return -1.0; Modified: python/trunk/Tools/unicode/makeunicodedata.py ============================================================================== --- python/trunk/Tools/unicode/makeunicodedata.py (original) +++ python/trunk/Tools/unicode/makeunicodedata.py Tue Oct 13 23:29:34 2009 @@ -468,6 +468,11 @@ print >>fp, '{' print >>fp, ' switch (ch) {' for value, codepoints in numeric_items: + # Turn text into float literals + parts = value.split('/') + parts = [repr(float(part)) for part in parts] + value = '/'.join(parts) + haswide = False hasnonewide = False codepoints.sort() From nnorwitz at gmail.com Tue Oct 13 23:58:28 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 13 Oct 2009 17:58:28 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091013215828.GA15991@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [0, 270, 10] references, sum=280 Less important issues: ---------------------- test_asynchat leaked [0, 0, 130] references, sum=130 test_smtplib leaked [4, -88, 3] references, sum=-81 test_sys leaked [0, -21, 104] references, sum=83 test_threading leaked [48, 48, 48] references, sum=144 test_xmlrpc leaked [9, -9, 0] references, sum=0 From python-checkins at python.org Wed Oct 14 01:18:54 2009 From: python-checkins at python.org (amaury.forgeotdarc) Date: Tue, 13 Oct 2009 23:18:54 -0000 Subject: [Python-checkins] r75397 - in python/branches/py3k: Objects/unicodetype_db.h Tools/unicode/makeunicodedata.py Message-ID: Author: amaury.forgeotdarc Date: Wed Oct 14 01:18:53 2009 New Revision: 75397 Log: Merged revisions 75396 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75396 | amaury.forgeotdarc | 2009-10-13 23:29:34 +0200 (mar., 13 oct. 2009) | 3 lines #7112: Fix compilation warning in unicodetype_db.h makeunicodedata now generates double literals ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Objects/unicodetype_db.h python/branches/py3k/Tools/unicode/makeunicodedata.py Modified: python/branches/py3k/Objects/unicodetype_db.h ============================================================================== --- python/branches/py3k/Objects/unicodetype_db.h (original) +++ python/branches/py3k/Objects/unicodetype_db.h Wed Oct 14 01:18:53 2009 @@ -1890,7 +1890,7 @@ { switch (ch) { case 0x0F33: - return (double) -1/2; + return (double) -1.0/2.0; case 0x0030: case 0x0660: case 0x06F0: @@ -1940,7 +1940,7 @@ case 0x1D7EC: case 0x1D7F6: #endif - return (double) 0; + return (double) 0.0; case 0x0031: case 0x00B9: case 0x0661: @@ -2023,7 +2023,7 @@ case 0x1D7F7: case 0x2092A: #endif - return (double) 1; + return (double) 1.0; case 0x00BD: case 0x0D74: case 0x0F2A: @@ -2033,13 +2033,13 @@ case 0x10175: case 0x10176: #endif - return (double) 1/2; + return (double) 1.0/2.0; case 0x2153: #ifdef Py_UNICODE_WIDE case 0x1245A: case 0x1245D: #endif - return (double) 1/3; + return (double) 1.0/3.0; case 0x00BC: case 0x0D73: #ifdef Py_UNICODE_WIDE @@ -2047,19 +2047,19 @@ case 0x12460: case 0x12462: #endif - return (double) 1/4; + return (double) 1.0/4.0; case 0x2155: - return (double) 1/5; + return (double) 1.0/5.0; case 0x2159: #ifdef Py_UNICODE_WIDE case 0x12461: #endif - return (double) 1/6; + return (double) 1.0/6.0; case 0x215B: #ifdef Py_UNICODE_WIDE case 0x1245F: #endif - return (double) 1/8; + return (double) 1.0/8.0; case 0x0BF0: case 0x0D70: case 0x1372: @@ -2096,7 +2096,7 @@ case 0x10A44: case 0x1D369: #endif - return (double) 10; + return (double) 10.0; case 0x0BF1: case 0x0D71: case 0x137B: @@ -2114,7 +2114,7 @@ case 0x10919: case 0x10A46: #endif - return (double) 100; + return (double) 100.0; case 0x0BF2: case 0x0D72: case 0x216F: @@ -2130,7 +2130,7 @@ case 0x10171: case 0x10A47: #endif - return (double) 1000; + return (double) 1000.0; case 0x137C: case 0x2182: case 0x4E07: @@ -2139,75 +2139,75 @@ case 0x1012B: case 0x10155: #endif - return (double) 10000; + return (double) 10000.0; case 0x2188: - return (double) 100000; + return (double) 100000.0; case 0x4EBF: case 0x5104: - return (double) 100000000; + return (double) 100000000.0; case 0x5146: - return (double) 1000000000000; + return (double) 1000000000000.0; case 0x216A: case 0x217A: case 0x246A: case 0x247E: case 0x2492: case 0x24EB: - return (double) 11; + return (double) 11.0; case 0x0F2F: - return (double) 11/2; + return (double) 11.0/2.0; case 0x216B: case 0x217B: case 0x246B: case 0x247F: case 0x2493: case 0x24EC: - return (double) 12; + return (double) 12.0; case 0x246C: case 0x2480: case 0x2494: case 0x24ED: - return (double) 13; + return (double) 13.0; case 0x0F30: - return (double) 13/2; + return (double) 13.0/2.0; case 0x246D: case 0x2481: case 0x2495: case 0x24EE: - return (double) 14; + return (double) 14.0; case 0x246E: case 0x2482: case 0x2496: case 0x24EF: - return (double) 15; + return (double) 15.0; case 0x0F31: - return (double) 15/2; + return (double) 15.0/2.0; case 0x09F9: case 0x246F: case 0x2483: case 0x2497: case 0x24F0: - return (double) 16; + return (double) 16.0; case 0x16EE: case 0x2470: case 0x2484: case 0x2498: case 0x24F1: - return (double) 17; + return (double) 17.0; case 0x0F32: - return (double) 17/2; + return (double) 17.0/2.0; case 0x16EF: case 0x2471: case 0x2485: case 0x2499: case 0x24F2: - return (double) 18; + return (double) 18.0; case 0x16F0: case 0x2472: case 0x2486: case 0x249A: case 0x24F3: - return (double) 19; + return (double) 19.0; case 0x0032: case 0x00B2: case 0x0662: @@ -2294,16 +2294,16 @@ case 0x1D7F8: case 0x22390: #endif - return (double) 2; + return (double) 2.0; case 0x2154: #ifdef Py_UNICODE_WIDE case 0x10177: case 0x1245B: case 0x1245E: #endif - return (double) 2/3; + return (double) 2.0/3.0; case 0x2156: - return (double) 2/5; + return (double) 2.0/5.0; case 0x1373: case 0x2473: case 0x2487: @@ -2319,37 +2319,37 @@ case 0x10A45: case 0x1D36A: #endif - return (double) 20; + return (double) 20.0; #ifdef Py_UNICODE_WIDE case 0x1011A: - return (double) 200; + return (double) 200.0; #endif #ifdef Py_UNICODE_WIDE case 0x10123: - return (double) 2000; + return (double) 2000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012C: - return (double) 20000; + return (double) 20000.0; #endif case 0x3251: - return (double) 21; + return (double) 21.0; case 0x3252: - return (double) 22; + return (double) 22.0; case 0x3253: - return (double) 23; + return (double) 23.0; case 0x3254: - return (double) 24; + return (double) 24.0; case 0x3255: - return (double) 25; + return (double) 25.0; case 0x3256: - return (double) 26; + return (double) 26.0; case 0x3257: - return (double) 27; + return (double) 27.0; case 0x3258: - return (double) 28; + return (double) 28.0; case 0x3259: - return (double) 29; + return (double) 29.0; case 0x0033: case 0x00B3: case 0x0663: @@ -2438,19 +2438,19 @@ case 0x22998: case 0x23B1B: #endif - return (double) 3; + return (double) 3.0; case 0x0F2B: - return (double) 3/2; + return (double) 3.0/2.0; case 0x00BE: case 0x0D75: #ifdef Py_UNICODE_WIDE case 0x10178: #endif - return (double) 3/4; + return (double) 3.0/4.0; case 0x2157: - return (double) 3/5; + return (double) 3.0/5.0; case 0x215C: - return (double) 3/8; + return (double) 3.0/8.0; case 0x1374: case 0x303A: case 0x325A: @@ -2461,38 +2461,38 @@ case 0x1D36B: case 0x20983: #endif - return (double) 30; + return (double) 30.0; #ifdef Py_UNICODE_WIDE case 0x1011B: case 0x1016B: - return (double) 300; + return (double) 300.0; #endif #ifdef Py_UNICODE_WIDE case 0x10124: - return (double) 3000; + return (double) 3000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012D: - return (double) 30000; + return (double) 30000.0; #endif case 0x325B: - return (double) 31; + return (double) 31.0; case 0x325C: - return (double) 32; + return (double) 32.0; case 0x325D: - return (double) 33; + return (double) 33.0; case 0x325E: - return (double) 34; + return (double) 34.0; case 0x325F: - return (double) 35; + return (double) 35.0; case 0x32B1: - return (double) 36; + return (double) 36.0; case 0x32B2: - return (double) 37; + return (double) 37.0; case 0x32B3: - return (double) 38; + return (double) 38.0; case 0x32B4: - return (double) 39; + return (double) 39.0; case 0x0034: case 0x0664: case 0x06F4: @@ -2574,9 +2574,9 @@ case 0x200E2: case 0x2626D: #endif - return (double) 4; + return (double) 4.0; case 0x2158: - return (double) 4/5; + return (double) 4.0/5.0; case 0x1375: case 0x32B5: case 0x534C: @@ -2586,37 +2586,37 @@ case 0x2098C: case 0x2099C: #endif - return (double) 40; + return (double) 40.0; #ifdef Py_UNICODE_WIDE case 0x1011C: - return (double) 400; + return (double) 400.0; #endif #ifdef Py_UNICODE_WIDE case 0x10125: - return (double) 4000; + return (double) 4000.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012E: - return (double) 40000; + return (double) 40000.0; #endif case 0x32B6: - return (double) 41; + return (double) 41.0; case 0x32B7: - return (double) 42; + return (double) 42.0; case 0x32B8: - return (double) 43; + return (double) 43.0; case 0x32B9: - return (double) 44; + return (double) 44.0; case 0x32BA: - return (double) 45; + return (double) 45.0; case 0x32BB: - return (double) 46; + return (double) 46.0; case 0x32BC: - return (double) 47; + return (double) 47.0; case 0x32BD: - return (double) 48; + return (double) 48.0; case 0x32BE: - return (double) 49; + return (double) 49.0; case 0x0035: case 0x0665: case 0x06F5: @@ -2696,16 +2696,16 @@ case 0x1D7FB: case 0x20121: #endif - return (double) 5; + return (double) 5.0; case 0x0F2C: - return (double) 5/2; + return (double) 5.0/2.0; case 0x215A: #ifdef Py_UNICODE_WIDE case 0x1245C: #endif - return (double) 5/6; + return (double) 5.0/6.0; case 0x215D: - return (double) 5/8; + return (double) 5.0/8.0; case 0x1376: case 0x216C: case 0x217C: @@ -2724,7 +2724,7 @@ case 0x10323: case 0x1D36D: #endif - return (double) 50; + return (double) 50.0; case 0x216E: case 0x217E: #ifdef Py_UNICODE_WIDE @@ -2738,7 +2738,7 @@ case 0x1016F: case 0x10170: #endif - return (double) 500; + return (double) 500.0; case 0x2181: #ifdef Py_UNICODE_WIDE case 0x10126: @@ -2746,14 +2746,14 @@ case 0x1014E: case 0x10172: #endif - return (double) 5000; + return (double) 5000.0; case 0x2187: #ifdef Py_UNICODE_WIDE case 0x1012F: case 0x10147: case 0x10156: #endif - return (double) 50000; + return (double) 50000.0; case 0x0036: case 0x0666: case 0x06F6: @@ -2825,24 +2825,24 @@ case 0x1D7FC: case 0x20AEA: #endif - return (double) 6; + return (double) 6.0; case 0x1377: #ifdef Py_UNICODE_WIDE case 0x10115: case 0x1D36E: #endif - return (double) 60; + return (double) 60.0; #ifdef Py_UNICODE_WIDE case 0x1011E: - return (double) 600; + return (double) 600.0; #endif #ifdef Py_UNICODE_WIDE case 0x10127: - return (double) 6000; + return (double) 6000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10130: - return (double) 60000; + return (double) 60000.0; #endif case 0x0037: case 0x0667: @@ -2914,28 +2914,28 @@ case 0x1D7FD: case 0x20001: #endif - return (double) 7; + return (double) 7.0; case 0x0F2D: - return (double) 7/2; + return (double) 7.0/2.0; case 0x215E: - return (double) 7/8; + return (double) 7.0/8.0; case 0x1378: #ifdef Py_UNICODE_WIDE case 0x10116: case 0x1D36F: #endif - return (double) 70; + return (double) 70.0; #ifdef Py_UNICODE_WIDE case 0x1011F: - return (double) 700; + return (double) 700.0; #endif #ifdef Py_UNICODE_WIDE case 0x10128: - return (double) 7000; + return (double) 7000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10131: - return (double) 70000; + return (double) 70000.0; #endif case 0x0038: case 0x0668: @@ -3003,24 +3003,24 @@ case 0x1D7F4: case 0x1D7FE: #endif - return (double) 8; + return (double) 8.0; case 0x1379: #ifdef Py_UNICODE_WIDE case 0x10117: case 0x1D370: #endif - return (double) 80; + return (double) 80.0; #ifdef Py_UNICODE_WIDE case 0x10120: - return (double) 800; + return (double) 800.0; #endif #ifdef Py_UNICODE_WIDE case 0x10129: - return (double) 8000; + return (double) 8000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10132: - return (double) 80000; + return (double) 80000.0; #endif case 0x0039: case 0x0669: @@ -3092,28 +3092,28 @@ case 0x1D7FF: case 0x2F890: #endif - return (double) 9; + return (double) 9.0; case 0x0F2E: - return (double) 9/2; + return (double) 9.0/2.0; case 0x137A: #ifdef Py_UNICODE_WIDE case 0x10118: case 0x10341: case 0x1D371: #endif - return (double) 90; + return (double) 90.0; #ifdef Py_UNICODE_WIDE case 0x10121: case 0x1034A: - return (double) 900; + return (double) 900.0; #endif #ifdef Py_UNICODE_WIDE case 0x1012A: - return (double) 9000; + return (double) 9000.0; #endif #ifdef Py_UNICODE_WIDE case 0x10133: - return (double) 90000; + return (double) 90000.0; #endif } return -1.0; Modified: python/branches/py3k/Tools/unicode/makeunicodedata.py ============================================================================== --- python/branches/py3k/Tools/unicode/makeunicodedata.py (original) +++ python/branches/py3k/Tools/unicode/makeunicodedata.py Wed Oct 14 01:18:53 2009 @@ -479,6 +479,11 @@ print('{', file=fp) print(' switch (ch) {', file=fp) for value, codepoints in numeric_items: + # Turn text into float literals + parts = value.split('/') + parts = [repr(float(part)) for part in parts] + value = '/'.join(parts) + haswide = False hasnonewide = False codepoints.sort() From python-checkins at python.org Wed Oct 14 04:50:59 2009 From: python-checkins at python.org (phillip.eby) Date: Wed, 14 Oct 2009 02:50:59 -0000 Subject: [Python-checkins] r75398 - sandbox/trunk/setuptools/README.txt Message-ID: Author: phillip.eby Date: Wed Oct 14 04:50:59 2009 New Revision: 75398 Log: Add a better link to the files Modified: sandbox/trunk/setuptools/README.txt Modified: sandbox/trunk/setuptools/README.txt ============================================================================== --- sandbox/trunk/setuptools/README.txt (original) +++ sandbox/trunk/setuptools/README.txt Wed Oct 14 04:50:59 2009 @@ -90,7 +90,7 @@ All setuptools downloads can be found at `the project's home page in the Python Package Index`_. Scroll to the very bottom of the page to find the links. -.. _the project's home page in the Python Package Index: http://pypi.python.org/pypi/setuptools +.. _the project's home page in the Python Package Index: http://pypi.python.org/pypi/setuptools#files In addition to the PyPI downloads, the development version of ``setuptools`` is available from the `Python SVN sandbox`_, and in-development versions of the @@ -159,3 +159,4 @@ "Code Bear" Taylor) contributed their time and stress as guinea pigs for the use of eggs and setuptools, even before eggs were "cool". (Thanks, guys!) +.. _files: From python-checkins at python.org Wed Oct 14 04:53:16 2009 From: python-checkins at python.org (phillip.eby) Date: Wed, 14 Oct 2009 02:53:16 -0000 Subject: [Python-checkins] r75399 - sandbox/branches/setuptools-0.6/README.txt Message-ID: Author: phillip.eby Date: Wed Oct 14 04:53:15 2009 New Revision: 75399 Log: Add a better link to the files Modified: sandbox/branches/setuptools-0.6/README.txt Modified: sandbox/branches/setuptools-0.6/README.txt ============================================================================== --- sandbox/branches/setuptools-0.6/README.txt (original) +++ sandbox/branches/setuptools-0.6/README.txt Wed Oct 14 04:53:15 2009 @@ -90,7 +90,7 @@ All setuptools downloads can be found at `the project's home page in the Python Package Index`_. Scroll to the very bottom of the page to find the links. -.. _the project's home page in the Python Package Index: http://pypi.python.org/pypi/setuptools +.. _the project's home page in the Python Package Index: http://pypi.python.org/pypi/setuptools#files In addition to the PyPI downloads, the development version of ``setuptools`` is available from the `Python SVN sandbox`_, and in-development versions of the @@ -159,3 +159,4 @@ "Code Bear" Taylor) contributed their time and stress as guinea pigs for the use of eggs and setuptools, even before eggs were "cool". (Thanks, guys!) +.. _files: From nnorwitz at gmail.com Wed Oct 14 11:47:03 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 14 Oct 2009 05:47:03 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (3) Message-ID: <20091014094703.GA11243@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_itertools leaked [0, 14, 0] references, sum=14 test_urllib2_localnet leaked [0, 280, 4] references, sum=284 Less important issues: ---------------------- test_asynchat leaked [-132, 0, 0] references, sum=-132 test_file2k leaked [0, 83, 0] references, sum=83 test_smtplib leaked [0, 88, -88] references, sum=0 test_sys leaked [0, 0, 42] references, sum=42 test_threading leaked [48, 48, 48] references, sum=144 From solipsis at pitrou.net Wed Oct 14 14:55:10 2009 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 14 Oct 2009 12:55:10 +0000 (UTC) Subject: [Python-checkins] Python Regression Test Failures refleak (3) References: <20091014094703.GA11243@python.psfb.org> Message-ID: Neal Norwitz gmail.com> writes: > > More important issues: > ---------------------- > test___all__ leaked [1, 1, 1] references, sum=3 After a bit of hunting, the reference leak occurs when importing ctypes.wintypes. Regards Antoine. From python-checkins at python.org Wed Oct 14 15:58:08 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 14 Oct 2009 13:58:08 -0000 Subject: [Python-checkins] r75400 - in python/trunk: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Wed Oct 14 15:58:07 2009 New Revision: 75400 Log: Enhanced Issue 7058 patch, which will not be backported. Refactors the code, adds checks for stdin/out/err, cwd, and sys.path, and adds a new section in the summary for tests that modify the environment (thanks to Ezio Melotti for that suggestion). Modified: python/trunk/Lib/test/regrtest.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Wed Oct 14 15:58:07 2009 @@ -312,7 +312,7 @@ try: result = runtest(*args, **kwargs) except BaseException, e: - result = -3, e.__class__.__name__ + result = -4, e.__class__.__name__ print # Force a newline (just in case) print json.dumps(result) sys.exit(0) @@ -327,6 +327,7 @@ bad = [] skipped = [] resource_denieds = [] + environment_changed = [] if findleaks: try: @@ -395,11 +396,13 @@ test_times.append((test_time, test)) if ok > 0: good.append(test) - elif ok == 0: + elif -2 < ok <= 0: bad.append(test) + if ok == -1: + environment_changed.append(test) else: skipped.append(test) - if ok == -2: + if ok == -3: resource_denieds.append(test) if use_mp: @@ -452,7 +455,7 @@ continue if out: print out - if result[0] == -3: + if result[0] == -4: assert result[1] == 'KeyboardInterrupt' pending.clear() raise KeyboardInterrupt # What else? @@ -498,6 +501,7 @@ good.sort() bad.sort() skipped.sort() + environment_changed.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: @@ -509,8 +513,14 @@ for time, test in test_times[:10]: print "%s: %.1fs" % (test, time) if bad: - print count(len(bad), "test"), "failed:" - printlist(bad) + bad = set(bad) - set(environment_changed) + if bad: + print count(len(bad), "test"), "failed:" + printlist(bad) + if environment_changed: + print "{} altered the execution environment:".format( + count(len(environment_changed), "test")) + printlist(environment_changed) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) @@ -612,8 +622,10 @@ huntrleaks -- run multiple times to test for leaks; requires a debug build; a triple corresponding to -R's three arguments Return: - -2 test skipped because resource denied - -1 test skipped for some other reason + -4 KeyboardInterrupt when run under -j + -3 test skipped because resource denied + -2 test skipped for some other reason + -1 test failed because it changed the execution environment 0 test failed 1 test passed """ @@ -627,6 +639,96 @@ finally: cleanup_test_droppings(test, verbose) + +# Unit tests are supposed to leave the execution environment unchanged +# once they complete. But sometimes tests have bugs, especially when +# tests fail, and the changes to environment go on to mess up other +# tests. This can cause issues with buildbot stability, since tests +# are run in random order and so problems may appear to come and go. +# There are a few things we can save and restore to mitigate this, and +# the following context manager handles this task. + +class saved_test_environment: + """Save bits of the test environment and restore them at block exit. + + with saved_test_environment(testname, quiet): + #stuff + + Unless quiet is True, a warning is printed to stderr if any of + the saved items was changed by the test. The attribute 'changed' + is initially False, but is set to True if a change is detected. + """ + + changed = False + + def __init__(self, testname, quiet=False): + self.testname = testname + self.quiet = quiet + + # To add things to save and restore, add a name XXX to the resources list + # and add corresponding get_XXX/restore_XXX functions. get_XXX should + # return the value to be saved and compared against a second call to the + # get function when test execution completes. restore_XXX should accept + # the saved value and restore the resource using it. It will be called if + # and only if a change in the value is detected. XXX will have any '_' + # replaced with '.' characters and will then be used in the error messages + # as the name of the resource that changed. + + resources = ('sys_argv', 'cwd', 'sys_stdin', 'sys_stdout', 'sys_stderr', + 'os_environ', 'sys_path') + + def get_sys_argv(self): + return sys.argv[:] + def restore_sys_argv(self, saved_argv): + sys.argv[:] = saved_argv + + def get_cwd(self): + return os.getcwd() + def restore_cwd(self, saved_cwd): + os.chdir(saved_cwd) + + def get_sys_stdout(self): + return sys.stdout + def restore_sys_stdout(self, saved_stdout): + sys.stdout = saved_stdout + + def get_sys_stderr(self): + return sys.stderr + def restore_sys_stderr(self, saved_stderr): + sys.stderr = saved_stderr + + def get_sys_stdin(self): + return sys.stdin + def restore_sys_stdin(self, saved_stdin): + sys.stdin = saved_stdin + + def get_os_environ(self): + return dict(os.environ) + def restore_os_environ(self, saved_environ): + os.environ.clear() + os.environ.update(saved_environ) + + def get_sys_path(self): + return sys.path[:] + def restore_sys_path(self, saved_path): + sys.path[:] = saved_path + + def __enter__(self): + self.saved_values = dict((name, getattr(self, 'get_'+name)()) + for name in self.resources) + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + for name in self.resources: + if not getattr(self, 'get_'+name)() == self.saved_values[name]: + self.changed = True + getattr(self, 'restore_'+name)(self.saved_values[name]) + if not self.quiet: + print >>sys.stderr, ("Warning -- {} was modified " + "by {}").format(name.replace('_', '.'), self.testname) + return False + + def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False): test_support.unload(test) @@ -641,10 +743,6 @@ refleak = False # True if the test leaked references. try: save_stdout = sys.stdout - # Save various things that tests may mess up so we can restore - # them afterward. - save_environ = dict(os.environ) - save_argv = sys.argv[:] try: if capture_stdout: sys.stdout = capture_stdout @@ -653,41 +751,32 @@ else: # Always import it from the test package abstest = 'test.' + test - start_time = time.time() - the_package = __import__(abstest, globals(), locals(), []) - the_module = getattr(the_package, test) - # Old tests run to completion simply as a side-effect of - # being imported. For tests based on unittest or doctest, - # explicitly invoke their test_main() function (if it exists). - indirect_test = getattr(the_module, "test_main", None) - if indirect_test is not None: - indirect_test() - if huntrleaks: - refleak = dash_R(the_module, test, indirect_test, huntrleaks) - test_time = time.time() - start_time + with saved_test_environment(test, quiet) as environment: + start_time = time.time() + the_package = __import__(abstest, globals(), locals(), []) + the_module = getattr(the_package, test) + # Old tests run to completion simply as a side-effect of + # being imported. For tests based on unittest or doctest, + # explicitly invoke their test_main() function (if it exists). + indirect_test = getattr(the_module, "test_main", None) + if indirect_test is not None: + indirect_test() + if huntrleaks: + refleak = dash_R(the_module, test, indirect_test, + huntrleaks) + test_time = time.time() - start_time finally: sys.stdout = save_stdout - # Restore what we saved if needed, but also complain if the test - # changed it so that the test may eventually get fixed. - if not os.environ == save_environ: - if not quiet: - print "Warning: os.environ was modified by", test - os.environ.clear() - os.environ.update(save_environ) - if not sys.argv == save_argv: - if not quiet: - print "Warning: argv was modified by", test - sys.argv[:] = save_argv except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() - return -2, test_time + return -3, test_time except unittest.SkipTest, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() - return -1, test_time + return -2, test_time except KeyboardInterrupt: raise except test_support.TestFailed, msg: @@ -705,6 +794,8 @@ else: if refleak: return 0, test_time + if environment.changed: + return -1, test_time # Except in verbose mode, tests should not print anything if verbose or huntrleaks: return 1, test_time Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 14 15:58:07 2009 @@ -1460,8 +1460,9 @@ - Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. -- Issue #7058: Added save/restore for argv and os.environ to runtest_inner - in regrtest, with warnings if the called test modifies them. +- Issue #7058: Added save/restore for things like sys.argv and cwd to + runtest_inner in regrtest, with warnings if the called test modifies them, + and a new section in the summary report at the end. - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. From python-checkins at python.org Wed Oct 14 17:51:35 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 14 Oct 2009 15:51:35 -0000 Subject: [Python-checkins] r75401 - python/branches/release31-maint Message-ID: Author: georg.brandl Date: Wed Oct 14 17:51:35 2009 New Revision: 75401 Log: Blocked revisions 74628-74630,74646,74648-74649,74654,74661,74744,74834,74875,75078-75079 via svnmerge ................ r74628 | georg.brandl | 2009-09-02 22:33:30 +0200 (Mi, 02 Sep 2009) | 1 line Use true kwonly arg instead of **kwds hackaround. ................ r74629 | georg.brandl | 2009-09-02 22:34:14 +0200 (Mi, 02 Sep 2009) | 1 line Use true booleans and a bit more PEP8. ................ r74630 | georg.brandl | 2009-09-02 22:34:52 +0200 (Mi, 02 Sep 2009) | 1 line Switch more function arguments docs to new-style. ................ r74646 | georg.brandl | 2009-09-04 10:09:32 +0200 (Fr, 04 Sep 2009) | 1 line Remove backwards compatibility stuff from profile/cProfile. ................ r74648 | georg.brandl | 2009-09-04 10:22:00 +0200 (Fr, 04 Sep 2009) | 1 line Remove pseudo-end markers from http.cookies. ................ r74649 | georg.brandl | 2009-09-04 10:28:01 +0200 (Fr, 04 Sep 2009) | 1 line Turn some comments into docstrings. ................ r74654 | georg.brandl | 2009-09-04 17:41:40 +0200 (Fr, 04 Sep 2009) | 8 lines Blocked revisions 74653 via svnmerge ........ r74653 | georg.brandl | 2009-09-04 13:32:18 +0200 (Fr, 04 Sep 2009) | 1 line #6777: dont discourage usage of Exception.args or promote usage of Exception.message. ........ ................ r74661 | georg.brandl | 2009-09-04 19:15:16 +0200 (Fr, 04 Sep 2009) | 1 line Remove the just-removed "help" from __all__. ................ r74744 | benjamin.peterson | 2009-09-11 23:30:05 +0200 (Fr, 11 Sep 2009) | 43 lines Blocked revisions 74300,74490,74519,74631,74635-74637,74684,74721 via svnmerge ........ r74300 | raymond.hettinger | 2009-08-04 14:08:05 -0500 (Tue, 04 Aug 2009) | 1 line Issue 6637: defaultdict.copy() failed with an empty factory. ........ r74490 | benjamin.peterson | 2009-08-17 08:39:41 -0500 (Mon, 17 Aug 2009) | 1 line typos ........ r74519 | guilherme.polo | 2009-08-18 11:39:36 -0500 (Tue, 18 Aug 2009) | 1 line Added missing static option for OptionMenu. Issue #5961. ........ r74631 | georg.brandl | 2009-09-02 15:37:16 -0500 (Wed, 02 Sep 2009) | 1 line #6821: fix signature of PyBuffer_Release(). ........ r74635 | armin.rigo | 2009-09-03 14:40:07 -0500 (Thu, 03 Sep 2009) | 2 lines Found the next crasher by thinking about this logic in PyPy. ........ r74636 | armin.rigo | 2009-09-03 14:42:03 -0500 (Thu, 03 Sep 2009) | 3 lines Does not terminate: consume all memory without responding to Ctrl-C. I am not too sure why, but you can surely find out by gdb'ing a bit... ........ r74637 | armin.rigo | 2009-09-03 14:45:27 -0500 (Thu, 03 Sep 2009) | 4 lines Sorry, sorry! Ignore my previous two commits. I mixed up the version of python with which I tried running the crashers. They don't crash the current HEAD. ........ r74684 | ronald.oussoren | 2009-09-06 07:23:18 -0500 (Sun, 06 Sep 2009) | 2 lines Fix for issue 4937 ........ r74721 | thomas.heller | 2009-09-08 14:24:36 -0500 (Tue, 08 Sep 2009) | 1 line Make ctypes compile again with older Python versions. ........ ................ r74834 | georg.brandl | 2009-09-16 17:58:51 +0200 (Mi, 16 Sep 2009) | 8 lines Blocked revisions 74832 via svnmerge ........ r74832 | georg.brandl | 2009-09-16 17:57:46 +0200 (Mi, 16 Sep 2009) | 1 line Rewrap long lines. ........ ................ r74875 | georg.brandl | 2009-09-17 13:50:17 +0200 (Do, 17 Sep 2009) | 8 lines Blocked revisions 74873 via svnmerge ........ r74873 | georg.brandl | 2009-09-17 13:48:31 +0200 (Do, 17 Sep 2009) | 1 line #6844 followup: the warning when setting Exception.message was removed, do not test for it. ........ ................ r75078 | georg.brandl | 2009-09-26 22:52:12 +0200 (Sa, 26 Sep 2009) | 1 line use new style optional args ................ r75079 | georg.brandl | 2009-09-26 22:59:11 +0200 (Sa, 26 Sep 2009) | 1 line fix default value ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Oct 14 17:51:48 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 14 Oct 2009 15:51:48 -0000 Subject: [Python-checkins] r75402 - python/trunk/Lib/threading.py Message-ID: Author: georg.brandl Date: Wed Oct 14 17:51:48 2009 New Revision: 75402 Log: #7125: fix typo. Modified: python/trunk/Lib/threading.py Modified: python/trunk/Lib/threading.py ============================================================================== --- python/trunk/Lib/threading.py (original) +++ python/trunk/Lib/threading.py Wed Oct 14 17:51:48 2009 @@ -133,7 +133,7 @@ def release(self): if self.__owner is not current_thread(): - raise RuntimeError("cannot release un-aquired lock") + raise RuntimeError("cannot release un-acquired lock") self.__count = count = self.__count - 1 if not count: self.__owner = None @@ -227,7 +227,7 @@ def wait(self, timeout=None): if not self._is_owned(): - raise RuntimeError("cannot wait on un-aquired lock") + raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) @@ -269,7 +269,7 @@ def notify(self, n=1): if not self._is_owned(): - raise RuntimeError("cannot notify on un-aquired lock") + raise RuntimeError("cannot notify on un-acquired lock") __waiters = self.__waiters waiters = __waiters[:n] if not waiters: From python-checkins at python.org Wed Oct 14 17:57:47 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 14 Oct 2009 15:57:47 -0000 Subject: [Python-checkins] r75403 - python/trunk/Doc/library/os.rst Message-ID: Author: georg.brandl Date: Wed Oct 14 17:57:46 2009 New Revision: 75403 Log: #7126: os.environ changes *do* take effect in subprocesses started with os.system(). Modified: python/trunk/Doc/library/os.rst Modified: python/trunk/Doc/library/os.rst ============================================================================== --- python/trunk/Doc/library/os.rst (original) +++ python/trunk/Doc/library/os.rst Wed Oct 14 17:57:46 2009 @@ -1836,9 +1836,9 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :cfunc:`system`, and has the same limitations. Changes - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the - environment of the executed command. + the Standard C function :cfunc:`system`, and has the same limitations. + Changes :data:`sys.stdin`, etc. are not reflected in the environment of the + executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning From rdmurray at bitdance.com Wed Oct 14 18:16:39 2009 From: rdmurray at bitdance.com (R. David Murray) Date: Wed, 14 Oct 2009 12:16:39 -0400 (EDT) Subject: [Python-checkins] r75403 - python/trunk/Doc/library/os.rst In-Reply-To: <20091014155810.5F212E3523@kimball.webabinitio.net> References: <20091014155810.5F212E3523@kimball.webabinitio.net> Message-ID: I think you lost a 'to' in the corrected sentence. On Wed, 14 Oct 2009 at 11:58, georg.brandl wrote: > Author: georg.brandl > Date: Wed Oct 14 17:57:46 2009 > New Revision: 75403 > > Log: > #7126: os.environ changes *do* take effect in subprocesses started with os.system(). > > Modified: > python/trunk/Doc/library/os.rst > > Modified: python/trunk/Doc/library/os.rst > ============================================================================== > --- python/trunk/Doc/library/os.rst (original) > +++ python/trunk/Doc/library/os.rst Wed Oct 14 17:57:46 2009 > @@ -1836,9 +1836,9 @@ > .. function:: system(command) > > Execute the command (a string) in a subshell. This is implemented by calling > - the Standard C function :cfunc:`system`, and has the same limitations. Changes > - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the > - environment of the executed command. > + the Standard C function :cfunc:`system`, and has the same limitations. > + Changes :data:`sys.stdin`, etc. are not reflected in the environment of the > + executed command. > > On Unix, the return value is the exit status of the process encoded in the > format specified for :func:`wait`. Note that POSIX does not specify the meaning > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Wed Oct 14 19:14:16 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 17:14:16 -0000 Subject: [Python-checkins] r75404 - in python/branches/py3k: Lib/test/test_bytes.py Misc/NEWS Objects/bytes_methods.c Message-ID: Author: antoine.pitrou Date: Wed Oct 14 19:14:16 2009 New Revision: 75404 Log: Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when using byte values greater than 127. Patch by egreen. Modified: python/branches/py3k/Lib/test/test_bytes.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/bytes_methods.c Modified: python/branches/py3k/Lib/test/test_bytes.py ============================================================================== --- python/branches/py3k/Lib/test/test_bytes.py (original) +++ python/branches/py3k/Lib/test/test_bytes.py Wed Oct 14 19:14:16 2009 @@ -454,8 +454,9 @@ def test_maketrans(self): transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' - self.assertEqual(self.type2test.maketrans(b'abc', b'xyz'), transtable) + transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374xyz' + self.assertEqual(self.type2test.maketrans(b'\375\376\377', b'xyz'), transtable) self.assertRaises(ValueError, self.type2test.maketrans, b'abc', b'xyzq') self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 'def') @@ -1074,13 +1075,10 @@ def test_main(): - test.support.run_unittest(BytesTest) - test.support.run_unittest(ByteArrayTest) - test.support.run_unittest(AssortedBytesTest) - test.support.run_unittest(BytesAsStringTest) - test.support.run_unittest(ByteArrayAsStringTest) - test.support.run_unittest(ByteArraySubclassTest) - test.support.run_unittest(BytearrayPEP3137Test) + test.support.run_unittest( + BytesTest, AssortedBytesTest, BytesAsStringTest, + ByteArrayTest, ByteArrayAsStringTest, ByteArraySubclassTest, + BytearrayPEP3137Test) if __name__ == "__main__": test_main() Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 14 19:14:16 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when + using byte values greater than 127. Patch by egreen. + - Issue #1571184: The Unicode database contains properties for more characters. The tables for code points representing numeric values, white spaces or line breaks are now generated from the official Unicode Character Database files, Modified: python/branches/py3k/Objects/bytes_methods.c ============================================================================== --- python/branches/py3k/Objects/bytes_methods.c (original) +++ python/branches/py3k/Objects/bytes_methods.c Wed Oct 14 19:14:16 2009 @@ -427,7 +427,7 @@ { PyObject *frm, *to, *res = NULL; Py_buffer bfrm, bto; - int i; + Py_ssize_t i; char *p; bfrm.len = -1; @@ -452,7 +452,7 @@ for (i = 0; i < 256; i++) p[i] = i; for (i = 0; i < bfrm.len; i++) { - p[(int)((char *)bfrm.buf)[i]] = ((char *)bto.buf)[i]; + p[((unsigned char *)bfrm.buf)[i]] = ((char *)bto.buf)[i]; } done: From python-checkins at python.org Wed Oct 14 19:17:14 2009 From: python-checkins at python.org (neil.schemenauer) Date: Wed, 14 Oct 2009 17:17:14 -0000 Subject: [Python-checkins] r75405 - in python/trunk: Misc/NEWS Python/compile.c Message-ID: Author: neil.schemenauer Date: Wed Oct 14 19:17:14 2009 New Revision: 75405 Log: Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. Modified: python/trunk/Misc/NEWS python/trunk/Python/compile.c Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 14 19:17:14 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #1754094: Improve the stack depth calculation in the compiler. + There should be no other effect than a small decrease in memory use. + Patch by Christopher Tur Lesniewski-Laas. + - Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. Modified: python/trunk/Python/compile.c ============================================================================== --- python/trunk/Python/compile.c (original) +++ python/trunk/Python/compile.c Wed Oct 14 19:17:14 2009 @@ -692,13 +692,13 @@ return -1; case SLICE+0: - return 1; - case SLICE+1: return 0; + case SLICE+1: + return -1; case SLICE+2: - return 0; - case SLICE+3: return -1; + case SLICE+3: + return -2; case STORE_SLICE+0: return -2; @@ -778,7 +778,8 @@ case POP_BLOCK: return 0; case END_FINALLY: - return -1; /* or -2 or -3 if exception occurred */ + return -3; /* or -1 or -2 if no exception occurred or + return/break/continue */ case BUILD_CLASS: return -2; @@ -789,7 +790,7 @@ case UNPACK_SEQUENCE: return oparg-1; case FOR_ITER: - return 1; + return 1; /* or -1, at end of iterator */ case STORE_ATTR: return -2; @@ -815,7 +816,7 @@ case COMPARE_OP: return -1; case IMPORT_NAME: - return 0; + return -1; case IMPORT_FROM: return 1; @@ -835,10 +836,9 @@ case CONTINUE_LOOP: return 0; case SETUP_LOOP: - return 0; case SETUP_EXCEPT: case SETUP_FINALLY: - return 3; /* actually pushed by an exception */ + return 0; case LOAD_FAST: return 1; @@ -867,7 +867,7 @@ return -1; case MAKE_CLOSURE: - return -oparg; + return -oparg-1; case LOAD_CLOSURE: return 1; case LOAD_DEREF: @@ -3328,7 +3328,7 @@ static int stackdepth_walk(struct compiler *c, basicblock *b, int depth, int maxdepth) { - int i; + int i, target_depth; struct instr *instr; if (b->b_seen || b->b_startdepth >= depth) return maxdepth; @@ -3341,8 +3341,17 @@ maxdepth = depth; assert(depth >= 0); /* invalid code or bug in stackdepth() */ if (instr->i_jrel || instr->i_jabs) { + target_depth = depth; + if (instr->i_opcode == FOR_ITER) { + target_depth = depth-2; + } else if (instr->i_opcode == SETUP_FINALLY || + instr->i_opcode == SETUP_EXCEPT) { + target_depth = depth+3; + if (target_depth > maxdepth) + maxdepth = target_depth; + } maxdepth = stackdepth_walk(c, instr->i_target, - depth, maxdepth); + target_depth, maxdepth); if (instr->i_opcode == JUMP_ABSOLUTE || instr->i_opcode == JUMP_FORWARD) { goto out; /* remaining code is dead */ From python-checkins at python.org Wed Oct 14 19:18:55 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 17:18:55 -0000 Subject: [Python-checkins] r75406 - in python/branches/release31-maint: Lib/test/test_bytes.py Misc/NEWS Objects/bytes_methods.c Message-ID: Author: antoine.pitrou Date: Wed Oct 14 19:18:54 2009 New Revision: 75406 Log: Merged revisions 75404 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75404 | antoine.pitrou | 2009-10-14 19:14:16 +0200 (mer., 14 oct. 2009) | 5 lines Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when using byte values greater than 127. Patch by egreen. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_bytes.py python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Objects/bytes_methods.c Modified: python/branches/release31-maint/Lib/test/test_bytes.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_bytes.py (original) +++ python/branches/release31-maint/Lib/test/test_bytes.py Wed Oct 14 19:18:54 2009 @@ -452,8 +452,9 @@ def test_maketrans(self): transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' - self.assertEqual(self.type2test.maketrans(b'abc', b'xyz'), transtable) + transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374xyz' + self.assertEqual(self.type2test.maketrans(b'\375\376\377', b'xyz'), transtable) self.assertRaises(ValueError, self.type2test.maketrans, b'abc', b'xyzq') self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 'def') @@ -1072,13 +1073,10 @@ def test_main(): - test.support.run_unittest(BytesTest) - test.support.run_unittest(ByteArrayTest) - test.support.run_unittest(AssortedBytesTest) - test.support.run_unittest(BytesAsStringTest) - test.support.run_unittest(ByteArrayAsStringTest) - test.support.run_unittest(ByteArraySubclassTest) - test.support.run_unittest(BytearrayPEP3137Test) + test.support.run_unittest( + BytesTest, AssortedBytesTest, BytesAsStringTest, + ByteArrayTest, ByteArrayAsStringTest, ByteArraySubclassTest, + BytearrayPEP3137Test) if __name__ == "__main__": test_main() Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Wed Oct 14 19:18:54 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when + using byte values greater than 127. Patch by egreen. + - Issue #7019: Raise ValueError when unmarshalling bad long data, instead of producing internally inconsistent Python longs. Modified: python/branches/release31-maint/Objects/bytes_methods.c ============================================================================== --- python/branches/release31-maint/Objects/bytes_methods.c (original) +++ python/branches/release31-maint/Objects/bytes_methods.c Wed Oct 14 19:18:54 2009 @@ -427,7 +427,7 @@ { PyObject *frm, *to, *res = NULL; Py_buffer bfrm, bto; - int i; + Py_ssize_t i; char *p; bfrm.len = -1; @@ -452,7 +452,7 @@ for (i = 0; i < 256; i++) p[i] = i; for (i = 0; i < bfrm.len; i++) { - p[(int)((char *)bfrm.buf)[i]] = ((char *)bto.buf)[i]; + p[((unsigned char *)bfrm.buf)[i]] = ((char *)bto.buf)[i]; } done: From python-checkins at python.org Wed Oct 14 19:30:52 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 17:30:52 -0000 Subject: [Python-checkins] r75407 - python/trunk/Lib/aifc.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 19:30:52 2009 New Revision: 75407 Log: Fix py3k warnings in the aifc module Modified: python/trunk/Lib/aifc.py Modified: python/trunk/Lib/aifc.py ============================================================================== --- python/trunk/Lib/aifc.py (original) +++ python/trunk/Lib/aifc.py Wed Oct 14 19:30:52 2009 @@ -409,7 +409,7 @@ data = self._ssnd_chunk.read(nframes * self._framesize) if self._convert and data: data = self._convert(data) - self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth) + self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) return data # @@ -420,7 +420,7 @@ import cl dummy = self._decomp.SetParam(cl.FRAME_BUFFER_SIZE, len(data) * 2) - return self._decomp.Decompress(len(data) / self._nchannels, + return self._decomp.Decompress(len(data) // self._nchannels, data) def _ulaw2lin(self, data): @@ -439,7 +439,7 @@ def _read_comm_chunk(self, chunk): self._nchannels = _read_short(chunk) self._nframes = _read_long(chunk) - self._sampwidth = (_read_short(chunk) + 7) / 8 + self._sampwidth = (_read_short(chunk) + 7) // 8 self._framerate = int(_read_float(chunk)) self._framesize = self._nchannels * self._sampwidth if self._aifc: @@ -468,7 +468,7 @@ pass else: self._convert = self._adpcm2lin - self._framesize = self._framesize / 4 + self._framesize = self._framesize // 4 return # for ULAW and ALAW try Compression Library try: @@ -478,17 +478,17 @@ try: import audioop self._convert = self._ulaw2lin - self._framesize = self._framesize / 2 + self._framesize = self._framesize // 2 return except ImportError: pass raise Error, 'cannot read compressed AIFF-C files' if self._comptype == 'ULAW': scheme = cl.G711_ULAW - self._framesize = self._framesize / 2 + self._framesize = self._framesize // 2 elif self._comptype == 'ALAW': scheme = cl.G711_ALAW - self._framesize = self._framesize / 2 + self._framesize = self._framesize // 2 else: raise Error, 'unsupported compression type' self._decomp = cl.OpenDecompressor(scheme) @@ -706,7 +706,7 @@ def writeframesraw(self, data): self._ensure_header_written(len(data)) - nframes = len(data) / (self._sampwidth * self._nchannels) + nframes = len(data) // (self._sampwidth * self._nchannels) if self._convert: data = self._convert(data) self._file.write(data) @@ -822,17 +822,17 @@ self._init_compression() self._file.write('FORM') if not self._nframes: - self._nframes = initlength / (self._nchannels * self._sampwidth) + self._nframes = initlength // (self._nchannels * self._sampwidth) self._datalength = self._nframes * self._nchannels * self._sampwidth if self._datalength & 1: self._datalength = self._datalength + 1 if self._aifc: if self._comptype in ('ULAW', 'ALAW'): - self._datalength = self._datalength / 2 + self._datalength = self._datalength // 2 if self._datalength & 1: self._datalength = self._datalength + 1 elif self._comptype == 'G722': - self._datalength = (self._datalength + 3) / 4 + self._datalength = (self._datalength + 3) // 4 if self._datalength & 1: self._datalength = self._datalength + 1 self._form_length_pos = self._file.tell() From python-checkins at python.org Wed Oct 14 19:34:31 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 17:34:31 -0000 Subject: [Python-checkins] r75408 - python/trunk/Lib/test/test_atexit.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 19:34:31 2009 New Revision: 75408 Log: Fix a test_atexit failure when run with -3 Modified: python/trunk/Lib/test/test_atexit.py Modified: python/trunk/Lib/test/test_atexit.py ============================================================================== --- python/trunk/Lib/test/test_atexit.py (original) +++ python/trunk/Lib/test/test_atexit.py Wed Oct 14 19:34:31 2009 @@ -2,6 +2,7 @@ import unittest import StringIO import atexit +from imp import reload from test import test_support class TestCase(unittest.TestCase): From python-checkins at python.org Wed Oct 14 20:01:34 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:01:34 -0000 Subject: [Python-checkins] r75409 - in python/trunk/Lib/bsddb: dbobj.py dbshelve.py dbtables.py dbutils.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:01:33 2009 New Revision: 75409 Log: Fix py3k warnings in bsddb Modified: python/trunk/Lib/bsddb/dbobj.py python/trunk/Lib/bsddb/dbshelve.py python/trunk/Lib/bsddb/dbtables.py python/trunk/Lib/bsddb/dbutils.py Modified: python/trunk/Lib/bsddb/dbobj.py ============================================================================== --- python/trunk/Lib/bsddb/dbobj.py (original) +++ python/trunk/Lib/bsddb/dbobj.py Wed Oct 14 20:01:33 2009 @@ -42,91 +42,91 @@ class DBEnv: def __init__(self, *args, **kwargs): - self._cobj = apply(db.DBEnv, args, kwargs) + self._cobj = db.DBEnv(*args, **kwargs) def close(self, *args, **kwargs): - return apply(self._cobj.close, args, kwargs) + return self._cobj.close(*args, **kwargs) def open(self, *args, **kwargs): - return apply(self._cobj.open, args, kwargs) + return self._cobj.open(*args, **kwargs) def remove(self, *args, **kwargs): - return apply(self._cobj.remove, args, kwargs) + return self._cobj.remove(*args, **kwargs) def set_shm_key(self, *args, **kwargs): - return apply(self._cobj.set_shm_key, args, kwargs) + return self._cobj.set_shm_key(*args, **kwargs) def set_cachesize(self, *args, **kwargs): - return apply(self._cobj.set_cachesize, args, kwargs) + return self._cobj.set_cachesize(*args, **kwargs) def set_data_dir(self, *args, **kwargs): - return apply(self._cobj.set_data_dir, args, kwargs) + return self._cobj.set_data_dir(*args, **kwargs) def set_flags(self, *args, **kwargs): - return apply(self._cobj.set_flags, args, kwargs) + return self._cobj.set_flags(*args, **kwargs) def set_lg_bsize(self, *args, **kwargs): - return apply(self._cobj.set_lg_bsize, args, kwargs) + return self._cobj.set_lg_bsize(*args, **kwargs) def set_lg_dir(self, *args, **kwargs): - return apply(self._cobj.set_lg_dir, args, kwargs) + return self._cobj.set_lg_dir(*args, **kwargs) def set_lg_max(self, *args, **kwargs): - return apply(self._cobj.set_lg_max, args, kwargs) + return self._cobj.set_lg_max(*args, **kwargs) def set_lk_detect(self, *args, **kwargs): - return apply(self._cobj.set_lk_detect, args, kwargs) + return self._cobj.set_lk_detect(*args, **kwargs) if db.version() < (4,5): def set_lk_max(self, *args, **kwargs): - return apply(self._cobj.set_lk_max, args, kwargs) + return self._cobj.set_lk_max(*args, **kwargs) def set_lk_max_locks(self, *args, **kwargs): - return apply(self._cobj.set_lk_max_locks, args, kwargs) + return self._cobj.set_lk_max_locks(*args, **kwargs) def set_lk_max_lockers(self, *args, **kwargs): - return apply(self._cobj.set_lk_max_lockers, args, kwargs) + return self._cobj.set_lk_max_lockers(*args, **kwargs) def set_lk_max_objects(self, *args, **kwargs): - return apply(self._cobj.set_lk_max_objects, args, kwargs) + return self._cobj.set_lk_max_objects(*args, **kwargs) def set_mp_mmapsize(self, *args, **kwargs): - return apply(self._cobj.set_mp_mmapsize, args, kwargs) + return self._cobj.set_mp_mmapsize(*args, **kwargs) def set_timeout(self, *args, **kwargs): - return apply(self._cobj.set_timeout, args, kwargs) + return self._cobj.set_timeout(*args, **kwargs) def set_tmp_dir(self, *args, **kwargs): - return apply(self._cobj.set_tmp_dir, args, kwargs) + return self._cobj.set_tmp_dir(*args, **kwargs) def txn_begin(self, *args, **kwargs): - return apply(self._cobj.txn_begin, args, kwargs) + return self._cobj.txn_begin(*args, **kwargs) def txn_checkpoint(self, *args, **kwargs): - return apply(self._cobj.txn_checkpoint, args, kwargs) + return self._cobj.txn_checkpoint(*args, **kwargs) def txn_stat(self, *args, **kwargs): - return apply(self._cobj.txn_stat, args, kwargs) + return self._cobj.txn_stat(*args, **kwargs) def set_tx_max(self, *args, **kwargs): - return apply(self._cobj.set_tx_max, args, kwargs) + return self._cobj.set_tx_max(*args, **kwargs) def set_tx_timestamp(self, *args, **kwargs): - return apply(self._cobj.set_tx_timestamp, args, kwargs) + return self._cobj.set_tx_timestamp(*args, **kwargs) def lock_detect(self, *args, **kwargs): - return apply(self._cobj.lock_detect, args, kwargs) + return self._cobj.lock_detect(*args, **kwargs) def lock_get(self, *args, **kwargs): - return apply(self._cobj.lock_get, args, kwargs) + return self._cobj.lock_get(*args, **kwargs) def lock_id(self, *args, **kwargs): - return apply(self._cobj.lock_id, args, kwargs) + return self._cobj.lock_id(*args, **kwargs) def lock_put(self, *args, **kwargs): - return apply(self._cobj.lock_put, args, kwargs) + return self._cobj.lock_put(*args, **kwargs) def lock_stat(self, *args, **kwargs): - return apply(self._cobj.lock_stat, args, kwargs) + return self._cobj.lock_stat(*args, **kwargs) def log_archive(self, *args, **kwargs): - return apply(self._cobj.log_archive, args, kwargs) + return self._cobj.log_archive(*args, **kwargs) def set_get_returns_none(self, *args, **kwargs): - return apply(self._cobj.set_get_returns_none, args, kwargs) + return self._cobj.set_get_returns_none(*args, **kwargs) def log_stat(self, *args, **kwargs): - return apply(self._cobj.log_stat, args, kwargs) + return self._cobj.log_stat(*args, **kwargs) if db.version() >= (4,1): def dbremove(self, *args, **kwargs): - return apply(self._cobj.dbremove, args, kwargs) + return self._cobj.dbremove(*args, **kwargs) def dbrename(self, *args, **kwargs): - return apply(self._cobj.dbrename, args, kwargs) + return self._cobj.dbrename(*args, **kwargs) def set_encrypt(self, *args, **kwargs): - return apply(self._cobj.set_encrypt, args, kwargs) + return self._cobj.set_encrypt(*args, **kwargs) if db.version() >= (4,4): def lsn_reset(self, *args, **kwargs): - return apply(self._cobj.lsn_reset, args, kwargs) + return self._cobj.lsn_reset(*args, **kwargs) class DB(MutableMapping): def __init__(self, dbenv, *args, **kwargs): # give it the proper DBEnv C object that its expecting - self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs) + self._cobj = db.DB(*((dbenv._cobj,) + args), **kwargs) # TODO are there other dict methods that need to be overridden? def __len__(self): @@ -143,126 +143,126 @@ return self._cobj.__iter__() def append(self, *args, **kwargs): - return apply(self._cobj.append, args, kwargs) + return self._cobj.append(*args, **kwargs) def associate(self, *args, **kwargs): - return apply(self._cobj.associate, args, kwargs) + return self._cobj.associate(*args, **kwargs) def close(self, *args, **kwargs): - return apply(self._cobj.close, args, kwargs) + return self._cobj.close(*args, **kwargs) def consume(self, *args, **kwargs): - return apply(self._cobj.consume, args, kwargs) + return self._cobj.consume(*args, **kwargs) def consume_wait(self, *args, **kwargs): - return apply(self._cobj.consume_wait, args, kwargs) + return self._cobj.consume_wait(*args, **kwargs) def cursor(self, *args, **kwargs): - return apply(self._cobj.cursor, args, kwargs) + return self._cobj.cursor(*args, **kwargs) def delete(self, *args, **kwargs): - return apply(self._cobj.delete, args, kwargs) + return self._cobj.delete(*args, **kwargs) def fd(self, *args, **kwargs): - return apply(self._cobj.fd, args, kwargs) + return self._cobj.fd(*args, **kwargs) def get(self, *args, **kwargs): - return apply(self._cobj.get, args, kwargs) + return self._cobj.get(*args, **kwargs) def pget(self, *args, **kwargs): - return apply(self._cobj.pget, args, kwargs) + return self._cobj.pget(*args, **kwargs) def get_both(self, *args, **kwargs): - return apply(self._cobj.get_both, args, kwargs) + return self._cobj.get_both(*args, **kwargs) def get_byteswapped(self, *args, **kwargs): - return apply(self._cobj.get_byteswapped, args, kwargs) + return self._cobj.get_byteswapped(*args, **kwargs) def get_size(self, *args, **kwargs): - return apply(self._cobj.get_size, args, kwargs) + return self._cobj.get_size(*args, **kwargs) def get_type(self, *args, **kwargs): - return apply(self._cobj.get_type, args, kwargs) + return self._cobj.get_type(*args, **kwargs) def join(self, *args, **kwargs): - return apply(self._cobj.join, args, kwargs) + return self._cobj.join(*args, **kwargs) def key_range(self, *args, **kwargs): - return apply(self._cobj.key_range, args, kwargs) + return self._cobj.key_range(*args, **kwargs) def has_key(self, *args, **kwargs): - return apply(self._cobj.has_key, args, kwargs) + return self._cobj.has_key(*args, **kwargs) def items(self, *args, **kwargs): - return apply(self._cobj.items, args, kwargs) + return self._cobj.items(*args, **kwargs) def keys(self, *args, **kwargs): - return apply(self._cobj.keys, args, kwargs) + return self._cobj.keys(*args, **kwargs) def open(self, *args, **kwargs): - return apply(self._cobj.open, args, kwargs) + return self._cobj.open(*args, **kwargs) def put(self, *args, **kwargs): - return apply(self._cobj.put, args, kwargs) + return self._cobj.put(*args, **kwargs) def remove(self, *args, **kwargs): - return apply(self._cobj.remove, args, kwargs) + return self._cobj.remove(*args, **kwargs) def rename(self, *args, **kwargs): - return apply(self._cobj.rename, args, kwargs) + return self._cobj.rename(*args, **kwargs) def set_bt_minkey(self, *args, **kwargs): - return apply(self._cobj.set_bt_minkey, args, kwargs) + return self._cobj.set_bt_minkey(*args, **kwargs) def set_bt_compare(self, *args, **kwargs): - return apply(self._cobj.set_bt_compare, args, kwargs) + return self._cobj.set_bt_compare(*args, **kwargs) def set_cachesize(self, *args, **kwargs): - return apply(self._cobj.set_cachesize, args, kwargs) + return self._cobj.set_cachesize(*args, **kwargs) def set_flags(self, *args, **kwargs): - return apply(self._cobj.set_flags, args, kwargs) + return self._cobj.set_flags(*args, **kwargs) def set_h_ffactor(self, *args, **kwargs): - return apply(self._cobj.set_h_ffactor, args, kwargs) + return self._cobj.set_h_ffactor(*args, **kwargs) def set_h_nelem(self, *args, **kwargs): - return apply(self._cobj.set_h_nelem, args, kwargs) + return self._cobj.set_h_nelem(*args, **kwargs) def set_lorder(self, *args, **kwargs): - return apply(self._cobj.set_lorder, args, kwargs) + return self._cobj.set_lorder(*args, **kwargs) def set_pagesize(self, *args, **kwargs): - return apply(self._cobj.set_pagesize, args, kwargs) + return self._cobj.set_pagesize(*args, **kwargs) def set_re_delim(self, *args, **kwargs): - return apply(self._cobj.set_re_delim, args, kwargs) + return self._cobj.set_re_delim(*args, **kwargs) def set_re_len(self, *args, **kwargs): - return apply(self._cobj.set_re_len, args, kwargs) + return self._cobj.set_re_len(*args, **kwargs) def set_re_pad(self, *args, **kwargs): - return apply(self._cobj.set_re_pad, args, kwargs) + return self._cobj.set_re_pad(*args, **kwargs) def set_re_source(self, *args, **kwargs): - return apply(self._cobj.set_re_source, args, kwargs) + return self._cobj.set_re_source(*args, **kwargs) def set_q_extentsize(self, *args, **kwargs): - return apply(self._cobj.set_q_extentsize, args, kwargs) + return self._cobj.set_q_extentsize(*args, **kwargs) def stat(self, *args, **kwargs): - return apply(self._cobj.stat, args, kwargs) + return self._cobj.stat(*args, **kwargs) def sync(self, *args, **kwargs): - return apply(self._cobj.sync, args, kwargs) + return self._cobj.sync(*args, **kwargs) def type(self, *args, **kwargs): - return apply(self._cobj.type, args, kwargs) + return self._cobj.type(*args, **kwargs) def upgrade(self, *args, **kwargs): - return apply(self._cobj.upgrade, args, kwargs) + return self._cobj.upgrade(*args, **kwargs) def values(self, *args, **kwargs): - return apply(self._cobj.values, args, kwargs) + return self._cobj.values(*args, **kwargs) def verify(self, *args, **kwargs): - return apply(self._cobj.verify, args, kwargs) + return self._cobj.verify(*args, **kwargs) def set_get_returns_none(self, *args, **kwargs): - return apply(self._cobj.set_get_returns_none, args, kwargs) + return self._cobj.set_get_returns_none(*args, **kwargs) if db.version() >= (4,1): def set_encrypt(self, *args, **kwargs): - return apply(self._cobj.set_encrypt, args, kwargs) + return self._cobj.set_encrypt(*args, **kwargs) class DBSequence: def __init__(self, *args, **kwargs): - self._cobj = apply(db.DBSequence, args, kwargs) + self._cobj = db.DBSequence(*args, **kwargs) def close(self, *args, **kwargs): - return apply(self._cobj.close, args, kwargs) + return self._cobj.close(*args, **kwargs) def get(self, *args, **kwargs): - return apply(self._cobj.get, args, kwargs) + return self._cobj.get(*args, **kwargs) def get_dbp(self, *args, **kwargs): - return apply(self._cobj.get_dbp, args, kwargs) + return self._cobj.get_dbp(*args, **kwargs) def get_key(self, *args, **kwargs): - return apply(self._cobj.get_key, args, kwargs) + return self._cobj.get_key(*args, **kwargs) def init_value(self, *args, **kwargs): - return apply(self._cobj.init_value, args, kwargs) + return self._cobj.init_value(*args, **kwargs) def open(self, *args, **kwargs): - return apply(self._cobj.open, args, kwargs) + return self._cobj.open(*args, **kwargs) def remove(self, *args, **kwargs): - return apply(self._cobj.remove, args, kwargs) + return self._cobj.remove(*args, **kwargs) def stat(self, *args, **kwargs): - return apply(self._cobj.stat, args, kwargs) + return self._cobj.stat(*args, **kwargs) def set_cachesize(self, *args, **kwargs): - return apply(self._cobj.set_cachesize, args, kwargs) + return self._cobj.set_cachesize(*args, **kwargs) def set_flags(self, *args, **kwargs): - return apply(self._cobj.set_flags, args, kwargs) + return self._cobj.set_flags(*args, **kwargs) def set_range(self, *args, **kwargs): - return apply(self._cobj.set_range, args, kwargs) + return self._cobj.set_range(*args, **kwargs) def get_cachesize(self, *args, **kwargs): - return apply(self._cobj.get_cachesize, args, kwargs) + return self._cobj.get_cachesize(*args, **kwargs) def get_flags(self, *args, **kwargs): - return apply(self._cobj.get_flags, args, kwargs) + return self._cobj.get_flags(*args, **kwargs) def get_range(self, *args, **kwargs): - return apply(self._cobj.get_range, args, kwargs) + return self._cobj.get_range(*args, **kwargs) Modified: python/trunk/Lib/bsddb/dbshelve.py ============================================================================== --- python/trunk/Lib/bsddb/dbshelve.py (original) +++ python/trunk/Lib/bsddb/dbshelve.py Wed Oct 14 20:01:33 2009 @@ -234,7 +234,7 @@ # given nothing is passed to the extension module. That way # an exception can be raised if set_get_returns_none is turned # off. - data = apply(self.db.get, args, kw) + data = self.db.get(*args, **kw) try: return cPickle.loads(data) except (EOFError, TypeError, cPickle.UnpicklingError): @@ -303,7 +303,7 @@ def get(self, *args): count = len(args) # a method overloading hack method = getattr(self, 'get_%d' % count) - apply(method, args) + method(*args) def get_1(self, flags): rec = self.dbc.get(flags) Modified: python/trunk/Lib/bsddb/dbtables.py ============================================================================== --- python/trunk/Lib/bsddb/dbtables.py (original) +++ python/trunk/Lib/bsddb/dbtables.py Wed Oct 14 20:01:33 2009 @@ -398,7 +398,7 @@ # column names newcolumnlist = copy.copy(oldcolumnlist) for c in columns: - if not oldcolumnhash.has_key(c): + if not c in oldcolumnhash: newcolumnlist.append(c) # store the table's new extended column list @@ -472,7 +472,7 @@ raise TableDBError, "unknown table" # check the validity of each column name - if not self.__tablecolumns.has_key(table): + if not table in self.__tablecolumns: self.__load_column_info(table) for column in rowdict.keys() : if not self.__tablecolumns[table].count(column): @@ -540,7 +540,7 @@ # error dataitem = None dataitem = mappings[column](dataitem) - if dataitem <> None: + if dataitem != None: self.db.put( _data_key(table, column, rowid), dataitem, txn=txn) @@ -615,7 +615,7 @@ argument and returning a boolean. """ try: - if not self.__tablecolumns.has_key(table): + if not table in self.__tablecolumns: self.__load_column_info(table) if columns is None: columns = self.__tablecolumns[table] @@ -639,7 +639,7 @@ argument and returning a boolean. """ # check the validity of each column name - if not self.__tablecolumns.has_key(table): + if not table in self.__tablecolumns: self.__load_column_info(table) if columns is None: columns = self.tablecolumns[table] @@ -709,28 +709,24 @@ # extract the rowid from the key rowid = key[-_rowid_str_len:] - if not rejected_rowids.has_key(rowid): + if not rowid in rejected_rowids: # if no condition was specified or the condition # succeeds, add row to our match list. if not condition or condition(data): - if not matching_rowids.has_key(rowid): + if not rowid in matching_rowids: matching_rowids[rowid] = {} if savethiscolumndata: matching_rowids[rowid][column] = data else: - if matching_rowids.has_key(rowid): + if rowid in matching_rowids: del matching_rowids[rowid] rejected_rowids[rowid] = rowid key, data = cur.next() except db.DBError, dberror: - if sys.version_info[0] < 3 : - if dberror[0] != db.DB_NOTFOUND: - raise - else : - if dberror.args[0] != db.DB_NOTFOUND: - raise + if dberror.args[0] != db.DB_NOTFOUND: + raise continue cur.close() @@ -743,7 +739,7 @@ if len(columns) > 0: for rowid, rowdata in matching_rowids.items(): for column in columns: - if rowdata.has_key(column): + if column in rowdata: continue try: rowdata[column] = self.db.get( @@ -815,13 +811,10 @@ txn.commit() txn = None - if self.__tablecolumns.has_key(table): + if table in self.__tablecolumns: del self.__tablecolumns[table] except db.DBError, dberror: if txn: txn.abort() - if sys.version_info[0] < 3 : - raise TableDBError, dberror[1] - else : - raise TableDBError, dberror.args[1] + raise TableDBError(dberror.args[1]) Modified: python/trunk/Lib/bsddb/dbutils.py ============================================================================== --- python/trunk/Lib/bsddb/dbutils.py (original) +++ python/trunk/Lib/bsddb/dbutils.py Wed Oct 14 20:01:33 2009 @@ -61,7 +61,7 @@ """ sleeptime = _deadlock_MinSleepTime max_retries = _kwargs.get('max_retries', -1) - if _kwargs.has_key('max_retries'): + if 'max_retries' in _kwargs: del _kwargs['max_retries'] while True: try: From python-checkins at python.org Wed Oct 14 20:09:45 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:09:45 -0000 Subject: [Python-checkins] r75410 - python/trunk/Lib/test/test_calendar.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:09:45 2009 New Revision: 75410 Log: Silence a py3k warning claiming to affect Lib/calendar.py Modified: python/trunk/Lib/test/test_calendar.py Modified: python/trunk/Lib/test/test_calendar.py ============================================================================== --- python/trunk/Lib/test/test_calendar.py (original) +++ python/trunk/Lib/test/test_calendar.py Wed Oct 14 20:09:45 2009 @@ -212,9 +212,11 @@ self.assertEqual(calendar.isleap(2003), 0) def test_setfirstweekday(self): - self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') - self.assertRaises(ValueError, calendar.setfirstweekday, -1) - self.assertRaises(ValueError, calendar.setfirstweekday, 200) + # Silence a py3k warning claiming to affect Lib/calendar.py + with test_support.check_warnings(): + self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') + self.assertRaises(ValueError, calendar.setfirstweekday, -1) + self.assertRaises(ValueError, calendar.setfirstweekday, 200) orig = calendar.firstweekday() calendar.setfirstweekday(calendar.SUNDAY) self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) From python-checkins at python.org Wed Oct 14 20:12:54 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:12:54 -0000 Subject: [Python-checkins] r75411 - python/trunk/Lib/StringIO.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:12:54 2009 New Revision: 75411 Log: Fix a py3k warning in the StringIO module (exhibited in test_codecencodings_cn) Modified: python/trunk/Lib/StringIO.py Modified: python/trunk/Lib/StringIO.py ============================================================================== --- python/trunk/Lib/StringIO.py (original) +++ python/trunk/Lib/StringIO.py Wed Oct 14 20:12:54 2009 @@ -128,7 +128,7 @@ if self.buflist: self.buf += ''.join(self.buflist) self.buflist = [] - if n < 0: + if n is None or n < 0: newpos = self.len else: newpos = min(self.pos+n, self.len) From python-checkins at python.org Wed Oct 14 20:27:32 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:27:32 -0000 Subject: [Python-checkins] r75412 - python/trunk/Lib/socket.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:27:32 2009 New Revision: 75412 Log: Fix py3k warnings in the socket module Modified: python/trunk/Lib/socket.py Modified: python/trunk/Lib/socket.py ============================================================================== --- python/trunk/Lib/socket.py (original) +++ python/trunk/Lib/socket.py Wed Oct 14 20:27:32 2009 @@ -46,7 +46,7 @@ import _socket from _socket import * from functools import partial -from new import instancemethod +from types import MethodType try: import _ssl @@ -224,7 +224,7 @@ p = partial(meth,_m) p.__name__ = _m p.__doc__ = getattr(_realsocket,_m).__doc__ - m = instancemethod(p,None,_socketobject) + m = MethodType(p,None,_socketobject) setattr(_socketobject,_m,m) socket = SocketType = _socketobject @@ -294,14 +294,15 @@ buffer_size = max(self._rbufsize, self.default_bufsize) data_size = len(data) write_offset = 0 + view = memoryview(data) try: while write_offset < data_size: - self._sock.sendall(buffer(data, write_offset, buffer_size)) + self._sock.sendall(view[write_offset:write_offset+buffer_size]) write_offset += buffer_size finally: if write_offset < data_size: remainder = data[write_offset:] - del data # explicit free + del view, data # explicit free self._wbuf.append(remainder) self._wbuf_len = len(remainder) @@ -346,7 +347,7 @@ try: data = self._sock.recv(rbufsize) except error, e: - if e[0] == EINTR: + if e.args[0] == EINTR: continue raise if not data: @@ -375,7 +376,7 @@ try: data = self._sock.recv(left) except error, e: - if e[0] == EINTR: + if e.args[0] == EINTR: continue raise if not data: @@ -430,7 +431,7 @@ except error, e: # The try..except to catch EINTR was moved outside the # recv loop to avoid the per byte overhead. - if e[0] == EINTR: + if e.args[0] == EINTR: continue raise break @@ -442,7 +443,7 @@ try: data = self._sock.recv(self._rbufsize) except error, e: - if e[0] == EINTR: + if e.args[0] == EINTR: continue raise if not data: @@ -471,7 +472,7 @@ try: data = self._sock.recv(self._rbufsize) except error, e: - if e[0] == EINTR: + if e.args[0] == EINTR: continue raise if not data: From python-checkins at python.org Wed Oct 14 20:31:05 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:31:05 -0000 Subject: [Python-checkins] r75413 - python/trunk/Lib/sndhdr.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:31:05 2009 New Revision: 75413 Log: Fix a py3k warning in the sndhdr module (found with test_email) Modified: python/trunk/Lib/sndhdr.py Modified: python/trunk/Lib/sndhdr.py ============================================================================== --- python/trunk/Lib/sndhdr.py (original) +++ python/trunk/Lib/sndhdr.py Wed Oct 14 20:31:05 2009 @@ -100,7 +100,7 @@ else: sample_bits = '?' frame_size = sample_size * nchannels - return type, rate, nchannels, data_size/frame_size, sample_bits + return type, rate, nchannels, data_size//frame_size, sample_bits tests.append(test_au) @@ -109,7 +109,7 @@ if h[65:69] != 'FSSD' or h[128:132] != 'HCOM': return None divisor = get_long_be(h[128+16:128+20]) - return 'hcom', 22050/divisor, 1, -1, 8 + return 'hcom', 22050//divisor, 1, -1, 8 tests.append(test_hcom) From python-checkins at python.org Wed Oct 14 20:39:18 2009 From: python-checkins at python.org (tarek.ziade) Date: Wed, 14 Oct 2009 18:39:18 -0000 Subject: [Python-checkins] r75414 - peps/trunk/pep-0376.txt Message-ID: Author: tarek.ziade Date: Wed Oct 14 20:39:17 2009 New Revision: 75414 Log: applying Carl's changes Modified: peps/trunk/pep-0376.txt Modified: peps/trunk/pep-0376.txt ============================================================================== --- peps/trunk/pep-0376.txt (original) +++ peps/trunk/pep-0376.txt Wed Oct 14 20:39:17 2009 @@ -30,7 +30,7 @@ The arguments passed to that function describe the distribution, like its `name`, its `version`, and so on. -Disutils provides, among other things, **commands** that can be called +Distutils provides, among other things, **commands** that can be called through the shell using the `setup.py` script. An `sdist` command is provided for instance to create a source distribution archive. An `install` command is also provided to perform an installation of the distribution in the Python @@ -169,14 +169,12 @@ This `.egg-info` directory contains a `PKG-INFO` file built by the `write_pkg_file` method of the `Distribution` class in Distutils. -This change is not impacting Python itself because the metadata files are not +This change does not impact Python itself because the metadata files are not used anywhere yet in the standard library besides Distutils. -However, it is impacting the `setuptools` and `pip` projects, but given -the fact that they already work with a directory that contains a `PKG-INFO` -file, the change will have no deep consequences. That said, packages installed -other existing pre-standardisation formats are ignored by the new -system, as explained in the backward compatibility section of this document. +It does impact the `setuptools` and `pip` projects, but given the fact that +they already work with a directory that contains a `PKG-INFO` file, the change +will have no deep consequences. Let's take an example of the new format with the `docutils` distribution. The elements installed in `site-packages` are:: @@ -318,6 +316,33 @@ `.egg-info` directory with this value, to keep track of **who** installed the distribution. The file is a single-line text file. +Adding a REQUESTED file in the .egg-info directory +================================================== + +Some install tools automatically detect unfulfilled dependencies and +install them. In these cases, it is useful to track which +distributions were installed purely as a dependency, so if their +dependent distribution is later uninstalled, the user can be alerted +to the orphaned dependency. + +If a distribution is installed by direct user request (the usual +case), a file REQUESTED is added to the .egg-info directory of the +installed distribution. The REQUESTED file may be empty, or may +contain a marker comment line beginning with the "#" character. + +If an install tool installs a distribution automatically, as a +dependency of another distribution, the REQUESTED file should not be +created. + +The ``install`` command of distutils by default creates the REQUESTED +file. It accepts --requested and --no-requested options to explicitly +specify whether the file is created. + +If a package that was already installed on the system as a dependency +is later installed by name, the distutils ``install`` command will +create the REQUESTED file in the .egg-info directory of the existing +installation. + New APIs in pkgutil =================== @@ -368,6 +393,10 @@ - ``metadata``: A ``DistributionMetadata`` instance loaded with the distribution's PKG-INFO file. +- ``requested``: A boolean that indicates whether the REQUESTED + metadata file is present (in other words, whether the package was + installed by user request). + And following methods: - ``get_installed_files(local=False)`` -> iterator of (path, md5, size) @@ -445,6 +474,9 @@ >>> dist.get_egginfo_file('PKG-INFO') + >>> dist.requested + True + PEP 262 replacement =================== @@ -550,17 +582,24 @@ another distribution. Although it makes sure that all the files it removes are not used by any other distribution, by using the uninstall function. +Also note that this uninstall script pays no attention to the +REQUESTED metadata; that is provided only for use by external tools to +provide more advanced dependency management. Backward compatibility and roadmap ================================== -These changes doesn't introduce any compatibility problems with the previous +These changes don't introduce any compatibility problems with the previous version of Distutils, and will also work with existing third-party tools. -Although, a backport of the new Distutils for 2.5, 2.6, 3.0 and 3.1 is -provided so people can benefit from these new features. - -The plan is to integrate them for Python 2.7 and Python 3.2 +The plan is to include the functionality outlined in this PEP in distutils for +Python 2.7 and Python 3.2. A backport of the new distutils for 2.5, 2.6, 3.0 +and 3.1 is provided so people can benefit from these new features. + +Distributions installed using existing, pre-standardization formats do not have +the necessary metadata available for the new API, and thus will be +ignored. Third-party tools may of course to continue to support previous +formats in addition to the new format, in order to ease the transition. References @@ -602,8 +641,8 @@ .. [#prototype] http://bitbucket.org/tarek/pep376/ -Aknowledgments -============== +Acknowledgements +================ Jim Fulton, Ian Bicking, Phillip Eby, and many people at Pycon and Distutils-SIG. From python-checkins at python.org Wed Oct 14 20:39:47 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:39:47 -0000 Subject: [Python-checkins] r75415 - python/trunk/Lib/test/test_memoryio.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:39:46 2009 New Revision: 75415 Log: Silence some py3k warnings claiming to affect _pyio Modified: python/trunk/Lib/test/test_memoryio.py Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Wed Oct 14 20:39:46 2009 @@ -129,7 +129,9 @@ pos = memio.tell() self.assertEqual(memio.truncate(None), pos) self.assertEqual(memio.tell(), pos) - self.assertRaises(TypeError, memio.truncate, '0') + # Silence a py3k warning + with support.check_warnings(): + self.assertRaises(TypeError, memio.truncate, '0') memio.close() self.assertRaises(ValueError, memio.truncate, 0) @@ -165,7 +167,9 @@ self.assertEqual(type(memio.read()), type(buf)) memio.seek(0) self.assertEqual(memio.read(None), buf) - self.assertRaises(TypeError, memio.read, '') + # Silence a py3k warning + with support.check_warnings(): + self.assertRaises(TypeError, memio.read, '') memio.close() self.assertRaises(ValueError, memio.read) From python-checkins at python.org Wed Oct 14 20:46:16 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 14 Oct 2009 18:46:16 -0000 Subject: [Python-checkins] r75416 - python/branches/py3k/Lib/turtle.py Message-ID: Author: georg.brandl Date: Wed Oct 14 20:46:15 2009 New Revision: 75416 Log: #7129: add missing function. Modified: python/branches/py3k/Lib/turtle.py Modified: python/branches/py3k/Lib/turtle.py ============================================================================== --- python/branches/py3k/Lib/turtle.py (original) +++ python/branches/py3k/Lib/turtle.py Wed Oct 14 20:46:15 2009 @@ -126,7 +126,7 @@ _tg_turtle_functions = ['back', 'backward', 'begin_fill', 'begin_poly', 'bk', 'circle', 'clear', 'clearstamp', 'clearstamps', 'clone', 'color', 'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd', - 'fillcolor', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', + 'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', 'getturtle', 'goto', 'heading', 'hideturtle', 'home', 'ht', 'isdown', 'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease', 'pd', 'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position', From python-checkins at python.org Wed Oct 14 20:47:14 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:47:14 -0000 Subject: [Python-checkins] r75417 - python/trunk/Lib/test/test_profilehooks.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:47:13 2009 New Revision: 75417 Log: Fix failures in test_profilehooks when run with -3 Modified: python/trunk/Lib/test/test_profilehooks.py Modified: python/trunk/Lib/test/test_profilehooks.py ============================================================================== --- python/trunk/Lib/test/test_profilehooks.py (original) +++ python/trunk/Lib/test/test_profilehooks.py Wed Oct 14 20:47:13 2009 @@ -110,7 +110,7 @@ def test_exception(self): def f(p): - 1/0 + 1./0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), @@ -118,7 +118,7 @@ def test_caught_exception(self): def f(p): - try: 1/0 + try: 1./0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), @@ -127,7 +127,7 @@ def test_caught_nested_exception(self): def f(p): - try: 1/0 + try: 1./0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), @@ -136,7 +136,7 @@ def test_nested_exception(self): def f(p): - 1/0 + 1./0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), # This isn't what I expected: @@ -147,7 +147,7 @@ def test_exception_in_except_clause(self): def f(p): - 1/0 + 1./0 def g(p): try: f(p) @@ -166,7 +166,7 @@ def test_exception_propogation(self): def f(p): - 1/0 + 1./0 def g(p): try: f(p) finally: p.add_event("falling through") @@ -181,8 +181,8 @@ def test_raise_twice(self): def f(p): - try: 1/0 - except: 1/0 + try: 1./0 + except: 1./0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), @@ -190,7 +190,7 @@ def test_raise_reraise(self): def f(p): - try: 1/0 + try: 1./0 except: raise f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), @@ -207,7 +207,7 @@ def test_distant_exception(self): def f(): - 1/0 + 1./0 def g(): f() def h(): @@ -292,7 +292,7 @@ def test_basic_exception(self): def f(p): - 1/0 + 1./0 f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), (1, 'return', f_ident), @@ -300,7 +300,7 @@ def test_caught_exception(self): def f(p): - try: 1/0 + try: 1./0 except: pass f_ident = ident(f) self.check_events(f, [(1, 'call', f_ident), @@ -309,7 +309,7 @@ def test_distant_exception(self): def f(): - 1/0 + 1./0 def g(): f() def h(): From python-checkins at python.org Wed Oct 14 20:48:33 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 14 Oct 2009 18:48:33 -0000 Subject: [Python-checkins] r75418 - in python/trunk: Doc/library/stdtypes.rst Objects/stringobject.c Objects/unicodeobject.c Message-ID: Author: georg.brandl Date: Wed Oct 14 20:48:32 2009 New Revision: 75418 Log: #7116: str.join() takes an iterable. Modified: python/trunk/Doc/library/stdtypes.rst python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Modified: python/trunk/Doc/library/stdtypes.rst ============================================================================== --- python/trunk/Doc/library/stdtypes.rst (original) +++ python/trunk/Doc/library/stdtypes.rst Wed Oct 14 20:48:32 2009 @@ -996,10 +996,11 @@ For 8-bit strings, this method is locale-dependent. -.. method:: str.join(seq) +.. method:: str.join(iterable) - Return a string which is the concatenation of the strings in the sequence *seq*. - The separator between elements is the string providing this method. + Return a string which is the concatenation of the strings in the + :term:`iterable` *iterable*. The separator between elements is the string + providing this method. .. method:: str.ljust(width[, fillchar]) Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Wed Oct 14 20:48:32 2009 @@ -1814,10 +1814,10 @@ PyDoc_STRVAR(join__doc__, -"S.join(sequence) -> string\n\ +"S.join(iterable) -> string\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject * string_join(PyStringObject *self, PyObject *orig) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Wed Oct 14 20:48:32 2009 @@ -7154,10 +7154,10 @@ } PyDoc_STRVAR(join__doc__, - "S.join(sequence) -> unicode\n\ + "S.join(iterable) -> unicode\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject* unicode_join(PyObject *self, PyObject *data) From python-checkins at python.org Wed Oct 14 20:56:12 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 18:56:12 -0000 Subject: [Python-checkins] r75419 - python/trunk/Lib/test/test_random.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 20:56:11 2009 New Revision: 75419 Log: Silence py3k warning claiming to affect the random module Modified: python/trunk/Lib/test/test_random.py Modified: python/trunk/Lib/test/test_random.py ============================================================================== --- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Wed Oct 14 20:56:11 2009 @@ -52,10 +52,12 @@ state3 = self.gen.getstate() # s/b distinct from state2 self.assertNotEqual(state2, state3) - self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg - self.assertRaises(TypeError, self.gen.jumpahead, "ick") # wrong type - self.assertRaises(TypeError, self.gen.jumpahead, 2.3) # wrong type - self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many + # Silence py3k warnings + with test_support.check_warnings(): + self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg + self.assertRaises(TypeError, self.gen.jumpahead, "ick") # wrong type + self.assertRaises(TypeError, self.gen.jumpahead, 2.3) # wrong type + self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many def test_sample(self): # For the entire allowable range of 0 <= k <= N, validate that From python-checkins at python.org Wed Oct 14 21:04:48 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 19:04:48 -0000 Subject: [Python-checkins] r75420 - python/trunk/Lib/httplib.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 21:04:48 2009 New Revision: 75420 Log: Fix py3k warnings in httplib Modified: python/trunk/Lib/httplib.py Modified: python/trunk/Lib/httplib.py ============================================================================== --- python/trunk/Lib/httplib.py (original) +++ python/trunk/Lib/httplib.py Wed Oct 14 21:04:48 2009 @@ -706,8 +706,8 @@ if code != 200: self.close() - raise socket.error, "Tunnel connection failed: %d %s" % (code, - message.strip()) + raise socket.error("Tunnel connection failed: %d %s" % (code, + message.strip())) while True: line = response.fp.readline() if line == '\r\n': break @@ -757,7 +757,7 @@ else: self.sock.sendall(str) except socket.error, v: - if v[0] == 32: # Broken pipe + if v.args[0] == 32: # Broken pipe self.close() raise @@ -929,7 +929,7 @@ self._send_request(method, url, body, headers) except socket.error, v: # trap 'Broken pipe' if we're allowed to automatically reconnect - if v[0] != 32 or not self.auto_open: + if v.args[0] != 32 or not self.auto_open: raise # try one more time self._send_request(method, url, body, headers) From python-checkins at python.org Wed Oct 14 21:09:49 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 14 Oct 2009 19:09:49 -0000 Subject: [Python-checkins] r75421 - python/trunk/Lib/uuid.py Message-ID: Author: antoine.pitrou Date: Wed Oct 14 21:09:48 2009 New Revision: 75421 Log: Fix py3k warnings in the uuid module Modified: python/trunk/Lib/uuid.py Modified: python/trunk/Lib/uuid.py ============================================================================== --- python/trunk/Lib/uuid.py (original) +++ python/trunk/Lib/uuid.py Wed Oct 14 21:09:48 2009 @@ -489,8 +489,8 @@ nanoseconds = int(time.time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. - timestamp = int(nanoseconds/100) + 0x01b21dd213814000L - if timestamp <= _last_timestamp: + timestamp = int(nanoseconds//100) + 0x01b21dd213814000L + if _last_timestamp is not None and timestamp <= _last_timestamp: timestamp = _last_timestamp + 1 _last_timestamp = timestamp if clock_seq is None: From python-checkins at python.org Wed Oct 14 21:14:39 2009 From: python-checkins at python.org (neil.schemenauer) Date: Wed, 14 Oct 2009 19:14:39 -0000 Subject: [Python-checkins] r75422 - in python/branches/py3k: Misc/NEWS Python/compile.c Message-ID: Author: neil.schemenauer Date: Wed Oct 14 21:14:38 2009 New Revision: 75422 Log: Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Modified: python/branches/py3k/Misc/NEWS python/branches/py3k/Python/compile.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 14 21:14:38 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #1754094: Improve the stack depth calculation in the compiler. + There should be no other effect than a small decrease in memory use. + Patch by Christopher Tur Lesniewski-Laas. + - Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when using byte values greater than 127. Patch by egreen. Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Wed Oct 14 21:14:38 2009 @@ -772,7 +772,7 @@ case UNPACK_EX: return (oparg&0xFF) + (oparg>>8); case FOR_ITER: - return 1; + return 1; /* or -1, at end of iterator */ case STORE_ATTR: return -2; @@ -799,7 +799,7 @@ case COMPARE_OP: return -1; case IMPORT_NAME: - return 0; + return -1; case IMPORT_FROM: return 1; @@ -3546,7 +3546,7 @@ static int stackdepth_walk(struct compiler *c, basicblock *b, int depth, int maxdepth) { - int i; + int i, target_depth; struct instr *instr; if (b->b_seen || b->b_startdepth >= depth) return maxdepth; @@ -3559,8 +3559,17 @@ maxdepth = depth; assert(depth >= 0); /* invalid code or bug in stackdepth() */ if (instr->i_jrel || instr->i_jabs) { + target_depth = depth; + if (instr->i_opcode == FOR_ITER) { + target_depth = depth-2; + } else if (instr->i_opcode == SETUP_FINALLY || + instr->i_opcode == SETUP_EXCEPT) { + target_depth = depth+3; + if (target_depth > maxdepth) + maxdepth = target_depth; + } maxdepth = stackdepth_walk(c, instr->i_target, - depth, maxdepth); + target_depth, maxdepth); if (instr->i_opcode == JUMP_ABSOLUTE || instr->i_opcode == JUMP_FORWARD) { goto out; /* remaining code is dead */ From python-checkins at python.org Wed Oct 14 21:23:53 2009 From: python-checkins at python.org (neil.schemenauer) Date: Wed, 14 Oct 2009 19:23:53 -0000 Subject: [Python-checkins] r75423 - in python/trunk: Lib/ihooks.py Misc/NEWS Message-ID: Author: neil.schemenauer Date: Wed Oct 14 21:23:53 2009 New Revision: 75423 Log: Add support to the ihooks module for relative imports. Modified: python/trunk/Lib/ihooks.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/ihooks.py ============================================================================== --- python/trunk/Lib/ihooks.py (original) +++ python/trunk/Lib/ihooks.py Wed Oct 14 21:23:53 2009 @@ -49,7 +49,7 @@ would also do wise to install a different version of reload(). """ -from warnings import warnpy3k +from warnings import warnpy3k, warn warnpy3k("the ihooks module has been removed in Python 3.0", stacklevel=2) del warnpy3k @@ -401,8 +401,9 @@ """A module importer that supports packages.""" - def import_module(self, name, globals=None, locals=None, fromlist=None): - parent = self.determine_parent(globals) + def import_module(self, name, globals=None, locals=None, fromlist=None, + level=-1): + parent = self.determine_parent(globals, level) q, tail = self.find_head_package(parent, str(name)) m = self.load_tail(q, tail) if not fromlist: @@ -411,21 +412,50 @@ self.ensure_fromlist(m, fromlist) return m - def determine_parent(self, globals): - if not globals or not "__name__" in globals: + def determine_parent(self, globals, level=-1): + if not globals or not level: return None - pname = globals['__name__'] - if "__path__" in globals: - parent = self.modules[pname] - assert globals is parent.__dict__ - return parent - if '.' in pname: - i = pname.rfind('.') - pname = pname[:i] - parent = self.modules[pname] - assert parent.__name__ == pname - return parent - return None + pkgname = globals.get('__package__') + if pkgname is not None: + if not pkgname and level > 0: + raise ValueError, 'Attempted relative import in non-package' + else: + # __package__ not set, figure it out and set it + modname = globals.get('__name__') + if modname is None: + return None + if "__path__" in globals: + # __path__ is set so modname is already the package name + pkgname = modname + else: + # normal module, work out package name if any + if '.' not in modname: + if level > 0: + raise ValueError, ('Attempted relative import in ' + 'non-package') + globals['__package__'] = None + return None + pkgname = modname.rpartition('.')[0] + globals['__package__'] = pkgname + if level > 0: + dot = len(pkgname) + for x in range(level, 1, -1): + try: + dot = pkgname.rindex('.', 0, dot) + except ValueError: + raise ValueError('attempted relative import beyond ' + 'top-level package') + pkgname = pkgname[:dot] + try: + return sys.modules[pkgname] + except KeyError: + if level < 1: + warn("Parent module '%s' not found while handling " + "absolute import" % pkgname, RuntimeWarning, 1) + return None + else: + raise SystemError, ("Parent module '%s' not loaded, cannot " + "perform relative import" % pkgname) def find_head_package(self, parent, name): if '.' in name: @@ -446,7 +476,7 @@ parent = None q = self.import_it(head, qname, parent) if q: return q, tail - raise ImportError, "No module named " + qname + raise ImportError, "No module named '%s'" % qname def load_tail(self, q, tail): m = q @@ -457,7 +487,7 @@ mname = "%s.%s" % (m.__name__, head) m = self.import_it(head, mname, m) if not m: - raise ImportError, "No module named " + mname + raise ImportError, "No module named '%s'" % mname return m def ensure_fromlist(self, m, fromlist, recursive=0): @@ -475,11 +505,13 @@ subname = "%s.%s" % (m.__name__, sub) submod = self.import_it(sub, subname, m) if not submod: - raise ImportError, "No module named " + subname + raise ImportError, "No module named '%s'" % subname def import_it(self, partname, fqname, parent, force_load=0): if not partname: - raise ValueError, "Empty module name" + # completely empty module name should only happen in + # 'from . import' or __import__("") + return parent if not force_load: try: return self.modules[fqname] Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 14 21:23:53 2009 @@ -405,6 +405,8 @@ Library ------- +- Add support to the `ihooks` module for relative imports. + - Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #7086: Added TCP support to SysLogHandler, and tidied up some From python-checkins at python.org Wed Oct 14 21:33:31 2009 From: python-checkins at python.org (neil.schemenauer) Date: Wed, 14 Oct 2009 19:33:31 -0000 Subject: [Python-checkins] r75424 - python/trunk/Modules/cPickle.c Message-ID: Author: neil.schemenauer Date: Wed Oct 14 21:33:31 2009 New Revision: 75424 Log: Make cPickle.Unpickler.noload() handle dict subclasses. noload() is an obscure, undocumentated feature so no test was added. Closes issue #1101399. Modified: python/trunk/Modules/cPickle.c Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Wed Oct 14 21:33:31 2009 @@ -5049,6 +5049,33 @@ return 0; } +static int +noload_append(Unpicklerobject *self) +{ + return Pdata_clear(self->stack, self->stack->length - 1); +} + +static int +noload_appends(Unpicklerobject *self) +{ + int i; + if ((i = marker(self)) < 0) return -1; + return Pdata_clear(self->stack, i); +} + +static int +noload_setitem(Unpicklerobject *self) +{ + return Pdata_clear(self->stack, self->stack->length - 2); +} + +static int +noload_setitems(Unpicklerobject *self) +{ + int i; + if ((i = marker(self)) < 0) return -1; + return Pdata_clear(self->stack, i); +} static PyObject * noload(Unpicklerobject *self) @@ -5207,12 +5234,12 @@ continue; case APPEND: - if (load_append(self) < 0) + if (noload_append(self) < 0) break; continue; case APPENDS: - if (load_appends(self) < 0) + if (noload_appends(self) < 0) break; continue; @@ -5287,12 +5314,12 @@ continue; case SETITEM: - if (load_setitem(self) < 0) + if (noload_setitem(self) < 0) break; continue; case SETITEMS: - if (load_setitems(self) < 0) + if (noload_setitems(self) < 0) break; continue; From python-checkins at python.org Wed Oct 14 21:53:24 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 14 Oct 2009 19:53:24 -0000 Subject: [Python-checkins] r75425 - in python/branches/release26-maint: Lib/logging/__init__.py Misc/NEWS Message-ID: Author: vinay.sajip Date: Wed Oct 14 21:53:23 2009 New Revision: 75425 Log: Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. Modified: python/branches/release26-maint/Lib/logging/__init__.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/logging/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/logging/__init__.py (original) +++ python/branches/release26-maint/Lib/logging/__init__.py Wed Oct 14 21:53:23 2009 @@ -273,12 +273,10 @@ self.threadName = None if not logMultiprocessing: self.processName = None + elif 'multiprocessing' not in sys.modules: + self.processName = 'MainProcess' else: - try: - from multiprocessing import current_process - self.processName = current_process().name - except ImportError: - self.processName = None + self.processName = sys.modules['multiprocessing'].current_process().name if logProcesses and hasattr(os, 'getpid'): self.process = os.getpid() else: Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Wed Oct 14 21:53:23 2009 @@ -18,12 +18,15 @@ Library ------- -- Issue #7115: Fixed the extension module builds that is failing when using +- Issue #7120: logging: Removed import of multiprocessing which is causing + crash in GAE. + +- Issue #7115: Fixed the extension module builds that is failing when using paths in the extension name instead of dotted names. - Issue #7068: Fixed the partial renaming that occured in r72594. -- Issue #7064: Fixed the incompatibility with Setuptools in distutils +- Issue #7064: Fixed the incompatibility with Setuptools in distutils when running the build_ext command. - Issue #7052: Removed nonexisting NullHandler from logging.__all__. @@ -127,7 +130,7 @@ Library ------- -- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. @@ -177,7 +180,7 @@ - Issue #1424152: Fix for httplib, urllib2 to support SSL while working through proxy. Original patch by Christopher Li, changes made by Senthil Kumaran. -- Issues #5155, 5313, 5331: multiprocessing.Process._bootstrap was +- Issues #5155, 5313, 5331: multiprocessing.Process._bootstrap was unconditionally calling "os.close(sys.stdin.fileno())" resulting in file descriptor errors @@ -277,7 +280,7 @@ - Issue #2622: Fixed an ImportError when importing email.messsage from a standalone application built with py2exe or py2app. -- Issue #6455: Fixed test_build_ext under win32. +- Issue #6455: Fixed test_build_ext under win32. - Issue #6403: Fixed package path usage in build_ext. From nnorwitz at gmail.com Thu Oct 15 00:25:17 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 14 Oct 2009 18:25:17 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091014222517.GA25143@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 Less important issues: ---------------------- test_asynchat leaked [0, 0, 131] references, sum=131 test_docxmlrpc leaked [-1, 1, 0] references, sum=0 test_file2k leaked [-84, 0, 0] references, sum=-84 test_smtplib leaked [179, -267, 0] references, sum=-88 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Thu Oct 15 00:44:45 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 14 Oct 2009 18:44:45 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091014224445.GA32181@python.psfb.org> 339 tests OK. 1 test failed: test_ssl 6 tests altered the execution environment: test_descr test_distutils test_httpservers test_re test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-25151 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr Warning -- sys.stdout was modified by test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re Warning -- sys.path was modified by test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 339 tests OK. 1 test failed: test_ssl 6 tests altered the execution environment: test_descr test_distutils test_httpservers test_re test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [797754 refs] From python-checkins at python.org Thu Oct 15 03:35:57 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 01:35:57 -0000 Subject: [Python-checkins] r75427 - sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 03:35:57 2009 New Revision: 75427 Log: force floor division Modified: sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Modified: sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py (original) +++ sandbox/trunk/2to3/lib2to3/pgen2/tokenize.py Thu Oct 15 03:35:57 2009 @@ -384,7 +384,7 @@ column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 - elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize + elif line[pos] == '\t': column = (column//tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 From python-checkins at python.org Thu Oct 15 03:39:21 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 01:39:21 -0000 Subject: [Python-checkins] r75428 - in sandbox/trunk/2to3/lib2to3: pgen2/pgen.py pytree.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 03:39:21 2009 New Revision: 75428 Log: silence -3 warnings about __hash__ Modified: sandbox/trunk/2to3/lib2to3/pgen2/pgen.py sandbox/trunk/2to3/lib2to3/pytree.py Modified: sandbox/trunk/2to3/lib2to3/pgen2/pgen.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/pgen2/pgen.py (original) +++ sandbox/trunk/2to3/lib2to3/pgen2/pgen.py Thu Oct 15 03:39:21 2009 @@ -379,6 +379,8 @@ return False return True + __hash__ = None # For Py3 compatibility. + def generate_grammar(filename="Grammar.txt"): p = ParserGenerator(filename) return p.make_grammar() Modified: sandbox/trunk/2to3/lib2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/pytree.py (original) +++ sandbox/trunk/2to3/lib2to3/pytree.py Thu Oct 15 03:39:21 2009 @@ -63,6 +63,8 @@ return NotImplemented return self._eq(other) + __hash__ = None # For Py3 compatibility. + def __ne__(self, other): """ Compare two nodes for inequality. From python-checkins at python.org Thu Oct 15 03:47:28 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 01:47:28 -0000 Subject: [Python-checkins] r75429 - python/trunk/Lib/tokenize.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 03:47:28 2009 New Revision: 75429 Log: pep8ify if blocks Modified: python/trunk/Lib/tokenize.py Modified: python/trunk/Lib/tokenize.py ============================================================================== --- python/trunk/Lib/tokenize.py (original) +++ python/trunk/Lib/tokenize.py Thu Oct 15 03:47:28 2009 @@ -316,12 +316,17 @@ if not line: break column = 0 while pos < max: # measure leading whitespace - if line[pos] == ' ': column = column + 1 - elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize - elif line[pos] == '\f': column = 0 - else: break + if line[pos] == ' ': + column = column + 1 + elif line[pos] == '\t': + column = (column/tabsize + 1)*tabsize + elif line[pos] == '\f': + column = 0 + else: + break pos = pos + 1 - if pos == max: break + if pos == max: + break if line[pos] in '#\r\n': # skip comments or blank lines if line[pos] == '#': @@ -397,8 +402,10 @@ elif initial == '\\': # continued stmt continued = 1 else: - if initial in '([{': parenlev = parenlev + 1 - elif initial in ')]}': parenlev = parenlev - 1 + if initial in '([{': + parenlev = parenlev + 1 + elif initial in ')]}': + parenlev = parenlev - 1 yield (OP, token, spos, epos, line) else: yield (ERRORTOKEN, line[pos], @@ -411,5 +418,7 @@ if __name__ == '__main__': # testing import sys - if len(sys.argv) > 1: tokenize(open(sys.argv[1]).readline) - else: tokenize(sys.stdin.readline) + if len(sys.argv) > 1: + tokenize(open(sys.argv[1]).readline) + else: + tokenize(sys.stdin.readline) From python-checkins at python.org Thu Oct 15 03:49:38 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 01:49:38 -0000 Subject: [Python-checkins] r75430 - in python/trunk/Lib: test/test_tokenize.py tokenize.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 03:49:37 2009 New Revision: 75430 Log: use floor division and add a test that exercises the tabsize codepath Modified: python/trunk/Lib/test/test_tokenize.py python/trunk/Lib/tokenize.py Modified: python/trunk/Lib/test/test_tokenize.py ============================================================================== --- python/trunk/Lib/test/test_tokenize.py (original) +++ python/trunk/Lib/test/test_tokenize.py Thu Oct 15 03:49:37 2009 @@ -508,6 +508,23 @@ ... break ... else: True True + +Evil tabs + >>> dump_tokens("def f():\\n\\tif x\\n \tpass") + NAME 'def' (1, 0) (1, 3) + NAME 'f' (1, 4) (1, 5) + OP '(' (1, 5) (1, 6) + OP ')' (1, 6) (1, 7) + OP ':' (1, 7) (1, 8) + NEWLINE '\\n' (1, 8) (1, 9) + INDENT '\\t' (2, 0) (2, 1) + NAME 'if' (2, 1) (2, 3) + NAME 'x' (2, 4) (2, 5) + NEWLINE '\\n' (2, 5) (2, 6) + INDENT ' ' (3, 0) (3, 9) + NAME 'pass' (3, 9) (3, 13) + DEDENT '' (4, 0) (4, 0) + DEDENT '' (4, 0) (4, 0) """ Modified: python/trunk/Lib/tokenize.py ============================================================================== --- python/trunk/Lib/tokenize.py (original) +++ python/trunk/Lib/tokenize.py Thu Oct 15 03:49:37 2009 @@ -319,7 +319,7 @@ if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': - column = (column/tabsize + 1)*tabsize + column = (column//tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: From python-checkins at python.org Thu Oct 15 03:56:25 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 01:56:25 -0000 Subject: [Python-checkins] r75431 - python/trunk/Lib/test/test_tokenize.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 03:56:25 2009 New Revision: 75431 Log: change test to what I intended Modified: python/trunk/Lib/test/test_tokenize.py Modified: python/trunk/Lib/test/test_tokenize.py ============================================================================== --- python/trunk/Lib/test/test_tokenize.py (original) +++ python/trunk/Lib/test/test_tokenize.py Thu Oct 15 03:56:25 2009 @@ -510,7 +510,7 @@ True Evil tabs - >>> dump_tokens("def f():\\n\\tif x\\n \tpass") + >>> dump_tokens("def f():\\n\\tif x\\n \\tpass") NAME 'def' (1, 0) (1, 3) NAME 'f' (1, 4) (1, 5) OP '(' (1, 5) (1, 6) @@ -521,7 +521,7 @@ NAME 'if' (2, 1) (2, 3) NAME 'x' (2, 4) (2, 5) NEWLINE '\\n' (2, 5) (2, 6) - INDENT ' ' (3, 0) (3, 9) + INDENT ' \\t' (3, 0) (3, 9) NAME 'pass' (3, 9) (3, 13) DEDENT '' (4, 0) (4, 0) DEDENT '' (4, 0) (4, 0) From python-checkins at python.org Thu Oct 15 05:05:40 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 03:05:40 -0000 Subject: [Python-checkins] r75432 - python/trunk/Lib/tokenize.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 05:05:39 2009 New Revision: 75432 Log: some cleanups Modified: python/trunk/Lib/tokenize.py Modified: python/trunk/Lib/tokenize.py ============================================================================== --- python/trunk/Lib/tokenize.py (original) +++ python/trunk/Lib/tokenize.py Thu Oct 15 05:05:39 2009 @@ -23,15 +23,15 @@ each time a new token is found.""" __author__ = 'Ka-Ping Yee ' -__credits__ = \ - 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, Raymond Hettinger' +__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, ' + 'Skip Montanaro, Raymond Hettinger') import string, re from token import * import token -__all__ = [x for x in dir(token) if x[0] != '_'] + ["COMMENT", "tokenize", - "generate_tokens", "NL", "untokenize"] +__all__ = [x for x in dir(token) if not x.startswith("_")] +__all__ += ["COMMENT", "tokenize", "generate_tokens", "NL", "untokenize"] del x del token @@ -288,7 +288,7 @@ line = readline() except StopIteration: line = '' - lnum = lnum + 1 + lnum += 1 pos, max = 0, len(line) if contstr: # continued string @@ -317,14 +317,14 @@ column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': - column = column + 1 + column += 1 elif line[pos] == '\t': column = (column//tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break - pos = pos + 1 + pos += 1 if pos == max: break @@ -403,14 +403,14 @@ continued = 1 else: if initial in '([{': - parenlev = parenlev + 1 + parenlev += 1 elif initial in ')]}': - parenlev = parenlev - 1 + parenlev -= 1 yield (OP, token, spos, epos, line) else: yield (ERRORTOKEN, line[pos], (lnum, pos), (lnum, pos+1), line) - pos = pos + 1 + pos += 1 for indent in indents[1:]: # pop remaining indent levels yield (DEDENT, '', (lnum, 0), (lnum, 0), '') From python-checkins at python.org Thu Oct 15 05:06:55 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 03:06:55 -0000 Subject: [Python-checkins] r75433 - in python/trunk: Lib/inspect.py Lib/test/test_inspect.py Misc/NEWS Message-ID: Author: benjamin.peterson Date: Thu Oct 15 05:06:55 2009 New Revision: 75433 Log: make inspect.isabstract() always return a boolean; add a test for it, too #7069 Modified: python/trunk/Lib/inspect.py python/trunk/Lib/test/test_inspect.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/inspect.py ============================================================================== --- python/trunk/Lib/inspect.py (original) +++ python/trunk/Lib/inspect.py Thu Oct 15 05:06:55 2009 @@ -242,7 +242,7 @@ def isabstract(object): """Return true if the object is an abstract base class (ABC).""" - return isinstance(object, type) and object.__flags__ & TPFLAGS_IS_ABSTRACT + return bool(isinstance(object, type) and object.__flags__ & TPFLAGS_IS_ABSTRACT) def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Modified: python/trunk/Lib/test/test_inspect.py ============================================================================== --- python/trunk/Lib/test/test_inspect.py (original) +++ python/trunk/Lib/test/test_inspect.py Thu Oct 15 05:06:55 2009 @@ -115,6 +115,29 @@ self.assertTrue('a' in members) self.assertTrue('b' not in members) + def test_isabstract(self): + from abc import ABCMeta, abstractmethod + + class AbstractClassExample(object): + __metaclass__ = ABCMeta + + @abstractmethod + def foo(self): + pass + + class ClassExample(AbstractClassExample): + def foo(self): + pass + + a = ClassExample() + + # Test general behaviour. + self.assertTrue(inspect.isabstract(AbstractClassExample)) + self.assertFalse(inspect.isabstract(ClassExample)) + self.assertFalse(inspect.isabstract(a)) + self.assertFalse(inspect.isabstract(int)) + self.assertFalse(inspect.isabstract(5)) + class TestInterpreterStack(IsTestBase): def __init__(self, *args, **kwargs): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 15 05:06:55 2009 @@ -405,6 +405,8 @@ Library ------- +- Issue #7069: Make inspect.isabstract() return a boolean. + - Add support to the `ihooks` module for relative imports. - Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment From nnorwitz at gmail.com Thu Oct 15 11:42:41 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 15 Oct 2009 05:42:41 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091015094241.GA10636@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 Less important issues: ---------------------- test_smtplib leaked [88, -88, 96] references, sum=96 test_socketserver leaked [0, 69, -69] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Thu Oct 15 12:02:37 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 15 Oct 2009 06:02:37 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091015100237.GA17708@python.psfb.org> 339 tests OK. 1 test failed: test_ssl 6 tests altered the execution environment: test_descr test_distutils test_httpservers test_re test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-10646 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr Warning -- sys.stdout was modified by test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re Warning -- sys.path was modified by test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 339 tests OK. 1 test failed: test_ssl 6 tests altered the execution environment: test_descr test_distutils test_httpservers test_re test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [797910 refs] From ncoghlan at gmail.com Thu Oct 15 13:50:32 2009 From: ncoghlan at gmail.com (Nick Coghlan) Date: Thu, 15 Oct 2009 21:50:32 +1000 Subject: [Python-checkins] r75400 - in python/trunk: Lib/test/regrtest.py Misc/NEWS In-Reply-To: <4ad5d8f8.0c67f10a.42b0.ffffa23cSMTPIN_ADDED@mx.google.com> References: <4ad5d8f8.0c67f10a.42b0.ffffa23cSMTPIN_ADDED@mx.google.com> Message-ID: <4AD70C88.1050206@gmail.com> r.david.murray wrote: > + # To add things to save and restore, add a name XXX to the resources list > + # and add corresponding get_XXX/restore_XXX functions. get_XXX should > + # return the value to be saved and compared against a second call to the > + # get function when test execution completes. restore_XXX should accept > + # the saved value and restore the resource using it. It will be called if > + # and only if a change in the value is detected. XXX will have any '_' > + # replaced with '.' characters and will then be used in the error messages > + # as the name of the resource that changed. To allow this decorator to be used with resources that have an actual "_" in their name, it may be better to do the lossy transformation the other way around (i.e. use "." in the resource names, but then replace it when looking up the corresponding method names). An iterator that centralises the method lookups would also be nice. > + > + resources = ('sys_argv', 'cwd', 'sys_stdin', 'sys_stdout', 'sys_stderr', > + 'os_environ', 'sys_path') resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', 'os.environ', 'sys.path') def resource_info(self): for name in self.resources: safe_name = name.replace(".", "_") get_name = 'get_'+safe_name restore_name = 'restore_'+safe_name yield name, getattr(self, get_name), getattr(self, restore_name) > + def __enter__(self): > + self.saved_values = dict((name, getattr(self, 'get_'+name)()) > + for name in self.resources) > + return self def __enter__(self): self.saved_values = dict((name, get()) for name, get, restore in self.resource_info()) return self > + def __exit__(self, exc_type, exc_val, exc_tb): > + for name in self.resources: > + if not getattr(self, 'get_'+name)() == self.saved_values[name]: > + self.changed = True > + getattr(self, 'restore_'+name)(self.saved_values[name]) > + if not self.quiet: > + print >>sys.stderr, ("Warning -- {} was modified " > + "by {}").format(name.replace('_', '.'), self.testname) > + return False def __exit__(self, exc_type, exc_val, exc_tb): for name, get, restore in self.resources: if get() != self.saved_values[name]: self.changed = True restore(self.saved_values[name]) if not self.quiet: print >>sys.stderr, ("Warning -- {} was modified " "by {}").format(name, self.testname) return False Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- From python-checkins at python.org Thu Oct 15 17:18:56 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 15:18:56 -0000 Subject: [Python-checkins] r75434 - python/trunk/Objects/bytearrayobject.c Message-ID: Author: mark.dickinson Date: Thu Oct 15 17:18:55 2009 New Revision: 75434 Log: Fix missing semicolon Modified: python/trunk/Objects/bytearrayobject.c Modified: python/trunk/Objects/bytearrayobject.c ============================================================================== --- python/trunk/Objects/bytearrayobject.c (original) +++ python/trunk/Objects/bytearrayobject.c Thu Oct 15 17:18:55 2009 @@ -3120,7 +3120,7 @@ latin1 = PyUnicode_DecodeLatin1(self->ob_bytes, Py_SIZE(self), NULL); #else - latin1 = PyString_FromStringAndSize(self->ob_bytes, Py_SIZE(self)) + latin1 = PyString_FromStringAndSize(self->ob_bytes, Py_SIZE(self)); #endif else #ifdef Py_USING_UNICODE From python-checkins at python.org Thu Oct 15 17:22:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 15:22:09 -0000 Subject: [Python-checkins] r75435 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Thu Oct 15 17:22:09 2009 New Revision: 75435 Log: Blocked revisions 75434 via svnmerge ........ r75434 | mark.dickinson | 2009-10-15 16:18:55 +0100 (Thu, 15 Oct 2009) | 1 line Fix missing semicolon ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Thu Oct 15 17:39:16 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 15:39:16 -0000 Subject: [Python-checkins] r75436 - python/trunk/Lib/test/test_re.py Message-ID: Author: benjamin.peterson Date: Thu Oct 15 17:39:15 2009 New Revision: 75436 Log: don't need to mess up sys.path Modified: python/trunk/Lib/test/test_re.py Modified: python/trunk/Lib/test/test_re.py ============================================================================== --- python/trunk/Lib/test/test_re.py (original) +++ python/trunk/Lib/test/test_re.py Thu Oct 15 17:39:15 2009 @@ -1,6 +1,3 @@ -import sys -sys.path = ['.'] + sys.path - from test.test_support import verbose, run_unittest import re from re import Scanner From python-checkins at python.org Thu Oct 15 17:44:46 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 15 Oct 2009 15:44:46 -0000 Subject: [Python-checkins] r75437 - in python/trunk: Lib/test/test_module.py Misc/NEWS Objects/moduleobject.c Message-ID: Author: benjamin.peterson Date: Thu Oct 15 17:44:46 2009 New Revision: 75437 Log: only clear a module's __dict__ if the module is the only one with a reference to it #7140 Modified: python/trunk/Lib/test/test_module.py python/trunk/Misc/NEWS python/trunk/Objects/moduleobject.c Modified: python/trunk/Lib/test/test_module.py ============================================================================== --- python/trunk/Lib/test/test_module.py (original) +++ python/trunk/Lib/test/test_module.py Thu Oct 15 17:44:46 2009 @@ -55,6 +55,14 @@ {"__name__": "foo", "__doc__": "foodoc", "bar": 42}) self.assertTrue(foo.__dict__ is d) + def test_dont_clear_dict(self): + # See issue 7140. + def f(): + foo = ModuleType("foo") + foo.bar = 4 + return foo + self.assertEqual(f().__dict__["bar"], 4) + def test_main(): run_unittest(ModuleTests) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 15 17:44:46 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7140: The __dict__ of a module should not be cleared unless the module + is the only object holding a reference to it. + - Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. Modified: python/trunk/Objects/moduleobject.c ============================================================================== --- python/trunk/Objects/moduleobject.c (original) +++ python/trunk/Objects/moduleobject.c Thu Oct 15 17:44:46 2009 @@ -175,7 +175,10 @@ { PyObject_GC_UnTrack(m); if (m->md_dict != NULL) { - _PyModule_Clear((PyObject *)m); + /* If we are the only ones holding a reference, we can clear + the dictionary. */ + if (Py_REFCNT(m->md_dict) == 1) + _PyModule_Clear((PyObject *)m); Py_DECREF(m->md_dict); } Py_TYPE(m)->tp_free((PyObject *)m); From python-checkins at python.org Thu Oct 15 17:53:59 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 15:53:59 -0000 Subject: [Python-checkins] r75438 - in python/trunk: Lib/test/test_memoryview.py Objects/memoryobject.c Message-ID: Author: mark.dickinson Date: Thu Oct 15 17:53:58 2009 New Revision: 75438 Log: Issue #7142: Fix uses of unicode in memoryview objects Modified: python/trunk/Lib/test/test_memoryview.py python/trunk/Objects/memoryobject.c Modified: python/trunk/Lib/test/test_memoryview.py ============================================================================== --- python/trunk/Lib/test/test_memoryview.py (original) +++ python/trunk/Lib/test/test_memoryview.py Thu Oct 15 17:53:58 2009 @@ -54,6 +54,12 @@ m = self._view(b) self.assertEqual(list(m), [m[i] for i in range(len(m))]) + def test_repr(self): + for tp in self._types: + b = tp(self._source) + m = self._view(b) + self.assertIsInstance(m.__repr__(), str) + def test_setitem_readonly(self): if not self.ro_type: return @@ -156,6 +162,7 @@ def check_attributes_with_type(self, tp): m = self._view(tp(self._source)) self.assertEquals(m.format, self.format) + self.assertIsInstance(m.format, str) self.assertEquals(m.itemsize, self.itemsize) self.assertEquals(m.ndim, 1) self.assertEquals(m.shape, (6,)) Modified: python/trunk/Objects/memoryobject.c ============================================================================== --- python/trunk/Objects/memoryobject.c (original) +++ python/trunk/Objects/memoryobject.c Thu Oct 15 17:53:58 2009 @@ -335,7 +335,7 @@ static PyObject * memory_format_get(PyMemoryViewObject *self) { - return PyUnicode_FromString(self->view.format); + return PyString_FromString(self->view.format); } static PyObject * @@ -503,7 +503,7 @@ static PyObject * memory_repr(PyMemoryViewObject *self) { - return PyUnicode_FromFormat("", self); + return PyString_FromFormat("", self); } /* Sequence methods */ From python-checkins at python.org Thu Oct 15 17:54:39 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 15:54:39 -0000 Subject: [Python-checkins] r75439 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Thu Oct 15 17:54:39 2009 New Revision: 75439 Log: Blocked revisions 75438 via svnmerge ........ r75438 | mark.dickinson | 2009-10-15 16:53:58 +0100 (Thu, 15 Oct 2009) | 1 line Issue #7142: Fix uses of unicode in memoryview objects ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Thu Oct 15 19:45:39 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 17:45:39 -0000 Subject: [Python-checkins] r75440 - in python/trunk/Python: compile.c formatter_string.c Message-ID: Author: mark.dickinson Date: Thu Oct 15 19:45:39 2009 New Revision: 75440 Log: Allow core Python build to succeed under WITHOUT_COMPLEX. The module build stage still fails. Modified: python/trunk/Python/compile.c python/trunk/Python/formatter_string.c Modified: python/trunk/Python/compile.c ============================================================================== --- python/trunk/Python/compile.c (original) +++ python/trunk/Python/compile.c Thu Oct 15 19:45:39 2009 @@ -910,10 +910,8 @@ { PyObject *t, *v; Py_ssize_t arg; - unsigned char *p, *q; - Py_complex z; + unsigned char *p; double d; - int real_part_zero, imag_part_zero; /* necessary to make sure types aren't coerced (e.g., int and long) */ /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ @@ -928,7 +926,11 @@ else t = PyTuple_Pack(2, o, o->ob_type); } +#ifndef WITHOUT_COMPLEX else if (PyComplex_Check(o)) { + Py_complex z; + int real_part_zero, imag_part_zero; + unsigned char *q; /* complex case is even messier: we need to make complex(x, 0.) different from complex(x, -0.) and complex(0., y) different from complex(-0., y), for any x and y. In @@ -958,6 +960,7 @@ t = PyTuple_Pack(2, o, o->ob_type); } } +#endif /* WITHOUT_COMPLEX */ else { t = PyTuple_Pack(2, o, o->ob_type); } Modified: python/trunk/Python/formatter_string.c ============================================================================== --- python/trunk/Python/formatter_string.c (original) +++ python/trunk/Python/formatter_string.c Thu Oct 15 19:45:39 2009 @@ -1,7 +1,7 @@ /***********************************************************************/ /* Implements the string (as opposed to unicode) version of the built-in formatters for string, int, float. That is, the versions - of int.__float__, etc., that take and return string objects */ + of int.__format__, etc., that take and return string objects */ #include "Python.h" #include "../Objects/stringlib/stringdefs.h" @@ -10,6 +10,8 @@ #define FORMAT_LONG _PyLong_FormatAdvanced #define FORMAT_INT _PyInt_FormatAdvanced #define FORMAT_FLOAT _PyFloat_FormatAdvanced +#ifndef WITHOUT_COMPLEX #define FORMAT_COMPLEX _PyComplex_FormatAdvanced +#endif #include "../Objects/stringlib/formatter.h" From python-checkins at python.org Thu Oct 15 21:55:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 15 Oct 2009 19:55:18 -0000 Subject: [Python-checkins] r75441 - in python/branches/py3k: Python/compile.c Python/formatter_unicode.c Message-ID: Author: mark.dickinson Date: Thu Oct 15 21:55:18 2009 New Revision: 75441 Log: Merged revisions 75440 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75440 | mark.dickinson | 2009-10-15 18:45:39 +0100 (Thu, 15 Oct 2009) | 1 line Allow core Python build to succeed under WITHOUT_COMPLEX. The module build stage still fails. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Python/compile.c python/branches/py3k/Python/formatter_unicode.c Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Thu Oct 15 21:55:18 2009 @@ -895,10 +895,8 @@ { PyObject *t, *v; Py_ssize_t arg; - unsigned char *p, *q; - Py_complex z; + unsigned char *p; double d; - int real_part_zero, imag_part_zero; /* necessary to make sure types aren't coerced (e.g., int and long) */ /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ @@ -913,7 +911,11 @@ else t = PyTuple_Pack(2, o, o->ob_type); } +#ifndef WITHOUT_COMPLEX else if (PyComplex_Check(o)) { + Py_complex z; + int real_part_zero, imag_part_zero; + unsigned char *q; /* complex case is even messier: we need to make complex(x, 0.) different from complex(x, -0.) and complex(0., y) different from complex(-0., y), for any x and y. In @@ -943,6 +945,7 @@ t = PyTuple_Pack(2, o, o->ob_type); } } +#endif /* WITHOUT_COMPLEX */ else { t = PyTuple_Pack(2, o, o->ob_type); } Modified: python/branches/py3k/Python/formatter_unicode.c ============================================================================== --- python/branches/py3k/Python/formatter_unicode.c (original) +++ python/branches/py3k/Python/formatter_unicode.c Thu Oct 15 21:55:18 2009 @@ -9,6 +9,8 @@ #define FORMAT_STRING _PyUnicode_FormatAdvanced #define FORMAT_LONG _PyLong_FormatAdvanced #define FORMAT_FLOAT _PyFloat_FormatAdvanced +#ifndef WITHOUT_COMPLEX #define FORMAT_COMPLEX _PyComplex_FormatAdvanced +#endif #include "../Objects/stringlib/formatter.h" From nnorwitz at gmail.com Thu Oct 15 23:57:05 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 15 Oct 2009 17:57:05 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091015215705.GA1282@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [-280, 0, 0] references, sum=-280 Less important issues: ---------------------- test_smtplib leaked [188, -188, -88] references, sum=-88 test_threadedtempfile leaked [-104, 0, 0] references, sum=-104 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Fri Oct 16 00:06:01 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 15 Oct 2009 22:06:01 -0000 Subject: [Python-checkins] r75442 - in sandbox/trunk/ccbench: ccbench.py Message-ID: Author: antoine.pitrou Date: Fri Oct 16 00:06:01 2009 New Revision: 75442 Log: Draft of a concurrency benchmark Added: sandbox/trunk/ccbench/ sandbox/trunk/ccbench/ccbench.py (contents, props changed) Added: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- (empty file) +++ sandbox/trunk/ccbench/ccbench.py Fri Oct 16 00:06:01 2009 @@ -0,0 +1,215 @@ +# -*- coding: utf-8 -*- +# This file should be kept compatible with both Python 2.6 and Python >= 3.0. + +from __future__ import division +from __future__ import print_function + +""" +ccbench, a Python concurrency benchmark. +""" + +import time +import os +import sys +import functools +import itertools +import zlib +import threading +import subprocess +import copy +from optparse import OptionParser + +# Compatibility +try: + xrange +except NameError: + xrange = range + +try: + map = itertools.imap +except AttributeError: + pass + + +THROUGHPUT_DURATION = 2.0 + + +def task_pidigits(): + """Pi calculation (Python)""" + _map = map + _count = itertools.count + _islice = itertools.islice + + def calc_ndigits(n): + # From http://shootout.alioth.debian.org/ + def gen_x(): + return _map(lambda k: (k, 4*k + 2, 0, 2*k + 1), _count(1)) + + def compose(a, b): + aq, ar, as_, at = a + bq, br, bs, bt = b + return (aq * bq, + aq * br + ar * bt, + as_ * bq + at * bs, + as_ * br + at * bt) + + def extract(z, j): + q, r, s, t = z + return (q*j + r) // (s*j + t) + + def pi_digits(): + z = (1, 0, 0, 1) + x = gen_x() + while 1: + y = extract(z, 3) + while y != extract(z, 4): + z = compose(z, next(x)) + y = extract(z, 3) + z = compose((10, -10*y, 0, 1), z) + yield y + + return list(_islice(pi_digits(), n)) + + return calc_ndigits, (20, ) + +def task_compress(): + """zlib compression (C)""" + with open(__file__, "rb") as f: + arg = f.read(5000) * 3 + + def compress(s): + zlib.decompress(zlib.compress(s)) + return compress, (arg, ) + + +throughput_tasks = [task_pidigits, task_compress] + + +class TimedLoop: + def __init__(self, func, args): + self.func = func + self.args = args + + def __call__(self, start_time, min_duration, end_event, do_yield=True): + step = 100 + niters = 0 + duration = 0.0 + _time = time.time + _sleep = time.sleep + _func = self.func + _args = self.args + t1 = start_time + while True: + for i in range(step): + _func(*_args) + t2 = _time() + # If another thread terminated, the current measurement is invalid + # => return the previous one. + # (note: Event.is_set() is cheap) + if end_event.is_set(): + return niters, duration + niters += step + duration = t2 - start_time + if duration >= min_duration: + end_event.set() + return niters, duration + if t2 - t1 < 0.02: + # Minimize interference of measurement on overall runtime + step *= 2 + else: + if do_yield: + # OS scheduling of Python threads is sometimes so bad that we + # have to force thread switching ourselves, otherwise we get + # completely useless results. + _sleep(0.0001) + t1 = t2 + + +def run_throughput_test(func, args, nthreads): + assert nthreads >= 1 + + results = [] + loop = TimedLoop(func, args) + end_event = threading.Event() + + if nthreads == 1: + # Pure single-threaded performance, without any switching or + # synchronization overhead. + start_time = time.time() + results.append(loop(start_time, THROUGHPUT_DURATION, + end_event, do_yield=False)) + return results + + start_cond = threading.Condition() + ready = [] + + def run(): + ready.append(None) + with start_cond: + start_cond.wait() + results.append(loop(start_time, THROUGHPUT_DURATION, + end_event)) + + threads = [] + for i in range(nthreads): + threads.append(threading.Thread(target=run)) + for t in threads: + t.start() + # We don't want measurements to include thread startup overhead, + # so we arrange for timing to start after all threads are ready. + while len(ready) < nthreads: + time.sleep(0.1) + with start_cond: + start_time = time.time() + start_cond.notify(nthreads) + for t in threads: + t.join() + + return results + +def run_throughput_tests(max_threads=4): + for task in throughput_tasks: + print(task.__doc__) + print() + func, args = task() + nthreads = 1 + baseline_speed = None + while nthreads <= max_threads: + results = run_throughput_test(func, args, nthreads) + # The max duration is assumed to be more representative of + # the total duration than the average would, especially with + # imperfect scheduling. + speed = sum(r[0] for r in results) / max(r[1] for r in results) + print("threads=%d: %d" % (nthreads, speed), end="") + if baseline_speed is None: + print(" iterations/s.") + baseline_speed = speed + else: + print(" ( %d %%)" % (speed / baseline_speed * 100)) + nthreads += 1 + print() + + +def main(): + usage = "usage: %prog [-h|--help] [options]" + parser = OptionParser(usage=usage) + parser.add_option("-t", "--throughput", + action="store_true", dest="throughput", default=False, + help="run throughput tests") + parser.add_option("-l", "--latency", + action="store_true", dest="latency", default=False, + help="run latency tests") + options, args = parser.parse_args() + if args: + parser.error("unexpected arguments") + + if not options.throughput and not options.latency: + options.throughput = options.latency = True + + if options.throughput: + print("--- Throughput ---") + print() + run_throughput_tests() + +if __name__ == "__main__": + main() From nnorwitz at gmail.com Fri Oct 16 00:16:38 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 15 Oct 2009 18:16:38 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091015221638.GA8366@python.psfb.org> 340 tests OK. 1 test failed: test_ssl 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-1291 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr Warning -- sys.stdout was modified by test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 340 tests OK. 1 test failed: test_ssl 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [894690 refs] From python-checkins at python.org Fri Oct 16 00:20:19 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 15 Oct 2009 22:20:19 -0000 Subject: [Python-checkins] r75443 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Fri Oct 16 00:20:18 2009 New Revision: 75443 Log: Tweak params a bit Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Fri Oct 16 00:20:18 2009 @@ -78,7 +78,7 @@ arg = f.read(5000) * 3 def compress(s): - zlib.decompress(zlib.compress(s)) + zlib.decompress(zlib.compress(s, 5)) return compress, (arg, ) @@ -91,7 +91,7 @@ self.args = args def __call__(self, start_time, min_duration, end_event, do_yield=True): - step = 100 + step = 20 niters = 0 duration = 0.0 _time = time.time @@ -113,9 +113,9 @@ if duration >= min_duration: end_event.set() return niters, duration - if t2 - t1 < 0.02: + if t2 - t1 < 0.01: # Minimize interference of measurement on overall runtime - step *= 2 + step = step * 3 // 2 else: if do_yield: # OS scheduling of Python threads is sometimes so bad that we @@ -128,6 +128,9 @@ def run_throughput_test(func, args, nthreads): assert nthreads >= 1 + # Warm up + func(*args) + results = [] loop = TimedLoop(func, args) end_event = threading.Event() @@ -176,9 +179,8 @@ baseline_speed = None while nthreads <= max_threads: results = run_throughput_test(func, args, nthreads) - # The max duration is assumed to be more representative of - # the total duration than the average would, especially with - # imperfect scheduling. + # Taking the max duration rather than average gives pessimistic + # results rather than optimistic. speed = sum(r[0] for r in results) / max(r[1] for r in results) print("threads=%d: %d" % (nthreads, speed), end="") if baseline_speed is None: From python-checkins at python.org Fri Oct 16 00:58:21 2009 From: python-checkins at python.org (antoine.pitrou) Date: Thu, 15 Oct 2009 22:58:21 -0000 Subject: [Python-checkins] r75444 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Fri Oct 16 00:58:21 2009 New Revision: 75444 Log: Various improvements Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Fri Oct 16 00:58:21 2009 @@ -13,10 +13,8 @@ import sys import functools import itertools -import zlib import threading import subprocess -import copy from optparse import OptionParser # Compatibility @@ -72,8 +70,9 @@ return calc_ndigits, (20, ) -def task_compress(): +def task_compress_zlib(): """zlib compression (C)""" + import zlib with open(__file__, "rb") as f: arg = f.read(5000) * 3 @@ -81,8 +80,40 @@ zlib.decompress(zlib.compress(s, 5)) return compress, (arg, ) +def task_compress_bz2(): + """bz2 compression (C)""" + import bz2 + with open(__file__, "rb") as f: + arg = f.read(3000) * 2 + + return bz2.compress, (arg, ) + +def task_hashing(): + """sha1 hashing (C)""" + import hashlib + with open(__file__, "rb") as f: + arg = f.read(5000) * 30 -throughput_tasks = [task_pidigits, task_compress] + def compute(s): + hashlib.sha1(s).digest() + return compute, (arg, ) + + +throughput_tasks = [task_pidigits] +# For whatever reasons, zlib gives irregular results, so we prefer bz2 or +# hashlib if available. +# (note: hashlib releases the GIL from 2.7 and 3.1 onwards) +try: + import bz2 +except ImportError: + try: + import hashlib + except ImportError: + throughput_tasks.append(task_compress_zlib) + else: + throughput_tasks.append(task_hashing) +else: + throughput_tasks.append(task_compress_bz2) class TimedLoop: @@ -105,13 +136,12 @@ t2 = _time() # If another thread terminated, the current measurement is invalid # => return the previous one. - # (note: Event.is_set() is cheap) - if end_event.is_set(): + if end_event: return niters, duration niters += step duration = t2 - start_time if duration >= min_duration: - end_event.set() + end_event.append(None) return niters, duration if t2 - t1 < 0.01: # Minimize interference of measurement on overall runtime @@ -133,7 +163,7 @@ results = [] loop = TimedLoop(func, args) - end_event = threading.Event() + end_event = [] if nthreads == 1: # Pure single-threaded performance, without any switching or @@ -201,12 +231,17 @@ parser.add_option("-l", "--latency", action="store_true", dest="latency", default=False, help="run latency tests") + parser.add_option("-i", "--interval", + action="store", type="int", dest="interval", default=None, + help="sys.setcheckinterval() value") options, args = parser.parse_args() if args: parser.error("unexpected arguments") if not options.throughput and not options.latency: options.throughput = options.latency = True + if options.interval: + sys.setcheckinterval(options.interval) if options.throughput: print("--- Throughput ---") From nnorwitz at gmail.com Fri Oct 16 11:43:43 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 16 Oct 2009 05:43:43 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091016094343.GA1299@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 Less important issues: ---------------------- test_smtplib leaked [0, 84, 4] references, sum=88 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Fri Oct 16 12:07:08 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 16 Oct 2009 06:07:08 -0400 Subject: [Python-checkins] Python Regression Test Failures all (5) Message-ID: <20091016100708.GA8619@python.psfb.org> 336 tests OK. 5 tests failed: test_timeout test_ssl test_urllib2net test_smtpnet test_urllibnet 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-1309 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr Warning -- sys.stdout was modified by test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test test_smtpnet failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_smtpnet.py", line 15, in test_connect server = smtplib.SMTP_SSL(self.testServer, self.remotePort) File "/tmp/python-test/local/lib/python2.7/smtplib.py", line 752, in __init__ SMTP.__init__(self, host, port, local_hostname, timeout) File "/tmp/python-test/local/lib/python2.7/smtplib.py", line 239, in __init__ (code, msg) = self.connect(host, port) File "/tmp/python-test/local/lib/python2.7/smtplib.py", line 295, in connect self.sock = self._get_socket(host, port, self.timeout) File "/tmp/python-test/local/lib/python2.7/smtplib.py", line 757, in _get_socket new_socket = socket.create_connection((host, port), timeout) File "/tmp/python-test/local/lib/python2.7/socket.py", line 547, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno -3] Temporary failure in name resolution test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- errors occurred; run in verbose mode for details test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test test_timeout failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_timeout.py", line 133, in testRecvTimeout self.sock.connect(self.addr_remote) File "/tmp/python-test/local/lib/python2.7/socket.py", line 221, in meth return getattr(self._sock,name)(*args) error: [Errno 113] No route to host test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test test_urllib2net failed -- errors occurred; run in verbose mode for details test_urllibnet test test_urllibnet failed -- errors occurred; run in verbose mode for details test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 336 tests OK. 5 tests failed: test_timeout test_ssl test_urllib2net test_smtpnet test_urllibnet 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [894691 refs] From python-checkins at python.org Fri Oct 16 16:06:44 2009 From: python-checkins at python.org (vinay.sajip) Date: Fri, 16 Oct 2009 14:06:44 -0000 Subject: [Python-checkins] r75445 - in python: branches/py3k/Lib/logging/__init__.py branches/py3k/Misc/NEWS trunk/Lib/logging/__init__.py trunk/Misc/NEWS Message-ID: Author: vinay.sajip Date: Fri Oct 16 16:06:44 2009 New Revision: 75445 Log: Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. Modified: python/branches/py3k/Lib/logging/__init__.py python/branches/py3k/Misc/NEWS python/trunk/Lib/logging/__init__.py python/trunk/Misc/NEWS Modified: python/branches/py3k/Lib/logging/__init__.py ============================================================================== --- python/branches/py3k/Lib/logging/__init__.py (original) +++ python/branches/py3k/Lib/logging/__init__.py Fri Oct 16 16:06:44 2009 @@ -284,12 +284,10 @@ self.threadName = None if not logMultiprocessing: self.processName = None + elif 'multiprocessing' not in sys.modules: + self.processName = 'MainProcess' else: - try: - from multiprocessing import current_process - self.processName = current_process().name - except ImportError: - self.processName = None + self.processName = sys.modules['multiprocessing'].current_process().name if logProcesses and hasattr(os, 'getpid'): self.process = os.getpid() else: Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Fri Oct 16 16:06:44 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7120: logging: Removed import of multiprocessing which is causing + crash in GAE. + - Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. @@ -94,11 +97,11 @@ Library ------- -- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #7086: Added TCP support to SysLogHandler, and tidied up some anachronisms in the code which were a relic of 1.5.2 compatibility. - + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. @@ -1116,7 +1119,7 @@ Library ------- -- Issue #6516: Added owner/group support when creating tar archives in +- Issue #6516: Added owner/group support when creating tar archives in Distutils. - Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils. Modified: python/trunk/Lib/logging/__init__.py ============================================================================== --- python/trunk/Lib/logging/__init__.py (original) +++ python/trunk/Lib/logging/__init__.py Fri Oct 16 16:06:44 2009 @@ -287,12 +287,10 @@ self.threadName = None if not logMultiprocessing: self.processName = None + elif 'multiprocessing' not in sys.modules: + self.processName = 'MainProcess' else: - try: - from multiprocessing import current_process - self.processName = current_process().name - except ImportError: - self.processName = None + self.processName = sys.modules['multiprocessing'].current_process().name if logProcesses and hasattr(os, 'getpid'): self.process = os.getpid() else: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Oct 16 16:06:44 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7120: logging: Removed import of multiprocessing which is causing + crash in GAE. + - Issue #7140: The __dict__ of a module should not be cleared unless the module is the only object holding a reference to it. @@ -412,18 +415,18 @@ - Add support to the `ihooks` module for relative imports. -- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment +- Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #7086: Added TCP support to SysLogHandler, and tidied up some anachronisms in the code which were a relic of 1.5.2 compatibility. - + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. -- Issue #6516: Added owner/group support when creating tar archives in +- Issue #6516: Added owner/group support when creating tar archives in Distutils. - Issue #7031: Add TestCase.assert(Not)IsInstance() methods. @@ -1292,11 +1295,11 @@ Build ----- -- Add 2 new options to ``--with-universal-archs`` on MacOSX: +- Add 2 new options to ``--with-universal-archs`` on MacOSX: ``intel`` builds a distribution with ``i386`` and ``x86_64`` architectures, - while ``3-way`` builds a distribution with the ``ppc``, ``i386`` - and ``x86_64`` architectures. - + while ``3-way`` builds a distribution with the ``ppc``, ``i386`` + and ``x86_64`` architectures. + - Issue #6802: Fix build issues on MacOSX 10.6 - Issue #6244: Allow detect_tkinter to look for Tcl/Tk 8.6. @@ -1356,12 +1359,12 @@ for Windows. - Issue #6801 : symmetric_difference_update also accepts |. - Thanks to Carl Chenet. + Thanks to Carl Chenet. C-API ----- -- Issue #6624: PyArg_ParseTuple with "s" format when parsing argument with +- Issue #6624: PyArg_ParseTuple with "s" format when parsing argument with NULL: Bogus TypeError detail string. - Issue #5954: Add a PyFrame_GetLineNumber() function to replace most uses of From python-checkins at python.org Fri Oct 16 16:26:37 2009 From: python-checkins at python.org (eric.smith) Date: Fri, 16 Oct 2009 14:26:37 -0000 Subject: [Python-checkins] r75446 - python/trunk/Objects/floatobject.c Message-ID: Author: eric.smith Date: Fri Oct 16 16:26:36 2009 New Revision: 75446 Log: Removed usage of unsafe PyFloat_AsString. Modified: python/trunk/Objects/floatobject.c Modified: python/trunk/Objects/floatobject.c ============================================================================== --- python/trunk/Objects/floatobject.c (original) +++ python/trunk/Objects/floatobject.c Fri Oct 16 16:26:36 2009 @@ -2012,15 +2012,21 @@ i++, p++) { if (PyFloat_CheckExact(p) && Py_REFCNT(p) != 0) { - char buf[100]; - PyFloat_AsString(buf, p); - /* XXX(twouters) cast refcount to - long until %zd is universally - available - */ - fprintf(stderr, + char *buf = PyOS_double_to_string( + PyFloat_AS_DOUBLE(p), 'r', + 0, 0, NULL); + if (buf) { + /* XXX(twouters) cast + refcount to long + until %zd is + universally + available + */ + fprintf(stderr, "# \n", p, (long)Py_REFCNT(p), buf); + PyMem_Free(buf); + } } } list = list->next; From python-checkins at python.org Fri Oct 16 16:28:33 2009 From: python-checkins at python.org (eric.smith) Date: Fri, 16 Oct 2009 14:28:33 -0000 Subject: [Python-checkins] r75447 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Fri Oct 16 16:28:33 2009 New Revision: 75447 Log: Blocked revisions 75446 via svnmerge ........ r75446 | eric.smith | 2009-10-16 10:26:36 -0400 (Fri, 16 Oct 2009) | 1 line Removed usage of unsafe PyFloat_AsString. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Fri Oct 16 16:33:35 2009 From: python-checkins at python.org (eric.smith) Date: Fri, 16 Oct 2009 14:33:35 -0000 Subject: [Python-checkins] r75448 - python/branches/py3k Message-ID: Author: eric.smith Date: Fri Oct 16 16:33:35 2009 New Revision: 75448 Log: Blocked revisions 75446 via svnmerge ........ r75446 | eric.smith | 2009-10-16 10:26:36 -0400 (Fri, 16 Oct 2009) | 1 line Removed usage of unsafe PyFloat_AsString. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Fri Oct 16 19:46:11 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 16 Oct 2009 17:46:11 -0000 Subject: [Python-checkins] r75449 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Fri Oct 16 19:46:11 2009 New Revision: 75449 Log: Add a latency test Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Fri Oct 16 19:46:11 2009 @@ -15,7 +15,8 @@ import itertools import threading import subprocess -from optparse import OptionParser +import socket +from optparse import OptionParser, SUPPRESS_HELP # Compatibility try: @@ -31,6 +32,9 @@ THROUGHPUT_DURATION = 2.0 +LATENCY_PING_INTERVAL = 0.1 +LATENCY_DURATION = 2.0 + def task_pidigits(): """Pi calculation (Python)""" @@ -86,10 +90,12 @@ with open(__file__, "rb") as f: arg = f.read(3000) * 2 - return bz2.compress, (arg, ) + def compress(s): + bz2.compress(s) + return compress, (arg, ) def task_hashing(): - """sha1 hashing (C)""" + """SHA1 hashing (C)""" import hashlib with open(__file__, "rb") as f: arg = f.read(5000) * 30 @@ -100,20 +106,23 @@ throughput_tasks = [task_pidigits] -# For whatever reasons, zlib gives irregular results, so we prefer bz2 or -# hashlib if available. -# (note: hashlib releases the GIL from 2.7 and 3.1 onwards) -try: - import bz2 -except ImportError: +for mod in 'bz2', 'hashlib': try: - import hashlib + globals()[mod] = __import__(mod) except ImportError: - throughput_tasks.append(task_compress_zlib) - else: - throughput_tasks.append(task_hashing) -else: + globals()[mod] = None + +# For whatever reasons, zlib gives irregular results, so we prefer bz2 or +# hashlib if available. +# (NOTE: hashlib releases the GIL from 2.7 and 3.1 onwards) +if bz2 is not None: throughput_tasks.append(task_compress_bz2) +elif hashlib is not None: + throughput_tasks.append(task_hashing) +else: + throughput_tasks.append(task_compress_zlib) + +latency_tasks = throughput_tasks class TimedLoop: @@ -121,7 +130,7 @@ self.func = func self.args = args - def __call__(self, start_time, min_duration, end_event, do_yield=True): + def __call__(self, start_time, min_duration, end_event, do_yield=False): step = 20 niters = 0 duration = 0.0 @@ -146,12 +155,11 @@ if t2 - t1 < 0.01: # Minimize interference of measurement on overall runtime step = step * 3 // 2 - else: - if do_yield: - # OS scheduling of Python threads is sometimes so bad that we - # have to force thread switching ourselves, otherwise we get - # completely useless results. - _sleep(0.0001) + elif do_yield: + # OS scheduling of Python threads is sometimes so bad that we + # have to force thread switching ourselves, otherwise we get + # completely useless results. + _sleep(0.0001) t1 = t2 @@ -181,7 +189,7 @@ with start_cond: start_cond.wait() results.append(loop(start_time, THROUGHPUT_DURATION, - end_event)) + end_event, do_yield=True)) threads = [] for i in range(nthreads): @@ -222,6 +230,119 @@ print() +LAT_END = "END" + +def _sendto(sock, s, addr): + sock.sendto(s.encode('ascii'), addr) + +def _recv(sock, n): + return sock.recv(n).decode('ascii') + +def latency_client(addr, nb_pings, interval): + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + _time = time.time + _sleep = time.sleep + for i in range(nb_pings): + _sleep(interval) + _sendto(sock, "%r\n" % _time(), addr) + _sendto(sock, LAT_END + "\n", addr) + +def run_latency_client(**kwargs): + cmd_line = [sys.executable, '-E', os.path.abspath(__file__)] + cmd_line.extend(['--latclient', repr(kwargs)]) + return subprocess.Popen(cmd_line) #, stdin=subprocess.PIPE, + #stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + +def run_latency_test(func, args, nthreads): + # Create a listening socket to receive the pings. We use UDP which should + # be painlessly cross-platform. + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + sock.bind(("127.0.0.1", 0)) + addr = sock.getsockname() + + interval = LATENCY_PING_INTERVAL + duration = LATENCY_DURATION + nb_pings = int(duration / interval) + + results = [] + threads = [] + start_cond = threading.Condition() + if nthreads > 0: + # Warm up + func(*args) + + results = [] + loop = TimedLoop(func, args) + end_event = [] + ready = [] + + def run(): + ready.append(None) + with start_cond: + start_cond.wait() + loop(start_time, duration, end_event, do_yield=False) + + for i in range(nthreads): + threads.append(threading.Thread(target=run)) + for t in threads: + t.start() + # Wait for threads to be ready + while len(ready) < nthreads: + time.sleep(0.1) + + # Run the client and wait for the first ping(s) to arrive before + # unblocking the background threads. + chunks = [] + process = run_latency_client(addr=sock.getsockname(), + nb_pings=nb_pings + 1, interval=interval) + s = _recv(sock, 4096) + _time = time.time + + with start_cond: + start_time = _time() + start_cond.notify(nthreads) + + while LAT_END not in s: + s = _recv(sock, 4096) + t = _time() + chunks.append((t, s)) + + for t in threads: + t.join() + process.wait() + + for recv_time, chunk in chunks: + # NOTE: it is assumed that a line sent by a client wasn't received + # in two chunks because the lines are very small. + for line in chunk.splitlines(): + line = line.strip() + if line and line != LAT_END: + send_time = eval(line) + assert isinstance(send_time, float) + results.append((send_time, recv_time)) + + return results + +def run_latency_tests(max_threads=4): + for task in latency_tasks: + print("Background CPU task:", task.__doc__) + print() + func, args = task() + nthreads = 0 + while nthreads <= max_threads: + results = run_latency_test(func, args, nthreads) + n = len(results) + # We print out milliseconds + lats = [1000 * (t2 - t1) for (t1, t2) in results] + avg = sum(lats) / n + dev = (sum((x - avg) ** 2 for x in lats) / n) ** 0.5 + print("CPU threads=%d: %d ms. (std dev: %d ms.)" % (nthreads, avg, dev), end="") + print() + #print(" [... from %d samples]" % n) + nthreads += 1 + print() + + def main(): usage = "usage: %prog [-h|--help] [options]" parser = OptionParser(usage=usage) @@ -234,10 +355,21 @@ parser.add_option("-i", "--interval", action="store", type="int", dest="interval", default=None, help="sys.setcheckinterval() value") + + # Hidden option to run the pinging client + parser.add_option("", "--latclient", + action="store", dest="latclient", default=None, + help=SUPPRESS_HELP) + options, args = parser.parse_args() if args: parser.error("unexpected arguments") + if options.latclient: + kwargs = eval(options.latclient) + latency_client(**kwargs) + return + if not options.throughput and not options.latency: options.throughput = options.latency = True if options.interval: @@ -247,6 +379,11 @@ print("--- Throughput ---") print() run_throughput_tests() + + if options.latency: + print("--- Latency ---") + print() + run_latency_tests() if __name__ == "__main__": main() From nnorwitz at gmail.com Fri Oct 16 23:43:49 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 16 Oct 2009 17:43:49 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091016214349.GA8983@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [-280, 0, 0] references, sum=-280 Less important issues: ---------------------- test_asynchat leaked [130, -130, 0] references, sum=0 test_smtplib leaked [0, -5, 5] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Sat Oct 17 00:03:12 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 16 Oct 2009 18:03:12 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091016220312.GA16059@python.psfb.org> 340 tests OK. 1 test failed: test_ssl 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-8991 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr Warning -- sys.stdout was modified by test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 340 tests OK. 1 test failed: test_ssl 5 tests altered the execution environment: test_descr test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [894693 refs] From python-checkins at python.org Sat Oct 17 01:04:16 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 16 Oct 2009 23:04:16 -0000 Subject: [Python-checkins] r75450 - python/trunk/Lib/distutils/tests/test_archive_util.py Message-ID: Author: tarek.ziade Date: Sat Oct 17 01:04:16 2009 New Revision: 75450 Log: this test requires zlib support Modified: python/trunk/Lib/distutils/tests/test_archive_util.py Modified: python/trunk/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_archive_util.py (original) +++ python/trunk/Lib/distutils/tests/test_archive_util.py Sat Oct 17 01:04:16 2009 @@ -209,6 +209,7 @@ base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') + @unittest.skipUnless(zlib, "Requires zlib") def test_make_archive_owner_group(self): # testing make_archive with owner and group, with various combinations # this works even if there's not gid/uid support From python-checkins at python.org Sat Oct 17 01:07:19 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 16 Oct 2009 23:07:19 -0000 Subject: [Python-checkins] r75451 - in python/branches/py3k: Lib/distutils/tests/test_archive_util.py Message-ID: Author: tarek.ziade Date: Sat Oct 17 01:07:19 2009 New Revision: 75451 Log: Merged revisions 75450 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75450 | tarek.ziade | 2009-10-17 01:04:16 +0200 (Sat, 17 Oct 2009) | 1 line this test requires zlib support ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/tests/test_archive_util.py Modified: python/branches/py3k/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_archive_util.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_archive_util.py Sat Oct 17 01:07:19 2009 @@ -209,6 +209,7 @@ base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') + @unittest.skipUnless(zlib, "Requires zlib") def test_make_archive_owner_group(self): # testing make_archive with owner and group, with various combinations # this works even if there's not gid/uid support From python-checkins at python.org Sat Oct 17 01:17:53 2009 From: python-checkins at python.org (tarek.ziade) Date: Fri, 16 Oct 2009 23:17:53 -0000 Subject: [Python-checkins] r75452 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Sat Oct 17 01:17:52 2009 New Revision: 75452 Log: Blocked revisions 75451 via svnmerge ................ r75451 | tarek.ziade | 2009-10-17 01:07:19 +0200 (Sat, 17 Oct 2009) | 9 lines Merged revisions 75450 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75450 | tarek.ziade | 2009-10-17 01:04:16 +0200 (Sat, 17 Oct 2009) | 1 line this test requires zlib support ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sat Oct 17 08:33:05 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 06:33:05 -0000 Subject: [Python-checkins] r75453 - python/trunk/Lib/test/test_descr.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 08:33:05 2009 New Revision: 75453 Log: Correctly restore sys.stdout in test_descr Modified: python/trunk/Lib/test/test_descr.py Modified: python/trunk/Lib/test/test_descr.py ============================================================================== --- python/trunk/Lib/test/test_descr.py (original) +++ python/trunk/Lib/test/test_descr.py Sat Oct 17 08:33:05 2009 @@ -4311,6 +4311,7 @@ def test_file_fault(self): # Testing sys.stdout is changed in getattr... import sys + test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): sys.stdout = sys.__stdout__ @@ -4320,6 +4321,8 @@ print "Oops!" except RuntimeError: pass + finally: + sys.stdout = test_stdout def test_vicious_descriptor_nonsense(self): # Testing vicious_descriptor_nonsense... From python-checkins at python.org Sat Oct 17 09:06:38 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 17 Oct 2009 07:06:38 -0000 Subject: [Python-checkins] r75454 - python/trunk/Lib/test/test_math.py Message-ID: Author: mark.dickinson Date: Sat Oct 17 09:06:37 2009 New Revision: 75454 Log: test_math ulp computation was wrong on big-endian systems Modified: python/trunk/Lib/test/test_math.py Modified: python/trunk/Lib/test/test_math.py ============================================================================== --- python/trunk/Lib/test/test_math.py (original) +++ python/trunk/Lib/test/test_math.py Sat Oct 17 09:06:37 2009 @@ -43,7 +43,7 @@ where C doubles are represented in IEEE 754 binary64 format. """ - n = struct.unpack('q', struct.pack(' Author: mark.dickinson Date: Sat Oct 17 09:10:00 2009 New Revision: 75455 Log: Merged revisions 75454 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75454 | mark.dickinson | 2009-10-17 08:06:37 +0100 (Sat, 17 Oct 2009) | 1 line test_math ulp computation was wrong on big-endian systems ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_math.py Modified: python/branches/py3k/Lib/test/test_math.py ============================================================================== --- python/branches/py3k/Lib/test/test_math.py (original) +++ python/branches/py3k/Lib/test/test_math.py Sat Oct 17 09:10:00 2009 @@ -43,7 +43,7 @@ where C doubles are represented in IEEE 754 binary64 format. """ - n = struct.unpack('q', struct.pack(' Author: nick.coghlan Date: Sat Oct 17 09:30:40 2009 New Revision: 75456 Log: Enhancement to the new environment checking code to print the changed items under -vv. Also includes a small tweak to allow underscores in the names of resources. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Sat Oct 17 09:30:40 2009 @@ -651,18 +651,22 @@ class saved_test_environment: """Save bits of the test environment and restore them at block exit. - with saved_test_environment(testname, quiet): + with saved_test_environment(testname, verbose, quiet): #stuff Unless quiet is True, a warning is printed to stderr if any of the saved items was changed by the test. The attribute 'changed' is initially False, but is set to True if a change is detected. + + If verbose is more than 1, the before and after state of changed + items is also printed. """ changed = False - def __init__(self, testname, quiet=False): + def __init__(self, testname, verbose=0, quiet=False): self.testname = testname + self.verbose = verbose self.quiet = quiet # To add things to save and restore, add a name XXX to the resources list @@ -670,12 +674,13 @@ # return the value to be saved and compared against a second call to the # get function when test execution completes. restore_XXX should accept # the saved value and restore the resource using it. It will be called if - # and only if a change in the value is detected. XXX will have any '_' - # replaced with '.' characters and will then be used in the error messages - # as the name of the resource that changed. + # and only if a change in the value is detected. + # + # Note: XXX will have any '.' replaced with '_' characters when determining + # the corresponding method names. - resources = ('sys_argv', 'cwd', 'sys_stdin', 'sys_stdout', 'sys_stderr', - 'os_environ', 'sys_path') + resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', + 'os.environ', 'sys.path') def get_sys_argv(self): return sys.argv[:] @@ -713,19 +718,38 @@ def restore_sys_path(self, saved_path): sys.path[:] = saved_path + def resource_info(self): + for name in self.resources: + method_suffix = name.replace('.', '_') + get_name = 'get_' + method_suffix + restore_name = 'restore_' + method_suffix + yield name, getattr(self, get_name), getattr(self, restore_name) + def __enter__(self): - self.saved_values = dict((name, getattr(self, 'get_'+name)()) - for name in self.resources) + self.saved_values = dict((name, get()) for name, get, restore + in self.resource_info()) return self def __exit__(self, exc_type, exc_val, exc_tb): - for name in self.resources: - if not getattr(self, 'get_'+name)() == self.saved_values[name]: + for name, get, restore in self.resource_info(): + current = get() + original = self.saved_values[name] + # Check for changes to the resource's value + if current != original: self.changed = True - getattr(self, 'restore_'+name)(self.saved_values[name]) + restore(original) if not self.quiet: - print >>sys.stderr, ("Warning -- {} was modified " - "by {}").format(name.replace('_', '.'), self.testname) + print >>sys.stderr, ( + "Warning -- {} was modified by {}".format( + name, self.testname)) + if self.verbose > 1: + print >>sys.stderr, ( + " Before: {}\n After: {} ".format( + original, current)) + # XXX (ncoghlan): for most resources (e.g. sys.path) identity + # matters at least as much as value. For others (e.g. cwd), + # identity is irrelevant. Should we add a mechanism to check + # for substitution in the cases where it matters? return False @@ -751,7 +775,7 @@ else: # Always import it from the test package abstest = 'test.' + test - with saved_test_environment(test, quiet) as environment: + with saved_test_environment(test, verbose, quiet) as environment: start_time = time.time() the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) From python-checkins at python.org Sat Oct 17 09:34:28 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 07:34:28 -0000 Subject: [Python-checkins] r75457 - python/trunk/Lib/test/regrtest.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 09:34:27 2009 New Revision: 75457 Log: Formatting tweak so that before and after values are vertically aligned Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Sat Oct 17 09:34:27 2009 @@ -744,8 +744,8 @@ name, self.testname)) if self.verbose > 1: print >>sys.stderr, ( - " Before: {}\n After: {} ".format( - original, current)) + " Before: {}\n After: {} ".format( + original, current)) # XXX (ncoghlan): for most resources (e.g. sys.path) identity # matters at least as much as value. For others (e.g. cwd), # identity is irrelevant. Should we add a mechanism to check From python-checkins at python.org Sat Oct 17 10:21:21 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 08:21:21 -0000 Subject: [Python-checkins] r75458 - python/trunk/Lib/test/test_unittest.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 10:21:21 2009 New Revision: 75458 Log: Check and revert expected sys.path alterations Modified: python/trunk/Lib/test/test_unittest.py Modified: python/trunk/Lib/test/test_unittest.py ============================================================================== --- python/trunk/Lib/test/test_unittest.py (original) +++ python/trunk/Lib/test/test_unittest.py Sat Oct 17 10:21:21 2009 @@ -3609,12 +3609,12 @@ os.path.isfile = lambda path: False self.addCleanup(restore_isfile) - full_path = os.path.abspath(os.path.normpath('/foo')) - def clean_path(): - if sys.path[-1] == full_path: - sys.path.pop(-1) - self.addCleanup(clean_path) + orig_sys_path = sys.path[:] + def restore_path(): + sys.path[:] = orig_sys_path + self.addCleanup(restore_path) + full_path = os.path.abspath(os.path.normpath('/foo')) with self.assertRaises(ImportError): loader.discover('/foo/bar', top_level_dir='/foo') @@ -3636,6 +3636,7 @@ self.assertEqual(suite, "['tests']") self.assertEqual(loader._top_level_dir, top_level_dir) self.assertEqual(_find_tests_args, [(start_dir, 'pattern')]) + self.assertIn(top_level_dir, sys.path) def test_discover_with_modules_that_fail_to_import(self): loader = unittest.TestLoader() @@ -3644,12 +3645,15 @@ os.listdir = lambda _: ['test_this_does_not_exist.py'] isfile = os.path.isfile os.path.isfile = lambda _: True + orig_sys_path = sys.path[:] def restore(): os.path.isfile = isfile os.listdir = listdir + sys.path[:] = orig_sys_path self.addCleanup(restore) suite = loader.discover('.') + self.assertIn(os.getcwd(), sys.path) self.assertEqual(suite.countTestCases(), 1) test = list(list(suite)[0])[0] # extract test from suite From python-checkins at python.org Sat Oct 17 10:57:43 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 17 Oct 2009 08:57:43 -0000 Subject: [Python-checkins] r75459 - python/trunk/Modules/_ctypes/_ctypes.c Message-ID: Author: georg.brandl Date: Sat Oct 17 10:57:43 2009 New Revision: 75459 Log: Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. Modified: python/trunk/Modules/_ctypes/_ctypes.c Modified: python/trunk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes.c (original) +++ python/trunk/Modules/_ctypes/_ctypes.c Sat Oct 17 10:57:43 2009 @@ -1889,17 +1889,16 @@ } fmt = _ctypes_get_fielddesc(PyString_AS_STRING(proto)); if (fmt == NULL) { - Py_DECREF(result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", PyString_AS_STRING(proto)); - return NULL; + goto error; } stgdict = (StgDictObject *)PyObject_CallObject( (PyObject *)&PyCStgDict_Type, NULL); if (!stgdict) - return NULL; + goto error; stgdict->ffi_type_pointer = *fmt->pffi_type; stgdict->align = fmt->pffi_type->alignment; @@ -1914,6 +1913,7 @@ #endif if (stgdict->format == NULL) { Py_DECREF(result); + Py_DECREF(proto); Py_DECREF((PyObject *)stgdict); return NULL; } From nnorwitz at gmail.com Sat Oct 17 12:42:15 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 17 Oct 2009 06:42:15 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091017104215.GA6444@python.psfb.org> More important issues: ---------------------- test___all__ leaked [1, 1, 1] references, sum=3 test_urllib2_localnet leaked [-280, 0, 0] references, sum=-280 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_cmd_line leaked [0, 0, -25] references, sum=-25 test_distutils leaked [0, 25, -25] references, sum=0 test_file2k leaked [0, 80, -80] references, sum=0 test_smtplib leaked [0, 0, 123] references, sum=123 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Sat Oct 17 13:01:41 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 17 Oct 2009 07:01:41 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091017110141.GA13529@python.psfb.org> 341 tests OK. 1 test failed: test_ssl 4 tests altered the execution environment: test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest Warning -- sys.path was modified by test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-6452 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] Warning -- os.environ was modified by test_httpservers test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc Warning -- sys.stdout was modified by test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 341 tests OK. 1 test failed: test_ssl 4 tests altered the execution environment: test_distutils test_httpservers test_unittest test_xmlrpc 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [894756 refs] From python-checkins at python.org Sat Oct 17 16:38:18 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 17 Oct 2009 14:38:18 -0000 Subject: [Python-checkins] r75460 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sat Oct 17 16:38:18 2009 New Revision: 75460 Log: Add an option to modify the max number of threads Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sat Oct 17 16:38:18 2009 @@ -208,7 +208,7 @@ return results -def run_throughput_tests(max_threads=4): +def run_throughput_tests(max_threads): for task in throughput_tasks: print(task.__doc__) print() @@ -323,7 +323,7 @@ return results -def run_latency_tests(max_threads=4): +def run_latency_tests(max_threads): for task in latency_tasks: print("Background CPU task:", task.__doc__) print() @@ -355,6 +355,9 @@ parser.add_option("-i", "--interval", action="store", type="int", dest="interval", default=None, help="sys.setcheckinterval() value") + parser.add_option("-n", "--num-threads", + action="store", type="int", dest="nthreads", default=4, + help="max number of threads in tests") # Hidden option to run the pinging client parser.add_option("", "--latclient", @@ -378,12 +381,12 @@ if options.throughput: print("--- Throughput ---") print() - run_throughput_tests() + run_throughput_tests(options.nthreads) if options.latency: print("--- Latency ---") print() - run_latency_tests() + run_latency_tests(options.nthreads) if __name__ == "__main__": main() From python-checkins at python.org Sat Oct 17 16:40:55 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 14:40:55 -0000 Subject: [Python-checkins] r75461 - in python/trunk/Lib/test: test_support.py test_ttk_guionly.py test_ttk_textonly.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 16:40:54 2009 New Revision: 75461 Log: Restore original sys.path when running TTK tests Modified: python/trunk/Lib/test/test_support.py python/trunk/Lib/test/test_ttk_guionly.py python/trunk/Lib/test/test_ttk_textonly.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Sat Oct 17 16:40:54 2009 @@ -578,6 +578,31 @@ self._environ[k] = v +class DirsOnSysPath(object): + """Context manager to temporarily add directories to sys.path. + + This makes a copy of sys.path, appends any directories given + as positional arguments, then reverts sys.path to the copied + settings when the context ends. + + Note that *all* sys.path modifications in the body of the + context manager, including replacement of the object, + will be reverted at the end of the block. + """ + + def __init__(self, *paths): + self.original_value = sys.path[:] + self.original_object = sys.path + sys.path.extend(paths) + + def __enter__(self): + return self + + def __exit__(self, *ignore_exc): + sys.path = self.original_object + sys.path[:] = self.original_value + + class TransientResource(object): """Raise ResourceDenied if an exception is raised while the context manager Modified: python/trunk/Lib/test/test_ttk_guionly.py ============================================================================== --- python/trunk/Lib/test/test_ttk_guionly.py (original) +++ python/trunk/Lib/test/test_ttk_guionly.py Sat Oct 17 16:40:54 2009 @@ -18,10 +18,9 @@ this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, 'lib-tk', 'test')) -if lib_tk_test not in sys.path: - sys.path.append(lib_tk_test) -import runtktests +with test_support.DirsOnSysPath(lib_tk_test): + import runtktests def test_main(enable_gui=False): if enable_gui: @@ -30,7 +29,8 @@ elif 'gui' not in test_support.use_resources: test_support.use_resources.append('gui') - test_support.run_unittest( + with test_support.DirsOnSysPath(lib_tk_test): + test_support.run_unittest( *runtktests.get_tests(text=False, packages=['test_ttk'])) if __name__ == '__main__': Modified: python/trunk/Lib/test/test_ttk_textonly.py ============================================================================== --- python/trunk/Lib/test/test_ttk_textonly.py (original) +++ python/trunk/Lib/test/test_ttk_textonly.py Sat Oct 17 16:40:54 2009 @@ -7,13 +7,13 @@ this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath(os.path.join(this_dir, '..', 'lib-tk', 'test')) -if lib_tk_test not in sys.path: - sys.path.append(lib_tk_test) -import runtktests +with test_support.DirsOnSysPath(lib_tk_test): + import runtktests def test_main(): - test_support.run_unittest( + with test_support.DirsOnSysPath(lib_tk_test): + test_support.run_unittest( *runtktests.get_tests(gui=False, packages=['test_ttk'])) if __name__ == '__main__': From python-checkins at python.org Sat Oct 17 17:09:41 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 15:09:41 -0000 Subject: [Python-checkins] r75462 - in python/trunk/Lib/test: test_support.py test_xmlrpc.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 17:09:41 2009 New Revision: 75462 Log: Don't invoke reload(sys) and use StringIO objects instead of real files to capture stdin and stdout when needed (ensures all sys attributes remain unmodified after test_xmlrpc runs) Modified: python/trunk/Lib/test/test_support.py python/trunk/Lib/test/test_xmlrpc.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Sat Oct 17 17:09:41 2009 @@ -659,6 +659,9 @@ def captured_stdout(): return captured_output("stdout") +def captured_stdin(): + return captured_output("stdin") + def gc_collect(): """Force as many objects as possible to be collected. Modified: python/trunk/Lib/test/test_xmlrpc.py ============================================================================== --- python/trunk/Lib/test/test_xmlrpc.py (original) +++ python/trunk/Lib/test/test_xmlrpc.py Sat Oct 17 17:09:41 2009 @@ -160,17 +160,17 @@ """ # sys.setdefaultencoding() normally doesn't exist after site.py is - # loaded. reload(sys) is the way to get it back. + # loaded. Import a temporary fresh copy to get access to it + # but then restore the original copy to avoid messing with + # other potentially modified sys module attributes old_encoding = sys.getdefaultencoding() - setdefaultencoding_existed = hasattr(sys, "setdefaultencoding") - reload(sys) # ugh! - sys.setdefaultencoding("iso-8859-1") - try: - (s, d), m = xmlrpclib.loads(utf8) - finally: - sys.setdefaultencoding(old_encoding) - if not setdefaultencoding_existed: - del sys.setdefaultencoding + with test_support.CleanImport('sys'): + import sys as temp_sys + temp_sys.setdefaultencoding("iso-8859-1") + try: + (s, d), m = xmlrpclib.loads(utf8) + finally: + temp_sys.setdefaultencoding(old_encoding) items = d.items() if have_unicode: @@ -831,54 +831,45 @@ env['REQUEST_METHOD'] = 'GET' # if the method is GET and no request_text is given, it runs handle_get # get sysout output - tmp = sys.stdout - sys.stdout = open(test_support.TESTFN, "w") - self.cgi.handle_request() - sys.stdout.close() - sys.stdout = tmp + with test_support.captured_stdout() as data_out: + self.cgi.handle_request() # parse Status header - handle = open(test_support.TESTFN, "r").read() + data_out.seek(0) + handle = data_out.read() status = handle.split()[1] message = ' '.join(handle.split()[2:4]) self.assertEqual(status, '400') self.assertEqual(message, 'Bad Request') - os.remove(test_support.TESTFN) def test_cgi_xmlrpc_response(self): data = """ - - test_method - - - foo - - - bar - - - -""" - open("xmldata.txt", "w").write(data) - tmp1 = sys.stdin - tmp2 = sys.stdout - - sys.stdin = open("xmldata.txt", "r") - sys.stdout = open(test_support.TESTFN, "w") - - with test_support.EnvironmentVarGuard() as env: + + test_method + + + foo + + + bar + + + + """ + + with test_support.EnvironmentVarGuard() as env, \ + test_support.captured_stdout() as data_out, \ + test_support.captured_stdin() as data_in: + data_in.write(data) + data_in.seek(0) env['CONTENT_LENGTH'] = str(len(data)) self.cgi.handle_request() - - sys.stdin.close() - sys.stdout.close() - sys.stdin = tmp1 - sys.stdout = tmp2 + data_out.seek(0) # will respond exception, if so, our goal is achieved ;) - handle = open(test_support.TESTFN, "r").read() + handle = data_out.read() # start with 44th char so as not to get http header, we just need only xml self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:]) @@ -895,9 +886,6 @@ len(content)) - os.remove("xmldata.txt") - os.remove(test_support.TESTFN) - class FakeSocket: def __init__(self): From python-checkins at python.org Sat Oct 17 17:23:08 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 15:23:08 -0000 Subject: [Python-checkins] r75463 - python/trunk/Lib/test/test_httpservers.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 17:23:08 2009 New Revision: 75463 Log: Revert changes made to environment in test_httpservers Modified: python/trunk/Lib/test/test_httpservers.py Modified: python/trunk/Lib/test/test_httpservers.py ============================================================================== --- python/trunk/Lib/test/test_httpservers.py (original) +++ python/trunk/Lib/test/test_httpservers.py Sat Oct 17 17:23:08 2009 @@ -50,6 +50,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): + os.environ = test_support.EnvironmentVarGuard() self.lock = threading.Lock() self.thread = TestServerThread(self, self.request_handler) self.thread.start() @@ -58,6 +59,8 @@ def tearDown(self): self.lock.release() self.thread.stop() + os.environ.__exit__() + os.environ = os.environ._environ def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) @@ -390,9 +393,9 @@ try: cwd = os.getcwd() test_support.run_unittest(BaseHTTPServerTestCase, - SimpleHTTPServerTestCase, - CGIHTTPServerTestCase - ) + SimpleHTTPServerTestCase, + CGIHTTPServerTestCase + ) finally: os.chdir(cwd) From python-checkins at python.org Sat Oct 17 17:29:23 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 17 Oct 2009 15:29:23 -0000 Subject: [Python-checkins] r75464 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sat Oct 17 17:29:23 2009 New Revision: 75464 Log: Try to improve the latency test a bit Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sat Oct 17 17:29:23 2009 @@ -242,9 +242,15 @@ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) _time = time.time _sleep = time.sleep + def _ping(): + _sendto(sock, "%r\n" % _time(), addr) + # The first ping signals the parent process that we are ready. + _ping() + # We give the parent a bit of time to notice. + _sleep(1.0) for i in range(nb_pings): _sleep(interval) - _sendto(sock, "%r\n" % _time(), addr) + _ping() _sendto(sock, LAT_END + "\n", addr) def run_latency_client(**kwargs): @@ -294,7 +300,7 @@ # unblocking the background threads. chunks = [] process = run_latency_client(addr=sock.getsockname(), - nb_pings=nb_pings + 1, interval=interval) + nb_pings=nb_pings, interval=interval) s = _recv(sock, 4096) _time = time.time From python-checkins at python.org Sat Oct 17 17:45:53 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 15:45:53 -0000 Subject: [Python-checkins] r75465 - in python/trunk/Lib/test: test_httpservers.py test_support.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 17:45:52 2009 New Revision: 75465 Log: Move restoration of the os.environ object into the context manager where it belongs Modified: python/trunk/Lib/test/test_httpservers.py python/trunk/Lib/test/test_support.py Modified: python/trunk/Lib/test/test_httpservers.py ============================================================================== --- python/trunk/Lib/test/test_httpservers.py (original) +++ python/trunk/Lib/test/test_httpservers.py Sat Oct 17 17:45:52 2009 @@ -60,7 +60,6 @@ self.lock.release() self.thread.stop() os.environ.__exit__() - os.environ = os.environ._environ def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Sat Oct 17 17:45:52 2009 @@ -576,6 +576,7 @@ del self._environ[k] else: self._environ[k] = v + os.environ = self._environ class DirsOnSysPath(object): From python-checkins at python.org Sat Oct 17 17:48:17 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 15:48:17 -0000 Subject: [Python-checkins] r75466 - python/trunk/Lib/test/regrtest.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 17:48:16 2009 New Revision: 75466 Log: Also check and restore identity of sys.path, sys.argv and os.environ rather than just their values (this picked up a few more misbehaving tests) Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Sat Oct 17 17:48:16 2009 @@ -683,9 +683,10 @@ 'os.environ', 'sys.path') def get_sys_argv(self): - return sys.argv[:] + return id(sys.argv), sys.argv, sys.argv[:] def restore_sys_argv(self, saved_argv): - sys.argv[:] = saved_argv + sys.argv = saved_argv[1] + sys.argv[:] = saved_argv[2] def get_cwd(self): return os.getcwd() @@ -708,15 +709,17 @@ sys.stdin = saved_stdin def get_os_environ(self): - return dict(os.environ) + return id(os.environ), os.environ, dict(os.environ) def restore_os_environ(self, saved_environ): + os.environ = saved_environ[1] os.environ.clear() - os.environ.update(saved_environ) + os.environ.update(saved_environ[2]) def get_sys_path(self): - return sys.path[:] + return id(sys.path), sys.path, sys.path[:] def restore_sys_path(self, saved_path): - sys.path[:] = saved_path + sys.path = saved_path[1] + sys.path[:] = saved_path[2] def resource_info(self): for name in self.resources: From python-checkins at python.org Sat Oct 17 17:57:42 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 15:57:42 -0000 Subject: [Python-checkins] r75467 - in python/trunk/Lib/test: test_imp.py test_import.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 17:57:42 2009 New Revision: 75467 Log: Avoid replacing existing modules and sys.path in import tests Modified: python/trunk/Lib/test/test_imp.py python/trunk/Lib/test/test_import.py Modified: python/trunk/Lib/test/test_imp.py ============================================================================== --- python/trunk/Lib/test/test_imp.py (original) +++ python/trunk/Lib/test/test_imp.py Sat Oct 17 17:57:42 2009 @@ -43,16 +43,19 @@ reload().""" def test_source(self): - import os - imp.reload(os) + with test_support.CleanImport('os'): + import os + imp.reload(os) def test_extension(self): - import time - imp.reload(time) + with test_support.CleanImport('time'): + import time + imp.reload(time) def test_builtin(self): - import marshal - imp.reload(marshal) + with test_support.CleanImport('marshal'): + import marshal + imp.reload(marshal) def test_main(): Modified: python/trunk/Lib/test/test_import.py ============================================================================== --- python/trunk/Lib/test/test_import.py (original) +++ python/trunk/Lib/test/test_import.py Sat Oct 17 17:57:42 2009 @@ -8,7 +8,7 @@ import warnings import marshal from test.test_support import (unlink, TESTFN, unload, run_unittest, - check_warnings, TestFailed) + check_warnings, TestFailed, CleanImport) def remove_files(name): @@ -122,8 +122,9 @@ def testImpModule(self): # Verify that the imp module can correctly load and find .py files import imp - x = imp.find_module("os") - os = imp.load_module("os", *x) + with CleanImport("os"): + x = imp.find_module("os") + os = imp.load_module("os", *x) def test_module_with_large_stack(self, module='longlist'): # create module w/list of 65000 elements to test bug #561858 @@ -361,7 +362,7 @@ def tearDown(self): shutil.rmtree(self.path) - sys.path = self.syspath + sys.path[:] = self.syspath # http://bugs.python.org/issue1293 def test_trailing_slash(self): From python-checkins at python.org Sat Oct 17 18:19:52 2009 From: python-checkins at python.org (nick.coghlan) Date: Sat, 17 Oct 2009 16:19:52 -0000 Subject: [Python-checkins] r75468 - python/trunk/Lib/test/test_site.py Message-ID: Author: nick.coghlan Date: Sat Oct 17 18:19:51 2009 New Revision: 75468 Log: Don't replace sys.path in test_site Modified: python/trunk/Lib/test/test_site.py Modified: python/trunk/Lib/test/test_site.py ============================================================================== --- python/trunk/Lib/test/test_site.py (original) +++ python/trunk/Lib/test/test_site.py Sat Oct 17 18:19:51 2009 @@ -41,7 +41,7 @@ def tearDown(self): """Restore sys.path""" - sys.path = self.sys_path + sys.path[:] = self.sys_path site.USER_BASE = self.old_base site.USER_SITE = self.old_site site.PREFIXES = self.old_prefixes @@ -248,7 +248,7 @@ def tearDown(self): """Restore sys.path""" - sys.path = self.sys_path + sys.path[:] = self.sys_path def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute From python-checkins at python.org Sat Oct 17 21:53:24 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 17 Oct 2009 19:53:24 -0000 Subject: [Python-checkins] r75469 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sat Oct 17 21:53:24 2009 New Revision: 75469 Log: Add some alternate tasks, and bump pidigit count Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sat Oct 17 21:53:24 2009 @@ -72,7 +72,26 @@ return list(_islice(pi_digits(), n)) - return calc_ndigits, (20, ) + return calc_ndigits, (50, ) + +def task_regex(): + """regular expression (C)""" + # XXX this task gives horrendous latency results. + import re + # Taken from the `inspect` module + pat = re.compile(r'^(\s*def\s)|(.*(? 0: # Warm up @@ -279,14 +300,13 @@ results = [] loop = TimedLoop(func, args) - end_event = [] ready = [] def run(): ready.append(None) with start_cond: start_cond.wait() - loop(start_time, duration, end_event, do_yield=False) + loop(start_time, duration * 1.5, end_event, do_yield=False) for i in range(nthreads): threads.append(threading.Thread(target=run)) @@ -312,7 +332,9 @@ s = _recv(sock, 4096) t = _time() chunks.append((t, s)) - + + # Tell the background threads to stop. + end_event.append(None) for t in threads: t.join() process.wait() @@ -340,6 +362,7 @@ n = len(results) # We print out milliseconds lats = [1000 * (t2 - t1) for (t1, t2) in results] + #print(list(map(int, lats))) avg = sum(lats) / n dev = (sum((x - avg) ** 2 for x in lats) / n) ** 0.5 print("CPU threads=%d: %d ms. (std dev: %d ms.)" % (nthreads, avg, dev), end="") From nnorwitz at gmail.com Sat Oct 17 22:13:50 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 17 Oct 2009 16:13:50 -0400 Subject: [Python-checkins] Python Regression Test Failures basics (3) Message-ID: <20091017201350.GA13970@python.psfb.org> 336 tests OK. 3 tests failed: test_pickletools test_pickle test_xpickle 1 test altered the execution environment: test_distutils 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn fetching http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml ... fetching http://people.freebsd.org/~perky/i18n/EUC-CN.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT ... test_codecmaps_hk fetching http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT ... test_codecmaps_jp fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-JP.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT ... fetching http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT ... test_codecmaps_kr fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT ... fetching http://people.freebsd.org/~perky/i18n/EUC-KR.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT ... test_codecmaps_tw fetching http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT ... fetching http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT ... test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.argv was modified by test_distutils Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils Warning -- sys.path was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization fetching http://www.unicode.org/Public/5.1.0/ucd/NormalizationTest.txt ... test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test test_pickle failed -- errors occurred; run in verbose mode for details test_pickletools test test_pickletools failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/pickletester.py", line 623, in test_structseq s = self.dumps(t, proto) File "/tmp/python-test/local/lib/python2.7/test/test_pickletools.py", line 10, in dumps return pickletools.optimize(pickle.dumps(arg, proto)) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 1374, in dumps Pickler(file, protocol).dump(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 224, in dump self.save(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 400, in save_reduce save(func) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/tmp/python-test/local/lib/python2.7/pickle.py", line 753, in save_global (obj, module, name)) PicklingError: Can't pickle : it's not the same object as os._make_stat_result test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test test_xpickle failed -- errors occurred; run in verbose mode for details test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 336 tests OK. 3 tests failed: test_pickletools test_pickle test_xpickle 1 test altered the execution environment: test_distutils 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [881785 refs] From nnorwitz at gmail.com Sat Oct 17 22:23:42 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 17 Oct 2009 16:23:42 -0400 Subject: [Python-checkins] Python Regression Test Failures opt (3) Message-ID: <20091017202342.GA17771@python.psfb.org> 336 tests OK. 3 tests failed: test_pickletools test_pickle test_xpickle 1 test altered the execution environment: test_distutils 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 test_bsddb3 skipped -- Use of the `bsddb' resource not enabled test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_curses test_curses skipped -- Use of the `curses' resource not enabled test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19545 refs] [19545 refs] [19545 refs] [19542 refs] Warning -- sys.argv was modified by test_distutils Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils Warning -- sys.path was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_linuxaudiodev test_linuxaudiodev skipped -- Use of the `audio' resource not enabled test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_ossaudiodev test_ossaudiodev skipped -- Use of the `audio' resource not enabled test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test test_pickle failed -- errors occurred; run in verbose mode for details test_pickletools test test_pickletools failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/pickletester.py", line 623, in test_structseq s = self.dumps(t, proto) File "/tmp/python-test/local/lib/python2.7/test/test_pickletools.py", line 10, in dumps return pickletools.optimize(pickle.dumps(arg, proto)) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 1374, in dumps Pickler(file, protocol).dump(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 224, in dump self.save(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 400, in save_reduce save(func) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/tmp/python-test/local/lib/python2.7/pickle.py", line 753, in save_global (obj, module, name)) PicklingError: Can't pickle : it's not the same object as os._make_stat_result test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_smtpnet skipped -- Use of the `network' resource not enabled test_socket test_socketserver test_socketserver skipped -- Use of the `network' resource not enabled test_softspace test_sort test_sqlite test_ssl test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_timeout skipped -- Use of the `network' resource not enabled test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib2net skipped -- Use of the `network' resource not enabled test_urllibnet test_urllibnet skipped -- Use of the `network' resource not enabled test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc test_xpickle test_xpickle -- skipping backwards compat tests. Use 'regrtest.py -u xpickle' to run them. test test_xpickle failed -- errors occurred; run in verbose mode for details test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 336 tests OK. 3 tests failed: test_pickletools test_pickle test_xpickle 1 test altered the execution environment: test_distutils 36 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_bsddb3 test_cd test_cl test_curses test_epoll test_gl test_imgfile test_ioctl test_kqueue test_linuxaudiodev test_macos test_macostools test_multiprocessing test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_smtpnet test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [880867 refs] From python-checkins at python.org Sat Oct 17 23:46:33 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 17 Oct 2009 21:46:33 -0000 Subject: [Python-checkins] r75470 - python/trunk/Lib/test/test_builtin.py Message-ID: Author: mark.dickinson Date: Sat Oct 17 23:46:32 2009 New Revision: 75470 Log: Protect against attempts to replace PyNumber_Add with PyNumber_InPlaceAdd in builtin sum Modified: python/trunk/Lib/test/test_builtin.py Modified: python/trunk/Lib/test/test_builtin.py ============================================================================== --- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Sat Oct 17 23:46:32 2009 @@ -1286,6 +1286,10 @@ raise ValueError self.assertRaises(ValueError, sum, BadSeq()) + empty = [] + sum(([x] for x in range(10)), empty) + self.assertEqual(empty, []) + def test_type(self): self.assertEqual(type(''), type('123')) self.assertNotEqual(type(''), type(())) From python-checkins at python.org Sat Oct 17 23:48:16 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 17 Oct 2009 21:48:16 -0000 Subject: [Python-checkins] r75471 - in python/branches/py3k: Lib/test/test_builtin.py Message-ID: Author: mark.dickinson Date: Sat Oct 17 23:48:16 2009 New Revision: 75471 Log: Merged revisions 75470 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75470 | mark.dickinson | 2009-10-17 22:46:32 +0100 (Sat, 17 Oct 2009) | 1 line Protect against attempts to replace PyNumber_Add with PyNumber_InPlaceAdd in builtin sum ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_builtin.py Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Sat Oct 17 23:48:16 2009 @@ -1151,6 +1151,10 @@ raise ValueError self.assertRaises(ValueError, sum, BadSeq()) + empty = [] + sum(([x] for x in range(10)), empty) + self.assertEqual(empty, []) + def test_type(self): self.assertEqual(type(''), type('123')) self.assertNotEqual(type(''), type(())) From nnorwitz at gmail.com Sun Oct 18 00:04:52 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 17 Oct 2009 18:04:52 -0400 Subject: [Python-checkins] Python Regression Test Failures all (4) Message-ID: <20091017220452.GA32646@python.psfb.org> 341 tests OK. 4 tests failed: test_pickletools test_ssl test_pickle test_xpickle 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-14531 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.argv was modified by test_distutils Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils Warning -- sys.path was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test test_pickle failed -- errors occurred; run in verbose mode for details test_pickletools test test_pickletools failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/pickletester.py", line 623, in test_structseq s = self.dumps(t, proto) File "/tmp/python-test/local/lib/python2.7/test/test_pickletools.py", line 10, in dumps return pickletools.optimize(pickle.dumps(arg, proto)) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 1374, in dumps Pickler(file, protocol).dump(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 224, in dump self.save(obj) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, *rv) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 400, in save_reduce save(func) File "/tmp/python-test/local/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/tmp/python-test/local/lib/python2.7/pickle.py", line 753, in save_global (obj, module, name)) PicklingError: Can't pickle : it's not the same object as os._make_stat_result test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [20294 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test test_xpickle failed -- errors occurred; run in verbose mode for details test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 341 tests OK. 4 tests failed: test_pickletools test_ssl test_pickle test_xpickle 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [897291 refs] From python-checkins at python.org Sun Oct 18 02:32:49 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 18 Oct 2009 00:32:49 -0000 Subject: [Python-checkins] r75472 - python/branches/py3k/Lib/codeop.py Message-ID: Author: benjamin.peterson Date: Sun Oct 18 02:32:49 2009 New Revision: 75472 Log: correct porting error with raise #7161 Modified: python/branches/py3k/Lib/codeop.py Modified: python/branches/py3k/Lib/codeop.py ============================================================================== --- python/branches/py3k/Lib/codeop.py (original) +++ python/branches/py3k/Lib/codeop.py Sun Oct 18 02:32:49 2009 @@ -96,7 +96,7 @@ if code: return code if not code1 and repr(err1) == repr(err2): - raise SyntaxError(err1) + raise err1 def _compile(source, filename, symbol): return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT) From python-checkins at python.org Sun Oct 18 02:34:08 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 18 Oct 2009 00:34:08 -0000 Subject: [Python-checkins] r75473 - in python/branches/release31-maint: Lib/codeop.py Message-ID: Author: benjamin.peterson Date: Sun Oct 18 02:34:08 2009 New Revision: 75473 Log: Merged revisions 75472 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75472 | benjamin.peterson | 2009-10-17 19:32:49 -0500 (Sat, 17 Oct 2009) | 1 line correct porting error with raise #7161 ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/codeop.py Modified: python/branches/release31-maint/Lib/codeop.py ============================================================================== --- python/branches/release31-maint/Lib/codeop.py (original) +++ python/branches/release31-maint/Lib/codeop.py Sun Oct 18 02:34:08 2009 @@ -96,7 +96,7 @@ if code: return code if not code1 and repr(err1) == repr(err2): - raise SyntaxError(err1) + raise err1 def _compile(source, filename, symbol): return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT) From python-checkins at python.org Sun Oct 18 03:24:41 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 01:24:41 -0000 Subject: [Python-checkins] r75474 - in python/trunk/Doc/library: urllib.rst urllib2.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 03:24:41 2009 New Revision: 75474 Log: Fix for Issue7155 - urllib do not document default use of system proxy configuration Modified: python/trunk/Doc/library/urllib.rst python/trunk/Doc/library/urllib2.rst Modified: python/trunk/Doc/library/urllib.rst ============================================================================== --- python/trunk/Doc/library/urllib.rst (original) +++ python/trunk/Doc/library/urllib.rst Sun Oct 18 03:24:41 2009 @@ -96,8 +96,10 @@ .. index:: single: Internet Config - In a Macintosh environment, :func:`urlopen` will retrieve proxy information from - Internet Config. + In a Mac OS X environment, :func:`urlopen` will retrieve proxy information + from the OS X System Configuration Framework, which can be managed with + Network System Preferences panel. + Alternatively, the optional *proxies* argument may be used to explicitly specify proxies. It must be a dictionary mapping scheme names to proxy URLs, where an Modified: python/trunk/Doc/library/urllib2.rst ============================================================================== --- python/trunk/Doc/library/urllib2.rst (original) +++ python/trunk/Doc/library/urllib2.rst Sun Oct 18 03:24:41 2009 @@ -53,6 +53,9 @@ default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). + In addition, default installed :class:`ProxyHandler` makes sure the requests + are handled through the proxy when they are set. + .. versionchanged:: 2.6 *timeout* was added. @@ -187,8 +190,13 @@ .. class:: ProxyHandler([proxies]) Cause requests to go through a proxy. If *proxies* is given, it must be a - dictionary mapping protocol names to URLs of proxies. The default is to read the - list of proxies from the environment variables :envvar:`_proxy`. + dictionary mapping protocol names to URLs of proxies. The default is to read + the list of proxies from the environment variables + :envvar:`_proxy`. If no proxy environment variables are set, in a + Windows environment, proxy settings are obtained from the registry's + Internet Settings section and in a Mac OS X environment, proxy information + is retrieved from from the OS X System Configuration Framework. + To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 03:31:15 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 01:31:15 -0000 Subject: [Python-checkins] r75475 - in python/branches/release26-maint: Doc/library/urllib.rst Doc/library/urllib2.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 03:31:15 2009 New Revision: 75475 Log: Merged revisions 75474 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75474 | senthil.kumaran | 2009-10-18 06:54:41 +0530 (Sun, 18 Oct 2009) | 2 lines Fix for Issue7155 - urllib do not document default use of system proxy configuration ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/urllib.rst python/branches/release26-maint/Doc/library/urllib2.rst Modified: python/branches/release26-maint/Doc/library/urllib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/urllib.rst (original) +++ python/branches/release26-maint/Doc/library/urllib.rst Sun Oct 18 03:31:15 2009 @@ -96,8 +96,10 @@ .. index:: single: Internet Config - In a Macintosh environment, :func:`urlopen` will retrieve proxy information from - Internet Config. + In a Mac OS X environment, :func:`urlopen` will retrieve proxy information + from the OS X System Configuration Framework, which can be managed with + Network System Preferences panel. + Alternatively, the optional *proxies* argument may be used to explicitly specify proxies. It must be a dictionary mapping scheme names to proxy URLs, where an 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 Sun Oct 18 03:31:15 2009 @@ -53,6 +53,9 @@ default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). + In addition, default installed :class:`ProxyHandler` makes sure the requests + are handled through the proxy when they are set. + .. versionchanged:: 2.6 *timeout* was added. @@ -187,8 +190,13 @@ .. class:: ProxyHandler([proxies]) Cause requests to go through a proxy. If *proxies* is given, it must be a - dictionary mapping protocol names to URLs of proxies. The default is to read the - list of proxies from the environment variables :envvar:`_proxy`. + dictionary mapping protocol names to URLs of proxies. The default is to read + the list of proxies from the environment variables + :envvar:`_proxy`. If no proxy environment variables are set, in a + Windows environment, proxy settings are obtained from the registry's + Internet Settings section and in a Mac OS X environment, proxy information + is retrieved from from the OS X System Configuration Framework. + To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 03:42:33 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 01:42:33 -0000 Subject: [Python-checkins] r75476 - in python/branches/py3k: Doc/library/urllib.request.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 03:42:33 2009 New Revision: 75476 Log: Merged revisions 75474 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75474 | senthil.kumaran | 2009-10-18 06:54:41 +0530 (Sun, 18 Oct 2009) | 2 lines Fix for Issue7155 - urllib do not document default use of system proxy configuration ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/urllib.request.rst Modified: python/branches/py3k/Doc/library/urllib.request.rst ============================================================================== --- python/branches/py3k/Doc/library/urllib.request.rst (original) +++ python/branches/py3k/Doc/library/urllib.request.rst Sun Oct 18 03:42:33 2009 @@ -49,6 +49,9 @@ the default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). + In addition, default installed :class:`ProxyHandler` makes sure the requests + are handled through the proxy when they are set. + The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been discontinued; :func:`urlopen` corresponds to the old ``urllib2.urlopen``. Proxy handling, which was done by passing a dictionary parameter to @@ -350,6 +353,11 @@ Cause requests to go through a proxy. If *proxies* is given, it must be a dictionary mapping protocol names to URLs of proxies. The default is to read the list of proxies from the environment variables :envvar:`_proxy`. + If no proxy environment variables are set, in a Windows environment, proxy + settings are obtained from the registry's Internet Settings section and in a + Mac OS X environment, proxy information is retrieved from the OS X System + Configuration Framework. + To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 03:57:26 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 01:57:26 -0000 Subject: [Python-checkins] r75477 - python/branches/release31-maint/Doc/library/urllib.request.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 03:57:26 2009 New Revision: 75477 Log: Manually merging the changes from r75476 Modified: python/branches/release31-maint/Doc/library/urllib.request.rst Modified: python/branches/release31-maint/Doc/library/urllib.request.rst ============================================================================== --- python/branches/release31-maint/Doc/library/urllib.request.rst (original) +++ python/branches/release31-maint/Doc/library/urllib.request.rst Sun Oct 18 03:57:26 2009 @@ -49,6 +49,9 @@ the default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). + In addition, default installed :class:`ProxyHandler` makes sure the requests + are handled through the proxy when they are set. + The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been discontinued; :func:`urlopen` corresponds to the old ``urllib2.urlopen``. Proxy handling, which was done by passing a dictionary parameter to @@ -350,6 +353,11 @@ Cause requests to go through a proxy. If *proxies* is given, it must be a dictionary mapping protocol names to URLs of proxies. The default is to read the list of proxies from the environment variables :envvar:`_proxy`. + If no proxy environment variables are set, in a Windows environment, proxy + settings are obtained from the registry's Internet Settings section and in a + Mac OS X environment, proxy information is retrieved from the OS X System + Configuration Framework. + To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 03:58:45 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 01:58:45 -0000 Subject: [Python-checkins] r75478 - python/trunk/Doc/library/urllib2.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 03:58:45 2009 New Revision: 75478 Log: Fix a typo. Modified: python/trunk/Doc/library/urllib2.rst Modified: python/trunk/Doc/library/urllib2.rst ============================================================================== --- python/trunk/Doc/library/urllib2.rst (original) +++ python/trunk/Doc/library/urllib2.rst Sun Oct 18 03:58:45 2009 @@ -195,7 +195,7 @@ :envvar:`_proxy`. If no proxy environment variables are set, in a Windows environment, proxy settings are obtained from the registry's Internet Settings section and in a Mac OS X environment, proxy information - is retrieved from from the OS X System Configuration Framework. + is retrieved from the OS X System Configuration Framework. To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 04:01:06 2009 From: python-checkins at python.org (senthil.kumaran) Date: Sun, 18 Oct 2009 02:01:06 -0000 Subject: [Python-checkins] r75479 - in python/branches/release26-maint: Doc/library/urllib2.rst Message-ID: Author: senthil.kumaran Date: Sun Oct 18 04:01:06 2009 New Revision: 75479 Log: Merged revisions 75478 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75478 | senthil.kumaran | 2009-10-18 07:28:45 +0530 (Sun, 18 Oct 2009) | 3 lines Fix a typo. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/urllib2.rst 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 Sun Oct 18 04:01:06 2009 @@ -195,7 +195,7 @@ :envvar:`_proxy`. If no proxy environment variables are set, in a Windows environment, proxy settings are obtained from the registry's Internet Settings section and in a Mac OS X environment, proxy information - is retrieved from from the OS X System Configuration Framework. + is retrieved from the OS X System Configuration Framework. To disable autodetected proxy pass an empty dictionary. From python-checkins at python.org Sun Oct 18 07:03:16 2009 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 18 Oct 2009 05:03:16 -0000 Subject: [Python-checkins] r75480 - python/branches/release26-maint/Tools/msi/uuids.py Message-ID: Author: martin.v.loewis Date: Sun Oct 18 07:03:16 2009 New Revision: 75480 Log: Add 2.6.4c2 and 2.6.5[c1]. Modified: python/branches/release26-maint/Tools/msi/uuids.py Modified: python/branches/release26-maint/Tools/msi/uuids.py ============================================================================== --- python/branches/release26-maint/Tools/msi/uuids.py (original) +++ python/branches/release26-maint/Tools/msi/uuids.py Sun Oct 18 07:03:16 2009 @@ -53,5 +53,8 @@ '2.6.3121':'{a73e0254-dcda-4fe4-bf37-c7e1c4f4ebb6}', # 2.6.3c1 '2.6.3150':'{3d9ac095-e115-4e94-bdef-7f7edf17697d}', # 2.6.3 '2.6.4121':'{727de605-0359-4606-a94b-c2033652379b}', # 2.6.4c1 + '2.6.4122':'{4f7603c6-6352-4299-a398-150a31b19acc}', # 2.6.4c2 '2.6.4150':'{e7394a0f-3f80-45b1-87fc-abcd51893246}', # 2.6.4 + '2.6.5121':'{e0e273d7-7598-4701-8325-c90c069fd5ff}', # 2.6.5c1 + '2.6.5150':'{4723f199-fa64-4233-8e6e-9fccc95a18ee}', # 2.6.5 } From python-checkins at python.org Sun Oct 18 07:38:48 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 05:38:48 -0000 Subject: [Python-checkins] r75481 - in python/trunk/Lib/test: test_imp.py test_import.py Message-ID: Author: nick.coghlan Date: Sun Oct 18 07:38:48 2009 New Revision: 75481 Log: Using CleanImport to revert a reload of the os module doesn't work due to function registrations in copy_reg. The perils of reloading modules even for tests... Modified: python/trunk/Lib/test/test_imp.py python/trunk/Lib/test/test_import.py Modified: python/trunk/Lib/test/test_imp.py ============================================================================== --- python/trunk/Lib/test/test_imp.py (original) +++ python/trunk/Lib/test/test_imp.py Sun Oct 18 07:38:48 2009 @@ -43,7 +43,14 @@ reload().""" def test_source(self): - with test_support.CleanImport('os'): + # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # here, but that breaks because the os module registers some + # handlers in copy_reg on import. Since CleanImport doesn't + # revert that registration, the module is left in a broken + # state after reversion. Reinitialising the module contents + # and just reverting os.environ to its previous state is an OK + # workaround + with test_support.EnvironmentVarGuard(): import os imp.reload(os) Modified: python/trunk/Lib/test/test_import.py ============================================================================== --- python/trunk/Lib/test/test_import.py (original) +++ python/trunk/Lib/test/test_import.py Sun Oct 18 07:38:48 2009 @@ -8,7 +8,7 @@ import warnings import marshal from test.test_support import (unlink, TESTFN, unload, run_unittest, - check_warnings, TestFailed, CleanImport) + check_warnings, TestFailed, EnvironmentVarGuard) def remove_files(name): @@ -121,10 +121,22 @@ def testImpModule(self): # Verify that the imp module can correctly load and find .py files - import imp - with CleanImport("os"): + import imp, os + # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # here, but that breaks because the os module registers some + # handlers in copy_reg on import. Since CleanImport doesn't + # revert that registration, the module is left in a broken + # state after reversion. Reinitialising the module contents + # and just reverting os.environ to its previous state is an OK + # workaround + orig_path = os.path + orig_getenv = os.getenv + with EnvironmentVarGuard(): x = imp.find_module("os") - os = imp.load_module("os", *x) + new_os = imp.load_module("os", *x) + self.assertIs(os, new_os) + self.assertIs(orig_path, new_os.path) + self.assertIsNot(orig_getenv, new_os.getenv) def test_module_with_large_stack(self, module='longlist'): # create module w/list of 65000 elements to test bug #561858 From python-checkins at python.org Sun Oct 18 09:07:01 2009 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 18 Oct 2009 07:07:01 -0000 Subject: [Python-checkins] r75482 - in python/trunk: Lib/urllib.py Misc/NEWS Message-ID: Author: ronald.oussoren Date: Sun Oct 18 09:07:00 2009 New Revision: 75482 Log: Fix for issue 7149: a regression in 2.6.3 that causes an exception when trying to detect proxy settings on OSX. Modified: python/trunk/Lib/urllib.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/urllib.py ============================================================================== --- python/trunk/Lib/urllib.py (original) +++ python/trunk/Lib/urllib.py Sun Oct 18 09:07:00 2009 @@ -1340,6 +1340,8 @@ import socket from fnmatch import fnmatch + hostonly, port = splitport(host) + def ip2num(ipAddr): parts = ipAddr.split('.') parts = map(int, parts) @@ -1354,6 +1356,8 @@ if proxy_settings['exclude_simple']: return True + hostIP = None + for value in proxy_settings.get('exceptions', ()): # Items in the list are strings like these: *.local, 169.254/16 if not value: continue @@ -1361,8 +1365,11 @@ m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value) if m is not None: if hostIP is None: - hostIP = socket.gethostbyname(host) - hostIP = ip2num(hostIP) + try: + hostIP = socket.gethostbyname(hostonly) + hostIP = ip2num(hostIP) + except socket.error: + continue base = ip2num(m.group(1)) mask = int(m.group(2)[1:]) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 18 09:07:00 2009 @@ -411,6 +411,8 @@ Library ------- +- Issue #7149: urllib fails on OSX in the proxy detection code + - Issue #7069: Make inspect.isabstract() return a boolean. - Add support to the `ihooks` module for relative imports. From python-checkins at python.org Sun Oct 18 09:08:27 2009 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 18 Oct 2009 07:08:27 -0000 Subject: [Python-checkins] r75483 - in python/branches/release26-maint: Lib/urllib.py Misc/NEWS Message-ID: Author: ronald.oussoren Date: Sun Oct 18 09:08:27 2009 New Revision: 75483 Log: Merged revisions 75482 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75482 | ronald.oussoren | 2009-10-18 09:07:00 +0200 (Sun, 18 Oct 2009) | 3 lines Fix for issue 7149: a regression in 2.6.3 that causes an exception when trying to detect proxy settings on OSX. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/urllib.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/urllib.py ============================================================================== --- python/branches/release26-maint/Lib/urllib.py (original) +++ python/branches/release26-maint/Lib/urllib.py Sun Oct 18 09:08:27 2009 @@ -1344,6 +1344,8 @@ import socket from fnmatch import fnmatch + hostonly, port = splitport(host) + def ip2num(ipAddr): parts = ipAddr.split('.') parts = map(int, parts) @@ -1358,6 +1360,8 @@ if proxy_settings['exclude_simple']: return True + hostIP = None + for value in proxy_settings.get('exceptions', ()): # Items in the list are strings like these: *.local, 169.254/16 if not value: continue @@ -1365,8 +1369,11 @@ m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value) if m is not None: if hostIP is None: - hostIP = socket.gethostbyname(host) - hostIP = ip2num(hostIP) + try: + hostIP = socket.gethostbyname(hostonly) + hostIP = ip2num(hostIP) + except socket.error: + continue base = ip2num(m.group(1)) mask = int(m.group(2)[1:]) Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Oct 18 09:08:27 2009 @@ -18,6 +18,8 @@ Library ------- +- Issue #7149: fix exception in urllib when detecting proxy settings on OSX. + - Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. From python-checkins at python.org Sun Oct 18 09:58:13 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 18 Oct 2009 07:58:13 -0000 Subject: [Python-checkins] r75484 - python/trunk/Doc/library/os.rst Message-ID: Author: georg.brandl Date: Sun Oct 18 09:58:12 2009 New Revision: 75484 Log: Fix missing word. Modified: python/trunk/Doc/library/os.rst Modified: python/trunk/Doc/library/os.rst ============================================================================== --- python/trunk/Doc/library/os.rst (original) +++ python/trunk/Doc/library/os.rst Sun Oct 18 09:58:12 2009 @@ -1837,7 +1837,7 @@ Execute the command (a string) in a subshell. This is implemented by calling the Standard C function :cfunc:`system`, and has the same limitations. - Changes :data:`sys.stdin`, etc. are not reflected in the environment of the + Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the executed command. On Unix, the return value is the exit status of the process encoded in the From python-checkins at python.org Sun Oct 18 11:28:26 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 18 Oct 2009 09:28:26 -0000 Subject: [Python-checkins] r75485 - in python/trunk/Lib/distutils/tests: support.py test_bdist_dumb.py test_bdist_rpm.py test_build_ext.py test_config.py test_core.py test_dist.py test_install.py test_install_data.py test_install_headers.py test_install_lib.py test_sysconfig.py test_util.py Message-ID: Author: tarek.ziade Date: Sun Oct 18 11:28:26 2009 New Revision: 75485 Log: Changed distutils tests to avoid environment alteration Modified: python/trunk/Lib/distutils/tests/support.py python/trunk/Lib/distutils/tests/test_bdist_dumb.py python/trunk/Lib/distutils/tests/test_bdist_rpm.py python/trunk/Lib/distutils/tests/test_build_ext.py python/trunk/Lib/distutils/tests/test_config.py python/trunk/Lib/distutils/tests/test_core.py python/trunk/Lib/distutils/tests/test_dist.py python/trunk/Lib/distutils/tests/test_install.py python/trunk/Lib/distutils/tests/test_install_data.py python/trunk/Lib/distutils/tests/test_install_headers.py python/trunk/Lib/distutils/tests/test_install_lib.py python/trunk/Lib/distutils/tests/test_sysconfig.py python/trunk/Lib/distutils/tests/test_util.py Modified: python/trunk/Lib/distutils/tests/support.py ============================================================================== --- python/trunk/Lib/distutils/tests/support.py (original) +++ python/trunk/Lib/distutils/tests/support.py Sun Oct 18 11:28:26 2009 @@ -2,11 +2,11 @@ import os import shutil import tempfile +from copy import deepcopy from distutils import log from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL from distutils.core import Distribution -from test.test_support import EnvironmentVarGuard class LoggingSilencer(object): @@ -111,8 +111,15 @@ def setUp(self): super(EnvironGuard, self).setUp() - self.environ = EnvironmentVarGuard() + self.old_environ = deepcopy(os.environ) def tearDown(self): - self.environ.__exit__() + for key, value in self.old_environ.items(): + if os.environ.get(key) != value: + os.environ[key] = value + + for key in os.environ.keys(): + if key not in self.old_environ: + del os.environ[key] + super(EnvironGuard, self).tearDown() Modified: python/trunk/Lib/distutils/tests/test_bdist_dumb.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_dumb.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_dumb.py Sun Oct 18 11:28:26 2009 @@ -26,16 +26,18 @@ class BuildDumbTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(BuildDumbTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildDumbTestCase, self).tearDown() @unittest.skipUnless(zlib, "requires zlib") Modified: python/trunk/Lib/distutils/tests/test_bdist_rpm.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_bdist_rpm.py (original) +++ python/trunk/Lib/distutils/tests/test_bdist_rpm.py Sun Oct 18 11:28:26 2009 @@ -29,11 +29,12 @@ def setUp(self): super(BuildRpmTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildRpmTestCase, self).tearDown() def test_quiet(self): Modified: python/trunk/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_build_ext.py (original) +++ python/trunk/Lib/distutils/tests/test_build_ext.py Sun Oct 18 11:28:26 2009 @@ -34,7 +34,7 @@ # Note that we're making changes to sys.path super(BuildExtTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.sys_path = sys.path[:] + self.sys_path = sys.path, sys.path[:] sys.path.append(self.tmp_dir) shutil.copy(_get_source_filename(), self.tmp_dir) if sys.version > "2.6": @@ -89,7 +89,8 @@ def tearDown(self): # Get everything back to normal test_support.unload('xx') - sys.path = self.sys_path + sys.path = self.sys_path[0] + sys.path[:] = self.sys_path[1] if sys.version > "2.6": import site site.USER_BASE = self.old_user_base Modified: python/trunk/Lib/distutils/tests/test_config.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_config.py (original) +++ python/trunk/Lib/distutils/tests/test_config.py Sun Oct 18 11:28:26 2009 @@ -56,7 +56,7 @@ """Patches the environment.""" super(PyPIRCCommandTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.environ['HOME'] = self.tmp_dir + os.environ['HOME'] = self.tmp_dir self.rc = os.path.join(self.tmp_dir, '.pypirc') self.dist = Distribution() Modified: python/trunk/Lib/distutils/tests/test_core.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_core.py (original) +++ python/trunk/Lib/distutils/tests/test_core.py Sun Oct 18 11:28:26 2009 @@ -8,7 +8,7 @@ import test.test_support from test.test_support import captured_stdout import unittest - +from distutils.tests import support # setup script that uses __file__ setup_using___file__ = """\ @@ -29,17 +29,20 @@ """ -class CoreTestCase(unittest.TestCase): +class CoreTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): + super(CoreTestCase, self).setUp() self.old_stdout = sys.stdout self.cleanup_testfn() - self.old_argv = sys.argv[:] + self.old_argv = sys.argv, sys.argv[:] def tearDown(self): sys.stdout = self.old_stdout self.cleanup_testfn() - sys.argv = self.old_argv[:] + sys.argv = self.old_argv[0] + sys.argv[:] = self.old_argv[1] + super(CoreTestCase, self).tearDown() def cleanup_testfn(self): path = test.test_support.TESTFN Modified: python/trunk/Lib/distutils/tests/test_dist.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_dist.py (original) +++ python/trunk/Lib/distutils/tests/test_dist.py Sun Oct 18 11:28:26 2009 @@ -39,15 +39,17 @@ class DistributionTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(DistributionTestCase, self).setUp() - self.argv = sys.argv[:] + self.argv = sys.argv, sys.argv[:] del sys.argv[1:] def tearDown(self): - sys.argv[:] = self.argv + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] super(DistributionTestCase, self).tearDown() def create_distribution(self, configfiles=()): @@ -210,6 +212,15 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): + def setUp(self): + super(MetadataTestCase, self).setUp() + self.argv = sys.argv, sys.argv[:] + + def tearDown(self): + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] + super(MetadataTestCase, self).tearDown() + def test_simple_metadata(self): attrs = {"name": "package", "version": "1.0"} @@ -308,14 +319,14 @@ # linux-style if sys.platform in ('linux', 'darwin'): - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files) # win32-style if sys.platform == 'win32': # home drive should be found - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files, '%r not found in %r' % (user_filename, files)) @@ -331,15 +342,11 @@ def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() - old_argv = sys.argv sys.argv = [] - try: - dist.help = 1 - dist.script_name = 'setup.py' - with captured_stdout() as s: - dist.parse_command_line() - finally: - sys.argv = old_argv + dist.help = 1 + dist.script_name = 'setup.py' + with captured_stdout() as s: + dist.parse_command_line() output = [line for line in s.getvalue().split('\n') if line.strip() != ''] Modified: python/trunk/Lib/distutils/tests/test_install.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install.py (original) +++ python/trunk/Lib/distutils/tests/test_install.py Sun Oct 18 11:28:26 2009 @@ -17,6 +17,7 @@ from distutils.tests import support class InstallTestCase(support.TempdirManager, + support.EnvironGuard, support.LoggingSilencer, unittest.TestCase): Modified: python/trunk/Lib/distutils/tests/test_install_data.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install_data.py (original) +++ python/trunk/Lib/distutils/tests/test_install_data.py Sun Oct 18 11:28:26 2009 @@ -9,6 +9,7 @@ class InstallDataTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/trunk/Lib/distutils/tests/test_install_headers.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install_headers.py (original) +++ python/trunk/Lib/distutils/tests/test_install_headers.py Sun Oct 18 11:28:26 2009 @@ -9,6 +9,7 @@ class InstallHeadersTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/trunk/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install_lib.py (original) +++ python/trunk/Lib/distutils/tests/test_install_lib.py Sun Oct 18 11:28:26 2009 @@ -10,9 +10,9 @@ class InstallLibTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): - def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) Modified: python/trunk/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_sysconfig.py (original) +++ python/trunk/Lib/distutils/tests/test_sysconfig.py Sun Oct 18 11:28:26 2009 @@ -17,8 +17,16 @@ def tearDown(self): if self.makefile is not None: os.unlink(self.makefile) + self.cleanup_testfn() super(SysconfigTestCase, self).tearDown() + def cleanup_testfn(self): + path = test.test_support.TESTFN + if os.path.isfile(path): + os.remove(path) + elif os.path.isdir(path): + shutil.rmtree(path) + def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() self.assertTrue(os.path.isfile(config_h), config_h) @@ -51,8 +59,8 @@ if get_default_compiler() != 'unix': return - self.environ['AR'] = 'my_ar' - self.environ['ARFLAGS'] = '-arflags' + os.environ['AR'] = 'my_ar' + os.environ['ARFLAGS'] = '-arflags' # make sure AR gets caught class compiler: Modified: python/trunk/Lib/distutils/tests/test_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_util.py (original) +++ python/trunk/Lib/distutils/tests/test_util.py Sun Oct 18 11:28:26 2009 @@ -121,7 +121,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') @@ -129,7 +129,7 @@ self.assertEquals(get_platform(), 'macosx-10.3-i386') # macbook with fat binaries (fat, universal or fat64) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -250,17 +250,18 @@ def test_check_environ(self): util._environ_checked = 0 + if 'HOME' in os.environ: + del os.environ['HOME'] # posix without HOME if os.name == 'posix': # this test won't run on windows check_environ() import pwd - self.assertEquals(self.environ['HOME'], - pwd.getpwuid(os.getuid())[5]) + self.assertEquals(os.environ['HOME'], pwd.getpwuid(os.getuid())[5]) else: check_environ() - self.assertEquals(self.environ['PLAT'], get_platform()) + self.assertEquals(os.environ['PLAT'], get_platform()) self.assertEquals(util._environ_checked, 1) def test_split_quoted(self): From nnorwitz at gmail.com Sun Oct 18 11:51:51 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 18 Oct 2009 05:51:51 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091018095151.GA7172@python.psfb.org> More important issues: ---------------------- test_warnings leaked [0, 0, 60] references, sum=60 Less important issues: ---------------------- test_asynchat leaked [0, 0, 132] references, sum=132 test_file2k leaked [80, -80, 0] references, sum=0 test_smtplib leaked [88, -88, 88] references, sum=88 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [280, -280, 0] references, sum=0 From ziade.tarek at gmail.com Sun Oct 18 12:16:31 2009 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Sun, 18 Oct 2009 12:16:31 +0200 Subject: [Python-checkins] Problem with py3k folder property Message-ID: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> Hey Senthil, There's something broken in the properties in the py3k branch. I've tried to merge a commit and I had: $ svnmerge.py merge -i -n -r75485 Traceback (most recent call last): File "/usr/sbin/svnmerge.py", line 2366, in main(sys.argv[1:]) File "/usr/sbin/svnmerge.py", line 2358, in main opts["source-pathid"]) File "/usr/sbin/svnmerge.py", line 828, in merge_props_to_revision_set return RevisionSet(merge_props[pathid]) File "/usr/sbin/svnmerge.py", line 749, in __init__ self._revs[int(rev_or_revs[0])] = 1 ValueError: invalid literal for int() with base 10: '75470>>>>>>>' Looks like the property contains now a unresolved conflict, it seems to happen at rev. 75476 $ svn di -r75475:75476 . <... shows the problem here ...> Regards Tarek -- Tarek Ziad? | http://ziade.org |????????????! |???????????? From nnorwitz at gmail.com Sun Oct 18 12:19:29 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 18 Oct 2009 06:19:29 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091018101929.GA16903@python.psfb.org> 344 tests OK. 1 test failed: test_ssl 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-7180 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler testCompileLibrary still working, be patient... test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.argv was modified by test_distutils Warning -- sys.stdout was modified by test_distutils Warning -- os.environ was modified by test_distutils Warning -- sys.path was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [21132 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net /tmp/python-test/local/lib/python2.7/test/test_urllib2net.py:181: DeprecationWarning: With-statements now directly support multiple context managers with test_support.transient_internet(): test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_ssl 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [894927 refs] From ziade.tarek at gmail.com Sun Oct 18 12:23:24 2009 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Sun, 18 Oct 2009 12:23:24 +0200 Subject: [Python-checkins] Problem with py3k folder property In-Reply-To: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> References: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> Message-ID: <94bdd2610910180323p5a696a9cv64cb7c77bd446c7e@mail.gmail.com> On Sun, Oct 18, 2009 at 12:16 PM, Tarek Ziad? wrote: > Looks like the property contains now a unresolved conflict, it seems > to happen at rev. 75476 s/75475/75476 From python-checkins at python.org Sun Oct 18 12:29:10 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 10:29:10 -0000 Subject: [Python-checkins] r75486 - python/trunk/Lib/test/test_support.py Message-ID: Author: nick.coghlan Date: Sun Oct 18 12:29:10 2009 New Revision: 75486 Log: Silence a deprecation warning by using the appropriate replacement construct Modified: python/trunk/Lib/test/test_support.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Sun Oct 18 12:29:10 2009 @@ -630,13 +630,15 @@ raise ResourceDenied("an optional resource is not available") + at contextlib.contextmanager def transient_internet(): """Return a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.""" time_out = TransientResource(IOError, errno=errno.ETIMEDOUT) socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET) ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET) - return contextlib.nested(time_out, socket_peer_reset, ioerror_peer_reset) + with time_out, socket_peer_reset, ioerror_peer_reset: + yield @contextlib.contextmanager From python-checkins at python.org Sun Oct 18 12:44:15 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 10:44:15 -0000 Subject: [Python-checkins] r75487 - python/branches/py3k Message-ID: Author: nick.coghlan Date: Sun Oct 18 12:44:15 2009 New Revision: 75487 Log: Revert broken commit to svnmerge properties Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sun Oct 18 12:46:43 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 10:46:43 -0000 Subject: [Python-checkins] r75488 - python/branches/py3k Message-ID: Author: nick.coghlan Date: Sun Oct 18 12:46:42 2009 New Revision: 75488 Log: Recorded merge of revisions 75474 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75474 | senthil.kumaran | 2009-10-18 11:24:41 +1000 (Sun, 18 Oct 2009) | 2 lines Fix for Issue7155 - urllib do not document default use of system proxy configuration ........ Modified: python/branches/py3k/ (props changed) From ncoghlan at gmail.com Sun Oct 18 12:52:37 2009 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sun, 18 Oct 2009 20:52:37 +1000 Subject: [Python-checkins] Problem with py3k folder property In-Reply-To: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> References: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> Message-ID: <4ADAF375.8070909@gmail.com> Tarek Ziad? wrote: > Hey Senthil, > > There's something broken in the properties in the py3k branch. Should be OK now (reverted the broken commit and then recorded the merge again). The easiest way to get that kind of problem is by running "svn update" after doing "svnmerge merge". If you make that mistake, it is best to revert everything and start the merge again*. Cheers, Nick. * If you know what you're doing and/or have already made corrections to the merged code that you don't want to lose, you can just revert the property changes on "." and rerun svnmerge in "record only" mode (via the -M switch). -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- From python-checkins at python.org Sun Oct 18 12:56:21 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 10:56:21 -0000 Subject: [Python-checkins] r75489 - python/trunk/Lib/test/test_tk.py Message-ID: Author: nick.coghlan Date: Sun Oct 18 12:56:21 2009 New Revision: 75489 Log: Restore sys.path in test_tk Modified: python/trunk/Lib/test/test_tk.py Modified: python/trunk/Lib/test/test_tk.py ============================================================================== --- python/trunk/Lib/test/test_tk.py (original) +++ python/trunk/Lib/test/test_tk.py Sun Oct 18 12:56:21 2009 @@ -17,10 +17,9 @@ this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, 'lib-tk', 'test')) -if lib_tk_test not in sys.path: - sys.path.append(lib_tk_test) -import runtktests +with test_support.DirsOnSysPath(lib_tk_test): + import runtktests def test_main(enable_gui=False): if enable_gui: @@ -29,7 +28,8 @@ elif 'gui' not in test_support.use_resources: test_support.use_resources.append('gui') - test_support.run_unittest( + with test_support.DirsOnSysPath(lib_tk_test): + test_support.run_unittest( *runtktests.get_tests(text=False, packages=['test_tkinter'])) if __name__ == '__main__': From orsenthil at gmail.com Sun Oct 18 13:13:46 2009 From: orsenthil at gmail.com (Senthil Kumaran) Date: Sun, 18 Oct 2009 16:43:46 +0530 Subject: [Python-checkins] Problem with py3k folder property In-Reply-To: <4ADAF375.8070909@gmail.com> References: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> <4ADAF375.8070909@gmail.com> Message-ID: <20091018111345.GA4470@ubuntu.ubuntu-domain> On Sun, Oct 18, 2009 at 08:52:37PM +1000, Nick Coghlan wrote: > Tarek Ziad? wrote: > > Hey Senthil, > > There's something broken in the properties in the py3k branch. > > Should be OK now (reverted the broken commit and then recorded the merge > again). Thanks Nick and sorry for the trouble, Tarek. > The easiest way to get that kind of problem is by running "svn update" > after doing "svnmerge merge". That was indeed the case (by mistake). I thought, I resolved it as the commit went through fine, looks I screwed it. Shall be careful henceforth. Thanks, Senthil From python-checkins at python.org Sun Oct 18 13:16:20 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 11:16:20 -0000 Subject: [Python-checkins] r75490 - python/branches/release26-maint Message-ID: Author: nick.coghlan Date: Sun Oct 18 13:16:19 2009 New Revision: 75490 Log: Blocked revisions 75453,75456-75458,75461-75463,75465-75468,75481,75486,75489 via svnmerge ........ r75453 | nick.coghlan | 2009-10-17 16:33:05 +1000 (Sat, 17 Oct 2009) | 1 line Correctly restore sys.stdout in test_descr ........ r75456 | nick.coghlan | 2009-10-17 17:30:40 +1000 (Sat, 17 Oct 2009) | 1 line Enhancement to the new environment checking code to print the changed items under -vv. Also includes a small tweak to allow underscores in the names of resources. ........ r75457 | nick.coghlan | 2009-10-17 17:34:27 +1000 (Sat, 17 Oct 2009) | 1 line Formatting tweak so that before and after values are vertically aligned ........ r75458 | nick.coghlan | 2009-10-17 18:21:21 +1000 (Sat, 17 Oct 2009) | 1 line Check and revert expected sys.path alterations ........ r75461 | nick.coghlan | 2009-10-18 00:40:54 +1000 (Sun, 18 Oct 2009) | 1 line Restore original sys.path when running TTK tests ........ r75462 | nick.coghlan | 2009-10-18 01:09:41 +1000 (Sun, 18 Oct 2009) | 1 line Don't invoke reload(sys) and use StringIO objects instead of real files to capture stdin and stdout when needed (ensures all sys attributes remain unmodified after test_xmlrpc runs) ........ r75463 | nick.coghlan | 2009-10-18 01:23:08 +1000 (Sun, 18 Oct 2009) | 1 line Revert changes made to environment in test_httpservers ........ r75465 | nick.coghlan | 2009-10-18 01:45:52 +1000 (Sun, 18 Oct 2009) | 1 line Move restoration of the os.environ object into the context manager where it belongs ........ r75466 | nick.coghlan | 2009-10-18 01:48:16 +1000 (Sun, 18 Oct 2009) | 1 line Also check and restore identity of sys.path, sys.argv and os.environ rather than just their values (this picked up a few more misbehaving tests) ........ r75467 | nick.coghlan | 2009-10-18 01:57:42 +1000 (Sun, 18 Oct 2009) | 1 line Avoid replacing existing modules and sys.path in import tests ........ r75468 | nick.coghlan | 2009-10-18 02:19:51 +1000 (Sun, 18 Oct 2009) | 1 line Don't replace sys.path in test_site ........ r75481 | nick.coghlan | 2009-10-18 15:38:48 +1000 (Sun, 18 Oct 2009) | 1 line Using CleanImport to revert a reload of the os module doesn't work due to function registrations in copy_reg. The perils of reloading modules even for tests... ........ r75486 | nick.coghlan | 2009-10-18 20:29:10 +1000 (Sun, 18 Oct 2009) | 1 line Silence a deprecation warning by using the appropriate replacement construct ........ r75489 | nick.coghlan | 2009-10-18 20:56:21 +1000 (Sun, 18 Oct 2009) | 1 line Restore sys.path in test_tk ........ Modified: python/branches/release26-maint/ (props changed) From ziade.tarek at gmail.com Sun Oct 18 13:23:12 2009 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Sun, 18 Oct 2009 13:23:12 +0200 Subject: [Python-checkins] Problem with py3k folder property In-Reply-To: <20091018111345.GA4470@ubuntu.ubuntu-domain> References: <94bdd2610910180316s1178b8dap80431e7c8aeef3a3@mail.gmail.com> <4ADAF375.8070909@gmail.com> <20091018111345.GA4470@ubuntu.ubuntu-domain> Message-ID: <94bdd2610910180423u7ea0128es66fe4725dfabf724@mail.gmail.com> On Sun, Oct 18, 2009 at 1:13 PM, Senthil Kumaran wrote: > On Sun, Oct 18, 2009 at 08:52:37PM +1000, Nick Coghlan wrote: >> Tarek Ziad? wrote: >> > Hey Senthil, >> > There's something broken in the properties in the py3k branch. >> >> Should be OK now (reverted the broken commit and then recorded the merge >> again). > > Thanks Nick and sorry for the trouble, Tarek. no worries, thanks all ! From python-checkins at python.org Sun Oct 18 13:34:51 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 18 Oct 2009 11:34:51 -0000 Subject: [Python-checkins] r75491 - in python/branches/py3k: Lib/distutils/tests/support.py Lib/distutils/tests/test_bdist_dumb.py Lib/distutils/tests/test_bdist_rpm.py Lib/distutils/tests/test_build_ext.py Lib/distutils/tests/test_config.py Lib/distutils/tests/test_core.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_install.py Lib/distutils/tests/test_install_data.py Lib/distutils/tests/test_install_headers.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_sysconfig.py Lib/distutils/tests/test_util.py Message-ID: Author: tarek.ziade Date: Sun Oct 18 13:34:51 2009 New Revision: 75491 Log: Merged revisions 75485 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75485 | tarek.ziade | 2009-10-18 11:28:26 +0200 (Sun, 18 Oct 2009) | 1 line Changed distutils tests to avoid environment alteration ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/tests/support.py python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py python/branches/py3k/Lib/distutils/tests/test_build_ext.py python/branches/py3k/Lib/distutils/tests/test_config.py python/branches/py3k/Lib/distutils/tests/test_core.py python/branches/py3k/Lib/distutils/tests/test_dist.py python/branches/py3k/Lib/distutils/tests/test_install.py python/branches/py3k/Lib/distutils/tests/test_install_data.py python/branches/py3k/Lib/distutils/tests/test_install_headers.py python/branches/py3k/Lib/distutils/tests/test_install_lib.py python/branches/py3k/Lib/distutils/tests/test_sysconfig.py python/branches/py3k/Lib/distutils/tests/test_util.py Modified: python/branches/py3k/Lib/distutils/tests/support.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/support.py (original) +++ python/branches/py3k/Lib/distutils/tests/support.py Sun Oct 18 13:34:51 2009 @@ -2,11 +2,11 @@ import os import shutil import tempfile +from copy import deepcopy from distutils import log from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL from distutils.core import Distribution -from test.support import EnvironmentVarGuard class LoggingSilencer(object): @@ -111,8 +111,15 @@ def setUp(self): super(EnvironGuard, self).setUp() - self.environ = EnvironmentVarGuard() + self.old_environ = deepcopy(os.environ) def tearDown(self): - self.environ.__exit__() + for key, value in self.old_environ.items(): + if os.environ.get(key) != value: + os.environ[key] = value + + for key in tuple(os.environ.keys()): + if key not in self.old_environ: + del os.environ[key] + super(EnvironGuard, self).tearDown() Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py Sun Oct 18 13:34:51 2009 @@ -26,16 +26,18 @@ class BuildDumbTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(BuildDumbTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildDumbTestCase, self).tearDown() @unittest.skipUnless(zlib, "requires zlib") Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py Sun Oct 18 13:34:51 2009 @@ -29,11 +29,12 @@ def setUp(self): super(BuildRpmTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildRpmTestCase, self).tearDown() def test_quiet(self): Modified: python/branches/py3k/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_build_ext.py Sun Oct 18 13:34:51 2009 @@ -35,7 +35,7 @@ # Note that we're making changes to sys.path super(BuildExtTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.sys_path = sys.path[:] + self.sys_path = sys.path, sys.path[:] sys.path.append(self.tmp_dir) shutil.copy(_get_source_filename(), self.tmp_dir) if sys.version > "2.6": @@ -90,7 +90,8 @@ def tearDown(self): # Get everything back to normal support.unload('xx') - sys.path = self.sys_path + sys.path = self.sys_path[0] + sys.path[:] = self.sys_path[1] if sys.version > "2.6": import site site.USER_BASE = self.old_user_base Modified: python/branches/py3k/Lib/distutils/tests/test_config.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_config.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_config.py Sun Oct 18 13:34:51 2009 @@ -55,7 +55,7 @@ """Patches the environment.""" super(PyPIRCCommandTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.environ['HOME'] = self.tmp_dir + os.environ['HOME'] = self.tmp_dir self.rc = os.path.join(self.tmp_dir, '.pypirc') self.dist = Distribution() Modified: python/branches/py3k/Lib/distutils/tests/test_core.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_core.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_core.py Sun Oct 18 13:34:51 2009 @@ -8,7 +8,7 @@ import test.support from test.support import captured_stdout import unittest - +from distutils.tests import support # setup script that uses __file__ setup_using___file__ = """\ @@ -29,17 +29,20 @@ """ -class CoreTestCase(unittest.TestCase): +class CoreTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): + super(CoreTestCase, self).setUp() self.old_stdout = sys.stdout self.cleanup_testfn() - self.old_argv = sys.argv[:] + self.old_argv = sys.argv, sys.argv[:] def tearDown(self): sys.stdout = self.old_stdout self.cleanup_testfn() - sys.argv = self.old_argv[:] + sys.argv = self.old_argv[0] + sys.argv[:] = self.old_argv[1] + super(CoreTestCase, self).tearDown() def cleanup_testfn(self): path = test.support.TESTFN Modified: python/branches/py3k/Lib/distutils/tests/test_dist.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_dist.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_dist.py Sun Oct 18 13:34:51 2009 @@ -38,15 +38,17 @@ class DistributionTestCase(support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(DistributionTestCase, self).setUp() - self.argv = sys.argv[:] + self.argv = sys.argv, sys.argv[:] del sys.argv[1:] def tearDown(self): - sys.argv[:] = self.argv + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] super(DistributionTestCase, self).tearDown() def create_distribution(self, configfiles=()): @@ -181,6 +183,15 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): + def setUp(self): + super(MetadataTestCase, self).setUp() + self.argv = sys.argv, sys.argv[:] + + def tearDown(self): + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] + super(MetadataTestCase, self).tearDown() + def test_simple_metadata(self): attrs = {"name": "package", "version": "1.0"} @@ -279,14 +290,14 @@ # linux-style if sys.platform in ('linux', 'darwin'): - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files) # win32-style if sys.platform == 'win32': # home drive should be found - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files, '%r not found in %r' % (user_filename, files)) @@ -302,15 +313,11 @@ def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() - old_argv = sys.argv sys.argv = [] - try: - dist.help = 1 - dist.script_name = 'setup.py' - with captured_stdout() as s: - dist.parse_command_line() - finally: - sys.argv = old_argv + dist.help = 1 + dist.script_name = 'setup.py' + with captured_stdout() as s: + dist.parse_command_line() output = [line for line in s.getvalue().split('\n') if line.strip() != ''] Modified: python/branches/py3k/Lib/distutils/tests/test_install.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_install.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_install.py Sun Oct 18 13:34:51 2009 @@ -17,6 +17,7 @@ from distutils.tests import support class InstallTestCase(support.TempdirManager, + support.EnvironGuard, support.LoggingSilencer, unittest.TestCase): Modified: python/branches/py3k/Lib/distutils/tests/test_install_data.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_install_data.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_install_data.py Sun Oct 18 13:34:51 2009 @@ -9,6 +9,7 @@ class InstallDataTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/branches/py3k/Lib/distutils/tests/test_install_headers.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_install_headers.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_install_headers.py Sun Oct 18 13:34:51 2009 @@ -9,6 +9,7 @@ class InstallHeadersTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/branches/py3k/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_install_lib.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_install_lib.py Sun Oct 18 13:34:51 2009 @@ -10,9 +10,9 @@ class InstallLibTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): - def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py Sun Oct 18 13:34:51 2009 @@ -17,8 +17,15 @@ def tearDown(self): if self.makefile is not None: os.unlink(self.makefile) + self.cleanup_testfn() super(SysconfigTestCase, self).tearDown() + def cleanup_testfn(self): + if os.path.isfile(TESTFN): + os.remove(TESTFN) + elif os.path.isdir(TESTFN): + shutil.rmtree(TESTFN) + def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() self.assertTrue(os.path.isfile(config_h), config_h) @@ -51,8 +58,8 @@ if get_default_compiler() != 'unix': return - self.environ['AR'] = 'my_ar' - self.environ['ARFLAGS'] = '-arflags' + os.environ['AR'] = 'my_ar' + os.environ['ARFLAGS'] = '-arflags' # make sure AR gets caught class compiler: Modified: python/branches/py3k/Lib/distutils/tests/test_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_util.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_util.py Sun Oct 18 13:34:51 2009 @@ -121,7 +121,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') @@ -129,7 +129,7 @@ self.assertEquals(get_platform(), 'macosx-10.3-i386') # macbook with fat binaries (fat, universal or fat64) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -250,17 +250,18 @@ def test_check_environ(self): util._environ_checked = 0 + if 'HOME' in os.environ: + del os.environ['HOME'] # posix without HOME if os.name == 'posix': # this test won't run on windows check_environ() import pwd - self.assertEquals(self.environ['HOME'], - pwd.getpwuid(os.getuid())[5]) + self.assertEquals(os.environ['HOME'], pwd.getpwuid(os.getuid())[5]) else: check_environ() - self.assertEquals(self.environ['PLAT'], get_platform()) + self.assertEquals(os.environ['PLAT'], get_platform()) self.assertEquals(util._environ_checked, 1) def test_split_quoted(self): From python-checkins at python.org Sun Oct 18 14:41:31 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 18 Oct 2009 12:41:31 -0000 Subject: [Python-checkins] r75492 - in python/branches/release31-maint: Lib/distutils/tests/support.py Lib/distutils/tests/test_bdist_dumb.py Lib/distutils/tests/test_bdist_rpm.py Lib/distutils/tests/test_build_ext.py Lib/distutils/tests/test_config.py Lib/distutils/tests/test_core.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_install.py Lib/distutils/tests/test_install_data.py Lib/distutils/tests/test_install_headers.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_sysconfig.py Lib/distutils/tests/test_util.py Message-ID: Author: tarek.ziade Date: Sun Oct 18 14:41:30 2009 New Revision: 75492 Log: Merged revisions 75491 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75491 | tarek.ziade | 2009-10-18 13:34:51 +0200 (Sun, 18 Oct 2009) | 9 lines Merged revisions 75485 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75485 | tarek.ziade | 2009-10-18 11:28:26 +0200 (Sun, 18 Oct 2009) | 1 line Changed distutils tests to avoid environment alteration ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/distutils/tests/support.py python/branches/release31-maint/Lib/distutils/tests/test_bdist_dumb.py python/branches/release31-maint/Lib/distutils/tests/test_bdist_rpm.py python/branches/release31-maint/Lib/distutils/tests/test_build_ext.py python/branches/release31-maint/Lib/distutils/tests/test_config.py python/branches/release31-maint/Lib/distutils/tests/test_core.py python/branches/release31-maint/Lib/distutils/tests/test_dist.py python/branches/release31-maint/Lib/distutils/tests/test_install.py python/branches/release31-maint/Lib/distutils/tests/test_install_data.py python/branches/release31-maint/Lib/distutils/tests/test_install_headers.py python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py python/branches/release31-maint/Lib/distutils/tests/test_sysconfig.py python/branches/release31-maint/Lib/distutils/tests/test_util.py Modified: python/branches/release31-maint/Lib/distutils/tests/support.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/support.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/support.py Sun Oct 18 14:41:30 2009 @@ -2,11 +2,11 @@ import os import shutil import tempfile +from copy import deepcopy from distutils import log from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL from distutils.core import Distribution -from test.support import EnvironmentVarGuard class LoggingSilencer(object): @@ -111,8 +111,15 @@ def setUp(self): super(EnvironGuard, self).setUp() - self.environ = EnvironmentVarGuard() + self.old_environ = deepcopy(os.environ) def tearDown(self): - self.environ.__exit__() + for key, value in self.old_environ.items(): + if os.environ.get(key) != value: + os.environ[key] = value + + for key in tuple(os.environ.keys()): + if key not in self.old_environ: + del os.environ[key] + super(EnvironGuard, self).tearDown() Modified: python/branches/release31-maint/Lib/distutils/tests/test_bdist_dumb.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_bdist_dumb.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_bdist_dumb.py Sun Oct 18 14:41:30 2009 @@ -19,16 +19,18 @@ class BuildDumbTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(BuildDumbTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildDumbTestCase, self).tearDown() def test_simple_built(self): Modified: python/branches/release31-maint/Lib/distutils/tests/test_bdist_rpm.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_bdist_rpm.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_bdist_rpm.py Sun Oct 18 14:41:30 2009 @@ -29,11 +29,12 @@ def setUp(self): super(BuildRpmTestCase, self).setUp() self.old_location = os.getcwd() - self.old_sys_argv = sys.argv[:] + self.old_sys_argv = sys.argv, sys.argv[:] def tearDown(self): os.chdir(self.old_location) - sys.argv = self.old_sys_argv[:] + sys.argv = self.old_sys_argv[0] + sys.argv[:] = self.old_sys_argv[1] super(BuildRpmTestCase, self).tearDown() def test_quiet(self): Modified: python/branches/release31-maint/Lib/distutils/tests/test_build_ext.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_build_ext.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_build_ext.py Sun Oct 18 14:41:30 2009 @@ -32,7 +32,7 @@ # Note that we're making changes to sys.path super(BuildExtTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.sys_path = sys.path[:] + self.sys_path = sys.path, sys.path[:] sys.path.append(self.tmp_dir) shutil.copy(_get_source_filename(), self.tmp_dir) if sys.version > "2.6": @@ -87,7 +87,8 @@ def tearDown(self): # Get everything back to normal support.unload('xx') - sys.path = self.sys_path + sys.path = self.sys_path[0] + sys.path[:] = self.sys_path[1] if sys.version > "2.6": import site site.USER_BASE = self.old_user_base Modified: python/branches/release31-maint/Lib/distutils/tests/test_config.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_config.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_config.py Sun Oct 18 14:41:30 2009 @@ -55,7 +55,7 @@ """Patches the environment.""" super(PyPIRCCommandTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - self.environ['HOME'] = self.tmp_dir + os.environ['HOME'] = self.tmp_dir self.rc = os.path.join(self.tmp_dir, '.pypirc') self.dist = Distribution() Modified: python/branches/release31-maint/Lib/distutils/tests/test_core.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_core.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_core.py Sun Oct 18 14:41:30 2009 @@ -8,7 +8,7 @@ import test.support from test.support import captured_stdout import unittest - +from distutils.tests import support # setup script that uses __file__ setup_using___file__ = """\ @@ -29,17 +29,20 @@ """ -class CoreTestCase(unittest.TestCase): +class CoreTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): + super(CoreTestCase, self).setUp() self.old_stdout = sys.stdout self.cleanup_testfn() - self.old_argv = sys.argv[:] + self.old_argv = sys.argv, sys.argv[:] def tearDown(self): sys.stdout = self.old_stdout self.cleanup_testfn() - sys.argv = self.old_argv[:] + sys.argv = self.old_argv[0] + sys.argv[:] = self.old_argv[1] + super(CoreTestCase, self).tearDown() def cleanup_testfn(self): path = test.support.TESTFN Modified: python/branches/release31-maint/Lib/distutils/tests/test_dist.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_dist.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_dist.py Sun Oct 18 14:41:30 2009 @@ -37,15 +37,17 @@ class DistributionTestCase(support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def setUp(self): super(DistributionTestCase, self).setUp() - self.argv = sys.argv[:] + self.argv = sys.argv, sys.argv[:] del sys.argv[1:] def tearDown(self): - sys.argv[:] = self.argv + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] super(DistributionTestCase, self).tearDown() def create_distribution(self, configfiles=()): @@ -159,6 +161,15 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): + def setUp(self): + super(MetadataTestCase, self).setUp() + self.argv = sys.argv, sys.argv[:] + + def tearDown(self): + sys.argv = self.argv[0] + sys.argv[:] = self.argv[1] + super(MetadataTestCase, self).tearDown() + def test_simple_metadata(self): attrs = {"name": "package", "version": "1.0"} @@ -257,14 +268,14 @@ # linux-style if sys.platform in ('linux', 'darwin'): - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files) # win32-style if sys.platform == 'win32': # home drive should be found - self.environ['HOME'] = temp_dir + os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertTrue(user_filename in files, '%r not found in %r' % (user_filename, files)) @@ -280,15 +291,11 @@ def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() - old_argv = sys.argv sys.argv = [] - try: - dist.help = 1 - dist.script_name = 'setup.py' - with captured_stdout() as s: - dist.parse_command_line() - finally: - sys.argv = old_argv + dist.help = 1 + dist.script_name = 'setup.py' + with captured_stdout() as s: + dist.parse_command_line() output = [line for line in s.getvalue().split('\n') if line.strip() != ''] Modified: python/branches/release31-maint/Lib/distutils/tests/test_install.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_install.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_install.py Sun Oct 18 14:41:30 2009 @@ -17,6 +17,7 @@ from distutils.tests import support class InstallTestCase(support.TempdirManager, + support.EnvironGuard, support.LoggingSilencer, unittest.TestCase): Modified: python/branches/release31-maint/Lib/distutils/tests/test_install_data.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_install_data.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_install_data.py Sun Oct 18 14:41:30 2009 @@ -9,6 +9,7 @@ class InstallDataTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/branches/release31-maint/Lib/distutils/tests/test_install_headers.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_install_headers.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_install_headers.py Sun Oct 18 14:41:30 2009 @@ -9,6 +9,7 @@ class InstallHeadersTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): def test_simple_run(self): Modified: python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py Sun Oct 18 14:41:30 2009 @@ -10,9 +10,9 @@ class InstallLibTestCase(support.TempdirManager, support.LoggingSilencer, + support.EnvironGuard, unittest.TestCase): - def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) Modified: python/branches/release31-maint/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_sysconfig.py Sun Oct 18 14:41:30 2009 @@ -17,8 +17,15 @@ def tearDown(self): if self.makefile is not None: os.unlink(self.makefile) + self.cleanup_testfn() super(SysconfigTestCase, self).tearDown() + def cleanup_testfn(self): + if os.path.isfile(TESTFN): + os.remove(TESTFN) + elif os.path.isdir(TESTFN): + shutil.rmtree(TESTFN) + def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() self.assertTrue(os.path.isfile(config_h), config_h) @@ -51,8 +58,8 @@ if get_default_compiler() != 'unix': return - self.environ['AR'] = 'my_ar' - self.environ['ARFLAGS'] = '-arflags' + os.environ['AR'] = 'my_ar' + os.environ['ARFLAGS'] = '-arflags' # make sure AR gets caught class compiler: Modified: python/branches/release31-maint/Lib/distutils/tests/test_util.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_util.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_util.py Sun Oct 18 14:41:30 2009 @@ -94,7 +94,7 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') @@ -102,7 +102,7 @@ self.assertEquals(get_platform(), 'macosx-10.3-i386') # macbook with fat binaries (fat, universal or fat64) - self.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -223,17 +223,18 @@ def test_check_environ(self): util._environ_checked = 0 + if 'HOME' in os.environ: + del os.environ['HOME'] # posix without HOME if os.name == 'posix': # this test won't run on windows check_environ() import pwd - self.assertEquals(self.environ['HOME'], - pwd.getpwuid(os.getuid())[5]) + self.assertEquals(os.environ['HOME'], pwd.getpwuid(os.getuid())[5]) else: check_environ() - self.assertEquals(self.environ['PLAT'], get_platform()) + self.assertEquals(os.environ['PLAT'], get_platform()) self.assertEquals(util._environ_checked, 1) def test_split_quoted(self): From python-checkins at python.org Sun Oct 18 15:19:33 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 13:19:33 -0000 Subject: [Python-checkins] r75493 - in python/branches/py3k: Lib/test/regrtest.py Lib/test/support.py Lib/test/test_cmd_line.py Lib/test/test_descr.py Lib/test/test_httpservers.py Lib/test/test_imp.py Lib/test/test_import.py Lib/test/test_site.py Lib/test/test_unittest.py Lib/test/test_xmlrpc.py Message-ID: Author: nick.coghlan Date: Sun Oct 18 15:19:33 2009 New Revision: 75493 Log: Note that a number of the changes listed below were not applicable to the Py3k branch, and hence the corresponding files are unchanged in this checkin. This checkin is also the first time the environment checking in regrtest has been forward ported to the Py3k branch. This checkin causes test_xmlrpc to fail - see issue 7165 (it's a bug in the 3.x version of xmlrpc.server) I am also getting a failure in test_telnetlib, but it isn't clear yet if that is due to these changes. Recorded merge of revisions 75400-75401,75404,75406,75414,75416,75422,75425-75428,75435,75439,75441-75444,75447-75449,75451-75453,75455-75458,75460-75469,75471-75473,75475-75477,75479-75481,75483,75486-75489 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75400 | r.david.murray | 2009-10-14 23:58:07 +1000 (Wed, 14 Oct 2009) | 6 lines Enhanced Issue 7058 patch, which will not be backported. Refactors the code, adds checks for stdin/out/err, cwd, and sys.path, and adds a new section in the summary for tests that modify the environment (thanks to Ezio Melotti for that suggestion). ........ r75453 | nick.coghlan | 2009-10-17 16:33:05 +1000 (Sat, 17 Oct 2009) | 1 line Correctly restore sys.stdout in test_descr ........ r75456 | nick.coghlan | 2009-10-17 17:30:40 +1000 (Sat, 17 Oct 2009) | 1 line Enhancement to the new environment checking code to print the changed items under -vv. Also includes a small tweak to allow underscores in the names of resources. ........ r75457 | nick.coghlan | 2009-10-17 17:34:27 +1000 (Sat, 17 Oct 2009) | 1 line Formatting tweak so that before and after values are vertically aligned ........ r75458 | nick.coghlan | 2009-10-17 18:21:21 +1000 (Sat, 17 Oct 2009) | 1 line Check and revert expected sys.path alterations ........ r75461 | nick.coghlan | 2009-10-18 00:40:54 +1000 (Sun, 18 Oct 2009) | 1 line Restore original sys.path when running TTK tests ........ r75462 | nick.coghlan | 2009-10-18 01:09:41 +1000 (Sun, 18 Oct 2009) | 1 line Don't invoke reload(sys) and use StringIO objects instead of real files to capture stdin and stdout when needed (ensures all sys attributes remain unmodified after test_xmlrpc runs) ........ r75463 | nick.coghlan | 2009-10-18 01:23:08 +1000 (Sun, 18 Oct 2009) | 1 line Revert changes made to environment in test_httpservers ........ r75465 | nick.coghlan | 2009-10-18 01:45:52 +1000 (Sun, 18 Oct 2009) | 1 line Move restoration of the os.environ object into the context manager where it belongs ........ r75466 | nick.coghlan | 2009-10-18 01:48:16 +1000 (Sun, 18 Oct 2009) | 1 line Also check and restore identity of sys.path, sys.argv and os.environ rather than just their values (this picked up a few more misbehaving tests) ........ r75467 | nick.coghlan | 2009-10-18 01:57:42 +1000 (Sun, 18 Oct 2009) | 1 line Avoid replacing existing modules and sys.path in import tests ........ r75468 | nick.coghlan | 2009-10-18 02:19:51 +1000 (Sun, 18 Oct 2009) | 1 line Don't replace sys.path in test_site ........ r75481 | nick.coghlan | 2009-10-18 15:38:48 +1000 (Sun, 18 Oct 2009) | 1 line Using CleanImport to revert a reload of the os module doesn't work due to function registrations in copy_reg. The perils of reloading modules even for tests... ........ r75486 | nick.coghlan | 2009-10-18 20:29:10 +1000 (Sun, 18 Oct 2009) | 1 line Silence a deprecation warning by using the appropriate replacement construct ........ r75489 | nick.coghlan | 2009-10-18 20:56:21 +1000 (Sun, 18 Oct 2009) | 1 line Restore sys.path in test_tk ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/support.py python/branches/py3k/Lib/test/test_cmd_line.py python/branches/py3k/Lib/test/test_descr.py python/branches/py3k/Lib/test/test_httpservers.py python/branches/py3k/Lib/test/test_imp.py python/branches/py3k/Lib/test/test_import.py python/branches/py3k/Lib/test/test_site.py python/branches/py3k/Lib/test/test_unittest.py python/branches/py3k/Lib/test/test_xmlrpc.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Sun Oct 18 15:19:33 2009 @@ -353,6 +353,7 @@ bad = [] skipped = [] resource_denieds = [] + environment_changed = [] if findleaks: try: @@ -429,11 +430,13 @@ test_times.append((test_time, test)) if ok > 0: good.append(test) - elif ok == 0: + elif -2 < ok <= 0: bad.append(test) + if ok == -1: + environment_changed.append(test) else: skipped.append(test) - if ok == -2: + if ok == -3: resource_denieds.append(test) if use_mp: @@ -539,6 +542,7 @@ good.sort() bad.sort() skipped.sort() + environment_changed.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: @@ -553,8 +557,14 @@ for time, test in test_times[:10]: print("%s: %.1fs" % (test, time)) if bad: - print(count(len(bad), "test"), "failed:") - printlist(bad) + bad = sorted(set(bad) - set(environment_changed)) + if bad: + print(count(len(bad), "test"), "failed:") + printlist(bad) + if environment_changed: + print("{} altered the execution environment:".format( + count(len(environment_changed), "test"))) + printlist(environment_changed) if skipped and not quiet: print(count(len(skipped), "test"), "skipped:") printlist(skipped) @@ -657,8 +667,10 @@ debug -- if true, print tracebacks for failed tests regardless of verbose setting Return: - -2 test skipped because resource denied - -1 test skipped for some other reason + -4 KeyboardInterrupt when run under -j + -3 test skipped because resource denied + -2 test skipped for some other reason + -1 test failed because it changed the execution environment 0 test failed 1 test passed """ @@ -672,6 +684,118 @@ finally: cleanup_test_droppings(test, verbose) +# Unit tests are supposed to leave the execution environment unchanged +# once they complete. But sometimes tests have bugs, especially when +# tests fail, and the changes to environment go on to mess up other +# tests. This can cause issues with buildbot stability, since tests +# are run in random order and so problems may appear to come and go. +# There are a few things we can save and restore to mitigate this, and +# the following context manager handles this task. + +class saved_test_environment: + """Save bits of the test environment and restore them at block exit. + + with saved_test_environment(testname, verbose, quiet): + #stuff + + Unless quiet is True, a warning is printed to stderr if any of + the saved items was changed by the test. The attribute 'changed' + is initially False, but is set to True if a change is detected. + + If verbose is more than 1, the before and after state of changed + items is also printed. + """ + + changed = False + + def __init__(self, testname, verbose=0, quiet=False): + self.testname = testname + self.verbose = verbose + self.quiet = quiet + + # To add things to save and restore, add a name XXX to the resources list + # and add corresponding get_XXX/restore_XXX functions. get_XXX should + # return the value to be saved and compared against a second call to the + # get function when test execution completes. restore_XXX should accept + # the saved value and restore the resource using it. It will be called if + # and only if a change in the value is detected. + # + # Note: XXX will have any '.' replaced with '_' characters when determining + # the corresponding method names. + + resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', + 'os.environ', 'sys.path') + + def get_sys_argv(self): + return id(sys.argv), sys.argv, sys.argv[:] + def restore_sys_argv(self, saved_argv): + sys.argv = saved_argv[1] + sys.argv[:] = saved_argv[2] + + def get_cwd(self): + return os.getcwd() + def restore_cwd(self, saved_cwd): + os.chdir(saved_cwd) + + def get_sys_stdout(self): + return sys.stdout + def restore_sys_stdout(self, saved_stdout): + sys.stdout = saved_stdout + + def get_sys_stderr(self): + return sys.stderr + def restore_sys_stderr(self, saved_stderr): + sys.stderr = saved_stderr + + def get_sys_stdin(self): + return sys.stdin + def restore_sys_stdin(self, saved_stdin): + sys.stdin = saved_stdin + + def get_os_environ(self): + return id(os.environ), os.environ, dict(os.environ) + def restore_os_environ(self, saved_environ): + os.environ = saved_environ[1] + os.environ.clear() + os.environ.update(saved_environ[2]) + + def get_sys_path(self): + return id(sys.path), sys.path, sys.path[:] + def restore_sys_path(self, saved_path): + sys.path = saved_path[1] + sys.path[:] = saved_path[2] + + def resource_info(self): + for name in self.resources: + method_suffix = name.replace('.', '_') + get_name = 'get_' + method_suffix + restore_name = 'restore_' + method_suffix + yield name, getattr(self, get_name), getattr(self, restore_name) + + def __enter__(self): + self.saved_values = dict((name, get()) for name, get, restore + in self.resource_info()) + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + for name, get, restore in self.resource_info(): + current = get() + original = self.saved_values[name] + # Check for changes to the resource's value + if current != original: + self.changed = True + restore(original) + if not self.quiet: + print("Warning -- {} was modified by {}".format( + name, self.testname), + file=sys.stderr) + if self.verbose > 1: + print(" Before: {}\n After: {} ".format( + original, current), + file=sys.stderr) + return False + + def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) @@ -692,18 +816,20 @@ else: # Always import it from the test package abstest = 'test.' + test - start_time = time.time() - the_package = __import__(abstest, globals(), locals(), []) - the_module = getattr(the_package, test) - # Old tests run to completion simply as a side-effect of - # being imported. For tests based on unittest or doctest, - # explicitly invoke their test_main() function (if it exists). - indirect_test = getattr(the_module, "test_main", None) - if indirect_test is not None: - indirect_test() - if huntrleaks: - refleak = dash_R(the_module, test, indirect_test, huntrleaks) - test_time = time.time() - start_time + with saved_test_environment(test, verbose, quiet) as environment: + start_time = time.time() + the_package = __import__(abstest, globals(), locals(), []) + the_module = getattr(the_package, test) + # Old tests run to completion simply as a side-effect of + # being imported. For tests based on unittest or doctest, + # explicitly invoke their test_main() function (if it exists). + indirect_test = getattr(the_module, "test_main", None) + if indirect_test is not None: + indirect_test() + if huntrleaks: + refleak = dash_R(the_module, test, indirect_test, + huntrleaks) + test_time = time.time() - start_time finally: sys.stdout = save_stdout # Restore what we saved if needed, but also complain if the test @@ -721,12 +847,12 @@ if not quiet: print(test, "skipped --", msg) sys.stdout.flush() - return -2, test_time + return -3, test_time except unittest.SkipTest as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() - return -1, test_time + return -2, test_time except KeyboardInterrupt: raise except support.TestFailed as msg: @@ -744,6 +870,8 @@ else: if refleak: return 0, test_time + if environment.changed: + return -1, test_time return 1, test_time def cleanup_test_droppings(testname, verbose): Modified: python/branches/py3k/Lib/test/support.py ============================================================================== --- python/branches/py3k/Lib/test/support.py (original) +++ python/branches/py3k/Lib/test/support.py Sun Oct 18 15:19:33 2009 @@ -567,6 +567,32 @@ del self._environ[k] else: self._environ[k] = v + os.environ = self._environ + + +class DirsOnSysPath(object): + """Context manager to temporarily add directories to sys.path. + + This makes a copy of sys.path, appends any directories given + as positional arguments, then reverts sys.path to the copied + settings when the context ends. + + Note that *all* sys.path modifications in the body of the + context manager, including replacement of the object, + will be reverted at the end of the block. + """ + + def __init__(self, *paths): + self.original_value = sys.path[:] + self.original_object = sys.path + sys.path.extend(paths) + + def __enter__(self): + return self + + def __exit__(self, *ignore_exc): + sys.path = self.original_object + sys.path[:] = self.original_value class TransientResource(object): @@ -623,6 +649,9 @@ def captured_stdout(): return captured_output("stdout") +def captured_stdin(): + return captured_output("stdin") + def gc_collect(): """Force as many objects as possible to be collected. Modified: python/branches/py3k/Lib/test/test_cmd_line.py ============================================================================== --- python/branches/py3k/Lib/test/test_cmd_line.py (original) +++ python/branches/py3k/Lib/test/test_cmd_line.py Sun Oct 18 15:19:33 2009 @@ -65,16 +65,6 @@ self.verify_valid_flag('-Qwarnall') def test_site_flag(self): - if os.name == 'posix': - # Workaround bug #586680 by adding the extension dir to PYTHONPATH - from distutils.util import get_platform - s = "./build/lib.%s-%.3s" % (get_platform(), sys.version) - if hasattr(sys, 'gettotalrefcount'): - s += '-pydebug' - p = os.environ.get('PYTHONPATH', '') - if p: - p += ':' - os.environ['PYTHONPATH'] = p + s self.verify_valid_flag('-S') def test_usage(self): Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Sun Oct 18 15:19:33 2009 @@ -4001,6 +4001,7 @@ def test_file_fault(self): # Testing sys.stdout is changed in getattr... import sys + test_stdout = sys.stdout class StdoutGuard: def __getattr__(self, attr): sys.stdout = sys.__stdout__ @@ -4010,6 +4011,8 @@ print("Oops!") except RuntimeError: pass + finally: + sys.stdout = test_stdout def test_vicious_descriptor_nonsense(self): # Testing vicious_descriptor_nonsense... Modified: python/branches/py3k/Lib/test/test_httpservers.py ============================================================================== --- python/branches/py3k/Lib/test/test_httpservers.py (original) +++ python/branches/py3k/Lib/test/test_httpservers.py Sun Oct 18 15:19:33 2009 @@ -51,6 +51,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): + os.environ = support.EnvironmentVarGuard() self.lock = threading.Lock() self.thread = TestServerThread(self, self.request_handler) self.thread.start() @@ -59,6 +60,7 @@ def tearDown(self): self.lock.release() self.thread.stop() + os.environ.__exit__() def request(self, uri, method='GET', body=None, headers={}): self.connection = http.client.HTTPConnection('localhost', self.PORT) Modified: python/branches/py3k/Lib/test/test_imp.py ============================================================================== --- python/branches/py3k/Lib/test/test_imp.py (original) +++ python/branches/py3k/Lib/test/test_imp.py Sun Oct 18 15:19:33 2009 @@ -146,18 +146,38 @@ support.rmtree(test_package_name) - def test_reload(self): - import marshal - imp.reload(marshal) - import string - imp.reload(string) - ## import sys - ## self.assertRaises(ImportError, reload, sys) +class ReloadTests(unittest.TestCase): + + """Very basic tests to make sure that imp.reload() operates just like + reload().""" + + def test_source(self): + # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # here, but that breaks because the os module registers some + # handlers in copy_reg on import. Since CleanImport doesn't + # revert that registration, the module is left in a broken + # state after reversion. Reinitialising the module contents + # and just reverting os.environ to its previous state is an OK + # workaround + with support.EnvironmentVarGuard(): + import os + imp.reload(os) + + def test_extension(self): + with support.CleanImport('time'): + import time + imp.reload(time) + + def test_builtin(self): + with support.CleanImport('marshal'): + import marshal + imp.reload(marshal) def test_main(): tests = [ ImportTests, + ReloadTests, ] try: import _thread Modified: python/branches/py3k/Lib/test/test_import.py ============================================================================== --- python/branches/py3k/Lib/test/test_import.py (original) +++ python/branches/py3k/Lib/test/test_import.py Sun Oct 18 15:19:33 2009 @@ -8,7 +8,8 @@ import warnings import imp import marshal -from test.support import unlink, TESTFN, unload, run_unittest, TestFailed +from test.support import (unlink, TESTFN, unload, run_unittest, + TestFailed, EnvironmentVarGuard) def remove_files(name): @@ -109,9 +110,22 @@ def testImpModule(self): # Verify that the imp module can correctly load and find .py files - import imp - x = imp.find_module("os") - os = imp.load_module("os", *x) + import imp, os + # XXX (ncoghlan): It would be nice to use test_support.CleanImport + # here, but that breaks because the os module registers some + # handlers in copy_reg on import. Since CleanImport doesn't + # revert that registration, the module is left in a broken + # state after reversion. Reinitialising the module contents + # and just reverting os.environ to its previous state is an OK + # workaround + orig_path = os.path + orig_getenv = os.getenv + with EnvironmentVarGuard(): + x = imp.find_module("os") + new_os = imp.load_module("os", *x) + self.assertIs(os, new_os) + self.assertIs(orig_path, new_os.path) + self.assertIsNot(orig_getenv, new_os.getenv) def test_module_with_large_stack(self, module='longlist'): # create module w/list of 65000 elements to test bug #561858 @@ -360,7 +374,7 @@ def tearDown(self): shutil.rmtree(self.path) - sys.path = self.syspath + sys.path[:] = self.syspath # http://bugs.python.org/issue1293 def test_trailing_slash(self): Modified: python/branches/py3k/Lib/test/test_site.py ============================================================================== --- python/branches/py3k/Lib/test/test_site.py (original) +++ python/branches/py3k/Lib/test/test_site.py Sun Oct 18 15:19:33 2009 @@ -41,7 +41,7 @@ def tearDown(self): """Restore sys.path""" - sys.path = self.sys_path + sys.path[:] = self.sys_path site.USER_BASE = self.old_base site.USER_SITE = self.old_site site.PREFIXES = self.old_prefixes @@ -247,7 +247,7 @@ def tearDown(self): """Restore sys.path""" - sys.path = self.sys_path + sys.path[:] = self.sys_path def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute Modified: python/branches/py3k/Lib/test/test_unittest.py ============================================================================== --- python/branches/py3k/Lib/test/test_unittest.py (original) +++ python/branches/py3k/Lib/test/test_unittest.py Sun Oct 18 15:19:33 2009 @@ -3572,12 +3572,12 @@ os.path.isfile = lambda path: False self.addCleanup(restore_isfile) - full_path = os.path.abspath(os.path.normpath('/foo')) - def clean_path(): - if sys.path[-1] == full_path: - sys.path.pop(-1) - self.addCleanup(clean_path) + orig_sys_path = sys.path[:] + def restore_path(): + sys.path[:] = orig_sys_path + self.addCleanup(restore_path) + full_path = os.path.abspath(os.path.normpath('/foo')) with self.assertRaises(ImportError): loader.discover('/foo/bar', top_level_dir='/foo') @@ -3599,6 +3599,7 @@ self.assertEqual(suite, "['tests']") self.assertEqual(loader._top_level_dir, top_level_dir) self.assertEqual(_find_tests_args, [(start_dir, 'pattern')]) + self.assertIn(top_level_dir, sys.path) def test_discover_with_modules_that_fail_to_import(self): loader = unittest.TestLoader() @@ -3607,12 +3608,15 @@ os.listdir = lambda _: ['test_this_does_not_exist.py'] isfile = os.path.isfile os.path.isfile = lambda _: True + orig_sys_path = sys.path[:] def restore(): os.path.isfile = isfile os.listdir = listdir + sys.path[:] = orig_sys_path self.addCleanup(restore) suite = loader.discover('.') + self.assertIn(os.getcwd(), sys.path) self.assertEqual(suite.countTestCases(), 1) test = list(list(suite)[0])[0] # extract test from suite Modified: python/branches/py3k/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_xmlrpc.py Sun Oct 18 15:19:33 2009 @@ -725,54 +725,45 @@ env['REQUEST_METHOD'] = 'GET' # if the method is GET and no request_text is given, it runs handle_get # get sysout output - tmp = sys.stdout - sys.stdout = open(support.TESTFN, "w") - self.cgi.handle_request() - sys.stdout.close() - sys.stdout = tmp + with support.captured_stdout() as data_out: + self.cgi.handle_request() # parse Status header - handle = open(support.TESTFN, "r").read() + data_out.seek(0) + handle = data_out.read() status = handle.split()[1] message = ' '.join(handle.split()[2:4]) self.assertEqual(status, '400') self.assertEqual(message, 'Bad Request') - os.remove(support.TESTFN) def test_cgi_xmlrpc_response(self): data = """ - - test_method - - - foo - - - bar - - - -""" - open("xmldata.txt", "w").write(data) - tmp1 = sys.stdin - tmp2 = sys.stdout - - sys.stdin = open("xmldata.txt", "r") - sys.stdout = open(support.TESTFN, "w") - - with support.EnvironmentVarGuard() as env: + + test_method + + + foo + + + bar + + + + """ + + with support.EnvironmentVarGuard() as env, \ + support.captured_stdout() as data_out, \ + support.captured_stdin() as data_in: + data_in.write(data) + data_in.seek(0) env['CONTENT_LENGTH'] = str(len(data)) self.cgi.handle_request() - - sys.stdin.close() - sys.stdout.close() - sys.stdin = tmp1 - sys.stdout = tmp2 + data_out.seek(0) # will respond exception, if so, our goal is achieved ;) - handle = open(support.TESTFN, "r").read() + handle = data_out.read() # start with 44th char so as not to get http header, we just # need only xml @@ -789,9 +780,6 @@ int(re.search('Content-Length: (\d+)', handle).group(1)), len(content)) - os.remove("xmldata.txt") - os.remove(support.TESTFN) - def test_main(): xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase, From python-checkins at python.org Sun Oct 18 15:25:20 2009 From: python-checkins at python.org (nick.coghlan) Date: Sun, 18 Oct 2009 13:25:20 -0000 Subject: [Python-checkins] r75494 - python/branches/release31-maint Message-ID: Author: nick.coghlan Date: Sun Oct 18 15:25:20 2009 New Revision: 75494 Log: Blocked revisions 75493 via svnmerge ................ r75493 | nick.coghlan | 2009-10-18 23:19:33 +1000 (Sun, 18 Oct 2009) | 75 lines Note that a number of the changes listed below were not applicable to the Py3k branch, and hence the corresponding files are unchanged in this checkin. This checkin is also the first time the environment checking in regrtest has been forward ported to the Py3k branch. This checkin causes test_xmlrpc to fail - see issue 7165 (it's a bug in the 3.x version of xmlrpc.server) I am also getting a failure in test_telnetlib, but it isn't clear yet if that is due to these changes. Recorded merge of revisions 75400-75401,75404,75406,75414,75416,75422,75425-75428,75435,75439,75441-75444,75447-75449,75451-75453,75455-75458,75460-75469,75471-75473,75475-75477,75479-75481,75483,75486-75489 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75400 | r.david.murray | 2009-10-14 23:58:07 +1000 (Wed, 14 Oct 2009) | 6 lines Enhanced Issue 7058 patch, which will not be backported. Refactors the code, adds checks for stdin/out/err, cwd, and sys.path, and adds a new section in the summary for tests that modify the environment (thanks to Ezio Melotti for that suggestion). ........ r75453 | nick.coghlan | 2009-10-17 16:33:05 +1000 (Sat, 17 Oct 2009) | 1 line Correctly restore sys.stdout in test_descr ........ r75456 | nick.coghlan | 2009-10-17 17:30:40 +1000 (Sat, 17 Oct 2009) | 1 line Enhancement to the new environment checking code to print the changed items under -vv. Also includes a small tweak to allow underscores in the names of resources. ........ r75457 | nick.coghlan | 2009-10-17 17:34:27 +1000 (Sat, 17 Oct 2009) | 1 line Formatting tweak so that before and after values are vertically aligned ........ r75458 | nick.coghlan | 2009-10-17 18:21:21 +1000 (Sat, 17 Oct 2009) | 1 line Check and revert expected sys.path alterations ........ r75461 | nick.coghlan | 2009-10-18 00:40:54 +1000 (Sun, 18 Oct 2009) | 1 line Restore original sys.path when running TTK tests ........ r75462 | nick.coghlan | 2009-10-18 01:09:41 +1000 (Sun, 18 Oct 2009) | 1 line Don't invoke reload(sys) and use StringIO objects instead of real files to capture stdin and stdout when needed (ensures all sys attributes remain unmodified after test_xmlrpc runs) ........ r75463 | nick.coghlan | 2009-10-18 01:23:08 +1000 (Sun, 18 Oct 2009) | 1 line Revert changes made to environment in test_httpservers ........ r75465 | nick.coghlan | 2009-10-18 01:45:52 +1000 (Sun, 18 Oct 2009) | 1 line Move restoration of the os.environ object into the context manager where it belongs ........ r75466 | nick.coghlan | 2009-10-18 01:48:16 +1000 (Sun, 18 Oct 2009) | 1 line Also check and restore identity of sys.path, sys.argv and os.environ rather than just their values (this picked up a few more misbehaving tests) ........ r75467 | nick.coghlan | 2009-10-18 01:57:42 +1000 (Sun, 18 Oct 2009) | 1 line Avoid replacing existing modules and sys.path in import tests ........ r75468 | nick.coghlan | 2009-10-18 02:19:51 +1000 (Sun, 18 Oct 2009) | 1 line Don't replace sys.path in test_site ........ r75481 | nick.coghlan | 2009-10-18 15:38:48 +1000 (Sun, 18 Oct 2009) | 1 line Using CleanImport to revert a reload of the os module doesn't work due to function registrations in copy_reg. The perils of reloading modules even for tests... ........ r75486 | nick.coghlan | 2009-10-18 20:29:10 +1000 (Sun, 18 Oct 2009) | 1 line Silence a deprecation warning by using the appropriate replacement construct ........ r75489 | nick.coghlan | 2009-10-18 20:56:21 +1000 (Sun, 18 Oct 2009) | 1 line Restore sys.path in test_tk ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sun Oct 18 16:25:35 2009 From: python-checkins at python.org (skip.montanaro) Date: Sun, 18 Oct 2009 14:25:35 -0000 Subject: [Python-checkins] r75495 - in python/branches/py3k: Include/Python.h Misc/NEWS Objects/complexobject.c Objects/object.c Parser/tokenizer.c Python/ast.c Python/bltinmodule.c Python/getargs.c Python/marshal.c Python/modsupport.c Message-ID: Author: skip.montanaro Date: Sun Oct 18 16:25:35 2009 New Revision: 75495 Log: Issue 7147 - remove ability to attempt to build Python without complex number support (was broken anyway) Modified: python/branches/py3k/Include/Python.h python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/complexobject.c python/branches/py3k/Objects/object.c python/branches/py3k/Parser/tokenizer.c python/branches/py3k/Python/ast.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/getargs.c python/branches/py3k/Python/marshal.c python/branches/py3k/Python/modsupport.c Modified: python/branches/py3k/Include/Python.h ============================================================================== --- python/branches/py3k/Include/Python.h (original) +++ python/branches/py3k/Include/Python.h Sun Oct 18 16:25:35 2009 @@ -73,9 +73,7 @@ #include "longintrepr.h" #include "boolobject.h" #include "floatobject.h" -#ifndef WITHOUT_COMPLEX #include "complexobject.h" -#endif #include "rangeobject.h" #include "memoryobject.h" #include "tupleobject.h" Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Oct 18 16:25:35 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue *7147: Remove support for compiling Python without complex number + support. + - Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. Modified: python/branches/py3k/Objects/complexobject.c ============================================================================== --- python/branches/py3k/Objects/complexobject.c (original) +++ python/branches/py3k/Objects/complexobject.c Sun Oct 18 16:25:35 2009 @@ -12,8 +12,6 @@ #include #endif -#ifndef WITHOUT_COMPLEX - /* elementary operations on complex numbers */ static Py_complex c_1 = {1., 0.}; @@ -1108,5 +1106,3 @@ complex_new, /* tp_new */ PyObject_Del, /* tp_free */ }; - -#endif Modified: python/branches/py3k/Objects/object.c ============================================================================== --- python/branches/py3k/Objects/object.c (original) +++ python/branches/py3k/Objects/object.c Sun Oct 18 16:25:35 2009 @@ -1536,10 +1536,9 @@ if (PyType_Ready(&PyStaticMethod_Type) < 0) Py_FatalError("Can't initialize static method type"); -#ifndef WITHOUT_COMPLEX if (PyType_Ready(&PyComplex_Type) < 0) Py_FatalError("Can't initialize complex type"); -#endif + if (PyType_Ready(&PyFloat_Type) < 0) Py_FatalError("Can't initialize float type"); Modified: python/branches/py3k/Parser/tokenizer.c ============================================================================== --- python/branches/py3k/Parser/tokenizer.c (original) +++ python/branches/py3k/Parser/tokenizer.c Sun Oct 18 16:25:35 2009 @@ -1383,10 +1383,8 @@ c = tok_nextc(tok); if (c == '.') goto fraction; -#ifndef WITHOUT_COMPLEX if (c == 'j' || c == 'J') goto imaginary; -#endif if (c == 'x' || c == 'X') { /* Hex */ @@ -1438,10 +1436,8 @@ goto fraction; else if (c == 'e' || c == 'E') goto exponent; -#ifndef WITHOUT_COMPLEX else if (c == 'j' || c == 'J') goto imaginary; -#endif else if (nonzero) { tok->done = E_TOKEN; tok_backup(tok, c); @@ -1478,12 +1474,10 @@ c = tok_nextc(tok); } while (isdigit(c)); } -#ifndef WITHOUT_COMPLEX if (c == 'j' || c == 'J') /* Imaginary part */ imaginary: c = tok_nextc(tok); -#endif } } tok_backup(tok, c); Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Sun Oct 18 16:25:35 2009 @@ -3177,17 +3177,13 @@ const char *end; long x; double dx; -#ifndef WITHOUT_COMPLEX Py_complex compl; int imflag; -#endif assert(s != NULL); errno = 0; end = s + strlen(s) - 1; -#ifndef WITHOUT_COMPLEX imflag = *end == 'j' || *end == 'J'; -#endif if (s[0] == '0') { x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); if (x < 0 && errno == 0) { @@ -3204,7 +3200,6 @@ return PyLong_FromLong(x); } /* XXX Huge floats may silently fail */ -#ifndef WITHOUT_COMPLEX if (imflag) { compl.real = 0.; compl.imag = PyOS_string_to_double(s, (char **)&end, NULL); @@ -3213,7 +3208,6 @@ return PyComplex_FromCComplex(compl); } else -#endif { dx = PyOS_string_to_double(s, NULL, NULL); if (dx == -1.0 && PyErr_Occurred()) Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Sun Oct 18 16:25:35 2009 @@ -2302,9 +2302,7 @@ SETBUILTIN("bytearray", &PyByteArray_Type); SETBUILTIN("bytes", &PyBytes_Type); SETBUILTIN("classmethod", &PyClassMethod_Type); -#ifndef WITHOUT_COMPLEX SETBUILTIN("complex", &PyComplex_Type); -#endif SETBUILTIN("dict", &PyDict_Type); SETBUILTIN("enumerate", &PyEnum_Type); SETBUILTIN("filter", &PyFilter_Type); Modified: python/branches/py3k/Python/getargs.c ============================================================================== --- python/branches/py3k/Python/getargs.c (original) +++ python/branches/py3k/Python/getargs.c Sun Oct 18 16:25:35 2009 @@ -818,7 +818,6 @@ break; } -#ifndef WITHOUT_COMPLEX case 'D': {/* complex double */ Py_complex *p = va_arg(*p_va, Py_complex *); Py_complex cval; @@ -829,7 +828,6 @@ *p = cval; break; } -#endif /* WITHOUT_COMPLEX */ case 'c': {/* char */ char *p = va_arg(*p_va, char *); @@ -1772,9 +1770,7 @@ #endif case 'f': /* float */ case 'd': /* double */ -#ifndef WITHOUT_COMPLEX case 'D': /* complex double */ -#endif case 'c': /* char */ { (void) va_arg(*p_va, void *); Modified: python/branches/py3k/Python/marshal.c ============================================================================== --- python/branches/py3k/Python/marshal.c (original) +++ python/branches/py3k/Python/marshal.c Sun Oct 18 16:25:35 2009 @@ -254,7 +254,6 @@ PyMem_Free(buf); } } -#ifndef WITHOUT_COMPLEX else if (PyComplex_CheckExact(v)) { if (p->version > 1) { unsigned char buf[8]; @@ -297,7 +296,6 @@ PyMem_Free(buf); } } -#endif else if (PyBytes_CheckExact(v)) { w_byte(TYPE_STRING, p); n = PyBytes_GET_SIZE(v); @@ -714,7 +712,6 @@ break; } -#ifndef WITHOUT_COMPLEX case TYPE_COMPLEX: { char buf[256]; @@ -773,7 +770,6 @@ retval = PyComplex_FromCComplex(c); break; } -#endif case TYPE_STRING: n = r_long(p); Modified: python/branches/py3k/Python/modsupport.c ============================================================================== --- python/branches/py3k/Python/modsupport.c (original) +++ python/branches/py3k/Python/modsupport.c Sun Oct 18 16:25:35 2009 @@ -279,11 +279,9 @@ return PyFloat_FromDouble( (double)va_arg(*p_va, va_double)); -#ifndef WITHOUT_COMPLEX case 'D': return PyComplex_FromCComplex( *((Py_complex *)va_arg(*p_va, Py_complex *))); -#endif /* WITHOUT_COMPLEX */ case 'c': { From python-checkins at python.org Sun Oct 18 18:41:32 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 18 Oct 2009 16:41:32 -0000 Subject: [Python-checkins] r75496 - in python/branches/py3k/Python: compile.c formatter_unicode.c Message-ID: Author: mark.dickinson Date: Sun Oct 18 18:41:32 2009 New Revision: 75496 Log: Remove the uses of WITHOUT_COMPLEX introduced in r75471 Modified: python/branches/py3k/Python/compile.c python/branches/py3k/Python/formatter_unicode.c Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Sun Oct 18 18:41:32 2009 @@ -911,7 +911,6 @@ else t = PyTuple_Pack(2, o, o->ob_type); } -#ifndef WITHOUT_COMPLEX else if (PyComplex_Check(o)) { Py_complex z; int real_part_zero, imag_part_zero; @@ -945,7 +944,6 @@ t = PyTuple_Pack(2, o, o->ob_type); } } -#endif /* WITHOUT_COMPLEX */ else { t = PyTuple_Pack(2, o, o->ob_type); } Modified: python/branches/py3k/Python/formatter_unicode.c ============================================================================== --- python/branches/py3k/Python/formatter_unicode.c (original) +++ python/branches/py3k/Python/formatter_unicode.c Sun Oct 18 18:41:32 2009 @@ -9,8 +9,6 @@ #define FORMAT_STRING _PyUnicode_FormatAdvanced #define FORMAT_LONG _PyLong_FormatAdvanced #define FORMAT_FLOAT _PyFloat_FormatAdvanced -#ifndef WITHOUT_COMPLEX #define FORMAT_COMPLEX _PyComplex_FormatAdvanced -#endif #include "../Objects/stringlib/formatter.h" From python-checkins at python.org Sun Oct 18 18:50:06 2009 From: python-checkins at python.org (barry.warsaw) Date: Sun, 18 Oct 2009 16:50:06 -0000 Subject: [Python-checkins] r75497 - in python/branches/release26-maint: Include/patchlevel.h Lib/distutils/__init__.py Lib/idlelib/idlever.py Lib/pydoc_topics.py Misc/NEWS Misc/RPM/python-2.6.spec README Message-ID: Author: barry.warsaw Date: Sun Oct 18 18:50:06 2009 New Revision: 75497 Log: Bump to 2.6.4rc2 Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Lib/distutils/__init__.py python/branches/release26-maint/Lib/idlelib/idlever.py python/branches/release26-maint/Lib/pydoc_topics.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Misc/RPM/python-2.6.spec python/branches/release26-maint/README Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Sun Oct 18 18:50:06 2009 @@ -24,10 +24,10 @@ #define PY_MINOR_VERSION 6 #define PY_MICRO_VERSION 4 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_SERIAL 2 /* Version as a string */ -#define PY_VERSION "2.6.4rc1" +#define PY_VERSION "2.6.4rc2" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Lib/distutils/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/__init__.py (original) +++ python/branches/release26-maint/Lib/distutils/__init__.py Sun Oct 18 18:50:06 2009 @@ -22,5 +22,5 @@ # #--start constants-- -__version__ = "2.6.4rc1" +__version__ = "2.6.4rc2" #--end constants-- Modified: python/branches/release26-maint/Lib/idlelib/idlever.py ============================================================================== --- python/branches/release26-maint/Lib/idlelib/idlever.py (original) +++ python/branches/release26-maint/Lib/idlelib/idlever.py Sun Oct 18 18:50:06 2009 @@ -1 +1 @@ -IDLE_VERSION = "2.6.4rc1" +IDLE_VERSION = "2.6.4rc2" Modified: python/branches/release26-maint/Lib/pydoc_topics.py ============================================================================== --- python/branches/release26-maint/Lib/pydoc_topics.py (original) +++ python/branches/release26-maint/Lib/pydoc_topics.py Sun Oct 18 18:50:06 2009 @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Tue Oct 6 09:18:05 2009 +# Autogenerated by Sphinx on Sun Oct 18 12:30:40 2009 topics = {'assert': u'\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError, expression2\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list is recursively defined as\nfollows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` statement in the\n current code block: the name is bound to the object in the current\n local namespace.\n\n * Otherwise: the name is bound to the object in the current global\n namespace.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield a plain integer. If it is negative, the\n sequence\'s length is added to it. The resulting value must be a\n nonnegative integer less than the sequence\'s length, and the\n sequence is asked to assign the assigned object to its item with\n that index. If the index is out of range, ``IndexError`` is raised\n (assignment to a subscripted sequence cannot add new items to a\n list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to (small) integers. If either\n bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n(In the current implementation, the syntax for targets is taken to be\nthe same as for expressions, and invalid syntax is rejected during the\ncode generation phase, causing less detailed error messages.)\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print x\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n', Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sun Oct 18 18:50:06 2009 @@ -4,27 +4,39 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.6.4rc1? +What's New in Python 2.6.4rc2? ============================== -*Release date: 07-Oct-2009* +*Release date: 18-Oct-2009* Core and Builtins ----------------- -- Issue #7019: Raise ValueError when unmarshalling bad long data, instead - of producing internally inconsistent Python longs. - Library ------- -- Issue #7149: fix exception in urllib when detecting proxy settings on OSX. +- Issue #7115: Fixed the extension module builds that is failing when using + paths in the extension name instead of dotted names. - Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. -- Issue #7115: Fixed the extension module builds that is failing when using - paths in the extension name instead of dotted names. +- Issue #7149: fix exception in urllib when detecting proxy settings on OSX. + + +What's New in Python 2.6.4rc1? +============================== + +*Release date: 07-Oct-2009* + +Core and Builtins +----------------- + +- Issue #7019: Raise ValueError when unmarshalling bad long data, instead + of producing internally inconsistent Python longs. + +Library +------- - Issue #7068: Fixed the partial renaming that occured in r72594. Modified: python/branches/release26-maint/Misc/RPM/python-2.6.spec ============================================================================== --- python/branches/release26-maint/Misc/RPM/python-2.6.spec (original) +++ python/branches/release26-maint/Misc/RPM/python-2.6.spec Sun Oct 18 18:50:06 2009 @@ -34,7 +34,7 @@ %define name python #--start constants-- -%define version 2.6.4rc1 +%define version 2.6.4rc2 %define libver 2.6 #--end constants-- %define release 1pydotorg Modified: python/branches/release26-maint/README ============================================================================== --- python/branches/release26-maint/README (original) +++ python/branches/release26-maint/README Sun Oct 18 18:50:06 2009 @@ -1,4 +1,4 @@ -This is Python version 2.6.4rc1 +This is Python version 2.6.4rc2 =============================== Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 From python-checkins at python.org Sun Oct 18 18:50:55 2009 From: python-checkins at python.org (barry.warsaw) Date: Sun, 18 Oct 2009 16:50:55 -0000 Subject: [Python-checkins] r75498 - python/tags/r264rc2 Message-ID: Author: barry.warsaw Date: Sun Oct 18 18:50:55 2009 New Revision: 75498 Log: Tagging 2.6.4rc2 Added: python/tags/r264rc2/ - copied from r75497, /python/branches/release26-maint/ From python-checkins at python.org Sun Oct 18 20:22:05 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 18 Oct 2009 18:22:05 -0000 Subject: [Python-checkins] r75499 - python/trunk/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Sun Oct 18 20:22:04 2009 New Revision: 75499 Log: Add a test for same-thread asynchronous exceptions (see #1779233). Modified: python/trunk/Lib/test/test_threading.py Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Sun Oct 18 20:22:04 2009 @@ -164,6 +164,25 @@ exception = ctypes.py_object(AsyncExc) + # First check it works when setting the exception from the same thread. + tid = thread.get_ident() + + try: + result = set_async_exc(ctypes.c_long(tid), exception) + # The exception is async, so we might have to keep the VM busy until + # it notices. + while True: + pass + except AsyncExc: + pass + else: + self.fail("AsyncExc not raised") + try: + self.assertEqual(result, 1) # one thread state modified + except UnboundLocalError: + # The exception was raised to quickly for us to get the result. + pass + # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that From python-checkins at python.org Sun Oct 18 20:27:18 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 18 Oct 2009 18:27:18 -0000 Subject: [Python-checkins] r75500 - in python/branches/py3k: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Sun Oct 18 20:27:17 2009 New Revision: 75500 Log: Merged revisions 75499 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75499 | antoine.pitrou | 2009-10-18 20:22:04 +0200 (dim., 18 oct. 2009) | 3 lines Add a test for same-thread asynchronous exceptions (see #1779233). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_threading.py Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Sun Oct 18 20:27:17 2009 @@ -162,6 +162,25 @@ exception = ctypes.py_object(AsyncExc) + # First check it works when setting the exception from the same thread. + tid = _thread.get_ident() + + try: + result = set_async_exc(ctypes.c_long(tid), exception) + # The exception is async, so we might have to keep the VM busy until + # it notices. + while True: + pass + except AsyncExc: + pass + else: + self.fail("AsyncExc not raised") + try: + self.assertEqual(result, 1) # one thread state modified + except UnboundLocalError: + # The exception was raised to quickly for us to get the result. + pass + # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that From python-checkins at python.org Sun Oct 18 20:37:11 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 18 Oct 2009 18:37:11 -0000 Subject: [Python-checkins] r75501 - python/trunk/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Sun Oct 18 20:37:11 2009 New Revision: 75501 Log: Add a comment about unreachable code, and fix a typo Modified: python/trunk/Lib/test/test_threading.py Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Sun Oct 18 20:37:11 2009 @@ -176,11 +176,13 @@ except AsyncExc: pass else: + # This code is unreachable but it reflects the intent. If we wanted + # to be smarter the above loop wouldn't be infinite. self.fail("AsyncExc not raised") try: self.assertEqual(result, 1) # one thread state modified except UnboundLocalError: - # The exception was raised to quickly for us to get the result. + # The exception was raised too quickly for us to get the result. pass # `worker_started` is set by the thread when it's inside a try/except From python-checkins at python.org Sun Oct 18 22:39:50 2009 From: python-checkins at python.org (brett.cannon) Date: Sun, 18 Oct 2009 20:39:50 -0000 Subject: [Python-checkins] r75502 - peps/trunk/pep-0391.txt Message-ID: Author: brett.cannon Date: Sun Oct 18 22:39:50 2009 New Revision: 75502 Log: Add PEP 391: logging configuration using dictionaries. Added: peps/trunk/pep-0391.txt (contents, props changed) Added: peps/trunk/pep-0391.txt ============================================================================== --- (empty file) +++ peps/trunk/pep-0391.txt Sun Oct 18 22:39:50 2009 @@ -0,0 +1,461 @@ +PEP: 391 +Title: Dictionary-Based Configuration For Logging +Version: $Revision$ +Last-Modified: $Date$ +Author: Vinay Sajip +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 15-Oct-2009 +Python-Version: 2.7, 3.2 +Post-History: + + +Abstract +======== + +This PEP describes a new way of configuring logging using a dictionary to hold +configuration information. + +Rationale +========= + +The present means for configuring Python's logging package is either by using +the logging API to configure logging programmatically, or else by means of +ConfigParser-based configuration files. + +Programmatic configuration, while offering maximal control, fixes the +configuration in Python code. This does not facilitate changing it easily at +runtime, and, as a result, the ability to flexibly turn the verbosity of +logging up and down for different parts of a using application is lost. This +limits the usability of logging as an aid to diagnosing problems - and +sometimes, logging is the only diagnostic aid available in production +environments. + +The ConfigParser-based configuration system is usable, but does not allow its +users to configure all aspects of the logging package. For example, Filters +cannot be configured using this system. Furthermore, the ConfigParser format +appears to engender dislike (sometimes strong dislike) in some quarters. +Though it was chosen because it was the only configuration format supported in +the Python standard at that time, many people regard it (or perhaps just the +particular schema chosen for logging's configuration) as 'crufty' or 'ugly', +in some cases apparently on purely aesthetic grounds. + +Recent versions of Python inlude JSON support in the standard library, and +this is also usable as a configuration format. In other environments, such as +Google App Engine, YAML is used to configure applications, and usually the +configuration of logging would be considered an integral part of the +application configuration. Although the standard library does not contain +YAML support at present, support for both JSON and YAML can be provided in a +common way because both of these serialization formats allow deserialization +of Python dictionaries. + +By providing a way to configure logging by passing the configuration in a +dictionary, logging will be easier to configure not only for users of JSON +and/or YAML, but also for users of bespoke configuration methods, by providing +a common format in which to describe the desired configuration. + +Another drawback of the current ConfigParser-based configuration system is +that it does not support incremental configuration: a new configuration +completely replaces the existing configuration. Although full flexibility for +incremental configuration is difficult to provide in a multi-threaded +environment, the new configuration mechanism will allow the provision of +limited support for incremental configuration. + +Specification +============= + +The specification consists of two parts: the API and the format of the +dictionary used to convey configuration information (i.e. the schema to which +it must conform). + +Naming +------ + +Historically, the logging package has not been PEP-8 conformant. At some +future time, this will be corrected by changing method and function names in +the package in order to conform with PEP-8. However, in the interests of +uniformity, the proposed additions to the API use a naming scheme which is +consistent with the present scheme used by logging. + +API +--- + +The logging.config module will have the following additions: + +* A class, called ``DictConfigurator``, whose constructor is passed the + dictionary used for configuration, and which has a ``configure()`` method. + +* A callable, called ``dictConfigClass``, which will (by default) be set to + ``DictConfigurator``. This is provided so that if desired, + ``DictConfigurator`` can be replaced with a suitable user-defined + implementation. + +* A function, called ``dictConfig()``, which takes a single argument - the + dictionary holding the configuration. This function will call + ``dictConfigClass`` passing the specified dictionary, and then call the + ``configure()`` method on the returned object to actually put the + configuration into effect:: + + def dictConfig(config): + dictConfigClass(config).configure() + +Dictionary Schema - Overview +---------------------------- + +Before describing the schema in detail, it is worth saying a few words about +object connections, support for user-defined objects and access to external +objects. + +Object connections +'''''''''''''''''' + +The schema is intended to describe a set of logging objects - loggers, +handlers, formatters, filters - which are connected to each other in an +object graph. Thus, the schema needs to represent connections between the +objects. For example, say that, once configured, a particular logger has an +attached to it a particular handler. For the purposes of this discussion, +we can say that the logger represents the source, and the handler the +destination, of a connection between the two. Of course in the configured +objects this is represented by the logger holding a reference to the +handler. In the configuration dict, this is done by giving each destination +object an id which identifies it unambiguously, and then using the id in the +source object's configuration to indicate that a connection exists between +the source and the destination object with that id. + +So, for example, consider the following YAML snippet:: + + handlers: + h1: #This is an id + # configuration of handler with id h1 goes here + h2: #This is another id + # configuration of handler with id h2 goes here + loggers: + foo.bar.baz: + # other configuration for logger "foo.bar.baz" + handlers: [h1, h2] + +(Note: YAML will be used in this document as it is more readable than the +equivalent Python source form for the dictionary.) + +The ids for loggers are the logger names which would be used +programmatically to obtain a reference to those loggers, e.g. +``foo.bar.baz``. The ids for other objects can be any string value (such as +``h1``, ``h2`` above) and they are transient, in that they are only +meaningful for processing the configuration dictionary and used to +determine connections between objects, and are not persisted anywhere when +the configuration call is complete. + +The above snippet indicates that logger named ``foo.bar.baz`` should have +two handlers attached to it, which are described by the handler ids ``h1`` +and ``h2``. + +User-defined objects +'''''''''''''''''''' + +The schema should support user-defined objects for handlers, filters and +formatters. (Loggers do not need to have different types for different +instances, so there is no support - in the configuration - for user-defined +logger classes.) + +Objects to be configured will typically be described by dictionaries which +detail their configuration. In some places, the logging system will be able +to infer from the context how an object is to be instantiated, but when a +user-defined object is to be instantiated, the system will not know how to do +this. In order to provide complete flexibility for user-defined object +instantiation, the user will need to provide a 'factory' - a callable which +is called with a configuration dictionary and which returns the instantiated +object. This will be signalled by the factory being made available under +the special key ``'()'``. Here's a concrete example:: + + formatters: + brief: + format: '%(message)s' + default: + format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s' + datefmt: '%Y-%m-%d %H:%M:%S' + custom: + (): my.package.customFormatterFactory + bar: baz + spam: 99.9 + answer: 42 + +The above YAML snippet defines three formatters. The first, with id +``brief``, is a standard ``logging.Formatter`` instance with the +specified format string. The second, with id ``default``, has a longer +format and also defines the time format explicitly, and will result in a +``logging.Formatter`` initialized with those two format strings. Shown in +Python source form, the ``brief`` and ``default`` formatters have +have configuration sub-dictionaries:: + + { + 'format' : '%(message)s' + } + +and:: + + { + 'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s', + 'datefmt' : '%Y-%m-%d %H:%M:%S' + } + +respectively, and as these dictionaries do not contain the special key +``'()'``, the instantiation is inferred from the context: as a result, +standard ``logging.Formatter`` instances are created. The configuration +sub-dictionary for the third formatter, with id ``custom``, is:: + + { + '()' : 'my.package.customFormatterFactory', + 'bar' : 'baz', + 'spam' : 99.9, + 'answer' : 42 + } + +and this contains the special key ``'()'``, which means that user-defined +instantiation is wanted. In this case, the specified factory callable will be +located using normal import mechanisms and called with the *remaining* items +in the configuration sub-dictionary as keyword arguments. In the above +example, the formatter with id ``custom`` will be assumed to be returned by +the call:: + + my.package.customFormatterFactory(bar="baz", spam=99.9, answer=42) + +The key ``'()'`` has been used as the special key because it is not a valid +keyword parameter name, and so will not clash with the names of the keyword +arguments used in the call. The ``'()'`` also serves as a mnemonic that the +corresponding value is a callable. + +Access to external objects +'''''''''''''''''''''''''' + +There are times where a configuration will need to refer to objects external +to the configuration, for example ``sys.stderr``. If the configuration dict +is constructed using Python code then this is straightforward, but a problem +arises when the configuration is provided via a text file (e.g. JSON, YAML). +In a text file, there is no standard way to distinguish ``sys.stderr`` from +the literal string ``'sys.stderr'``. To facilitate this distinction, the +configuration system will look for certain special prefixes in string values +and treat them specially. For example, if the literal string +``'ext://sys.stderr'`` is provided as a value in the configuration, then the +``ext://`` will be stripped off and the remainder of the value processed using +normal import mechanisms. + +The handling of such prefixes will be done in a way analogous to protocol +handling: there will be a generic mechanism to look for prefixes which match +the regular expression ``^(?P[a-z]+)://(?P.*)$`` whereby, if +the ``prefix`` is recognised, the ``suffix`` is processed in a +prefix-dependent manner and the result of the processing replaces the string +value. If the prefix is not recognised, then the string value will be left +as-is. + +The implementation will provide for a set of standard prefixes such as +``ext://`` but it will be possible to disable the mechanism completely or +provide additional or different prefixes for special handling. + +Dictionary Schema - Detail +-------------------------- + +The dictionary passed to ``dictConfig()`` must contain the following keys: + +* `version` - to be set to an integer value representing the schema + version. The only valid value at present is 1, but having this key allows + the schema to evolve while still preserving backwards compatibility. + +All other keys are optional, but if present they will be interpreted as described +below. In all cases below where a 'configuring dict' is mentioned, it will be +checked for the special ``'()'`` key to see if a custom instantiation is +required. If so, the mechanism described above is used to instantiate; +otherwise, the context is used to determine how to instantiate. + +* `formatters` - the corresponding value will be a dict in which each key is + a formatter id and each value is a dict describing how to configure the + corresponding Formatter instance. + + The configuring dict is searched for keys ``format`` and ``datefmt`` (with + defaults of ``None``) and these are used to construct a + ``logging.Formatter`` instance. + +* `filters` - the corresponding value will be a dict in which each key is + a filter id and each value is a dict describing how to configure the + corresponding Filter instance. + + The configuring dict is searched for key ``name`` (defaulting to the empty + string) and this is used to construct a ``logging.Filter`` instance. + +* `handlers` - the corresponding value will be a dict in which each key is + a handler id and each value is a dict describing how to configure the + corresponding Handler instance. + + The configuring dict is searched for the following keys: + + * ``class`` (mandatory). This is the fully qualified name of the handler + class. + + * ``level`` (optional). The level of the handler. + + * ``formatter`` (optional). The id of the formatter for this handler. + + * ``filters`` (optional). A list of ids of the filters for this handler. + + All *other* keys are passed through as keyword arguments to the handler's + constructor. For example, given the snippet:: + + handlers: + console: + class : logging.StreamHandler + formatter: brief + level : INFO + filters: [allow_foo] + stream : ext://sys.stdout + file: + class : logging.handlers.RotatingFileHandler + formatter: precise + filename: logconfig.log + maxBytes: 1024 + backupCount: 3 + + the handler with id ``console`` is instantiated as a + ``logging.StreamHandler``, using ``sys.stdout`` as the underlying stream. + The handler with id ``file`` is instantiated as a + ``logging.handlers.RotatingFileHandler`` with the keyword arguments + ``filename="logconfig.log", maxBytes=1024, backupCount=3``. + +* `loggers` - the corresponding value will be a dict in which each key is + a logger name and each value is a dict describing how to configure the + corresponding Logger instance. + + The configuring dict is searched for the following keys: + + * ``level`` (optional). The level of the logger. + + * ``propagate`` (optional). The propagation setting of the logger. + + * ``filters`` (optional). A list of ids of the filters for this logger. + + * ``handlers`` (optional). A list of ids of the handlers for this logger. + + The specified loggers will be configured according to the level, + propagation, filters and handlers specified. + +* `root` - this will be the configuration for the root logger. Processing of + the configuration will be as for any logger, except that the ``propagate`` + setting will not be applicable. + +* `incremental` - whether the configuration is to be interpreted as + incremental to the existing configuration. This value defaults to False, + which means that the specified configuration replaces the existing + configuration with the same semantics as used by the existing + ``fileConfig()`` API. + + If the specified value is True, the configuration is processed as described + in the section on "Incremental Configuration", below. + +A Working Example +----------------- + +The following is an actual working configuration in YAML format (except that +the email addresses are bogus):: + + formatters: + brief: + format: '%(levelname)-8s: %(name)-15s: %(message)s' + precise: + format: '%(asctime)s %(name)-15s %(levelname)-8s %(message)s' + filters: + allow_foo: + name: foo + handlers: + console: + class : logging.StreamHandler + formatter: brief + level : INFO + stream : ext://sys.stdout + filters: [allow_foo] + file: + class : logging.handlers.RotatingFileHandler + formatter: precise + filename: logconfig.log + maxBytes: 1024 + backupCount: 3 + debugfile: + class : logging.FileHandler + formatter: precise + filename: logconfig-detail.log + mode: a + email: + class: logging.handlers.SMTPHandler + mailhost: localhost + fromaddr: my_app at domain.tld + toaddrs: + - support_team at domain.tld + - dev_team at domain.tld + subject: Houston, we have a problem. + loggers: + foo: + level : ERROR + handlers: [debugfile] + spam: + level : CRITICAL + handlers: [debugfile] + propagate: no + bar.baz: + level: WARNING + root: + level : DEBUG + handlers : [console, file] + +Incremental Configuration +========================= + +It is difficult to provide complete flexibility for incremental configuration. +For example, because objects such as handlers, filters and formatters are +anonymous, once a configuration is set up, it is not possible to refer to such +anonymous objects when augmenting a configuration. For example, if an initial +call is made to configure the system where logger ``foo`` has a handler with +id ``console`` attached, then a subsequent call to configure a logger ``bar`` +with id ``console`` would create a new handler instance, as the id ``console`` +from the first call isn't kept. + +Furthermore, there is not a compelling case for arbitrarily altering the +object graph of loggers, handlers, filters, formatters at run-time, once a +configuration is set up; the verbosity of loggers can be controlled just by +setting levels (and perhaps propagation flags). + +Thus, when the ``incremental`` key of a configuration dict is present and +is ``True``, the system will ignore the ``formatters``, ``filters``, +``handlers`` entries completely, and process only the ``level`` and +``propagate`` settings in the ``loggers`` and ``root`` entries. + +Configuration Errors +==================== + +If an error is encountered during configuration, the system will raise a +``ValueError`` or a ``TypeError`` with a suitably descriptive message. The +following is a (possibly incomplete) list of conditions which will raise an +error: + +* A ``level`` which is not a string or which is a string not corresponding to + an actual logging level + +* A ``propagate`` value which is not a Boolean + +* An id which does not have a corresponding destination + +* An invalid logger name + +Copyright +========= + +This document has been placed in the public domain. + + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: + From python-checkins at python.org Sun Oct 18 23:12:37 2009 From: python-checkins at python.org (r.david.murray) Date: Sun, 18 Oct 2009 21:12:37 -0000 Subject: [Python-checkins] r75503 - in python/trunk: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Sun Oct 18 23:12:37 2009 New Revision: 75503 Log: Issue #7151: regrtest would generate a JSON failure if there was output to stderr during the test run and it happened to get emitted after the worker thread emitted the result JSON. Now we capture stdout and stderr separately, which avoids that problem. It also means that _all_ stderr output is after all stdout output when we print the test results, but that seems acceptable, since output ordering is not guaranteed anyway. The patch also moves the emit of the test name into the output block generated after the test completes. Otherwise test names and test output/errors were mixed in the terminal display, making it difficult to determine which test generated the output. Modified: python/trunk/Lib/test/regrtest.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Sun Oct 18 23:12:37 2009 @@ -426,35 +426,38 @@ try: test, args_tuple = pending.popleft() except IndexError: - output.put((None, None, None)) + output.put((None, None, None, None)) return - if not quiet: - print test - sys.stdout.flush() # -E is needed by some tests, e.g. test_import popen = Popen([sys.executable, '-E', '-m', 'test.regrtest', '--slaveargs', json.dumps(args_tuple)], - stdout=PIPE, stderr=STDOUT, + stdout=PIPE, stderr=PIPE, universal_newlines=True, close_fds=True) - out = popen.communicate()[0].strip() - out = debug_output_pat.sub("", out) - out, _, result = out.strip().rpartition("\n") + stdout, stderr = popen.communicate() + # Strip last refcount output line if it exists, since it + # comes from the shutdown of the interpreter in the subcommand. + stderr = debug_output_pat.sub("", stderr) + stdout, _, result = stdout.strip().rpartition("\n") result = json.loads(result) - output.put((test, out.strip(), result)) + if not quiet: + stdout = test+'\n'+stdout + output.put((test, stdout.rstrip(), stderr.rstrip(), result)) except BaseException: - output.put((None, None, None)) + output.put((None, None, None, None)) raise workers = [Thread(target=work) for i in range(use_mp)] for worker in workers: worker.start() finished = 0 while finished < use_mp: - test, out, result = output.get() + test, stdout, stderr, result = output.get() if test is None: finished += 1 continue - if out: - print out + if stdout: + print stdout + if stderr: + print >>sys.stderr, stderr if result[0] == -4: assert result[1] == 'KeyboardInterrupt' pending.clear() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 18 23:12:37 2009 @@ -1473,6 +1473,9 @@ Tests ----- +- Issue #7151: fixed regrtest -j so that output to stderr from a test no + longer runs the risk of causing the worker thread to fail. + - Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. From nnorwitz at gmail.com Mon Oct 19 00:14:48 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sun, 18 Oct 2009 18:14:48 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20091018221448.GA11344@python.psfb.org> 344 tests OK. 1 test failed: test_ssl 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_unittest test_doctest test_doctest2 test_MimeWriter test_SimpleHTTPServer test_StringIO test___all__ test___future__ test__locale test_abc test_abstract_numbers test_aepack test_aepack skipped -- No module named aetypes test_aifc test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named MacOS test_array test_ascii_formatd test_ast test_asynchat test_asyncore test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Sleepycat Software: Berkeley DB 4.1.25: (December 19, 2002) Test path prefix: /tmp/z-test_bsddb3-4258 test_buffer test_bufio test_bytes test_bz2 test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_collections test_colorsys test_commands test_compare test_compile test_compileall test_compiler test_complex test_complex_args test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_cprofile test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_difflib test_dircache test_dis test_distutils [19542 refs] Warning -- sys.stdout was modified by test_distutils test_dl test_docxmlrpc test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_epoll test_epoll skipped -- kernel doesn't support epoll() test_errno test_exception_variations test_extcall test_fcntl test_file test_file2k test_filecmp test_fileinput test_fileio test_float test_fnmatch test_fork1 test_format test_fpformat test_fractions test_frozen test_ftplib test_funcattrs test_functools test_future test_future3 test_future4 test_future5 test_future_builtins test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_httpservers [15421 refs] [15421 refs] [15421 refs] [25435 refs] test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_json test_kqueue test_kqueue skipped -- test works only on BSD test_largefile test_lib2to3 test_linecache test_list test_locale test_logging test_long test_long_future test_longexp test_macos test_macos skipped -- No module named MacOS test_macostools test_macostools skipped -- No module named MacOS test_macpath test_mailbox test_marshal test_math test_md5 test_memoryio test_memoryview test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_modulefinder test_multibytecodec test_multibytecodec_support test_multifile test_multiprocessing test_multiprocessing skipped -- OSError raises on RLock creation, see issue 3111! test_mutants test_mutex test_netrc test_new test_nis test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser Expecting 's_push: parser stack overflow' in next line s_push: parser stack overflow test_pdb test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pipes test_pkg test_pkgimport test_pkgutil test_platform [17009 refs] [17009 refs] test_plistlib test_poll test_popen [15426 refs] [15426 refs] [15426 refs] test_popen2 test_poplib test_posix test_posixpath test_pow test_pprint test_print test_profile test_profilehooks test_property test_pstats test_pty test_pwd test_py3kwarn test_py3kwarn skipped -- test.test_py3kwarn must be run with the -3 flag test_pyclbr test_pydoc [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20920 refs] [20919 refs] [20919 refs] test_pyexpat test_queue test_quopri [17947 refs] [17947 refs] test_random test_re test_readline test_repr test_resource test_rfc822 test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site [15421 refs] [15421 refs] [15424 refs] [15421 refs] test_slice test_smtplib test_smtpnet test_socket test_socketserver test_softspace test_sort test_sqlite test_ssl Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 282, in _handle_request_noblock self.process_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 308, in process_request self.finish_request(request, client_address) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 321, in finish_request self.RequestHandlerClass(request, client_address, self) File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 639, in __init__ self.finish() File "/tmp/python-test/local/lib/python2.7/SocketServer.py", line 692, in finish self.wfile.flush() File "/tmp/python-test/local/lib/python2.7/socket.py", line 300, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 203, in sendall v = self.send(data[count:]) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 94, in self.send = lambda data, flags=0: SSLSocket.send(self, data, flags) File "/tmp/python-test/local/lib/python2.7/ssl.py", line 174, in send v = self._sslobj.write(data) TypeError: must be string or read-only buffer, not memoryview test test_ssl failed -- Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 985, in testSocketServer raise test_support.TestFailed(msg) TestFailed: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.7/test/test_ssl.py", line 972, in testSocketServer f = urllib.urlopen(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 206, in open return getattr(self, name)(url) File "/tmp/python-test/local/lib/python2.7/urllib.py", line 445, in open_https 'got a bad status line', None) IOError: ('http protocol error', 0, 'got a bad status line', None) test_startfile test_startfile skipped -- module os has no attribute startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structmembers test_structseq test_subprocess [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [17264 refs] [15636 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] [15421 refs] . [15421 refs] [15421 refs] this bit of output is from a test of stdout in a different process ... [15421 refs] [15421 refs] [15636 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [15421 refs] [15421 refs] [15650 refs] [15444 refs] test_tarfile /tmp/python-test/local/lib/python2.7/test/test_tarfile.py:654: DeprecationWarning: use the filter argument instead tar.add(tempdir, arcname="empty_dir", exclude=exclude) /tmp/python-test/local/lib/python2.7/tarfile.py:1978: DeprecationWarning: use the filter argument instead recursive, exclude, filter) test_tcl test_tcl skipped -- No module named _tkinter test_telnetlib test_tempfile [15424 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading [18734 refs] [20294 refs] [20108 refs] [20108 refs] [20108 refs] [20108 refs] test_threading_local test_threadsignals test_time test_timeout test_tk test_tk skipped -- No module named _tkinter test_tokenize test_trace test_traceback test_transformer test_ttk_guionly test_ttk_guionly skipped -- No module named _tkinter test_ttk_textonly test_ttk_textonly skipped -- No module named _tkinter test_tuple test_typechecks test_ucn test_unary test_undocumented_details test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_univnewlines test_univnewlines2k test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib /tmp/python-test/local/lib/python2.7/test/test_xmllib.py:24: DeprecationWarning: The xmllib module is obsolete. Use xml.sax instead. import xmllib test_xmlrpc test_xpickle sh: line 1: python2.4: command not found sh: line 1: python2.6: command not found test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zipimport_support test_zlib 344 tests OK. 1 test failed: test_ssl 1 test altered the execution environment: test_distutils 27 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_epoll test_gl test_imgfile test_ioctl test_kqueue test_macos test_macostools test_multiprocessing test_pep277 test_py3kwarn test_scriptpackages test_startfile test_sunaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_unicode_file test_winreg test_winsound test_zipfile64 6 skips unexpected on linux2: test_multiprocessing test_ttk_guionly test_epoll test_tk test_ioctl test_ttk_textonly [895071 refs] From python-checkins at python.org Mon Oct 19 00:18:17 2009 From: python-checkins at python.org (r.david.murray) Date: Sun, 18 Oct 2009 22:18:17 -0000 Subject: [Python-checkins] r75504 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Mon Oct 19 00:18:17 2009 New Revision: 75504 Log: Clean up merge of r75400. Modified: python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Oct 19 00:18:17 2009 @@ -337,7 +337,7 @@ try: result = runtest(*args, **kwargs) except BaseException as e: - result = -3, e.__class__.__name__ + result = -4, e.__class__.__name__ sys.stdout.flush() print() # Force a newline (just in case) print(json.dumps(result)) @@ -496,7 +496,7 @@ if test is None: finished += 1 continue - if result[0] == -3: + if result[0] == -4: assert result[1] == 'KeyboardInterrupt' pending.clear() raise KeyboardInterrupt # What else? @@ -805,44 +805,25 @@ test_time = 0.0 refleak = False # True if the test leaked references. try: - save_stdout = sys.stdout - # Save various things that tests may mess up so we can restore - # them afterward. - save_environ = dict(os.environ) - save_argv = sys.argv[:] - try: - if test.startswith('test.'): - abstest = test - else: - # Always import it from the test package - abstest = 'test.' + test - with saved_test_environment(test, verbose, quiet) as environment: - start_time = time.time() - the_package = __import__(abstest, globals(), locals(), []) - the_module = getattr(the_package, test) - # Old tests run to completion simply as a side-effect of - # being imported. For tests based on unittest or doctest, - # explicitly invoke their test_main() function (if it exists). - indirect_test = getattr(the_module, "test_main", None) - if indirect_test is not None: - indirect_test() - if huntrleaks: - refleak = dash_R(the_module, test, indirect_test, - huntrleaks) - test_time = time.time() - start_time - finally: - sys.stdout = save_stdout - # Restore what we saved if needed, but also complain if the test - # changed it so that the test may eventually get fixed. - if not os.environ == save_environ: - if not quiet: - print("Warning: os.environ was modified by", test) - os.environ.clear() - os.environ.update(save_environ) - if not sys.argv == save_argv: - if not quiet: - print("Warning: argv was modified by", test) - sys.argv[:] = save_argv + if test.startswith('test.'): + abstest = test + else: + # Always import it from the test package + abstest = 'test.' + test + with saved_test_environment(test, verbose, quiet) as environment: + start_time = time.time() + the_package = __import__(abstest, globals(), locals(), []) + the_module = getattr(the_package, test) + # Old tests run to completion simply as a side-effect of + # being imported. For tests based on unittest or doctest, + # explicitly invoke their test_main() function (if it exists). + indirect_test = getattr(the_module, "test_main", None) + if indirect_test is not None: + indirect_test() + if huntrleaks: + refleak = dash_R(the_module, test, indirect_test, + huntrleaks) + test_time = time.time() - start_time except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 19 00:18:17 2009 @@ -289,8 +289,9 @@ - Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. -- Issue #7058: Added save/restore for argv and os.environ to runtest_inner - in regrtest, with warnings if the called test modifies them. +- Issue #7058: Added save/restore for things like sys.argv and cwd to + runtest_inner in regrtest, with warnings if the called test modifies them, + and a new section in the summary report at the end. - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. From python-checkins at python.org Mon Oct 19 00:19:23 2009 From: python-checkins at python.org (r.david.murray) Date: Sun, 18 Oct 2009 22:19:23 -0000 Subject: [Python-checkins] r75505 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 00:19:23 2009 New Revision: 75505 Log: Blocked revisions 75504 via svnmerge ........ r75504 | r.david.murray | 2009-10-18 18:18:17 -0400 (Sun, 18 Oct 2009) | 2 lines Clean up merge of r75400. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 19 02:34:13 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 00:34:13 -0000 Subject: [Python-checkins] r75506 - python/trunk/Python/marshal.c Message-ID: Author: eric.smith Date: Mon Oct 19 02:34:12 2009 New Revision: 75506 Log: Removed calls to PyFloat_AsReprString. This is in anticipation of possibly implementing issue 7117 (short float repr). This removes the last calls to PyFloat_AsString, PyFloat_AsReprString, and PyFloat_AsStringEx, which are unsafe. Also, switch to defines for error values to bring this code more in line with the py3k branch. Modified: python/trunk/Python/marshal.c Modified: python/trunk/Python/marshal.c ============================================================================== --- python/trunk/Python/marshal.c (original) +++ python/trunk/Python/marshal.c Mon Oct 19 02:34:12 2009 @@ -44,9 +44,14 @@ #define TYPE_SET '<' #define TYPE_FROZENSET '>' +#define WFERR_OK 0 +#define WFERR_UNMARSHALLABLE 1 +#define WFERR_NESTEDTOODEEP 2 +#define WFERR_NOMEMORY 3 + typedef struct { FILE *fp; - int error; + int error; /* see WFERR_* values */ int depth; /* If fp == NULL, the following are valid: */ PyObject *str; @@ -179,7 +184,7 @@ p->depth++; if (p->depth > MAX_MARSHAL_STACK_DEPTH) { - p->error = 2; + p->error = WFERR_NESTEDTOODEEP; } else if (v == NULL) { w_byte(TYPE_NULL, p); @@ -223,19 +228,24 @@ unsigned char buf[8]; if (_PyFloat_Pack8(PyFloat_AsDouble(v), buf, 1) < 0) { - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_byte(TYPE_BINARY_FLOAT, p); w_string((char*)buf, 8, p); } else { - char buf[256]; /* Plenty to format any double */ - PyFloat_AsReprString(buf, (PyFloatObject *)v); + char *buf = PyOS_double_to_string(PyFloat_AS_DOUBLE(v), + 'g', 17, 0, NULL); + if (!buf) { + p->error = WFERR_NOMEMORY; + return; + } n = strlen(buf); w_byte(TYPE_FLOAT, p); w_byte((int)n, p); w_string(buf, (int)n, p); + PyMem_Free(buf); } } #ifndef WITHOUT_COMPLEX @@ -244,44 +254,41 @@ unsigned char buf[8]; if (_PyFloat_Pack8(PyComplex_RealAsDouble(v), buf, 1) < 0) { - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_byte(TYPE_BINARY_COMPLEX, p); w_string((char*)buf, 8, p); if (_PyFloat_Pack8(PyComplex_ImagAsDouble(v), buf, 1) < 0) { - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_string((char*)buf, 8, p); } else { - char buf[256]; /* Plenty to format any double */ - PyFloatObject *temp; + char *buf; w_byte(TYPE_COMPLEX, p); - temp = (PyFloatObject*)PyFloat_FromDouble( - PyComplex_RealAsDouble(v)); - if (!temp) { - p->error = 1; + buf = PyOS_double_to_string(PyComplex_RealAsDouble(v), + 'g', 17, 0, NULL); + if (!buf) { + p->error = WFERR_NOMEMORY; return; } - PyFloat_AsReprString(buf, temp); - Py_DECREF(temp); n = strlen(buf); w_byte((int)n, p); w_string(buf, (int)n, p); - temp = (PyFloatObject*)PyFloat_FromDouble( - PyComplex_ImagAsDouble(v)); - if (!temp) { - p->error = 1; + PyMem_Free(buf); + buf = PyOS_double_to_string(PyComplex_ImagAsDouble(v), + 'g', 17, 0, NULL); + if (!buf) { + p->error = WFERR_NOMEMORY; return; } - PyFloat_AsReprString(buf, temp); - Py_DECREF(temp); n = strlen(buf); w_byte((int)n, p); w_string(buf, (int)n, p); + PyMem_Free(buf); } } #endif @@ -302,7 +309,7 @@ Py_XDECREF(o); if (!ok) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_byte(TYPE_INTERNED, p); @@ -315,7 +322,7 @@ if (n > INT_MAX) { /* huge strings are not supported */ p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_long((long)n, p); @@ -327,14 +334,14 @@ utf8 = PyUnicode_AsUTF8String(v); if (utf8 == NULL) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_byte(TYPE_UNICODE, p); n = PyString_GET_SIZE(utf8); if (n > INT_MAX) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_long((long)n, p); @@ -380,14 +387,14 @@ n = PyObject_Size(v); if (n == -1) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_long((long)n, p); it = PyObject_GetIter(v); if (it == NULL) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } while ((value = PyIter_Next(it)) != NULL) { @@ -397,7 +404,7 @@ Py_DECREF(it); if (PyErr_Occurred()) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } } @@ -427,7 +434,7 @@ n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s); if (n > INT_MAX) { p->depth--; - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; return; } w_long((long)n, p); @@ -435,7 +442,7 @@ } else { w_byte(TYPE_UNKNOWN, p); - p->error = 1; + p->error = WFERR_UNMARSHALLABLE; } exit: p->depth--; @@ -447,7 +454,7 @@ { WFILE wf; wf.fp = fp; - wf.error = 0; + wf.error = WFERR_OK; wf.depth = 0; wf.strings = NULL; wf.version = version; @@ -459,7 +466,7 @@ { WFILE wf; wf.fp = fp; - wf.error = 0; + wf.error = WFERR_OK; wf.depth = 0; wf.strings = (version > 0) ? PyDict_New() : NULL; wf.version = version; @@ -1184,6 +1191,24 @@ return result; } +static void +set_error(int error) +{ + switch (error) { + case WFERR_NOMEMORY: + PyErr_NoMemory(); + break; + case WFERR_UNMARSHALLABLE: + PyErr_SetString(PyExc_ValueError, "unmarshallable object"); + break; + case WFERR_NESTEDTOODEEP: + default: + PyErr_SetString(PyExc_ValueError, + "object too deeply nested to marshal"); + break; + } +} + PyObject * PyMarshal_WriteObjectToString(PyObject *x, int version) { @@ -1194,7 +1219,7 @@ return NULL; wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str); wf.end = wf.ptr + PyString_Size(wf.str); - wf.error = 0; + wf.error = WFERR_OK; wf.depth = 0; wf.version = version; wf.strings = (version > 0) ? PyDict_New() : NULL; @@ -1210,11 +1235,9 @@ } _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)); } - if (wf.error) { + if (wf.error != WFERR_OK) { Py_XDECREF(wf.str); - PyErr_SetString(PyExc_ValueError, - (wf.error==1)?"unmarshallable object" - :"object too deeply nested to marshal"); + set_error(wf.error); return NULL; } return wf.str; @@ -1239,16 +1262,14 @@ wf.fp = PyFile_AsFile(f); wf.str = NULL; wf.ptr = wf.end = NULL; - wf.error = 0; + wf.error = WFERR_OK; wf.depth = 0; wf.strings = (version > 0) ? PyDict_New() : 0; wf.version = version; w_object(x, &wf); Py_XDECREF(wf.strings); - if (wf.error) { - PyErr_SetString(PyExc_ValueError, - (wf.error==1)?"unmarshallable object" - :"object too deeply nested to marshal"); + if (wf.error != WFERR_OK) { + set_error(wf.error); return NULL; } Py_INCREF(Py_None); From python-checkins at python.org Mon Oct 19 02:34:49 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 00:34:49 -0000 Subject: [Python-checkins] r75507 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Mon Oct 19 02:34:48 2009 New Revision: 75507 Log: Blocked revisions 75506 via svnmerge ........ r75506 | eric.smith | 2009-10-18 20:34:12 -0400 (Sun, 18 Oct 2009) | 7 lines Removed calls to PyFloat_AsReprString. This is in anticipation of possibly implementing issue 7117 (short float repr). This removes the last calls to PyFloat_AsString, PyFloat_AsReprString, and PyFloat_AsStringEx, which are unsafe. Also, switch to defines for error values to bring this code more in line with the py3k branch. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 19 02:35:35 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 00:35:35 -0000 Subject: [Python-checkins] r75508 - python/branches/py3k Message-ID: Author: eric.smith Date: Mon Oct 19 02:35:35 2009 New Revision: 75508 Log: Blocked revisions 75506 via svnmerge ........ r75506 | eric.smith | 2009-10-18 20:34:12 -0400 (Sun, 18 Oct 2009) | 7 lines Removed calls to PyFloat_AsReprString. This is in anticipation of possibly implementing issue 7117 (short float repr). This removes the last calls to PyFloat_AsString, PyFloat_AsReprString, and PyFloat_AsStringEx, which are unsafe. Also, switch to defines for error values to bring this code more in line with the py3k branch. ........ Modified: python/branches/py3k/ (props changed) From ncoghlan at gmail.com Mon Oct 19 03:09:49 2009 From: ncoghlan at gmail.com (Nick Coghlan) Date: Mon, 19 Oct 2009 11:09:49 +1000 Subject: [Python-checkins] r75504 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS In-Reply-To: <4adb9516.0867f10a.6b21.ffffd621SMTPIN_ADDED@mx.google.com> References: <4adb9516.0867f10a.6b21.ffffd621SMTPIN_ADDED@mx.google.com> Message-ID: <4ADBBC5D.6080007@gmail.com> r.david.murray wrote: > Author: r.david.murray > Date: Mon Oct 19 00:18:17 2009 > New Revision: 75504 > > Log: > Clean up merge of r75400. Thanks, I was afraid I'd missed something when I did that. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- From rdmurray at bitdance.com Mon Oct 19 07:11:27 2009 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 19 Oct 2009 01:11:27 -0400 (EDT) Subject: [Python-checkins] r75504 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS In-Reply-To: <4ADBBC5D.6080007@gmail.com> References: <4adb9516.0867f10a.6b21.ffffd621SMTPIN_ADDED@mx.google.com> <4ADBBC5D.6080007@gmail.com> Message-ID: On Mon, 19 Oct 2009 at 11:09, Nick Coghlan wrote: > r.david.murray wrote: >> Author: r.david.murray >> Date: Mon Oct 19 00:18:17 2009 >> New Revision: 75504 >> >> Log: >> Clean up merge of r75400. > > Thanks, I was afraid I'd missed something when I did that. No problem. Thanks for doing all that cleanup work on the tests. --David From python-checkins at python.org Mon Oct 19 15:49:12 2009 From: python-checkins at python.org (georg.brandl) Date: Mon, 19 Oct 2009 13:49:12 -0000 Subject: [Python-checkins] r75509 - peps/trunk/pep-0391.txt Message-ID: Author: georg.brandl Date: Mon Oct 19 15:49:12 2009 New Revision: 75509 Log: Reformat according to PEP 12. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Mon Oct 19 15:49:12 2009 @@ -14,195 +14,211 @@ Abstract ======== -This PEP describes a new way of configuring logging using a dictionary to hold -configuration information. +This PEP describes a new way of configuring logging using a dictionary +to hold configuration information. + Rationale ========= -The present means for configuring Python's logging package is either by using -the logging API to configure logging programmatically, or else by means of -ConfigParser-based configuration files. +The present means for configuring Python's logging package is either +by using the logging API to configure logging programmatically, or +else by means of ConfigParser-based configuration files. Programmatic configuration, while offering maximal control, fixes the -configuration in Python code. This does not facilitate changing it easily at -runtime, and, as a result, the ability to flexibly turn the verbosity of -logging up and down for different parts of a using application is lost. This -limits the usability of logging as an aid to diagnosing problems - and -sometimes, logging is the only diagnostic aid available in production -environments. - -The ConfigParser-based configuration system is usable, but does not allow its -users to configure all aspects of the logging package. For example, Filters -cannot be configured using this system. Furthermore, the ConfigParser format -appears to engender dislike (sometimes strong dislike) in some quarters. -Though it was chosen because it was the only configuration format supported in -the Python standard at that time, many people regard it (or perhaps just the -particular schema chosen for logging's configuration) as 'crufty' or 'ugly', -in some cases apparently on purely aesthetic grounds. - -Recent versions of Python inlude JSON support in the standard library, and -this is also usable as a configuration format. In other environments, such as -Google App Engine, YAML is used to configure applications, and usually the -configuration of logging would be considered an integral part of the -application configuration. Although the standard library does not contain -YAML support at present, support for both JSON and YAML can be provided in a -common way because both of these serialization formats allow deserialization +configuration in Python code. This does not facilitate changing it +easily at runtime, and, as a result, the ability to flexibly turn the +verbosity of logging up and down for different parts of a using +application is lost. This limits the usability of logging as an aid +to diagnosing problems - and sometimes, logging is the only diagnostic +aid available in production environments. + +The ConfigParser-based configuration system is usable, but does not +allow its users to configure all aspects of the logging package. For +example, Filters cannot be configured using this system. Furthermore, +the ConfigParser format appears to engender dislike (sometimes strong +dislike) in some quarters. Though it was chosen because it was the +only configuration format supported in the Python standard at that +time, many people regard it (or perhaps just the particular schema +chosen for logging's configuration) as 'crufty' or 'ugly', in some +cases apparently on purely aesthetic grounds. + +Recent versions of Python include JSON support in the standard +library, and this is also usable as a configuration format. In other +environments, such as Google App Engine, YAML is used to configure +applications, and usually the configuration of logging would be +considered an integral part of the application configuration. +Although the standard library does not contain YAML support at +present, support for both JSON and YAML can be provided in a common +way because both of these serialization formats allow deserialization of Python dictionaries. -By providing a way to configure logging by passing the configuration in a -dictionary, logging will be easier to configure not only for users of JSON -and/or YAML, but also for users of bespoke configuration methods, by providing -a common format in which to describe the desired configuration. - -Another drawback of the current ConfigParser-based configuration system is -that it does not support incremental configuration: a new configuration -completely replaces the existing configuration. Although full flexibility for -incremental configuration is difficult to provide in a multi-threaded -environment, the new configuration mechanism will allow the provision of -limited support for incremental configuration. +By providing a way to configure logging by passing the configuration +in a dictionary, logging will be easier to configure not only for +users of JSON and/or YAML, but also for users of bespoke configuration +methods, by providing a common format in which to describe the desired +configuration. + +Another drawback of the current ConfigParser-based configuration +system is that it does not support incremental configuration: a new +configuration completely replaces the existing configuration. +Although full flexibility for incremental configuration is difficult +to provide in a multi-threaded environment, the new configuration +mechanism will allow the provision of limited support for incremental +configuration. + Specification ============= The specification consists of two parts: the API and the format of the -dictionary used to convey configuration information (i.e. the schema to which -it must conform). +dictionary used to convey configuration information (i.e. the schema +to which it must conform). + Naming ------ -Historically, the logging package has not been PEP-8 conformant. At some -future time, this will be corrected by changing method and function names in -the package in order to conform with PEP-8. However, in the interests of -uniformity, the proposed additions to the API use a naming scheme which is -consistent with the present scheme used by logging. +Historically, the logging package has not been PEP 8 conformant [1]_. +At some future time, this will be corrected by changing method and +function names in the package in order to conform with PEP 8. +However, in the interests of uniformity, the proposed additions to the +API use a naming scheme which is consistent with the present scheme +used by logging. + API --- The logging.config module will have the following additions: -* A class, called ``DictConfigurator``, whose constructor is passed the - dictionary used for configuration, and which has a ``configure()`` method. +* A class, called ``DictConfigurator``, whose constructor is passed + the dictionary used for configuration, and which has a + ``configure()`` method. -* A callable, called ``dictConfigClass``, which will (by default) be set to - ``DictConfigurator``. This is provided so that if desired, +* A callable, called ``dictConfigClass``, which will (by default) be + set to ``DictConfigurator``. This is provided so that if desired, ``DictConfigurator`` can be replaced with a suitable user-defined implementation. -* A function, called ``dictConfig()``, which takes a single argument - the - dictionary holding the configuration. This function will call - ``dictConfigClass`` passing the specified dictionary, and then call the - ``configure()`` method on the returned object to actually put the - configuration into effect:: - - def dictConfig(config): - dictConfigClass(config).configure() +* A function, called ``dictConfig()``, which takes a single argument + - the dictionary holding the configuration. This function will + call ``dictConfigClass`` passing the specified dictionary, and then + call the ``configure()`` method on the returned object to actually + put the configuration into effect:: + + def dictConfig(config): + dictConfigClass(config).configure() + Dictionary Schema - Overview ---------------------------- -Before describing the schema in detail, it is worth saying a few words about -object connections, support for user-defined objects and access to external -objects. +Before describing the schema in detail, it is worth saying a few words +about object connections, support for user-defined objects and access +to external objects. + Object connections '''''''''''''''''' The schema is intended to describe a set of logging objects - loggers, -handlers, formatters, filters - which are connected to each other in an -object graph. Thus, the schema needs to represent connections between the -objects. For example, say that, once configured, a particular logger has an -attached to it a particular handler. For the purposes of this discussion, -we can say that the logger represents the source, and the handler the -destination, of a connection between the two. Of course in the configured -objects this is represented by the logger holding a reference to the -handler. In the configuration dict, this is done by giving each destination -object an id which identifies it unambiguously, and then using the id in the -source object's configuration to indicate that a connection exists between -the source and the destination object with that id. - +handlers, formatters, filters - which are connected to each other in +an object graph. Thus, the schema needs to represent connections +between the objects. For example, say that, once configured, a +particular logger has an attached to it a particular handler. For the +purposes of this discussion, we can say that the logger represents the +source, and the handler the destination, of a connection between the +two. Of course in the configured objects this is represented by the +logger holding a reference to the handler. In the configuration dict, +this is done by giving each destination object an id which identifies +it unambiguously, and then using the id in the source object's +configuration to indicate that a connection exists between the source +and the destination object with that id. + So, for example, consider the following YAML snippet:: - - handlers: - h1: #This is an id - # configuration of handler with id h1 goes here - h2: #This is another id - # configuration of handler with id h2 goes here - loggers: - foo.bar.baz: - # other configuration for logger "foo.bar.baz" - handlers: [h1, h2] - -(Note: YAML will be used in this document as it is more readable than the -equivalent Python source form for the dictionary.) - + + handlers: + h1: #This is an id + # configuration of handler with id h1 goes here + h2: #This is another id + # configuration of handler with id h2 goes here + loggers: + foo.bar.baz: + # other configuration for logger "foo.bar.baz" + handlers: [h1, h2] + +(Note: YAML will be used in this document as it is more readable than +the equivalent Python source form for the dictionary.) + The ids for loggers are the logger names which would be used programmatically to obtain a reference to those loggers, e.g. -``foo.bar.baz``. The ids for other objects can be any string value (such as -``h1``, ``h2`` above) and they are transient, in that they are only -meaningful for processing the configuration dictionary and used to -determine connections between objects, and are not persisted anywhere when -the configuration call is complete. - -The above snippet indicates that logger named ``foo.bar.baz`` should have -two handlers attached to it, which are described by the handler ids ``h1`` -and ``h2``. +``foo.bar.baz``. The ids for other objects can be any string value +(such as ``h1``, ``h2`` above) and they are transient, in that they +are only meaningful for processing the configuration dictionary and +used to determine connections between objects, and are not persisted +anywhere when the configuration call is complete. + +The above snippet indicates that logger named ``foo.bar.baz`` should +have two handlers attached to it, which are described by the handler +ids ``h1`` and ``h2``. + User-defined objects '''''''''''''''''''' -The schema should support user-defined objects for handlers, filters and -formatters. (Loggers do not need to have different types for different -instances, so there is no support - in the configuration - for user-defined -logger classes.) - -Objects to be configured will typically be described by dictionaries which -detail their configuration. In some places, the logging system will be able -to infer from the context how an object is to be instantiated, but when a -user-defined object is to be instantiated, the system will not know how to do -this. In order to provide complete flexibility for user-defined object -instantiation, the user will need to provide a 'factory' - a callable which -is called with a configuration dictionary and which returns the instantiated -object. This will be signalled by the factory being made available under -the special key ``'()'``. Here's a concrete example:: - - formatters: - brief: - format: '%(message)s' - default: - format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s' - datefmt: '%Y-%m-%d %H:%M:%S' - custom: - (): my.package.customFormatterFactory - bar: baz - spam: 99.9 - answer: 42 +The schema should support user-defined objects for handlers, filters +and formatters. (Loggers do not need to have different types for +different instances, so there is no support - in the configuration - +for user-defined logger classes.) + +Objects to be configured will typically be described by dictionaries +which detail their configuration. In some places, the logging system +will be able to infer from the context how an object is to be +instantiated, but when a user-defined object is to be instantiated, +the system will not know how to do this. In order to provide complete +flexibility for user-defined object instantiation, the user will need +to provide a 'factory' - a callable which is called with a +configuration dictionary and which returns the instantiated object. +This will be signalled by the factory being made available under the +special key ``'()'``. Here's a concrete example:: + + formatters: + brief: + format: '%(message)s' + default: + format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s' + datefmt: '%Y-%m-%d %H:%M:%S' + custom: + (): my.package.customFormatterFactory + bar: baz + spam: 99.9 + answer: 42 The above YAML snippet defines three formatters. The first, with id ``brief``, is a standard ``logging.Formatter`` instance with the -specified format string. The second, with id ``default``, has a longer -format and also defines the time format explicitly, and will result in a -``logging.Formatter`` initialized with those two format strings. Shown in -Python source form, the ``brief`` and ``default`` formatters have -have configuration sub-dictionaries:: - - { - 'format' : '%(message)s' - } - +specified format string. The second, with id ``default``, has a +longer format and also defines the time format explicitly, and will +result in a ``logging.Formatter`` initialized with those two format +strings. Shown in Python source form, the ``brief`` and ``default`` +formatters have configuration sub-dictionaries:: + + { + 'format' : '%(message)s' + } + and:: - - { - 'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s', - 'datefmt' : '%Y-%m-%d %H:%M:%S' - } - + + { + 'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s', + 'datefmt' : '%Y-%m-%d %H:%M:%S' + } + respectively, and as these dictionaries do not contain the special key ``'()'``, the instantiation is inferred from the context: as a result, -standard ``logging.Formatter`` instances are created. The configuration -sub-dictionary for the third formatter, with id ``custom``, is:: +standard ``logging.Formatter`` instances are created. The +configuration sub-dictionary for the third formatter, with id +``custom``, is:: { '()' : 'my.package.customFormatterFactory', @@ -210,151 +226,164 @@ 'spam' : 99.9, 'answer' : 42 } - -and this contains the special key ``'()'``, which means that user-defined -instantiation is wanted. In this case, the specified factory callable will be -located using normal import mechanisms and called with the *remaining* items -in the configuration sub-dictionary as keyword arguments. In the above -example, the formatter with id ``custom`` will be assumed to be returned by -the call:: - - my.package.customFormatterFactory(bar="baz", spam=99.9, answer=42) - -The key ``'()'`` has been used as the special key because it is not a valid -keyword parameter name, and so will not clash with the names of the keyword -arguments used in the call. The ``'()'`` also serves as a mnemonic that the -corresponding value is a callable. + +and this contains the special key ``'()'``, which means that +user-defined instantiation is wanted. In this case, the specified +factory callable will be located using normal import mechanisms and +called with the *remaining* items in the configuration sub-dictionary +as keyword arguments. In the above example, the formatter with id +``custom`` will be assumed to be returned by the call:: + + my.package.customFormatterFactory(bar="baz", spam=99.9, answer=42) + +The key ``'()'`` has been used as the special key because it is not a +valid keyword parameter name, and so will not clash with the names of +the keyword arguments used in the call. The ``'()'`` also serves as a +mnemonic that the corresponding value is a callable. + Access to external objects '''''''''''''''''''''''''' -There are times where a configuration will need to refer to objects external -to the configuration, for example ``sys.stderr``. If the configuration dict -is constructed using Python code then this is straightforward, but a problem -arises when the configuration is provided via a text file (e.g. JSON, YAML). -In a text file, there is no standard way to distinguish ``sys.stderr`` from -the literal string ``'sys.stderr'``. To facilitate this distinction, the -configuration system will look for certain special prefixes in string values -and treat them specially. For example, if the literal string -``'ext://sys.stderr'`` is provided as a value in the configuration, then the -``ext://`` will be stripped off and the remainder of the value processed using -normal import mechanisms. - -The handling of such prefixes will be done in a way analogous to protocol -handling: there will be a generic mechanism to look for prefixes which match -the regular expression ``^(?P[a-z]+)://(?P.*)$`` whereby, if -the ``prefix`` is recognised, the ``suffix`` is processed in a -prefix-dependent manner and the result of the processing replaces the string -value. If the prefix is not recognised, then the string value will be left +There are times where a configuration will need to refer to objects +external to the configuration, for example ``sys.stderr``. If the +configuration dict is constructed using Python code then this is +straightforward, but a problem arises when the configuration is +provided via a text file (e.g. JSON, YAML). In a text file, there is +no standard way to distinguish ``sys.stderr`` from the literal string +``'sys.stderr'``. To facilitate this distinction, the configuration +system will look for certain special prefixes in string values and +treat them specially. For example, if the literal string +``'ext://sys.stderr'`` is provided as a value in the configuration, +then the ``ext://`` will be stripped off and the remainder of the +value processed using normal import mechanisms. + +The handling of such prefixes will be done in a way analogous to +protocol handling: there will be a generic mechanism to look for +prefixes which match the regular expression +``^(?P[a-z]+)://(?P.*)$`` whereby, if the ``prefix`` +is recognised, the ``suffix`` is processed in a prefix-dependent +manner and the result of the processing replaces the string value. If +the prefix is not recognised, then the string value will be left as-is. The implementation will provide for a set of standard prefixes such as -``ext://`` but it will be possible to disable the mechanism completely or -provide additional or different prefixes for special handling. +``ext://`` but it will be possible to disable the mechanism completely +or provide additional or different prefixes for special handling. + Dictionary Schema - Detail -------------------------- -The dictionary passed to ``dictConfig()`` must contain the following keys: +The dictionary passed to ``dictConfig()`` must contain the following +keys: * `version` - to be set to an integer value representing the schema - version. The only valid value at present is 1, but having this key allows - the schema to evolve while still preserving backwards compatibility. + version. The only valid value at present is 1, but having this key + allows the schema to evolve while still preserving backwards + compatibility. + +All other keys are optional, but if present they will be interpreted +as described below. In all cases below where a 'configuring dict' is +mentioned, it will be checked for the special ``'()'`` key to see if a +custom instantiation is required. If so, the mechanism described +above is used to instantiate; otherwise, the context is used to +determine how to instantiate. + +* `formatters` - the corresponding value will be a dict in which each + key is a formatter id and each value is a dict describing how to + configure the corresponding Formatter instance. -All other keys are optional, but if present they will be interpreted as described -below. In all cases below where a 'configuring dict' is mentioned, it will be -checked for the special ``'()'`` key to see if a custom instantiation is -required. If so, the mechanism described above is used to instantiate; -otherwise, the context is used to determine how to instantiate. - -* `formatters` - the corresponding value will be a dict in which each key is - a formatter id and each value is a dict describing how to configure the - corresponding Formatter instance. - - The configuring dict is searched for keys ``format`` and ``datefmt`` (with - defaults of ``None``) and these are used to construct a + The configuring dict is searched for keys ``format`` and ``datefmt`` + (with defaults of ``None``) and these are used to construct a ``logging.Formatter`` instance. -* `filters` - the corresponding value will be a dict in which each key is - a filter id and each value is a dict describing how to configure the - corresponding Filter instance. - - The configuring dict is searched for key ``name`` (defaulting to the empty - string) and this is used to construct a ``logging.Filter`` instance. - -* `handlers` - the corresponding value will be a dict in which each key is - a handler id and each value is a dict describing how to configure the - corresponding Handler instance. +* `filters` - the corresponding value will be a dict in which each key + is a filter id and each value is a dict describing how to configure + the corresponding Filter instance. + + The configuring dict is searched for key ``name`` (defaulting to the + empty string) and this is used to construct a ``logging.Filter`` + instance. + +* `handlers` - the corresponding value will be a dict in which each + key is a handler id and each value is a dict describing how to + configure the corresponding Handler instance. The configuring dict is searched for the following keys: - - * ``class`` (mandatory). This is the fully qualified name of the handler - class. - + + * ``class`` (mandatory). This is the fully qualified name of the + handler class. + * ``level`` (optional). The level of the handler. - - * ``formatter`` (optional). The id of the formatter for this handler. - - * ``filters`` (optional). A list of ids of the filters for this handler. - All *other* keys are passed through as keyword arguments to the handler's - constructor. For example, given the snippet:: + * ``formatter`` (optional). The id of the formatter for this + handler. - handlers: - console: - class : logging.StreamHandler - formatter: brief - level : INFO - filters: [allow_foo] - stream : ext://sys.stdout - file: - class : logging.handlers.RotatingFileHandler - formatter: precise - filename: logconfig.log - maxBytes: 1024 - backupCount: 3 + * ``filters`` (optional). A list of ids of the filters for this + handler. + + All *other* keys are passed through as keyword arguments to the + handler's constructor. For example, given the snippet:: + + handlers: + console: + class : logging.StreamHandler + formatter: brief + level : INFO + filters: [allow_foo] + stream : ext://sys.stdout + file: + class : logging.handlers.RotatingFileHandler + formatter: precise + filename: logconfig.log + maxBytes: 1024 + backupCount: 3 the handler with id ``console`` is instantiated as a - ``logging.StreamHandler``, using ``sys.stdout`` as the underlying stream. - The handler with id ``file`` is instantiated as a + ``logging.StreamHandler``, using ``sys.stdout`` as the underlying + stream. The handler with id ``file`` is instantiated as a ``logging.handlers.RotatingFileHandler`` with the keyword arguments ``filename="logconfig.log", maxBytes=1024, backupCount=3``. -* `loggers` - the corresponding value will be a dict in which each key is - a logger name and each value is a dict describing how to configure the - corresponding Logger instance. +* `loggers` - the corresponding value will be a dict in which each key + is a logger name and each value is a dict describing how to + configure the corresponding Logger instance. The configuring dict is searched for the following keys: - + * ``level`` (optional). The level of the logger. - + * ``propagate`` (optional). The propagation setting of the logger. - - * ``filters`` (optional). A list of ids of the filters for this logger. - * ``handlers`` (optional). A list of ids of the handlers for this logger. + * ``filters`` (optional). A list of ids of the filters for this + logger. + + * ``handlers`` (optional). A list of ids of the handlers for this + logger. The specified loggers will be configured according to the level, propagation, filters and handlers specified. -* `root` - this will be the configuration for the root logger. Processing of - the configuration will be as for any logger, except that the ``propagate`` - setting will not be applicable. - +* `root` - this will be the configuration for the root logger. + Processing of the configuration will be as for any logger, except + that the ``propagate`` setting will not be applicable. + * `incremental` - whether the configuration is to be interpreted as - incremental to the existing configuration. This value defaults to False, - which means that the specified configuration replaces the existing - configuration with the same semantics as used by the existing - ``fileConfig()`` API. - - If the specified value is True, the configuration is processed as described - in the section on "Incremental Configuration", below. + incremental to the existing configuration. This value defaults to + ``False``, which means that the specified configuration replaces the + existing configuration with the same semantics as used by the + existing ``fileConfig()`` API. + + If the specified value is ``True``, the configuration is processed + as described in the section on `Incremental Configuration`_, below. + A Working Example ----------------- -The following is an actual working configuration in YAML format (except that -the email addresses are bogus):: +The following is an actual working configuration in YAML format +(except that the email addresses are bogus):: formatters: brief: @@ -404,45 +433,57 @@ level : DEBUG handlers : [console, file] + Incremental Configuration ========================= -It is difficult to provide complete flexibility for incremental configuration. -For example, because objects such as handlers, filters and formatters are -anonymous, once a configuration is set up, it is not possible to refer to such -anonymous objects when augmenting a configuration. For example, if an initial -call is made to configure the system where logger ``foo`` has a handler with -id ``console`` attached, then a subsequent call to configure a logger ``bar`` -with id ``console`` would create a new handler instance, as the id ``console`` +It is difficult to provide complete flexibility for incremental +configuration. For example, because objects such as handlers, filters +and formatters are anonymous, once a configuration is set up, it is +not possible to refer to such anonymous objects when augmenting a +configuration. For example, if an initial call is made to configure +the system where logger ``foo`` has a handler with id ``console`` +attached, then a subsequent call to configure a logger ``bar`` with id +``console`` would create a new handler instance, as the id ``console`` from the first call isn't kept. -Furthermore, there is not a compelling case for arbitrarily altering the -object graph of loggers, handlers, filters, formatters at run-time, once a -configuration is set up; the verbosity of loggers can be controlled just by -setting levels (and perhaps propagation flags). - -Thus, when the ``incremental`` key of a configuration dict is present and -is ``True``, the system will ignore the ``formatters``, ``filters``, -``handlers`` entries completely, and process only the ``level`` and -``propagate`` settings in the ``loggers`` and ``root`` entries. +Furthermore, there is not a compelling case for arbitrarily altering +the object graph of loggers, handlers, filters, formatters at +run-time, once a configuration is set up; the verbosity of loggers can +be controlled just by setting levels (and perhaps propagation flags). + +Thus, when the ``incremental`` key of a configuration dict is present +and is ``True``, the system will ignore the ``formatters``, +``filters``, ``handlers`` entries completely, and process only the +``level`` and ``propagate`` settings in the ``loggers`` and ``root`` +entries. + Configuration Errors ==================== -If an error is encountered during configuration, the system will raise a -``ValueError`` or a ``TypeError`` with a suitably descriptive message. The -following is a (possibly incomplete) list of conditions which will raise an -error: +If an error is encountered during configuration, the system will raise +a ``ValueError`` or a ``TypeError`` with a suitably descriptive +message. The following is a (possibly incomplete) list of conditions +which will raise an error: -* A ``level`` which is not a string or which is a string not corresponding to - an actual logging level +* A ``level`` which is not a string or which is a string not + corresponding to an actual logging level -* A ``propagate`` value which is not a Boolean +* A ``propagate`` value which is not a boolean * An id which does not have a corresponding destination * An invalid logger name + +References +========== + +.. [1] PEP 8, Style Guide for Python Code, van Rossum, Warsaw + (http://www.python.org/dev/peps/pep-0008) + + Copyright ========= @@ -458,4 +499,3 @@ fill-column: 70 coding: utf-8 End: - From python-checkins at python.org Mon Oct 19 16:38:14 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 14:38:14 -0000 Subject: [Python-checkins] r75510 - in python/trunk: Doc/c-api/float.rst Misc/NEWS Message-ID: Author: eric.smith Date: Mon Oct 19 16:38:14 2009 New Revision: 75510 Log: Issue #7169: Document PyFloat_AsString and PyFloat_AsReprString, and note that they are unsafe and deprecated. Modified: python/trunk/Doc/c-api/float.rst python/trunk/Misc/NEWS Modified: python/trunk/Doc/c-api/float.rst ============================================================================== --- python/trunk/Doc/c-api/float.rst (original) +++ python/trunk/Doc/c-api/float.rst Mon Oct 19 16:38:14 2009 @@ -92,3 +92,27 @@ be freed. .. versionadded:: 2.6 + + +.. cfunction:: void PyFloat_AsString(char *buf, PyFloatObject *v) + + Convert the argument *v* to a string, using the same rules as + :func:`str`. The length of *buf* should be at least 100. + + This function is unsafe to call because it writes to a buffer whose + length it does not know. + + .. deprecated:: 2.7 + Use :func:`PyObject_Str` or :func:`PyOS_double_to_string` instead. + + +.. cfunction:: void PyFloat_AsReprString(char *buf, PyFloatObject *v) + + Same as PyFloat_AsString, except uses the same rules as + :func:`repr`. The length of *buf* should be at least 100. + + This function is unsafe to call because it writes to a buffer whose + length it does not know. + + .. deprecated:: 2.7 + Use :func:`PyObject_Repr` or :func:`PyOS_double_to_string` instead. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 19 16:38:14 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #7168: Document PyFloat_AsString and PyFloat_AsReprString, and + note that they are unsafe and deprecated. + - Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. From python-checkins at python.org Mon Oct 19 16:39:25 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 14:39:25 -0000 Subject: [Python-checkins] r75511 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Mon Oct 19 16:39:24 2009 New Revision: 75511 Log: Blocked revisions 75510 via svnmerge ........ r75510 | eric.smith | 2009-10-19 10:38:14 -0400 (Mon, 19 Oct 2009) | 1 line Issue #7169: Document PyFloat_AsString and PyFloat_AsReprString, and note that they are unsafe and deprecated. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 19 16:42:59 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 19 Oct 2009 14:42:59 -0000 Subject: [Python-checkins] r75512 - python/branches/py3k Message-ID: Author: eric.smith Date: Mon Oct 19 16:42:58 2009 New Revision: 75512 Log: Blocked revisions 75510 via svnmerge ........ r75510 | eric.smith | 2009-10-19 10:38:14 -0400 (Mon, 19 Oct 2009) | 1 line Issue #7169: Document PyFloat_AsString and PyFloat_AsReprString, and note that they are unsafe and deprecated. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 19 17:26:17 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 15:26:17 -0000 Subject: [Python-checkins] r75513 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS Message-ID: Author: r.david.murray Date: Mon Oct 19 17:26:16 2009 New Revision: 75513 Log: Merged revisions 75503 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75503 | r.david.murray | 2009-10-18 17:12:37 -0400 (Sun, 18 Oct 2009) | 11 lines Issue #7151: regrtest would generate a JSON failure if there was output to stderr during the test run and it happened to get emitted after the worker thread emitted the result JSON. Now we capture stdout and stderr separately, which avoids that problem. It also means that _all_ stderr output is after all stdout output when we print the test results, but that seems acceptable, since output ordering is not guaranteed anyway. The patch also moves the emit of the test name into the output block generated after the test completes. Otherwise test names and test output/errors were mixed in the terminal display, making it difficult to determine which test generated the output. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Oct 19 17:26:16 2009 @@ -464,38 +464,38 @@ try: test, args_tuple = pending.popleft() except IndexError: - output.put((None, None, None)) + output.put((None, None, None, None)) return - if not quiet: - with print_lock: - print(test) - sys.stdout.flush() # -E is needed by some tests, e.g. test_import popen = Popen([sys.executable, '-E', '-m', 'test.regrtest', '--slaveargs', json.dumps(args_tuple)], - stdout=PIPE, stderr=STDOUT, + stdout=PIPE, stderr=PIPE, universal_newlines=True, close_fds=True) - out = popen.communicate()[0].strip() - out = debug_output_pat.sub("", out) - out, _, result = out.strip().rpartition("\n") + stdout, stderr = popen.communicate() + # Strip last refcount output line if it exists, since it + # comes from the shutdown of the interpreter in the subcommand. + stderr = debug_output_pat.sub("", stderr) + stdout, _, result = stdout.strip().rpartition("\n") result = json.loads(result) - output.put((test, out.strip(), result)) + if not quiet: + stdout = test+'\n'+stdout + output.put((test, stdout.rstrip(), stderr.rstrip(), result)) except BaseException: - output.put((None, None, None)) + output.put((None, None, None, None)) raise workers = [Thread(target=work) for i in range(use_mp)] for worker in workers: worker.start() finished = 0 while finished < use_mp: - test, out, result = output.get() - if out: - with print_lock: - print(out) - sys.stdout.flush() + test, stdout, stderr, result = output.get() if test is None: finished += 1 continue + if stdout: + print(stdout) + if stderr: + print(stderr, file=sys.stderr) if result[0] == -4: assert result[1] == 'KeyboardInterrupt' pending.clear() Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 19 17:26:16 2009 @@ -286,6 +286,9 @@ Tests ----- +- Issue #7151: fixed regrtest -j so that output to stderr from a test no + longer runs the risk of causing the worker thread to fail. + - Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. From python-checkins at python.org Mon Oct 19 17:31:21 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 15:31:21 -0000 Subject: [Python-checkins] r75514 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 17:31:21 2009 New Revision: 75514 Log: Blocked revisions 75513 via svnmerge ................ r75513 | r.david.murray | 2009-10-19 11:26:16 -0400 (Mon, 19 Oct 2009) | 18 lines Merged revisions 75503 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75503 | r.david.murray | 2009-10-18 17:12:37 -0400 (Sun, 18 Oct 2009) | 11 lines Issue #7151: regrtest would generate a JSON failure if there was output to stderr during the test run and it happened to get emitted after the worker thread emitted the result JSON. Now we capture stdout and stderr separately, which avoids that problem. It also means that _all_ stderr output is after all stdout output when we print the test results, but that seems acceptable, since output ordering is not guaranteed anyway. The patch also moves the emit of the test name into the output block generated after the test completes. Otherwise test names and test output/errors were mixed in the terminal display, making it difficult to determine which test generated the output. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 19 17:34:11 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 15:34:11 -0000 Subject: [Python-checkins] r75515 - python/branches/release26-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 17:34:11 2009 New Revision: 75515 Log: Blocked revisions 75503 via svnmerge ........ r75503 | r.david.murray | 2009-10-18 17:12:37 -0400 (Sun, 18 Oct 2009) | 11 lines Issue #7151: regrtest would generate a JSON failure if there was output to stderr during the test run and it happened to get emitted after the worker thread emitted the result JSON. Now we capture stdout and stderr separately, which avoids that problem. It also means that _all_ stderr output is after all stdout output when we print the test results, but that seems acceptable, since output ordering is not guaranteed anyway. The patch also moves the emit of the test name into the output block generated after the test completes. Otherwise test names and test output/errors were mixed in the terminal display, making it difficult to determine which test generated the output. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 19 17:36:52 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 15:36:52 -0000 Subject: [Python-checkins] r75516 - python/branches/release26-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 17:36:52 2009 New Revision: 75516 Log: Blocked revisions 75400 via svnmerge ........ r75400 | r.david.murray | 2009-10-14 09:58:07 -0400 (Wed, 14 Oct 2009) | 6 lines Enhanced Issue 7058 patch, which will not be backported. Refactors the code, adds checks for stdin/out/err, cwd, and sys.path, and adds a new section in the summary for tests that modify the environment (thanks to Ezio Melotti for that suggestion). ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 19 18:00:35 2009 From: python-checkins at python.org (barry.warsaw) Date: Mon, 19 Oct 2009 16:00:35 -0000 Subject: [Python-checkins] r75517 - in python/branches/release26-maint: Include/patchlevel.h Misc/NEWS Message-ID: Author: barry.warsaw Date: Mon Oct 19 18:00:35 2009 New Revision: 75517 Log: done with 2.6.4rc2 Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Mon Oct 19 18:00:35 2009 @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 2 /* Version as a string */ -#define PY_VERSION "2.6.4rc2" +#define PY_VERSION "2.6.4rc2+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Mon Oct 19 18:00:35 2009 @@ -4,6 +4,18 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.6.4 final? +================================= + +*Release date: XX-Oct-2009* + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 2.6.4rc2? ============================== From python-checkins at python.org Mon Oct 19 18:01:28 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:01:28 -0000 Subject: [Python-checkins] r75518 - python/trunk/Lib/test/test_curses.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:01:28 2009 New Revision: 75518 Log: Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. Modified: python/trunk/Lib/test/test_curses.py Modified: python/trunk/Lib/test/test_curses.py ============================================================================== --- python/trunk/Lib/test/test_curses.py (original) +++ python/trunk/Lib/test/test_curses.py Mon Oct 19 18:01:28 2009 @@ -276,6 +276,8 @@ curses.wrapper(main) unit_tests() else: + if not sys.__stdout__.isatty(): + raise unittest.SkipTest("sys.__stdout__ is not a tty") # testing setupterm() inside initscr/endwin # causes terminal breakage curses.setupterm(fd=sys.__stdout__.fileno()) From python-checkins at python.org Mon Oct 19 18:04:44 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:04:44 -0000 Subject: [Python-checkins] r75519 - in python/branches/py3k: Lib/test/test_curses.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:04:44 2009 New Revision: 75519 Log: Note that on py3k we are actually looking at sys.stdout, not sys.__stdout__. Merged revisions 75518 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75518 | r.david.murray | 2009-10-19 12:01:28 -0400 (Mon, 19 Oct 2009) | 3 lines Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_curses.py Modified: python/branches/py3k/Lib/test/test_curses.py ============================================================================== --- python/branches/py3k/Lib/test/test_curses.py (original) +++ python/branches/py3k/Lib/test/test_curses.py Mon Oct 19 18:04:44 2009 @@ -275,6 +275,8 @@ curses.resetty() def test_main(): + if not sys.stdout.isatty(): + raise unittest.SkipTest("sys.stdout is not a tty") # testing setupterm() inside initscr/endwin # causes terminal breakage curses.setupterm(fd=sys.stdout.fileno()) From python-checkins at python.org Mon Oct 19 18:07:41 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:07:41 -0000 Subject: [Python-checkins] r75520 - python/branches/release26-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 18:07:41 2009 New Revision: 75520 Log: Blocked revisions 75518 via svnmerge ........ r75518 | r.david.murray | 2009-10-19 12:01:28 -0400 (Mon, 19 Oct 2009) | 3 lines Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Mon Oct 19 18:08:16 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:08:16 -0000 Subject: [Python-checkins] r75521 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 18:08:15 2009 New Revision: 75521 Log: Blocked revisions 75519 via svnmerge ................ r75519 | r.david.murray | 2009-10-19 12:04:44 -0400 (Mon, 19 Oct 2009) | 12 lines Note that on py3k we are actually looking at sys.stdout, not sys.__stdout__. Merged revisions 75518 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75518 | r.david.murray | 2009-10-19 12:01:28 -0400 (Mon, 19 Oct 2009) | 3 lines Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 19 18:15:23 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:15:23 -0000 Subject: [Python-checkins] r75522 - python/branches/py3k/Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:15:22 2009 New Revision: 75522 Log: The stdout from tests is no longer compared against anything (not even to make sure it is empty), so eliminate the message that says running under verbose is different from running without it. Modified: python/branches/py3k/Lib/test/regrtest.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Oct 19 18:15:22 2009 @@ -548,9 +548,6 @@ if not bad and not skipped and len(good) > 1: print("All", end=' ') print(count(len(good), "test"), "OK.") - if verbose: - print("CAUTION: stdout isn't compared in verbose mode:") - print("a test that passes in verbose mode may fail without it.") if print_slow: test_times.sort(reverse=True) print("10 slowest tests:") From python-checkins at python.org Mon Oct 19 18:16:18 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:16:18 -0000 Subject: [Python-checkins] r75523 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 18:16:18 2009 New Revision: 75523 Log: Blocked revisions 75522 via svnmerge ........ r75522 | r.david.murray | 2009-10-19 12:15:22 -0400 (Mon, 19 Oct 2009) | 4 lines The stdout from tests is no longer compared against anything (not even to make sure it is empty), so eliminate the message that says running under verbose is different from running without it. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 19 18:28:24 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:28:24 -0000 Subject: [Python-checkins] r75524 - python/trunk/Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:28:24 2009 New Revision: 75524 Log: Eliminate warning message that looks like an error message. When it was added not finding Lib/test in the path indicated something was wrong, but when running regtest using "python -m" Lib/test isn't typically in the path, so this message is now more disturbing than it is helpful. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Mon Oct 19 18:28:24 2009 @@ -1445,6 +1445,4 @@ i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] - if '--slaveargs' not in sys.argv and len(sys.path) == pathlen: - print 'Could not find %r in sys.path to remove it' % mydir main() From python-checkins at python.org Mon Oct 19 18:33:43 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:33:43 -0000 Subject: [Python-checkins] r75525 - in python/branches/py3k: Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:33:43 2009 New Revision: 75525 Log: Merged revisions 75524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75524 | r.david.murray | 2009-10-19 12:28:24 -0400 (Mon, 19 Oct 2009) | 6 lines Eliminate warning message that looks like an error message. When it was added not finding Lib/test in the path indicated something was wrong, but when running regtest using "python -m" Lib/test isn't typically in the path, so this message is now more disturbing than it is helpful. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Oct 19 18:33:43 2009 @@ -1368,6 +1368,4 @@ i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] - if '--slaveargs' not in sys.argv and len(sys.path) == pathlen: - print('Could not find %r in sys.path to remove it' % mydir) main() From python-checkins at python.org Mon Oct 19 18:53:55 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:53:55 -0000 Subject: [Python-checkins] r75526 - python/branches/py3k/Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Mon Oct 19 18:53:55 2009 New Revision: 75526 Log: Since all regrtest -j output is now done in the main thread we are no longer using the print lock, so remove it. Modified: python/branches/py3k/Lib/test/regrtest.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Mon Oct 19 18:53:55 2009 @@ -440,13 +440,12 @@ resource_denieds.append(test) if use_mp: - from threading import Thread, Lock + from threading import Thread from queue import Queue, Empty from subprocess import Popen, PIPE, STDOUT from collections import deque # TextIOWrapper is not entirely thread-safe now, # it can produce duplicate output when printing from several threads. - print_lock = Lock() debug_output_pat = re.compile(r"\[\d+ refs\]$") pending = deque() output = Queue() From python-checkins at python.org Mon Oct 19 18:54:35 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 16:54:35 -0000 Subject: [Python-checkins] r75527 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Mon Oct 19 18:54:35 2009 New Revision: 75527 Log: Blocked revisions 75526 via svnmerge ........ r75526 | r.david.murray | 2009-10-19 12:53:55 -0400 (Mon, 19 Oct 2009) | 4 lines Since all regrtest -j output is now done in the main thread we are no longer using the print lock, so remove it. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 19 19:53:58 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 17:53:58 -0000 Subject: [Python-checkins] r75528 - python/trunk/Lib/test/test_support.py Message-ID: Author: r.david.murray Date: Mon Oct 19 19:53:58 2009 New Revision: 75528 Log: Clarify error report message, and don't recommend running in verbose mode for more information if we are already running in verbose mode. Modified: python/trunk/Lib/test/test_support.py Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Mon Oct 19 19:53:58 2009 @@ -894,7 +894,9 @@ elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - err = "errors occurred; run in verbose mode for details" + err = "multiple errors occurred" + if not verbose: + err += "; run in verbose mode for details" raise TestFailed(err) From python-checkins at python.org Mon Oct 19 19:59:08 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 17:59:08 -0000 Subject: [Python-checkins] r75529 - in python/trunk: Lib/test/test_ssl.py Misc/NEWS Modules/_ssl.c Message-ID: Author: antoine.pitrou Date: Mon Oct 19 19:59:07 2009 New Revision: 75529 Log: Issue #7133: SSL objects now support the new buffer API. This fixes the test_ssl failure. Modified: python/trunk/Lib/test/test_ssl.py python/trunk/Misc/NEWS python/trunk/Modules/_ssl.c Modified: python/trunk/Lib/test/test_ssl.py ============================================================================== --- python/trunk/Lib/test/test_ssl.py (original) +++ python/trunk/Lib/test/test_ssl.py Mon Oct 19 19:59:07 2009 @@ -662,20 +662,21 @@ except Exception, x: raise test_support.TestFailed("Unexpected exception: " + str(x)) else: - if connectionchatty: - if test_support.verbose: - sys.stdout.write( - " client: sending %s...\n" % (repr(indata))) - s.write(indata) - outdata = s.read() - if connectionchatty: - if test_support.verbose: - sys.stdout.write(" client: read %s\n" % repr(outdata)) - if outdata != indata.lower(): - raise test_support.TestFailed( - "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" - % (outdata[:min(len(outdata),20)], len(outdata), - indata[:min(len(indata),20)].lower(), len(indata))) + for arg in [indata, bytearray(indata), memoryview(indata)]: + if connectionchatty: + if test_support.verbose: + sys.stdout.write( + " client: sending %s...\n" % (repr(arg))) + s.write(arg) + outdata = s.read() + if connectionchatty: + if test_support.verbose: + sys.stdout.write(" client: read %s\n" % repr(outdata)) + if outdata != indata.lower(): + raise test_support.TestFailed( + "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" + % (outdata[:min(len(outdata),20)], len(outdata), + indata[:min(len(indata),20)].lower(), len(indata))) s.write("over\n") if connectionchatty: if test_support.verbose: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 19 19:59:07 2009 @@ -414,6 +414,8 @@ Library ------- +- Issue #7133: SSL objects now support the new buffer API. + - Issue #7149: urllib fails on OSX in the proxy detection code - Issue #7069: Make inspect.isabstract() return a boolean. Modified: python/trunk/Modules/_ssl.c ============================================================================== --- python/trunk/Modules/_ssl.c (original) +++ python/trunk/Modules/_ssl.c Mon Oct 19 19:59:07 2009 @@ -1144,14 +1144,13 @@ static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args) { - char *data; + Py_buffer buf; int len; - int count; int sockstate; int err; int nonblocking; - if (!PyArg_ParseTuple(args, "s#:write", &data, &count)) + if (!PyArg_ParseTuple(args, "s*:write", &buf)) return NULL; /* just in case the blocking state of the socket has been changed */ @@ -1163,24 +1162,24 @@ if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); - return NULL; + goto error; } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); - return NULL; + goto error; } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) { PyErr_SetString(PySSLErrorObject, "Underlying socket too large for select()."); - return NULL; + goto error; } do { err = 0; PySSL_BEGIN_ALLOW_THREADS - len = SSL_write(self->ssl, data, count); + len = SSL_write(self->ssl, buf.buf, buf.len); err = SSL_get_error(self->ssl, len); PySSL_END_ALLOW_THREADS - if(PyErr_CheckSignals()) { - return NULL; + if (PyErr_CheckSignals()) { + goto error; } if (err == SSL_ERROR_WANT_READ) { sockstate = @@ -1194,19 +1193,25 @@ if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); - return NULL; + goto error; } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); - return NULL; + goto error; } else if (sockstate == SOCKET_IS_NONBLOCKING) { break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); + + PyBuffer_Release(&buf); if (len > 0) return PyInt_FromLong(len); else return PySSL_SetError(self, len, __FILE__, __LINE__); + +error: + PyBuffer_Release(&buf); + return NULL; } PyDoc_STRVAR(PySSL_SSLwrite_doc, From python-checkins at python.org Mon Oct 19 20:06:17 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 18:06:17 -0000 Subject: [Python-checkins] r75530 - in python/branches/py3k: Lib/test/support.py Message-ID: Author: r.david.murray Date: Mon Oct 19 20:06:17 2009 New Revision: 75530 Log: Merged revisions 75528 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75528 | r.david.murray | 2009-10-19 13:53:58 -0400 (Mon, 19 Oct 2009) | 4 lines Clarify error report message, and don't recommend running in verbose mode for more information if we are already running in verbose mode. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/support.py Modified: python/branches/py3k/Lib/test/support.py ============================================================================== --- python/branches/py3k/Lib/test/support.py (original) +++ python/branches/py3k/Lib/test/support.py Mon Oct 19 20:06:17 2009 @@ -889,7 +889,8 @@ elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - err = "errors occurred; run in verbose mode for details" + err = "multiple errors occurred" + if not verbose: err += "; run in verbose mode for details" raise TestFailed(err) From python-checkins at python.org Mon Oct 19 20:17:19 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 18:17:19 -0000 Subject: [Python-checkins] r75531 - python/trunk/Modules/readline.c Message-ID: Author: antoine.pitrou Date: Mon Oct 19 20:17:18 2009 New Revision: 75531 Log: Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. Modified: python/trunk/Modules/readline.c Modified: python/trunk/Modules/readline.c ============================================================================== --- python/trunk/Modules/readline.c (original) +++ python/trunk/Modules/readline.c Mon Oct 19 20:17:18 2009 @@ -801,6 +801,10 @@ static char ** flex_complete(char *text, int start, int end) { +#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER + rl_completion_append_character ='\0'; + rl_completion_suppress_append = 0; +#endif Py_XDECREF(begidx); Py_XDECREF(endidx); begidx = PyInt_FromLong((long) start); @@ -843,9 +847,6 @@ rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character ='\0'; -#endif begidx = PyInt_FromLong(0L); endidx = PyInt_FromLong(0L); From python-checkins at python.org Mon Oct 19 20:20:22 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 18:20:22 -0000 Subject: [Python-checkins] r75532 - python/trunk/Misc/NEWS Message-ID: Author: antoine.pitrou Date: Mon Oct 19 20:20:21 2009 New Revision: 75532 Log: NEWS entry for r75531. Modified: python/trunk/Misc/NEWS Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 19 20:20:21 2009 @@ -414,6 +414,9 @@ Library ------- +- Issue #5833: Fix extra space character in readline completion with the + GNU readline library version 6.0. + - Issue #7133: SSL objects now support the new buffer API. - Issue #7149: urllib fails on OSX in the proxy detection code From python-checkins at python.org Mon Oct 19 20:22:37 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 18:22:37 -0000 Subject: [Python-checkins] r75533 - in python/branches/py3k: Misc/NEWS Modules/readline.c Message-ID: Author: antoine.pitrou Date: Mon Oct 19 20:22:37 2009 New Revision: 75533 Log: Merged revisions 75531-75532 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75531 | antoine.pitrou | 2009-10-19 20:17:18 +0200 (lun., 19 oct. 2009) | 4 lines Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. ........ r75532 | antoine.pitrou | 2009-10-19 20:20:21 +0200 (lun., 19 oct. 2009) | 3 lines NEWS entry for r75531. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/readline.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 19 20:22:37 2009 @@ -100,6 +100,9 @@ Library ------- +- Issue #5833: Fix extra space character in readline completion with the + GNU readline library version 6.0. + - Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #7086: Added TCP support to SysLogHandler, and tidied up some Modified: python/branches/py3k/Modules/readline.c ============================================================================== --- python/branches/py3k/Modules/readline.c (original) +++ python/branches/py3k/Modules/readline.c Mon Oct 19 20:22:37 2009 @@ -800,6 +800,10 @@ static char ** flex_complete(char *text, int start, int end) { +#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER + rl_completion_append_character ='\0'; + rl_completion_suppress_append = 0; +#endif Py_XDECREF(begidx); Py_XDECREF(endidx); begidx = PyLong_FromLong((long) start); @@ -842,9 +846,6 @@ rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character ='\0'; -#endif begidx = PyLong_FromLong(0L); endidx = PyLong_FromLong(0L); From python-checkins at python.org Mon Oct 19 20:24:35 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 18:24:35 -0000 Subject: [Python-checkins] r75534 - in python/branches/release31-maint: Misc/NEWS Modules/readline.c Message-ID: Author: antoine.pitrou Date: Mon Oct 19 20:24:35 2009 New Revision: 75534 Log: Merged revisions 75533 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75533 | antoine.pitrou | 2009-10-19 20:22:37 +0200 (lun., 19 oct. 2009) | 14 lines Merged revisions 75531-75532 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75531 | antoine.pitrou | 2009-10-19 20:17:18 +0200 (lun., 19 oct. 2009) | 4 lines Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. ........ r75532 | antoine.pitrou | 2009-10-19 20:20:21 +0200 (lun., 19 oct. 2009) | 3 lines NEWS entry for r75531. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/readline.c Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Mon Oct 19 20:24:35 2009 @@ -30,6 +30,9 @@ Library ------- +- Issue #5833: Fix extra space character in readline completion with the + GNU readline library version 6.0. + - Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" environment - Issue #7082: When falling back to the MIME 'name' parameter, the Modified: python/branches/release31-maint/Modules/readline.c ============================================================================== --- python/branches/release31-maint/Modules/readline.c (original) +++ python/branches/release31-maint/Modules/readline.c Mon Oct 19 20:24:35 2009 @@ -758,6 +758,10 @@ static char ** flex_complete(char *text, int start, int end) { +#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER + rl_completion_append_character ='\0'; + rl_completion_suppress_append = 0; +#endif Py_XDECREF(begidx); Py_XDECREF(endidx); begidx = PyLong_FromLong((long) start); @@ -800,9 +804,6 @@ rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character ='\0'; -#endif begidx = PyLong_FromLong(0L); endidx = PyLong_FromLong(0L); From python-checkins at python.org Mon Oct 19 21:12:39 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 19:12:39 -0000 Subject: [Python-checkins] r75535 - python/branches/py3k/Misc/maintainers.rst Message-ID: Author: r.david.murray Date: Mon Oct 19 21:12:38 2009 New Revision: 75535 Log: Add 'idlelib' to modules, and add a new table for the Tools, with one entry for which I noticed an active maintainer. IMO, if a tool doesn't get put on this list with at least one maintainer it may be in danger of being deleted by and by... Modified: python/branches/py3k/Misc/maintainers.rst Modified: python/branches/py3k/Misc/maintainers.rst ============================================================================== --- python/branches/py3k/Misc/maintainers.rst (original) +++ python/branches/py3k/Misc/maintainers.rst Mon Oct 19 21:12:38 2009 @@ -114,6 +114,7 @@ hmac html http +idlelib imaplib imghdr imp @@ -239,7 +240,13 @@ ================== =========== -Platform Maintainer +Tool Maintainers +------------------ ----------- +pybench lemburg + + +================== =========== +Platform Maintainers ------------------ ----------- AIX Cygwin jlt63 From python-checkins at python.org Mon Oct 19 21:14:42 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 19 Oct 2009 19:14:42 -0000 Subject: [Python-checkins] r75536 - in python/branches/release31-maint: Misc/maintainers.rst Message-ID: Author: r.david.murray Date: Mon Oct 19 21:14:42 2009 New Revision: 75536 Log: Merged revisions 75535 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75535 | r.david.murray | 2009-10-19 15:12:38 -0400 (Mon, 19 Oct 2009) | 6 lines Add 'idlelib' to modules, and add a new table for the Tools, with one entry for which I noticed an active maintainer. IMO, if a tool doesn't get put on this list with at least one maintainer it may be in danger of being deleted by and by... ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/maintainers.rst Modified: python/branches/release31-maint/Misc/maintainers.rst ============================================================================== --- python/branches/release31-maint/Misc/maintainers.rst (original) +++ python/branches/release31-maint/Misc/maintainers.rst Mon Oct 19 21:14:42 2009 @@ -114,6 +114,7 @@ hmac html http +idlelib imaplib imghdr imp @@ -239,7 +240,13 @@ ================== =========== -Platform Maintainer +Tool Maintainers +------------------ ----------- +pybench lemburg + + +================== =========== +Platform Maintainers ------------------ ----------- AIX Cygwin jlt63 From python-checkins at python.org Mon Oct 19 21:37:26 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 19:37:26 -0000 Subject: [Python-checkins] r75537 - in python/branches/py3k/Misc: ACKS NEWS Message-ID: Author: antoine.pitrou Date: Mon Oct 19 21:37:25 2009 New Revision: 75537 Log: egreen is Derk Drukker + fix NEWS formatting Modified: python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Mon Oct 19 21:37:25 2009 @@ -188,6 +188,7 @@ Cesar Douady Dean Draayer Fred L. Drake, Jr. +Derk Drukker John DuBois Paul Dubois Graham Dumpleton Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 19 21:37:25 2009 @@ -12,7 +12,7 @@ Core and Builtins ----------------- -- Issue *7147: Remove support for compiling Python without complex number +- Issue #7147: Remove support for compiling Python without complex number support. - Issue #7120: logging: Removed import of multiprocessing which is causing @@ -23,7 +23,7 @@ Patch by Christopher Tur Lesniewski-Laas. - Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when - using byte values greater than 127. Patch by egreen. + using byte values greater than 127. Patch by Derk Drukker. - Issue #1571184: The Unicode database contains properties for more characters. The tables for code points representing numeric values, white spaces or line From python-checkins at python.org Mon Oct 19 21:39:01 2009 From: python-checkins at python.org (kurt.kaiser) Date: Mon, 19 Oct 2009 19:39:01 -0000 Subject: [Python-checkins] r75538 - python/branches/py3k/Misc/maintainers.rst Message-ID: Author: kurt.kaiser Date: Mon Oct 19 21:39:00 2009 New Revision: 75538 Log: add myself to idlelib Modified: python/branches/py3k/Misc/maintainers.rst Modified: python/branches/py3k/Misc/maintainers.rst ============================================================================== --- python/branches/py3k/Misc/maintainers.rst (original) +++ python/branches/py3k/Misc/maintainers.rst Mon Oct 19 21:39:00 2009 @@ -114,7 +114,7 @@ hmac html http -idlelib +idlelib kurt.kaiser imaplib imghdr imp From python-checkins at python.org Mon Oct 19 21:43:10 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 19:43:10 -0000 Subject: [Python-checkins] r75539 - in python/branches/py3k: Lib/locale.py Lib/test/test_locale.py Misc/NEWS Modules/_localemodule.c PC/pyconfig.h Message-ID: Author: antoine.pitrou Date: Mon Oct 19 21:43:09 2009 New Revision: 75539 Log: Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows platforms, and assorted locale fixes by Derk Drukker. Modified: python/branches/py3k/Lib/locale.py python/branches/py3k/Lib/test/test_locale.py python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/_localemodule.c python/branches/py3k/PC/pyconfig.h Modified: python/branches/py3k/Lib/locale.py ============================================================================== --- python/branches/py3k/Lib/locale.py (original) +++ python/branches/py3k/Lib/locale.py Mon Oct 19 21:43:09 2009 @@ -578,14 +578,13 @@ # returning nothing will crash the # interpreter. result = 'UTF-8' - setlocale(LC_CTYPE, oldloc) - return result else: result = nl_langinfo(CODESET) if not result and sys.platform == 'darwin': # See above for explanation result = 'UTF-8' + return result ### Database Modified: python/branches/py3k/Lib/test/test_locale.py ============================================================================== --- python/branches/py3k/Lib/test/test_locale.py (original) +++ python/branches/py3k/Lib/test/test_locale.py Mon Oct 19 21:43:09 2009 @@ -8,12 +8,10 @@ def get_enUS_locale(): global enUS_locale - if sys.platform == 'darwin': - raise unittest.SkipTest("Locale support on MacOSX is minimal") if sys.platform.startswith("win"): tlocs = ("En", "English") else: - tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US") + tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US.US-ASCII", "en_US") oldlocale = locale.setlocale(locale.LC_NUMERIC) for tloc in tlocs: try: @@ -309,6 +307,39 @@ grouping=True, international=True) +class TestCollation(unittest.TestCase): + # Test string collation functions + + def test_strcoll(self): + self.assertLess(locale.strcoll('a', 'b'), 0) + self.assertEqual(locale.strcoll('a', 'a'), 0) + self.assertGreater(locale.strcoll('b', 'a'), 0) + + def test_strxfrm(self): + self.assertLess(locale.strxfrm('a'), locale.strxfrm('b')) + + +class TestEnUSCollation(BaseLocalizedTest, TestCollation): + # Test string collation functions with a real English locale + + locale_type = locale.LC_ALL + + def setUp(self): + BaseLocalizedTest.setUp(self) + enc = codecs.lookup(locale.getpreferredencoding(False) or 'ascii').name + if enc not in ('utf-8', 'iso8859-1', 'cp1252'): + raise unittest.SkipTest('encoding not suitable') + if enc != 'iso8859-1' and (sys.platform == 'darwin' or + sys.platform.startswith('freebsd')): + raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs') + + def test_strcoll_with_diacritic(self): + self.assertLess(locale.strcoll('?', 'b'), 0) + + def test_strxfrm_with_diacritic(self): + self.assertLess(locale.strxfrm('?'), locale.strxfrm('b')) + + class TestMiscellaneous(unittest.TestCase): def test_getpreferredencoding(self): # Invoke getpreferredencoding to make sure it does not cause exceptions. @@ -317,11 +348,10 @@ # If encoding non-empty, make sure it is valid codecs.lookup(enc) - if hasattr(locale, "strcoll"): - def test_strcoll_3303(self): - # test crasher from bug #3303 - self.assertRaises(TypeError, locale.strcoll, "a", None) - self.assertRaises(TypeError, locale.strcoll, b"a", None) + def test_strcoll_3303(self): + # test crasher from bug #3303 + self.assertRaises(TypeError, locale.strcoll, "a", None) + self.assertRaises(TypeError, locale.strcoll, b"a", None) def test_main(): @@ -331,6 +361,7 @@ TestEnUSNumberFormatting, TestCNumberFormatting, TestFrFRNumberFormatting, + TestCollation ] # SkipTest can't be raised inside unittests, handle it manually instead try: @@ -339,7 +370,7 @@ if verbose: print("Some tests will be disabled: %s" % e) else: - tests += [TestNumberFormatting] + tests += [TestNumberFormatting, TestEnUSCollation] run_unittest(*tests) if __name__ == '__main__': Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 19 21:43:09 2009 @@ -100,6 +100,9 @@ Library ------- +- Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows + platforms, and assorted locale fixes by Derk Drukker. + - Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. @@ -118,7 +121,7 @@ is too large to fit in the current precision. - Issue #6236, #6348: Fix various failures in the I/O library under AIX - and other platforms, when using a non-gcc compiler. Patch by egreen. + and other platforms, when using a non-gcc compiler. Patch by Derk Drukker. - Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...) does now always result in NULL. Modified: python/branches/py3k/Modules/_localemodule.c ============================================================================== --- python/branches/py3k/Modules/_localemodule.c (original) +++ python/branches/py3k/Modules/_localemodule.c Mon Oct 19 21:43:09 2009 @@ -9,6 +9,7 @@ ******************************************************************/ +#define PY_SSIZE_T_CLEAN #include "Python.h" #include @@ -315,7 +316,7 @@ result = PyUnicode_FromWideChar(buf, n2); exit: if (buf) PyMem_Free(buf); -#ifdef HAVE_USABLE_WCHAR_T +#ifndef HAVE_USABLE_WCHAR_T PyMem_Free(s); #endif return result; Modified: python/branches/py3k/PC/pyconfig.h ============================================================================== --- python/branches/py3k/PC/pyconfig.h (original) +++ python/branches/py3k/PC/pyconfig.h Mon Oct 19 21:43:09 2009 @@ -641,6 +641,11 @@ #define HAVE_WCSCOLL 1 #endif +/* Define to 1 if you have the `wcsxfrm' function. */ +#ifndef MS_WINCE +#define HAVE_WCSXFRM 1 +#endif + /* Define if you have the header file. */ /* #undef HAVE_DLFCN_H */ From python-checkins at python.org Mon Oct 19 21:46:35 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 19:46:35 -0000 Subject: [Python-checkins] r75540 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setuptools.egg-info/entry_points.txt setuptools/command/sdist.py Message-ID: Author: phillip.eby Date: Mon Oct 19 21:46:34 2009 New Revision: 75540 Log: Release update, fix string.join in README warning Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Mon Oct 19 21:46:34 2009 @@ -28,6 +28,10 @@ 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', + 'setuptools-0.6c10-py2.3.egg': 'cb00cbd3d93b66f6c118a1c042113f93', + 'setuptools-0.6c10-py2.4.egg': 'be702e15b4b61628e059d6ab88335a87', + 'setuptools-0.6c10-py2.5.egg': '79b809922c0ce55e2d8b5b0cc31da0f2', + 'setuptools-0.6c10-py2.6.egg': 'c4b741e774a793609d508ff4a2a21194', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Mon Oct 19 21:46:34 2009 @@ -12,6 +12,7 @@ python2.3 setup.py -q release source --target-version=2.3 upload && \ python2.4 setup.py -q release binary --target-version=2.4 upload && \ python2.5 setup.py -q release binary --target-version=2.5 upload && \ +python2.6 setup.py -q release binary --target-version=2.6 upload && \ python2.3 ez_setup.py --md5update dist/setuptools-$VERSION*-py2.?.egg && \ cp ez_setup.py virtual-python.py ~/distrib/ && \ cp ez_setup.py ~/projects/ez_setup/__init__.py && \ Modified: sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt Mon Oct 19 21:46:34 2009 @@ -31,7 +31,7 @@ [console_scripts] easy_install = setuptools.command.easy_install:main -easy_install-2.5 = setuptools.command.easy_install:main +easy_install-2.6 = setuptools.command.easy_install:main [setuptools.file_finders] svn_cvs = setuptools.command.sdist:_default_revctrl Modified: sandbox/branches/setuptools-0.6/setuptools/command/sdist.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/sdist.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Mon Oct 19 21:46:34 2009 @@ -181,7 +181,7 @@ if not got_it: self.warn("standard file not found: should have one of " + - string.join(alts, ', ')) + ', '.join(alts)) else: if os.path.exists(fn): self.filelist.append(fn) From python-checkins at python.org Mon Oct 19 21:47:59 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 19 Oct 2009 19:47:59 -0000 Subject: [Python-checkins] r75541 - in python/branches/release31-maint: Lib/locale.py Lib/test/test_locale.py Misc/ACKS Misc/NEWS Modules/_localemodule.c PC/pyconfig.h Message-ID: Author: antoine.pitrou Date: Mon Oct 19 21:47:59 2009 New Revision: 75541 Log: Merged revisions 75537,75539 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75537 | antoine.pitrou | 2009-10-19 21:37:25 +0200 (lun., 19 oct. 2009) | 3 lines egreen is Derk Drukker + fix NEWS formatting ........ r75539 | antoine.pitrou | 2009-10-19 21:43:09 +0200 (lun., 19 oct. 2009) | 4 lines Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows platforms, and assorted locale fixes by Derk Drukker. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/locale.py python/branches/release31-maint/Lib/test/test_locale.py python/branches/release31-maint/Misc/ACKS python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/_localemodule.c python/branches/release31-maint/PC/pyconfig.h Modified: python/branches/release31-maint/Lib/locale.py ============================================================================== --- python/branches/release31-maint/Lib/locale.py (original) +++ python/branches/release31-maint/Lib/locale.py Mon Oct 19 21:47:59 2009 @@ -575,14 +575,13 @@ # returning nothing will crash the # interpreter. result = 'UTF-8' - setlocale(LC_CTYPE, oldloc) - return result else: result = nl_langinfo(CODESET) if not result and sys.platform == 'darwin': # See above for explanation result = 'UTF-8' + return result ### Database Modified: python/branches/release31-maint/Lib/test/test_locale.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_locale.py (original) +++ python/branches/release31-maint/Lib/test/test_locale.py Mon Oct 19 21:47:59 2009 @@ -8,12 +8,10 @@ def get_enUS_locale(): global enUS_locale - if sys.platform == 'darwin': - raise unittest.SkipTest("Locale support on MacOSX is minimal") if sys.platform.startswith("win"): tlocs = ("En", "English") else: - tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US") + tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US.US-ASCII", "en_US") oldlocale = locale.setlocale(locale.LC_NUMERIC) for tloc in tlocs: try: @@ -309,6 +307,39 @@ grouping=True, international=True) +class TestCollation(unittest.TestCase): + # Test string collation functions + + def test_strcoll(self): + self.assertLess(locale.strcoll('a', 'b'), 0) + self.assertEqual(locale.strcoll('a', 'a'), 0) + self.assertGreater(locale.strcoll('b', 'a'), 0) + + def test_strxfrm(self): + self.assertLess(locale.strxfrm('a'), locale.strxfrm('b')) + + +class TestEnUSCollation(BaseLocalizedTest, TestCollation): + # Test string collation functions with a real English locale + + locale_type = locale.LC_ALL + + def setUp(self): + BaseLocalizedTest.setUp(self) + enc = codecs.lookup(locale.getpreferredencoding(False) or 'ascii').name + if enc not in ('utf-8', 'iso8859-1', 'cp1252'): + raise unittest.SkipTest('encoding not suitable') + if enc != 'iso8859-1' and (sys.platform == 'darwin' or + sys.platform.startswith('freebsd')): + raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs') + + def test_strcoll_with_diacritic(self): + self.assertLess(locale.strcoll('?', 'b'), 0) + + def test_strxfrm_with_diacritic(self): + self.assertLess(locale.strxfrm('?'), locale.strxfrm('b')) + + class TestMiscellaneous(unittest.TestCase): def test_getpreferredencoding(self): # Invoke getpreferredencoding to make sure it does not cause exceptions. @@ -317,11 +348,10 @@ # If encoding non-empty, make sure it is valid codecs.lookup(enc) - if hasattr(locale, "strcoll"): - def test_strcoll_3303(self): - # test crasher from bug #3303 - self.assertRaises(TypeError, locale.strcoll, "a", None) - self.assertRaises(TypeError, locale.strcoll, b"a", None) + def test_strcoll_3303(self): + # test crasher from bug #3303 + self.assertRaises(TypeError, locale.strcoll, "a", None) + self.assertRaises(TypeError, locale.strcoll, b"a", None) def test_main(): @@ -331,6 +361,7 @@ TestEnUSNumberFormatting, TestCNumberFormatting, TestFrFRNumberFormatting, + TestCollation ] # SkipTest can't be raised inside unittests, handle it manually instead try: @@ -339,7 +370,7 @@ if verbose: print("Some tests will be disabled: %s" % e) else: - tests += [TestNumberFormatting] + tests += [TestNumberFormatting, TestEnUSCollation] run_unittest(*tests) if __name__ == '__main__': Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Mon Oct 19 21:47:59 2009 @@ -184,6 +184,7 @@ Dima Dorfman Cesar Douady Dean Draayer +Derk Drukker John DuBois Paul Dubois Graham Dumpleton Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Mon Oct 19 21:47:59 2009 @@ -13,7 +13,7 @@ ----------------- - Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when - using byte values greater than 127. Patch by egreen. + using byte values greater than 127. Patch by Derk Drukker. - Issue #7019: Raise ValueError when unmarshalling bad long data, instead of producing internally inconsistent Python longs. @@ -30,6 +30,9 @@ Library ------- +- Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows + platforms, and assorted locale fixes by Derk Drukker. + - Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. @@ -45,7 +48,7 @@ is too large to fit in the current precision. - Issue #6236, #6348: Fix various failures in the I/O library under AIX - and other platforms, when using a non-gcc compiler. Patch by egreen. + and other platforms, when using a non-gcc compiler. Patch by Derk Drukker. - Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils. Modified: python/branches/release31-maint/Modules/_localemodule.c ============================================================================== --- python/branches/release31-maint/Modules/_localemodule.c (original) +++ python/branches/release31-maint/Modules/_localemodule.c Mon Oct 19 21:47:59 2009 @@ -9,6 +9,7 @@ ******************************************************************/ +#define PY_SSIZE_T_CLEAN #include "Python.h" #include @@ -315,7 +316,7 @@ result = PyUnicode_FromWideChar(buf, n2); exit: if (buf) PyMem_Free(buf); -#ifdef HAVE_USABLE_WCHAR_T +#ifndef HAVE_USABLE_WCHAR_T PyMem_Free(s); #endif return result; Modified: python/branches/release31-maint/PC/pyconfig.h ============================================================================== --- python/branches/release31-maint/PC/pyconfig.h (original) +++ python/branches/release31-maint/PC/pyconfig.h Mon Oct 19 21:47:59 2009 @@ -647,6 +647,11 @@ #define HAVE_WCSCOLL 1 #endif +/* Define to 1 if you have the `wcsxfrm' function. */ +#ifndef MS_WINCE +#define HAVE_WCSXFRM 1 +#endif + /* Define if you have the header file. */ /* #undef HAVE_DLFCN_H */ From python-checkins at python.org Mon Oct 19 21:52:20 2009 From: python-checkins at python.org (raymond.hettinger) Date: Mon, 19 Oct 2009 19:52:20 -0000 Subject: [Python-checkins] r75542 - python/branches/py3k/Misc/maintainers.rst Message-ID: Author: raymond.hettinger Date: Mon Oct 19 21:52:20 2009 New Revision: 75542 Log: Add maintainers. Modified: python/branches/py3k/Misc/maintainers.rst Modified: python/branches/py3k/Misc/maintainers.rst ============================================================================== --- python/branches/py3k/Misc/maintainers.rst (original) +++ python/branches/py3k/Misc/maintainers.rst Mon Oct 19 21:52:20 2009 @@ -84,7 +84,7 @@ datetime dbm decimal facundobatista, rhettinger, mark.dickinson -difflib +difflib tim_one dis distutils tarek doctest tim_one (inactive) @@ -99,7 +99,7 @@ fnmatch formatter fpectl -fractions mark.dickinson +fractions mark.dickinson rhettinger ftplib functools gc pitrou @@ -132,7 +132,7 @@ mailbox andrew.kuchling mailcap marshal -math mark.dickinson +math mark.dickinson rhettinger mimetypes mmap modulefinder theller, jvr @@ -165,7 +165,7 @@ pybench lemburg, pitrou pyclbr pydoc -queue +queue rhettinger quopri random rhettinger re effbot (inactive), pitrou From python-checkins at python.org Mon Oct 19 23:02:07 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:02:07 -0000 Subject: [Python-checkins] r75543 - in sandbox/trunk/setuptools: launcher.c setuptools/cli.exe setuptools/command/sdist.py setuptools/gui.exe Message-ID: Author: phillip.eby Date: Mon Oct 19 23:02:06 2009 New Revision: 75543 Log: Fix lost launcher changes, string.split(). Modified: sandbox/trunk/setuptools/launcher.c sandbox/trunk/setuptools/setuptools/cli.exe sandbox/trunk/setuptools/setuptools/command/sdist.py sandbox/trunk/setuptools/setuptools/gui.exe Modified: sandbox/trunk/setuptools/launcher.c ============================================================================== --- sandbox/trunk/setuptools/launcher.c (original) +++ sandbox/trunk/setuptools/launcher.c Mon Oct 19 23:02:06 2009 @@ -81,17 +81,18 @@ char *loadable_exe(char *exename) { - HINSTANCE hPython; /* DLL handle for python executable */ + /* HINSTANCE hPython; DLL handle for python executable */ char *result; - hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!hPython) return NULL; + /* hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!hPython) return NULL; */ /* Return the absolute filename for spawnv */ result = calloc(MAX_PATH, sizeof(char)); - if (result) GetModuleFileName(hPython, result, MAX_PATH); + strncpy(result, exename, MAX_PATH); + /*if (result) GetModuleFileName(hPython, result, MAX_PATH); - FreeLibrary(hPython); + FreeLibrary(hPython); */ return result; } Modified: sandbox/trunk/setuptools/setuptools/cli.exe ============================================================================== Binary files. No diff available. Modified: sandbox/trunk/setuptools/setuptools/command/sdist.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/sdist.py (original) +++ sandbox/trunk/setuptools/setuptools/command/sdist.py Mon Oct 19 23:02:06 2009 @@ -181,7 +181,7 @@ if not got_it: self.warn("standard file not found: should have one of " + - string.join(alts, ', ')) + ', '.join(alts)) else: if os.path.exists(fn): self.filelist.append(fn) Modified: sandbox/trunk/setuptools/setuptools/gui.exe ============================================================================== Binary files. No diff available. From python-checkins at python.org Mon Oct 19 23:03:30 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:03:30 -0000 Subject: [Python-checkins] r75544 - in sandbox/branches/setuptools-0.6: launcher.c setuptools/cli.exe setuptools/gui.exe Message-ID: Author: phillip.eby Date: Mon Oct 19 23:03:29 2009 New Revision: 75544 Log: Missing launcher fixes Modified: sandbox/branches/setuptools-0.6/launcher.c sandbox/branches/setuptools-0.6/setuptools/cli.exe sandbox/branches/setuptools-0.6/setuptools/gui.exe Modified: sandbox/branches/setuptools-0.6/launcher.c ============================================================================== --- sandbox/branches/setuptools-0.6/launcher.c (original) +++ sandbox/branches/setuptools-0.6/launcher.c Mon Oct 19 23:03:29 2009 @@ -81,17 +81,18 @@ char *loadable_exe(char *exename) { - HINSTANCE hPython; /* DLL handle for python executable */ + /* HINSTANCE hPython; DLL handle for python executable */ char *result; - hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!hPython) return NULL; + /* hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!hPython) return NULL; */ /* Return the absolute filename for spawnv */ result = calloc(MAX_PATH, sizeof(char)); - if (result) GetModuleFileName(hPython, result, MAX_PATH); + strncpy(result, exename, MAX_PATH); + /*if (result) GetModuleFileName(hPython, result, MAX_PATH); - FreeLibrary(hPython); + FreeLibrary(hPython); */ return result; } Modified: sandbox/branches/setuptools-0.6/setuptools/cli.exe ============================================================================== Binary files. No diff available. Modified: sandbox/branches/setuptools-0.6/setuptools/gui.exe ============================================================================== Binary files. No diff available. From python-checkins at python.org Mon Oct 19 23:06:29 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:06:29 -0000 Subject: [Python-checkins] r75545 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setup.py setuptools/__init__.py version.dat Message-ID: Author: phillip.eby Date: Mon Oct 19 23:06:29 2009 New Revision: 75545 Log: Update to version 0.6c11 Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/version.dat Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Mon Oct 19 23:06:29 2009 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6c10" +DEFAULT_VERSION = "0.6c11" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Mon Oct 19 23:06:29 2009 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6c10" +export VERSION="0.6c11" python2.3 setup.py -q release source --target-version=2.3 upload && \ python2.4 setup.py -q release binary --target-version=2.4 upload && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Mon Oct 19 23:06:29 2009 @@ -7,7 +7,7 @@ execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6c10" +VERSION = "0.6c11" from setuptools import setup, find_packages import sys Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Mon Oct 19 23:06:29 2009 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6c10' +__version__ = '0.6c11' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Mon Oct 19 23:06:29 2009 @@ -1,6 +1,6 @@ [setuptools] status = 'release candidate' major = 0 -build = 10 +build = 11 minor = 6 From python-checkins at python.org Mon Oct 19 23:19:30 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:19:30 -0000 Subject: [Python-checkins] r75546 - sandbox/branches/setuptools-0.6/release.sh Message-ID: Author: phillip.eby Date: Mon Oct 19 23:19:30 2009 New Revision: 75546 Log: Build correct filenames for py2.6 "cross-compile" Modified: sandbox/branches/setuptools-0.6/release.sh Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Mon Oct 19 23:19:30 2009 @@ -8,11 +8,11 @@ # export VERSION="0.6c11" - +python2.3 setup.py -q egg_info # force upload to be available python2.3 setup.py -q release source --target-version=2.3 upload && \ python2.4 setup.py -q release binary --target-version=2.4 upload && \ python2.5 setup.py -q release binary --target-version=2.5 upload && \ -python2.6 setup.py -q release binary --target-version=2.6 upload && \ +python2.6 setup.py -q release binary --target-version=2.6 -p win32 upload && \ python2.3 ez_setup.py --md5update dist/setuptools-$VERSION*-py2.?.egg && \ cp ez_setup.py virtual-python.py ~/distrib/ && \ cp ez_setup.py ~/projects/ez_setup/__init__.py && \ From python-checkins at python.org Mon Oct 19 23:46:36 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:46:36 -0000 Subject: [Python-checkins] r75547 - sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Message-ID: Author: phillip.eby Date: Mon Oct 19 23:46:36 2009 New Revision: 75547 Log: Fix the elusive "double upload bdist_wininst" bug Modified: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Modified: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Mon Oct 19 23:46:36 2009 @@ -2,26 +2,24 @@ import os, sys class bdist_wininst(_bdist_wininst): + _good_upload = _bad_upload = None def create_exe(self, arcname, fullname, bitmap=None): _bdist_wininst.create_exe(self, arcname, fullname, bitmap) - dist_files = getattr(self.distribution, 'dist_files', []) - + installer_name = self.get_installer_filename(fullname) if self.target_version: - installer_name = os.path.join(self.dist_dir, - "%s.win32-py%s.exe" % - (fullname, self.target_version)) pyversion = self.target_version - - # fix 2.5 bdist_wininst ignoring --target-version spec - bad = ('bdist_wininst','any',installer_name) - if bad in dist_files: - dist_files.remove(bad) + # fix 2.5+ bdist_wininst ignoring --target-version spec + self._bad_upload = ('bdist_wininst', 'any', installer_name) else: - installer_name = os.path.join(self.dist_dir, - "%s.win32.exe" % fullname) pyversion = 'any' - good = ('bdist_wininst', pyversion, installer_name) + self._good_upload = ('bdist_wininst', pyversion, installer_name) + + def _fix_upload_names(self): + good, bad = self._good_upload, self._bad_upload + dist_files = getattr(self.distribution, 'dist_files', []) + if bad in dist_files: + dist_files.remove(bad) if good not in dist_files: dist_files.append(good) @@ -36,6 +34,49 @@ self._is_running = True try: _bdist_wininst.run(self) + self._fix_upload_names() finally: self._is_running = False + + if not hasattr(_bdist_wininst, 'get_installer_filename'): + def get_installer_filename(self, fullname): + # Factored out to allow overriding in subclasses + if self.target_version: + # if we create an installer for a specific python version, + # it's better to include this in the name + installer_name = os.path.join(self.dist_dir, + "%s.win32-py%s.exe" % + (fullname, self.target_version)) + else: + installer_name = os.path.join(self.dist_dir, + "%s.win32.exe" % fullname) + return installer_name + # get_installer_filename() + + + + + + + + + + + + + + + + + + + + + + + + + + + From nnorwitz at gmail.com Mon Oct 19 23:46:30 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 19 Oct 2009 17:46:30 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091019214630.GA23683@python.psfb.org> More important issues: ---------------------- test_distutils leaked [-25, 0, 0] references, sum=-25 test_ssl leaked [339, 0, -420] references, sum=-81 Less important issues: ---------------------- test_smtplib leaked [179, -264, -3] references, sum=-88 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Mon Oct 19 23:47:45 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:47:45 -0000 Subject: [Python-checkins] r75548 - sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Message-ID: Author: phillip.eby Date: Mon Oct 19 23:47:44 2009 New Revision: 75548 Log: Fix the elusive "double upload bdist_wininst" bug Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Mon Oct 19 23:47:44 2009 @@ -2,26 +2,24 @@ import os, sys class bdist_wininst(_bdist_wininst): + _good_upload = _bad_upload = None def create_exe(self, arcname, fullname, bitmap=None): _bdist_wininst.create_exe(self, arcname, fullname, bitmap) - dist_files = getattr(self.distribution, 'dist_files', []) - + installer_name = self.get_installer_filename(fullname) if self.target_version: - installer_name = os.path.join(self.dist_dir, - "%s.win32-py%s.exe" % - (fullname, self.target_version)) pyversion = self.target_version - - # fix 2.5 bdist_wininst ignoring --target-version spec - bad = ('bdist_wininst','any',installer_name) - if bad in dist_files: - dist_files.remove(bad) + # fix 2.5+ bdist_wininst ignoring --target-version spec + self._bad_upload = ('bdist_wininst', 'any', installer_name) else: - installer_name = os.path.join(self.dist_dir, - "%s.win32.exe" % fullname) pyversion = 'any' - good = ('bdist_wininst', pyversion, installer_name) + self._good_upload = ('bdist_wininst', pyversion, installer_name) + + def _fix_upload_names(self): + good, bad = self._good_upload, self._bad_upload + dist_files = getattr(self.distribution, 'dist_files', []) + if bad in dist_files: + dist_files.remove(bad) if good not in dist_files: dist_files.append(good) @@ -36,6 +34,49 @@ self._is_running = True try: _bdist_wininst.run(self) + self._fix_upload_names() finally: self._is_running = False + + if not hasattr(_bdist_wininst, 'get_installer_filename'): + def get_installer_filename(self, fullname): + # Factored out to allow overriding in subclasses + if self.target_version: + # if we create an installer for a specific python version, + # it's better to include this in the name + installer_name = os.path.join(self.dist_dir, + "%s.win32-py%s.exe" % + (fullname, self.target_version)) + else: + installer_name = os.path.join(self.dist_dir, + "%s.win32.exe" % fullname) + return installer_name + # get_installer_filename() + + + + + + + + + + + + + + + + + + + + + + + + + + + From python-checkins at python.org Mon Oct 19 23:49:47 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:49:47 -0000 Subject: [Python-checkins] r75549 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools.txt Message-ID: Author: phillip.eby Date: Mon Oct 19 23:49:47 2009 New Revision: 75549 Log: Update change logs for release Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools.txt Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Mon Oct 19 23:49:47 2009 @@ -1217,11 +1217,13 @@ Release Notes/Change History ============================ +0.6c11 + * Fix installed script .exe files not working with 64-bit Python on Windows + (wasn't actually released in 0.6c10 due to a lost checkin) + 0.6c10 * Fix easy_install.exe giving UAC errors on Windows Vista - * Fix installed script .exe files not working with 64-bit Python on Windows - * Support for the most recent Sourceforge download link insanity * Stop crashing on certain types of HTTP error Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Mon Oct 19 23:49:47 2009 @@ -2632,6 +2632,9 @@ Release Notes/Change History ---------------------------- +0.6c11 + * Fix "bdist_wininst upload" trying to upload same file twice + 0.6c10 * Fix for the Python 2.6.3 build_ext API change From python-checkins at python.org Mon Oct 19 23:51:25 2009 From: python-checkins at python.org (phillip.eby) Date: Mon, 19 Oct 2009 21:51:25 -0000 Subject: [Python-checkins] r75550 - sandbox/branches/setuptools-0.6/ez_setup.py Message-ID: Author: phillip.eby Date: Mon Oct 19 23:51:24 2009 New Revision: 75550 Log: Fixed MD5's Modified: sandbox/branches/setuptools-0.6/ez_setup.py Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Mon Oct 19 23:51:24 2009 @@ -28,10 +28,10 @@ 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', - 'setuptools-0.6c10-py2.3.egg': 'cb00cbd3d93b66f6c118a1c042113f93', - 'setuptools-0.6c10-py2.4.egg': 'be702e15b4b61628e059d6ab88335a87', - 'setuptools-0.6c10-py2.5.egg': '79b809922c0ce55e2d8b5b0cc31da0f2', - 'setuptools-0.6c10-py2.6.egg': 'c4b741e774a793609d508ff4a2a21194', + 'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090', + 'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4', + 'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7', + 'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', From python-checkins at python.org Tue Oct 20 05:14:10 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 20 Oct 2009 03:14:10 -0000 Subject: [Python-checkins] r75551 - python/trunk/Doc/library/queue.rst Message-ID: Author: benjamin.peterson Date: Tue Oct 20 05:14:10 2009 New Revision: 75551 Log: use property api Modified: python/trunk/Doc/library/queue.rst Modified: python/trunk/Doc/library/queue.rst ============================================================================== --- python/trunk/Doc/library/queue.rst (original) +++ python/trunk/Doc/library/queue.rst Tue Oct 20 05:14:10 2009 @@ -183,7 +183,7 @@ q = Queue() for i in range(num_worker_threads): t = Thread(target=worker) - t.setDaemon(True) + t.daemon = True t.start() for item in source(): From nnorwitz at gmail.com Tue Oct 20 06:44:28 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 19 Oct 2009 21:44:28 -0700 Subject: [Python-checkins] r75526 - python/branches/py3k/Lib/test/regrtest.py In-Reply-To: <4adc99ae.1467f10a.4636.ffffefc3SMTPIN_ADDED@mx.google.com> References: <4adc99ae.1467f10a.4636.ffffefc3SMTPIN_ADDED@mx.google.com> Message-ID: On Mon, Oct 19, 2009 at 9:54 AM, r.david.murray wrote: > Author: r.david.murray > Date: Mon Oct 19 18:53:55 2009 > New Revision: 75526 > > Log: > Since all regrtest -j output is now done in the main thread we are no > longer using the print lock, so remove it. > > > > Modified: > ? python/branches/py3k/Lib/test/regrtest.py > > Modified: python/branches/py3k/Lib/test/regrtest.py > ============================================================================== > --- python/branches/py3k/Lib/test/regrtest.py ? (original) > +++ python/branches/py3k/Lib/test/regrtest.py ? Mon Oct 19 18:53:55 2009 > @@ -440,13 +440,12 @@ > ? ? ? ? ? ? ? ? resource_denieds.append(test) > > ? ? if use_mp: > - ? ? ? ?from threading import Thread, Lock > + ? ? ? ?from threading import Thread > ? ? ? ? from queue import Queue, Empty > ? ? ? ? from subprocess import Popen, PIPE, STDOUT > ? ? ? ? from collections import deque > ? ? ? ? # TextIOWrapper is not entirely thread-safe now, > ? ? ? ? # it can produce duplicate output when printing from several threads. > - ? ? ? ?print_lock = Lock() > ? ? ? ? debug_output_pat = re.compile(r"\[\d+ refs\]$") > ? ? ? ? pending = deque() > ? ? ? ? output = Queue() Should the comment about TextIOWrapper also be removed? n From python-checkins at python.org Tue Oct 20 09:59:46 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 20 Oct 2009 07:59:46 -0000 Subject: [Python-checkins] r75552 - peps/trunk/pep-0345.txt Message-ID: Author: tarek.ziade Date: Tue Oct 20 09:59:46 2009 New Revision: 75552 Log: udpating 345 with Tres branch Modified: peps/trunk/pep-0345.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Tue Oct 20 09:59:46 2009 @@ -26,8 +26,10 @@ Version 1.2 of the metadata format adds a number of optional fields designed to make third-party packaging of Python Software easier. -These fields are "Requires-Python" and "Requires-External". Also, the -"Metadata-Version" field is updated. +These fields are "Requires-Python", "Requires-External", "Requires-Dist", +"Provides-Dist", and "Obsoletes-Dist". This version also updates the +"Metadata-Version" field, and adds new fields, "Maintainer" and +Maintainer-email". Fields @@ -59,9 +61,7 @@ Version A string containing the package's version number. This - field should be parseable by one of the Version classes - (StrictVersion or LooseVersion) in the distutils.version - module. + field must be in the format specified in `PEP 386`_. Example:: @@ -132,7 +132,7 @@ Download-URL A string containing the URL from which this version of the package can be downloaded. (This means that the URL can't be something like - ".../package-latest.tgz", but instead must be "../package-0.45.tgz".) + ".../package-latest.tgz", but instead must be ".../package-0.45.tgz".) Author (optional) A string containing the author's name at a minimum; additional @@ -146,7 +146,7 @@ Author-email A string containing the author's e-mail address. It can contain a name and e-mail address in the legal forms for a RFC-822 - 'From:' header. It's not optional because cataloging systems + ``From:`` header. It's not optional because cataloging systems can use the e-mail portion of this field as a unique key representing the author. A catalog might provide authors the ability to store their GPG key, personal home page, and other @@ -159,17 +159,47 @@ Author-email: "C. Schultz" -License +Maintainer (optional) + A string containing the maintainer's name at a minimum; additional + contact information may be provided. + + Note that this field is intended for use when a package is being + maintained by someone other than the original author: it should be + omitted if it is identical to ``Author``. + + Example:: + + Maintainer: C. Schultz, Universal Features Syndicate, + Los Angeles, CA + +Maintainer-email (optional) + A string containing the maintainer's e-mail address. It can contain + a name and e-mail address in the legal forms for a RFC-822 + ``From:`` header. + + Note that this field is intended for use when a package is being + maintained by someone other than the original author: it should be + omitted if it is identical to ``Author-email``. + + Example:: + + Maintainer-email: "C. Schultz" + +License (optional) Text indicating the license covering the package where the license is not a selection from the "License" Trove classifiers. See - "Classifier" below. + "Classifier" below. This field may also be used to specify a + particular version of a licencse which is named via the ``Classifier`` + field, or to indicate a variation or exception to such a license. - Example:: + Examples:: License: This software may only be obtained by sending the author a postcard, and then the user promises not to redistribute it. + License: GPL version 3, excluding DRM provisions + Classifier (multiple use) Each entry is a string giving a single classification value for the package. Classifiers are described in PEP 301 [2]. @@ -184,7 +214,7 @@ package required by this package. The format of a requirement string is identical to that of a - module or package name usable with the 'import' statement, + module or package name usable with the ``import`` statement, optionally followed by a version declaration within parentheses. A version declaration is a series of conditional operators and @@ -205,7 +235,7 @@ There's no canonical list of what strings should be used; the Python community is left to choose its own standards. - Example:: + Examples:: Requires: re Requires: sys @@ -213,6 +243,8 @@ Requires: xml.parsers.expat (>1.0) Requires: psycopg + Note: this field is now deprecated in favor of ``Requires-Dist``. + Provides (multiple use) Each entry contains a string describing a package or module that will be provided by this package once it is installed. These @@ -221,7 +253,7 @@ operator); the package's version number will be implied if none is specified. - Example:: + Examples:: Provides: xml Provides: xml.utils @@ -229,6 +261,8 @@ Provides: xml.dom Provides: xmltools (1.3) + Note: this field is now deprecated in favor of ``Provides-Dist``. + Obsoletes (multiple use) Each entry contains a string describing a package or module that this package renders obsolete, meaning that the two packages @@ -244,35 +278,105 @@ Obsoletes: Gorgon + Note: this field is now deprecated in favor of ``Obsoletes-Dist``. + +Requires-Dist (multiple use) + Each entry contains a string naming some other distutils + project required by this package. + + The format of a requirement string is identical to that of a + distutils project name (e.g., as found in the ``Name:`` field. + optionally followed by a version declaration within parentheses. + + The distutils project names should correspond to names as found + on the `Python Package Index`_. + + A version declaration is a series of conditional operators and + version numbers, separated by commas. Conditional operators + must be one of "<", ">", "<=", ">=", "==", and "!=". Version + numbers must be in the format specified in `PEP 386`_. + + Any number of conditional operators can be specified, e.g. + the string ">1.0, !=1.3.4, <2.0" is a legal version declaration. + + Examples:: + + Requires-Dist: pkginfo + Requires-Dist: PasteDeploy + Requires-Dist: zope.interface (>3.5.0) + +Provides-Dist (multiple use) + Each entry contains a string naming a distutlis project which + is contained within this distribution. This field *must* include + the project identified in the ``Name`` field. + + A distribution may provide additional names, e.g. to indicate that + multiple projects have been bundled together. For instance, source + distributions of the ``ZODB`` project have historically included + the ``transaction`` project, which is now available as a separate + distribution. Installing such a source distribution satisfies + requirements for both ``ZODB`` and ``transaction``. + + A distribution may also provide a "virtual" project name, which does + not correspond to any separately-distributed project: such a name + might be used to indicate an abstract capability which could be supplied + by one of multiple projects. E.g., multiple projects might supply + RDBMS bindings for use by a given ORM: each project might declare + that it provides ``ORM-bindings``, allowing other projects to depend + only on having at most one of them installed. + + A version declaration may be supplied (without a comparison + operator); the distribution's version number will be implied if none + is specified. Version numbers must be in the format specified in + `PEP 386`_. + + Examples:: + + Provides-Dist: OtherPackage + Provides-Dist: AnotherPackage (3.4) + Provides-Dist: virtual_package + +Obsoletes-Dist (multiple use) + Each entry contains a string describing a distutils project which + this package renders obsolete, meaning that the two packages + should not be installed at the same time. + + Version declarations can be supplied. Version numbers must be in the + format specified in `PEP 386`_. + + The most common use of this field will be in case a project name + changes, e.g. Gorgon 2.3 gets subsumed into Torqued Python 1.0. + When you install Torqued Python, the Gorgon distribution should be + removed. + + Examples:: + + Obsoletes-Dist: Gorgon + Obsoletes-Dist: OtherPackage (<3.0) + Requires-Python This field specifies the Python version(s) that the package is guaranteed to be compatible with. The format of the field is a series of conditional operators and version numbers, separated by commas. Conditional operators must be one of "<", ">", "<=", - ">=", "==", and "!=". Version numbers must be in the format - accepted by the distutils.version.StrictVersion class: two or three - dot-separated numeric components, with an optional "pre-release" - tag on the end consisting of the letter 'a' or 'b' followed by a - number. Example version numbers are "1.0", "2.3a2" and "1.3.99". + ">=", "==", and "!=". + + Version numbers must be in the format specified in `PEP 386`_. Any number of conditional operators can be specified, e.g. the string ">1.0, !=1.3.4, <2.0" is a legal version declaration. - Example:: + Examples:: Requires-Python: >2.1 Requires-Python: >=2.3.4 - XXX This field doesn't take into account possible future - incompatibilities through deprecation. We could specify that the - ">" operator only work for up to two releases? This is based on - the typical deprecation plan that Python usually follows (warning - for two releases and then error). That is, >=2.3.4 works for - 2.3.4, 2.4 and 2.5. Requires-External (multiple use) Each entry contains a string describing some dependency in the - system that the package is to be used. + system that the package is to be used. This field is intended to + serve as a hint to downstream package maintainers, and has no + semantics which are meaningful to the ``distutils`` package. The format of a requirement string is a name of an external dependency, optionally followed by a version declaration within @@ -280,45 +384,50 @@ A version declaration is a series of conditional operators and version numbers, separated by commas. Conditional operators - must be one of "<", ">", "<=", ">=", "==", and "!=". Version - numbers must be in the format accepted by the - distutils.version.StrictVersion class: two or three - dot-separated numeric components, with an optional "pre-release" - tag on the end consisting of the letter 'a' or 'b' followed by a - number. Example version numbers are "1.0", "2.3a2", "1.3.99", + must be one of "<", ">", "<=", ">=", "==", and "!=". Because they + refer to non-Python software releases, version numbers for + this field are **not** required to conform to the format + specified in `PEP 386`_: they should correspond to the + version scheme used by the external dependency. Any number of conditional operators can be specified, e.g. the string ">1.0, !=1.3.4, <2.0" is a legal version declaration. The canonical list of what strings are allowed is available - in the `Cheese Shop`_ database. New names may be added to the - database either through the web or using the command-line; - Python community is left to choose its own standards. + in the `Python Package Index`_ database: see + `External References Registry`_ below for a description of how + the allowed values are managed. Some dependencies are anticipated to be quite broad, eg. "C", indicating a C compiler is required. - Example:: + Examples:: Requires: C - Requires: libpng + Requires: libpng (>=1.5) Copyright Indicates the party or parties, and the year of copyright covering the package. - Example:: + Examples:: Copyright: Guido van Rossum, 1991 Copyright: Python Software Foundation, 2005 Copyright: Public Domain +Version Specifiers +================== + +The specification for distribution version specifiers has been moved to +`PEP 386`_. + External References Registry ============================ -Stores in the `Cheese Shop`_ database a list of (name, description, +Stores in the `Python Package Index`_ database a list of (name, description, URI) identifying an external reference that may be used as a value in a Requires-External field. @@ -330,11 +439,32 @@ The names in the registry will be created under a first-comes first-wins basis. Other packagers of Python software (eg. to deb, rpm, etc) should be -able to translate the requires-external field to names in their own +able to translate the `Requires-external` field to names in their own packaging system. XXX command-line interface needs work, obviously +Summary of Differences From PEP 314 +=================================== + +* Metadata-Version is now 1.2. + +* Added fields: + + - Maintainer + - Maintainer-email + - Requires-Python + - Requires-External + - Requires-Dist + - Provides-Dist + - Obsoletes-Dist + +* Deprecated fields: + + - Requires (in favor of Requires-Dist) + - Provides (in favor of Provides-Dist) + - Obsoletes (in favor of Obsoletes-Dist) + References ========== @@ -346,7 +476,10 @@ .. [1] reStructuredText markup: http://docutils.sourceforge.net/ -.. _`Cheese Shop`: http://cheeseshop.python.org/ +.. _`Python Package Index`: http://pypi.python.org/pypi/ + +.. _`PEP 386`: http://svn.python.org/projects/peps/trunk/pep-0386.txt + Copyright From python-checkins at python.org Tue Oct 20 10:11:53 2009 From: python-checkins at python.org (vinay.sajip) Date: Tue, 20 Oct 2009 08:11:53 -0000 Subject: [Python-checkins] r75553 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Tue Oct 20 10:11:52 2009 New Revision: 75553 Log: Added section on internal objects, and did some miscellaneous tidying up. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Tue Oct 20 10:11:52 2009 @@ -116,7 +116,7 @@ Before describing the schema in detail, it is worth saying a few words about object connections, support for user-defined objects and access -to external objects. +to external and internal objects. Object connections @@ -145,11 +145,11 @@ # configuration of handler with id h2 goes here loggers: foo.bar.baz: - # other configuration for logger "foo.bar.baz" + # other configuration for logger 'foo.bar.baz' handlers: [h1, h2] -(Note: YAML will be used in this document as it is more readable than -the equivalent Python source form for the dictionary.) +(Note: YAML will be used in this document as it is a little more +readable than the equivalent Python source form for the dictionary.) The ids for loggers are the logger names which would be used programmatically to obtain a reference to those loggers, e.g. @@ -234,7 +234,7 @@ as keyword arguments. In the above example, the formatter with id ``custom`` will be assumed to be returned by the call:: - my.package.customFormatterFactory(bar="baz", spam=99.9, answer=42) + my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42) The key ``'()'`` has been used as the special key because it is not a valid keyword parameter name, and so will not clash with the names of @@ -271,6 +271,68 @@ ``ext://`` but it will be possible to disable the mechanism completely or provide additional or different prefixes for special handling. +Access to internal objects +'''''''''''''''''''''''''' + +As well as external objects, there is sometimes also a need to refer +to objects in the configuration. This will be done implicitly by the +configuration system for things that it knows about. For example, the +string value ``'DEBUG'`` for a ``level`` in a logger or handler will +automatically be converted to the value ``logging.DEBUG``, and the +``handlers``, ``filters`` and ``formatter`` entries will take an +object id and resolve to the appropriate destination object. + +However, a more generic mechanism needs to be provided for the case +of user-defined objects which are not known to logging. For example, +take the instance of ``logging.handlers.MemoryHandler``, which takes +a ``target`` which is another handler to delegate to. Since the system +already knows about this class, then in the configuration, the given +``target`` just needs to be the object id of the relevant target +handler, and the system will resolve to the handler from the id. If, +however, a user defines a ``my.package.MyHandler`` which has a +``alternate`` handler, the configuration system would not know that +the ``alternate`` referred to a handler. To cater for this, a +generic resolution system will be provided which allows the user to +specify:: + + handlers: + file: + # configuration of file handler goes here + + custom: + (): my.package.MyHandler + alternate: int://handlers.file + +The literal string ``'int://handlers.file'`` will be resolved in an +analogous way to the strings with the ``ext://`` prefix, but looking +in the configuration itself rather than the import namespace. The +mechanism will allow access by dot or by index, in a similar way to +that provided by ``str.format``. Thus, given the following snippet:: + + handlers: + email: + class: logging.handlers.SMTPHandler + mailhost: localhost + fromaddr: my_app at domain.tld + toaddrs: + - support_team at domain.tld + - dev_team at domain.tld + subject: Houston, we have a problem. + +in the configuration, the string ``'int://handlers'`` would resolve to +the dict with key ``handlers``, the string ``'int://handlers.email`` +would resolve to the dict with key ``email`` in the ``handlers`` dict, +and so on. The string ``'int://handlers.email.toaddrs[1]`` would +resolve to ``'dev_team.domain.tld'`` and the string +``'int://handlers.email.toaddrs[0]'`` would resolve to the value +``'support_team at domain.tld'``. The ``subject`` value could be accessed +using either ``'int://handlers.email.subject'`` or, equivalently, +``'int://handlers.email[subject]'``. The latter form only needs to be +used if the key contains spaces or non-alphanumeric characters. If an +index value consists only of decimal digits, access will be attempted +using the corresponding integer value, falling back to the string +value if needed. + Dictionary Schema - Detail -------------------------- @@ -344,7 +406,7 @@ ``logging.StreamHandler``, using ``sys.stdout`` as the underlying stream. The handler with id ``file`` is instantiated as a ``logging.handlers.RotatingFileHandler`` with the keyword arguments - ``filename="logconfig.log", maxBytes=1024, backupCount=3``. + ``filename='logconfig.log', maxBytes=1024, backupCount=3``. * `loggers` - the corresponding value will be a dict in which each key is a logger name and each value is a dict describing how to @@ -453,7 +515,7 @@ be controlled just by setting levels (and perhaps propagation flags). Thus, when the ``incremental`` key of a configuration dict is present -and is ``True``, the system will ignore the ``formatters``, +and is ``True``, the system will ignore any ``formatters``, ``filters``, ``handlers`` entries completely, and process only the ``level`` and ``propagate`` settings in the ``loggers`` and ``root`` entries. @@ -463,9 +525,9 @@ ==================== If an error is encountered during configuration, the system will raise -a ``ValueError`` or a ``TypeError`` with a suitably descriptive -message. The following is a (possibly incomplete) list of conditions -which will raise an error: +a ``ValueError``,``TypeError``, ``AttributeError`` or ``ImportError`` +with a suitably descriptive message. The following is a (possibly +incomplete) list of conditions which will raise an error: * A ``level`` which is not a string or which is a string not corresponding to an actual logging level @@ -476,6 +538,7 @@ * An invalid logger name +* Inability to resolve to an internal or external object References ========== From python-checkins at python.org Tue Oct 20 10:35:19 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 20 Oct 2009 08:35:19 -0000 Subject: [Python-checkins] r75554 - peps/trunk/pep-0386.txt Message-ID: Author: tarek.ziade Date: Tue Oct 20 10:35:18 2009 New Revision: 75554 Log: updated with latest feedback + PEP 345 changes Modified: peps/trunk/pep-0386.txt Modified: peps/trunk/pep-0386.txt ============================================================================== --- peps/trunk/pep-0386.txt (original) +++ peps/trunk/pep-0386.txt Tue Oct 20 10:35:18 2009 @@ -19,22 +19,29 @@ Motivation ========== -Distutils will soon extend the metadata standard, by including the -`install_requires` field from Setuptools [#requires]_ among other changes. +Distutils will soon extend the metadata standard, by including an +``install_requires``-like field from Setuptools [#requires]_ among +other changes. This field will be called ``Requires-Dist``. -These changes are a work in progress in PEP 345 [#pep345]_, but validating -the current PEP is mandatory to continue the work. +These changes are located in PEP 345 [#pep345]_. -The `install_requires` field will allow a package to define a dependency on -another package and optionally restrict this dependency to a set of -compatible versions. +The ``Requires-Dist`` field will allow a package to define a dependency on +another package and optionally restrict this dependency to a set of +compatible versions, so one may write:: + + Requires-Dist: zope.interface (>3.5.0) + +This means that the distribution requires ``zope.interface``, as long as its +version is superior to ``3.5.0``. That's why Distutils needs to provide a robust standard and reference -implementation to compare versions numbers. +version scheme, and an API to provide version comparisons. -This will also provide to the community a convention for their package -versioning needs. +This PEP describes a new version scheme that will be added in Distutils. +Of course developers are **not** required to conform to this scheme, but +it is suggested to use it as a standard for interoperability between the +existing Python distributions installers. Current status ============== @@ -246,12 +253,11 @@ During Pycon, members of the Python, Ubuntu and Fedora community worked on a version standard that would be acceptable for everyone. -It's currently called `verlib` and a prototype lives here : -http://bitbucket.org/tarek/distutilsversion/src/ +It's currently called `verlib` and a prototype lives at [#prototype]_. The pseudo-format supported is:: - N.N[.N]+[abc]N[.N]+[.postN+][.devN+] + N.N[.N]+[abc]N[.N]+[.postN+][.devN+] Some examples probably make it clearer:: @@ -267,16 +273,19 @@ ... < V('1.0c1') ... < V('1.0.dev456') ... < V('1.0') - ... < V('1.0.post623.dev456') + ... < V('1.0.post456.dev34') ... < V('1.0.post456')) True -The trailing ".dev123" is for pre-releases. The ".post123" is for +The trailing ``.dev123`` is for pre-releases. The ``.post123`` is for post-releases -- which apparently is used by a number of projects out there -(e.g. Twisted [#twisted]_). For example *after* a "1.2.0" release there might -be a "1.2.0-r678" release. We used "post" instead of "r" because the "r" is -ambiguous as to whether it indicates a pre- or post-release. -Last ".post623.dev456" is a development version of a post-release. +(e.g. Twisted [#twisted]_). For example *after* a ``1.2.0`` release there might +be a ``1.2.0-r678`` release. We used ``post`` instead of ``r`` because the +``r`` is ambiguous as to whether it indicates a pre- or post-release. + +Last, ``.post456.dev34`` indicates a dev parker for a post release, that sorts +before a ``.post345`` marker. This can be used to do development versions +of post releases. ``verlib`` provides a ``RationalVersion`` class and a ``suggest_rational_version`` function. @@ -310,7 +319,6 @@ - the main version part - the pre-release part -- the `postdev` marker part Examples :: @@ -326,10 +334,22 @@ >>> str(version) '1.0c4.dev34' + suggest_rational_version ------------------------ -XXX explain here suggest_rational_version +``suggest_rational_version`` is a function that suggests a rational version +close to the given version string. If you have a version string that isn't +rational (i.e. ``RationalVersion`` doesn't like it) then you might be able +to get an equivalent (or close) rational version from this function. + +This does a number of simple normalizations to the given string, based +on observation of versions currently in use on PyPI. Given a dump of those +version during PyCon 2009, 4287 of them: + +- 2312 (53.93%) match RationalVersion without change with the automatic + suggestion +- 3474 (81.04%) match when using this suggestion method References @@ -365,8 +385,11 @@ .. [#pep345] http://svn.python.org/projects/peps/branches/jim-update-345/pep-0345.txt -Aknowledgments -============== +.. [#prototype] + http://bitbucket.org/tarek/distutilsversion/ + +Acknowledgments +=============== Trent Mick, Matthias Klose, Phillip Eby, and many people at Pycon and Distutils-SIG. From python-checkins at python.org Tue Oct 20 10:46:30 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 20 Oct 2009 08:46:30 -0000 Subject: [Python-checkins] r75555 - peps/trunk/pep-0345.txt Message-ID: Author: tarek.ziade Date: Tue Oct 20 10:46:30 2009 New Revision: 75555 Log: using a web link instead of the svn link Modified: peps/trunk/pep-0345.txt Modified: peps/trunk/pep-0345.txt ============================================================================== --- peps/trunk/pep-0345.txt (original) +++ peps/trunk/pep-0345.txt Tue Oct 20 10:46:30 2009 @@ -478,8 +478,8 @@ .. _`Python Package Index`: http://pypi.python.org/pypi/ -.. _`PEP 386`: http://svn.python.org/projects/peps/trunk/pep-0386.txt - +.. _`PEP 386`: http://www.python.org/dev/peps/pep-0386 + Copyright From nnorwitz at gmail.com Tue Oct 20 11:46:00 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 20 Oct 2009 05:46:00 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091020094600.GA19047@python.psfb.org> More important issues: ---------------------- test_distutils leaked [0, -25, 0] references, sum=-25 test_ssl leaked [0, 0, -81] references, sum=-81 Less important issues: ---------------------- test_smtplib leaked [-5, -88, 82] references, sum=-11 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [0, 284, -284] references, sum=0 From python-checkins at python.org Tue Oct 20 13:18:29 2009 From: python-checkins at python.org (r.david.murray) Date: Tue, 20 Oct 2009 11:18:29 -0000 Subject: [Python-checkins] r75556 - python/branches/py3k/Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Tue Oct 20 13:18:29 2009 New Revision: 75556 Log: Remove comment that went with the print_lock that was previously deleted. Modified: python/branches/py3k/Lib/test/regrtest.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Tue Oct 20 13:18:29 2009 @@ -444,8 +444,6 @@ from queue import Queue, Empty from subprocess import Popen, PIPE, STDOUT from collections import deque - # TextIOWrapper is not entirely thread-safe now, - # it can produce duplicate output when printing from several threads. debug_output_pat = re.compile(r"\[\d+ refs\]$") pending = deque() output = Queue() From python-checkins at python.org Tue Oct 20 13:19:20 2009 From: python-checkins at python.org (r.david.murray) Date: Tue, 20 Oct 2009 11:19:20 -0000 Subject: [Python-checkins] r75557 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Tue Oct 20 13:19:19 2009 New Revision: 75557 Log: Blocked revisions 75556 via svnmerge ........ r75556 | r.david.murray | 2009-10-20 07:18:29 -0400 (Tue, 20 Oct 2009) | 2 lines Remove comment that went with the print_lock that was previously deleted. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 20 13:32:53 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 11:32:53 -0000 Subject: [Python-checkins] r75558 - in sandbox/trunk/decimal/decimal_in_c: decimaltestdata/abs.decTest decimaltestdata/add.decTest decimaltestdata/and.decTest decimaltestdata/base.decTest decimaltestdata/clamp.decTest decimaltestdata/class.decTest decimaltestdata/compare.decTest decimaltestdata/comparetotal.decTest decimaltestdata/comparetotmag.decTest decimaltestdata/copy.decTest decimaltestdata/copyabs.decTest decimaltestdata/copynegate.decTest decimaltestdata/copysign.decTest decimaltestdata/ddAbs.decTest decimaltestdata/ddAdd.decTest decimaltestdata/ddAnd.decTest decimaltestdata/ddBase.decTest decimaltestdata/ddCanonical.decTest decimaltestdata/ddClass.decTest decimaltestdata/ddCompare.decTest decimaltestdata/ddCompareSig.decTest decimaltestdata/ddCompareTotal.decTest decimaltestdata/ddCompareTotalMag.decTest decimaltestdata/ddCopy.decTest decimaltestdata/ddCopyAbs.decTest decimaltestdata/ddCopyNegate.decTest decimaltestdata/ddCopySign.decTest decimaltestdata/ddDivide.decTest decimaltestdata/ddDivideInt.decTest decimaltestdata/ddEncode.decTest decimaltestdata/ddFMA.decTest decimaltestdata/ddInvert.decTest decimaltestdata/ddLogB.decTest decimaltestdata/ddMax.decTest decimaltestdata/ddMaxMag.decTest decimaltestdata/ddMin.decTest decimaltestdata/ddMinMag.decTest decimaltestdata/ddMinus.decTest decimaltestdata/ddMultiply.decTest decimaltestdata/ddNextMinus.decTest decimaltestdata/ddNextPlus.decTest decimaltestdata/ddNextToward.decTest decimaltestdata/ddOr.decTest decimaltestdata/ddPlus.decTest decimaltestdata/ddQuantize.decTest decimaltestdata/ddReduce.decTest decimaltestdata/ddRemainder.decTest decimaltestdata/ddRemainderNear.decTest decimaltestdata/ddRotate.decTest decimaltestdata/ddSameQuantum.decTest decimaltestdata/ddScaleB.decTest decimaltestdata/ddShift.decTest decimaltestdata/ddSubtract.decTest decimaltestdata/ddToIntegral.decTest decimaltestdata/ddXor.decTest decimaltestdata/decDouble.decTest decimaltestdata/decQuad.decTest decimaltestdata/decSingle.decTest decimaltestdata/divide.decTest decimaltestdata/divideint.decTest decimaltestdata/dqAbs.decTest decimaltestdata/dqAdd.decTest decimaltestdata/dqAnd.decTest decimaltestdata/dqBase.decTest decimaltestdata/dqCanonical.decTest decimaltestdata/dqClass.decTest decimaltestdata/dqCompare.decTest decimaltestdata/dqCompareSig.decTest decimaltestdata/dqCompareTotal.decTest decimaltestdata/dqCompareTotalMag.decTest decimaltestdata/dqCopy.decTest decimaltestdata/dqCopyAbs.decTest decimaltestdata/dqCopyNegate.decTest decimaltestdata/dqCopySign.decTest decimaltestdata/dqDivide.decTest decimaltestdata/dqDivideInt.decTest decimaltestdata/dqEncode.decTest decimaltestdata/dqFMA.decTest decimaltestdata/dqInvert.decTest decimaltestdata/dqLogB.decTest decimaltestdata/dqMax.decTest decimaltestdata/dqMaxMag.decTest decimaltestdata/dqMin.decTest decimaltestdata/dqMinMag.decTest decimaltestdata/dqMinus.decTest decimaltestdata/dqMultiply.decTest decimaltestdata/dqNextMinus.decTest decimaltestdata/dqNextPlus.decTest decimaltestdata/dqNextToward.decTest decimaltestdata/dqOr.decTest decimaltestdata/dqPlus.decTest decimaltestdata/dqQuantize.decTest decimaltestdata/dqReduce.decTest decimaltestdata/dqRemainder.decTest decimaltestdata/dqRemainderNear.decTest decimaltestdata/dqRotate.decTest decimaltestdata/dqSameQuantum.decTest decimaltestdata/dqScaleB.decTest decimaltestdata/dqShift.decTest decimaltestdata/dqSubtract.decTest decimaltestdata/dqToIntegral.decTest decimaltestdata/dqXor.decTest decimaltestdata/dsBase.decTest decimaltestdata/dsEncode.decTest decimaltestdata/exp.decTest decimaltestdata/extra.decTest decimaltestdata/fma.decTest decimaltestdata/inexact.decTest decimaltestdata/invert.decTest decimaltestdata/ln.decTest decimaltestdata/log10.decTest decimaltestdata/logb.decTest decimaltestdata/max.decTest decimaltestdata/maxmag.decTest decimaltestdata/min.decTest decimaltestdata/minmag.decTest decimaltestdata/minus.decTest decimaltestdata/multiply.decTest decimaltestdata/nextminus.decTest decimaltestdata/nextplus.decTest decimaltestdata/nexttoward.decTest decimaltestdata/or.decTest decimaltestdata/plus.decTest decimaltestdata/power.decTest decimaltestdata/powersqrt.decTest decimaltestdata/quantize.decTest decimaltestdata/randomBound32.decTest decimaltestdata/randoms.decTest decimaltestdata/reduce.decTest decimaltestdata/remainder.decTest decimaltestdata/remainderNear.decTest decimaltestdata/rescale.decTest decimaltestdata/rotate.decTest decimaltestdata/rounding.decTest decimaltestdata/samequantum.decTest decimaltestdata/scaleb.decTest decimaltestdata/shift.decTest decimaltestdata/squareroot.decTest decimaltestdata/subtract.decTest decimaltestdata/testall.decTest decimaltestdata/tointegral.decTest decimaltestdata/tointegralx.decTest decimaltestdata/xor.decTest test_decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 20 13:32:51 2009 New Revision: 75558 Log: Update decimal tests Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/abs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/add.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/and.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/base.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/clamp.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/class.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/compare.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotal.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotmag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copy.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copyabs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copynegate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copysign.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAbs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAdd.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAnd.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddBase.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCanonical.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddClass.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompare.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareSig.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotal.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotalMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopy.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyAbs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyNegate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopySign.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivide.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivideInt.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddEncode.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddFMA.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddInvert.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddLogB.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMax.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMaxMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMin.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMultiply.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextMinus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextPlus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextToward.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddOr.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddPlus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddQuantize.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddReduce.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainder.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainderNear.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRotate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSameQuantum.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddScaleB.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddShift.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSubtract.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddToIntegral.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddXor.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decDouble.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decQuad.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decSingle.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divide.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divideint.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAbs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAdd.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAnd.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqBase.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCanonical.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqClass.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompare.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareSig.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotal.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotalMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopy.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyAbs.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyNegate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopySign.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivide.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivideInt.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqEncode.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqFMA.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqInvert.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqLogB.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMax.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMaxMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMin.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinMag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMultiply.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextMinus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextPlus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextToward.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqOr.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqPlus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqQuantize.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqReduce.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainder.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainderNear.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRotate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSameQuantum.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqScaleB.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqShift.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSubtract.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqToIntegral.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqXor.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsBase.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsEncode.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/exp.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/fma.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/inexact.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/invert.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ln.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/log10.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/logb.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/max.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/maxmag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/min.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minmag.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/multiply.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextminus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextplus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nexttoward.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/or.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/plus.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/power.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/powersqrt.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/quantize.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randomBound32.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randoms.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/reduce.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainder.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainderNear.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rescale.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rotate.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rounding.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/samequantum.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/scaleb.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/shift.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/squareroot.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/subtract.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/testall.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegral.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegralx.decTest sandbox/trunk/decimal/decimal_in_c/decimaltestdata/xor.decTest sandbox/trunk/decimal/decimal_in_c/test_decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/abs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/abs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/abs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/add.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/add.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/add.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 9 rounding: half_up Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/and.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/and.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/and.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/base.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/base.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/base.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 -- This file tests base conversions from string to a decimal number Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/clamp.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/clamp.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/clamp.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/class.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/class.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/class.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/compare.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/compare.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/compare.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotal.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotal.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotal.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotmag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotmag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/comparetotmag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that it cannot be assumed that add/subtract tests cover paths -- for this operation adequately, here, because the code might be Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copy.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copy.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copy.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copyabs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copyabs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copyabs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copynegate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copynegate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copynegate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copysign.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copysign.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/copysign.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAbs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAbs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAbs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAdd.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAdd.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAdd.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAnd.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAnd.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddAnd.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddBase.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddBase.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddBase.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCanonical.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCanonical.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCanonical.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddClass.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddClass.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddClass.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompare.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompare.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompare.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareSig.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareSig.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareSig.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotal.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotal.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotal.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotalMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotalMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCompareTotalMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopy.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopy.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopy.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyAbs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyAbs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyAbs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyNegate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyNegate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopyNegate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopySign.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopySign.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddCopySign.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivide.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivide.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivide.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 @@ -160,7 +160,7 @@ dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded --- test some cases that are close to exponent overflow +-- test some cases that are close to exponent overflow, some with coefficient padding dddiv270 divide 1 1e384 -> 1E-384 Subnormal dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow @@ -168,7 +168,16 @@ dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped -dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 +dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped +dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped +dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 + +dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped +dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded +dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped +dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded +dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped + -- Divide into 0 tests dddiv301 divide 0 7 -> 0 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivideInt.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivideInt.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddDivideInt.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddEncode.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddEncode.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddEncode.decTest Tue Oct 20 13:32:51 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal64.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddFMA.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddFMA.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddFMA.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddInvert.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddInvert.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddInvert.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddLogB.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddLogB.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddLogB.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMax.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMax.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMax.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMaxMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMaxMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMaxMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMin.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMin.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMin.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMinus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMultiply.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMultiply.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddMultiply.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextMinus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextMinus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextMinus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextPlus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextPlus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextPlus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextToward.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextToward.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddNextToward.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddOr.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddOr.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddOr.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddPlus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddPlus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddPlus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddQuantize.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddQuantize.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddQuantize.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddReduce.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddReduce.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddReduce.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainder.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainder.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainder.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainderNear.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainderNear.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRemainderNear.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRotate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRotate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddRotate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSameQuantum.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSameQuantum.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSameQuantum.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddScaleB.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddScaleB.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddScaleB.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddShift.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddShift.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddShift.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSubtract.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSubtract.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddSubtract.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddToIntegral.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddToIntegral.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddToIntegral.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddXor.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddXor.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ddXor.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decDouble.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decDouble.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decDouble.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decDouble tests dectest: ddAbs Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decQuad.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decQuad.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decQuad.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decQuad tests dectest: dqAbs Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decSingle.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decSingle.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/decSingle.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decSingle tests dectest: dsBase Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divide.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divide.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divide.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divideint.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divideint.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/divideint.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAbs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAbs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAbs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAdd.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAdd.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAdd.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad @@ -637,7 +637,7 @@ dqadd7732 add 0 0 -> 0 dqadd7733 add 0 -0 -> 0 dqadd7734 add -0 0 -> 0 -dqadd7735 add -0 -0 -> -0 -- IEEE 854 special case +dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case dqadd7736 add 1 -1 -> 0 dqadd7737 add -1 -1 -> -2 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAnd.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAnd.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqAnd.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqBase.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqBase.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqBase.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCanonical.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCanonical.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCanonical.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqClass.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqClass.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqClass.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompare.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompare.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompare.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareSig.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareSig.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareSig.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotal.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotal.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotal.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotalMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotalMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCompareTotalMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopy.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopy.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopy.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyAbs.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyAbs.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyAbs.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyNegate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyNegate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopyNegate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopySign.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopySign.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqCopySign.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivide.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivide.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivide.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivideInt.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivideInt.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqDivideInt.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqEncode.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqEncode.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqEncode.decTest Tue Oct 20 13:32:51 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal128.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqFMA.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqFMA.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqFMA.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqInvert.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqInvert.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqInvert.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqLogB.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqLogB.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqLogB.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMax.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMax.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMax.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMaxMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMaxMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMaxMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMin.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMin.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMin.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinMag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinMag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinMag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMinus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMultiply.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMultiply.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqMultiply.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextMinus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextMinus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextMinus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextPlus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextPlus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextPlus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextToward.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextToward.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqNextToward.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqOr.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqOr.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqOr.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqPlus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqPlus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqPlus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqQuantize.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqQuantize.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqQuantize.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. @@ -357,8 +357,6 @@ rounding: down dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation --- ? should that one instead have been: --- dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqReduce.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqReduce.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqReduce.decTest Tue Oct 20 13:32:51 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainder.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainder.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainder.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainderNear.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainderNear.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRemainderNear.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRotate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRotate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqRotate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSameQuantum.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSameQuantum.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSameQuantum.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqScaleB.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqScaleB.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqScaleB.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqShift.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqShift.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqShift.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSubtract.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSubtract.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqSubtract.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqToIntegral.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqToIntegral.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqToIntegral.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqXor.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqXor.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dqXor.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsBase.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsBase.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsBase.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsEncode.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsEncode.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/dsEncode.decTest Tue Oct 20 13:32:51 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal32.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/exp.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/exp.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/exp.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Tests of the exponential funtion. Currently all testcases here -- show results which are correctly rounded (within <= 0.5 ulp). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest Tue Oct 20 13:32:51 2009 @@ -154,6 +154,22 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1400 comparetotal NaN123 NaN45 -> 1 +extr1401 comparetotal sNaN123 sNaN45 -> 1 +extr1402 comparetotal -NaN123 -NaN45 -> -1 +extr1403 comparetotal -sNaN123 -sNaN45 -> -1 +extr1404 comparetotal NaN45 NaN123 -> -1 +extr1405 comparetotal sNaN45 sNaN123 -> -1 +extr1406 comparetotal -NaN45 -NaN123 -> 1 +extr1407 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 + + -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/fma.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/fma.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/fma.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/inexact.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/inexact.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/inexact.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/invert.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/invert.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/invert.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ln.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ln.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/ln.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 16 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/log10.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/log10.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/log10.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/logb.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/logb.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/logb.decTest Tue Oct 20 13:32:51 2009 @@ -1,6 +1,6 @@ ------------------------------------------------------------------------ -- logb.decTest -- return integral adjusted exponent as per 754r -- --- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. -- +-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). @@ -143,7 +143,33 @@ logbx1419 logb 1000E2 -> 5 logbx1420 logb 10000E2 -> 6 +-- inexacts +precision: 2 +logbx1500 logb 10000E2 -> 6 +logbx1501 logb 1E+99 -> 99 +logbx1502 logb 1E-99 -> -99 +logbx1503 logb 1E+100 -> 1.0E+2 Rounded +logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded +logbx1505 logb 1E-100 -> -1.0E+2 Rounded +logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded +logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded +logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded +logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded +logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded +logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded +precision: 1 +logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded +logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded +logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded +precision: 8 +logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded +logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded +precision: 9 +logbx1523 logb 1E+999999999 -> 999999999 +logbx1524 logb 1E-999999999 -> -999999999 + -- special values +precision: 9 logbx820 logb Infinity -> Infinity logbx821 logb -Infinity -> Infinity logbx822 logb 0 -> -Infinity Division_by_zero Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/max.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/max.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/max.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/maxmag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/maxmag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/maxmag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/min.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/min.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/min.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minmag.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minmag.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minmag.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/minus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/multiply.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/multiply.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/multiply.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextminus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextminus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextminus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextplus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextplus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nextplus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nexttoward.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nexttoward.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/nexttoward.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/or.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/or.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/or.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/plus.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/plus.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/plus.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/power.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/power.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/power.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- In addition to the power operator testcases here, see also the file -- powersqrt.decTest which includes all the tests from Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/powersqrt.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/powersqrt.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/powersqrt.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases are taken from squareroot.decTest but are -- evaluated using the power operator. The differences in results Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/quantize.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/quantize.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/quantize.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randomBound32.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randomBound32.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randomBound32.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases test calculations at precisions 31, 32, and 33, to -- exercise the boundaries around 2**5 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randoms.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randoms.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/randoms.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 maxexponent: 999999999 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/reduce.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/reduce.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/reduce.decTest Tue Oct 20 13:32:51 2009 @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ -- [This used to be called normalize.] -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainder.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainder.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainder.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainderNear.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainderNear.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/remainderNear.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rescale.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rescale.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rescale.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [obsolete] Quantize.decTest has the improved version Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rotate.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rotate.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rotate.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rounding.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rounding.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/rounding.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These tests require that implementations take account of residues in -- order to get correct results for some rounding modes. Rather than Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/samequantum.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/samequantum.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/samequantum.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/scaleb.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/scaleb.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/scaleb.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -198,3 +198,12 @@ scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998 scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded + +-- Krah examples +precision: 34 +maxExponent: 999999999 +minExponent: -999999999 +-- integer overflow in 3.61 or earlier +scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation +-- out of range +scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/shift.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/shift.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/shift.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/squareroot.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/squareroot.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/squareroot.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -3812,6 +3812,16 @@ clamp: 1 sqtx9045 squareroot 1 -> 1.00000 Clamped +-- other +maxexponent: 999 +minexponent: -999 +precision: 16 +sqtx9046 squareroot 10 -> 3.162277660168379 inexact rounded +sqtx9047 squareroot 10E-1 -> 1.0 +sqtx9048 squareroot 10E-2 -> 0.3162277660168379 inexact rounded +sqtx9049 squareroot 10E-3 -> 0.10 + + -- High-precision exact and inexact maxexponent: 999 minexponent: -999 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/subtract.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/subtract.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/subtract.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/testall.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/testall.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/testall.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- core tests (using Extended: 1) -------------------------------------- dectest: base Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegral.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegral.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegral.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegralx.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegralx.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/tointegralx.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/xor.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/xor.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/xor.decTest Tue Oct 20 13:32:51 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: sandbox/trunk/decimal/decimal_in_c/test_decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/test_decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/test_decimal.py Tue Oct 20 13:32:51 2009 @@ -31,8 +31,7 @@ import unittest from decimal import * import numbers -from test.support import (TestSkipped, run_unittest, run_doctest, - is_resource_enabled) +from test.support import run_unittest, run_doctest, is_resource_enabled import random try: import threading @@ -64,6 +63,13 @@ skip_expected = not os.path.isdir(directory) +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False @@ -194,7 +200,7 @@ def eval_file(self, file): global skip_expected if skip_expected: - raise TestSkipped + raise unittest.SkipTest return for line in open(file): line = line.replace('\r\n', '').replace('\n', '') @@ -263,6 +269,10 @@ val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val + + if id in skipped_test_ids: + return + fname = nameAdapter.get(funct, funct) if fname == 'rescale': return @@ -426,9 +436,6 @@ self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4') self.assertEqual(str(Decimal(' -7.89')), '-7.89') - #but alternate unicode digits should not - self.assertEqual(str(Decimal('\uff11')), 'NaN') - def test_explicit_from_tuples(self): #zero @@ -508,7 +515,7 @@ # from int d = nc.create_decimal(456) - self.failUnless(isinstance(d, Decimal)) + self.assertTrue(isinstance(d, Decimal)) self.assertEqual(nc.create_decimal(45678), nc.create_decimal('457E+2')) @@ -535,6 +542,15 @@ d = nc.create_decimal(prevdec) self.assertEqual(str(d), '5.00E+8') + def test_unicode_digits(self): + test_values = { + '\uff11': '1', + '\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372', + '-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400', + } + for input, expected in test_values.items(): + self.assertEqual(str(Decimal(input)), expected) + class DecimalImplicitConstructionTest(unittest.TestCase): '''Unit tests for Implicit Construction cases of Decimal.''' @@ -605,6 +621,7 @@ self.assertEqual(eval('Decimal(10)' + sym + 'E()'), '10' + rop + 'str') + class DecimalFormatTest(unittest.TestCase): '''Unit tests for the format function.''' def test_formatting(self): @@ -693,10 +710,137 @@ ('.0g', '-sNaN', '-sNaN'), ('', '1.00', '1.00'), + + # test alignment and padding + ('6', '123', ' 123'), + ('<6', '123', '123 '), + ('>6', '123', ' 123'), + ('^6', '123', ' 123 '), + ('=+6', '123', '+ 123'), + ('#<10', 'NaN', 'NaN#######'), + ('#<10', '-4.3', '-4.3######'), + ('#<+10', '0.0130', '+0.0130###'), + ('#< 10', '0.0130', ' 0.0130###'), + ('@>10', '-Inf', '@-Infinity'), + ('#>5', '-Inf', '-Infinity'), + ('?^5', '123', '?123?'), + ('%^6', '123', '%123%%'), + (' ^6', '-45.6', '-45.6 '), + ('/=10', '-45.6', '-/////45.6'), + ('/=+10', '45.6', '+/////45.6'), + ('/= 10', '45.6', ' /////45.6'), + + # thousands separator + (',', '1234567', '1,234,567'), + (',', '123456', '123,456'), + (',', '12345', '12,345'), + (',', '1234', '1,234'), + (',', '123', '123'), + (',', '12', '12'), + (',', '1', '1'), + (',', '0', '0'), + (',', '-1234567', '-1,234,567'), + (',', '-123456', '-123,456'), + ('7,', '123456', '123,456'), + ('8,', '123456', ' 123,456'), + ('08,', '123456', '0,123,456'), # special case: extra 0 needed + ('+08,', '123456', '+123,456'), # but not if there's a sign + (' 08,', '123456', ' 123,456'), + ('08,', '-123456', '-123,456'), + ('+09,', '123456', '+0,123,456'), + # ... with fractional part... + ('07,', '1234.56', '1,234.56'), + ('08,', '1234.56', '1,234.56'), + ('09,', '1234.56', '01,234.56'), + ('010,', '1234.56', '001,234.56'), + ('011,', '1234.56', '0,001,234.56'), + ('012,', '1234.56', '0,001,234.56'), + ('08,.1f', '1234.5', '01,234.5'), + # no thousands separators in fraction part + (',', '1.23456789', '1.23456789'), + (',%', '123.456789', '12,345.6789%'), + (',e', '123456', '1.23456e+5'), + (',E', '123456', '1.23456E+5'), + + # issue 6850 + ('a=-7.0', '0.12345', 'aaaa0.1'), ] for fmt, d, result in test_values: self.assertEqual(format(Decimal(d), fmt), result) + def test_n_format(self): + try: + from locale import CHAR_MAX + except ImportError: + return + + # Set up some localeconv-like dictionaries + en_US = { + 'decimal_point' : '.', + 'grouping' : [3, 3, 0], + 'thousands_sep': ',' + } + + fr_FR = { + 'decimal_point' : ',', + 'grouping' : [CHAR_MAX], + 'thousands_sep' : '' + } + + ru_RU = { + 'decimal_point' : ',', + 'grouping' : [3, 3, 0], + 'thousands_sep' : ' ' + } + + crazy = { + 'decimal_point' : '&', + 'grouping' : [1, 4, 2, CHAR_MAX], + 'thousands_sep' : '-' + } + + + def get_fmt(x, locale, fmt='n'): + return Decimal.__format__(Decimal(x), fmt, _localeconv=locale) + + self.assertEqual(get_fmt(Decimal('12.7'), en_US), '12.7') + self.assertEqual(get_fmt(Decimal('12.7'), fr_FR), '12,7') + self.assertEqual(get_fmt(Decimal('12.7'), ru_RU), '12,7') + self.assertEqual(get_fmt(Decimal('12.7'), crazy), '1-2&7') + + self.assertEqual(get_fmt(123456789, en_US), '123,456,789') + self.assertEqual(get_fmt(123456789, fr_FR), '123456789') + self.assertEqual(get_fmt(123456789, ru_RU), '123 456 789') + self.assertEqual(get_fmt(1234567890123, crazy), '123456-78-9012-3') + + self.assertEqual(get_fmt(123456789, en_US, '.6n'), '1.23457e+8') + self.assertEqual(get_fmt(123456789, fr_FR, '.6n'), '1,23457e+8') + self.assertEqual(get_fmt(123456789, ru_RU, '.6n'), '1,23457e+8') + self.assertEqual(get_fmt(123456789, crazy, '.6n'), '1&23457e+8') + + # zero padding + self.assertEqual(get_fmt(1234, fr_FR, '03n'), '1234') + self.assertEqual(get_fmt(1234, fr_FR, '04n'), '1234') + self.assertEqual(get_fmt(1234, fr_FR, '05n'), '01234') + self.assertEqual(get_fmt(1234, fr_FR, '06n'), '001234') + + self.assertEqual(get_fmt(12345, en_US, '05n'), '12,345') + self.assertEqual(get_fmt(12345, en_US, '06n'), '12,345') + self.assertEqual(get_fmt(12345, en_US, '07n'), '012,345') + self.assertEqual(get_fmt(12345, en_US, '08n'), '0,012,345') + self.assertEqual(get_fmt(12345, en_US, '09n'), '0,012,345') + self.assertEqual(get_fmt(12345, en_US, '010n'), '00,012,345') + + self.assertEqual(get_fmt(123456, crazy, '06n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '07n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '08n'), '1-2345-6') + self.assertEqual(get_fmt(123456, crazy, '09n'), '01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '010n'), '0-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '011n'), '0-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '012n'), '00-01-2345-6') + self.assertEqual(get_fmt(123456, crazy, '013n'), '000-01-2345-6') + + class DecimalArithmeticOperatorsTest(unittest.TestCase): '''Unit tests for all arithmetic operators, binary and unary.''' @@ -927,12 +1071,12 @@ f = Decimal('2') for x, y in [(n, n), (n, i), (i, n), (n, f), (f, n), (s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)]: - self.assert_(x != y) - self.assert_(not (x == y)) - self.assert_(not (x < y)) - self.assert_(not (x <= y)) - self.assert_(not (x > y)) - self.assert_(not (x >= y)) + self.assertTrue(x != y) + self.assertTrue(not (x == y)) + self.assertTrue(not (x < y)) + self.assertTrue(not (x <= y)) + self.assertTrue(not (x > y)) + self.assertTrue(not (x >= y)) # The following are two functions used to test threading in the next class @@ -1005,18 +1149,18 @@ dc = Decimal('45') #two Decimals - self.failUnless(dc > da) - self.failUnless(dc >= da) - self.failUnless(da < dc) - self.failUnless(da <= dc) + self.assertTrue(dc > da) + self.assertTrue(dc >= da) + self.assertTrue(da < dc) + self.assertTrue(da <= dc) self.assertEqual(da, db) - self.failUnless(da != dc) - self.failUnless(da <= db) - self.failUnless(da >= db) + self.assertTrue(da != dc) + self.assertTrue(da <= db) + self.assertTrue(da >= db) #a Decimal and an int - self.failUnless(dc > 23) - self.failUnless(23 < dc) + self.assertTrue(dc > 23) + self.assertTrue(23 < dc) self.assertEqual(dc, 45) #a Decimal and uncomparable @@ -1077,8 +1221,8 @@ #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) self.assertRaises(TypeError, hash, Decimal('NaN')) - self.assert_(hash(Decimal('Inf'))) - self.assert_(hash(Decimal('-Inf'))) + self.assertTrue(hash(Decimal('Inf'))) + self.assertTrue(hash(Decimal('-Inf'))) # check that the value of the hash doesn't depend on the # current context (issue #1757) @@ -1105,22 +1249,22 @@ l2 = 28 #between Decimals - self.failUnless(min(d1,d2) is d1) - self.failUnless(min(d2,d1) is d1) - self.failUnless(max(d1,d2) is d2) - self.failUnless(max(d2,d1) is d2) + self.assertTrue(min(d1,d2) is d1) + self.assertTrue(min(d2,d1) is d1) + self.assertTrue(max(d1,d2) is d2) + self.assertTrue(max(d2,d1) is d2) #between Decimal and long - self.failUnless(min(d1,l2) is d1) - self.failUnless(min(l2,d1) is d1) - self.failUnless(max(l1,d2) is d2) - self.failUnless(max(d2,l1) is d2) + self.assertTrue(min(d1,l2) is d1) + self.assertTrue(min(l2,d1) is d1) + self.assertTrue(max(l1,d2) is d2) + self.assertTrue(max(d2,l1) is d2) def test_as_nonzero(self): #as false - self.failIf(Decimal(0)) + self.assertFalse(Decimal(0)) #as true - self.failUnless(Decimal('0.372')) + self.assertTrue(Decimal('0.372')) def test_tostring_methods(self): #Test str and repr methods. @@ -1390,10 +1534,10 @@ class DecimalPythonAPItests(unittest.TestCase): def test_abc(self): - self.assert_(issubclass(Decimal, numbers.Number)) - self.assert_(not issubclass(Decimal, numbers.Real)) - self.assert_(isinstance(Decimal(0), numbers.Number)) - self.assert_(not isinstance(Decimal(0), numbers.Real)) + self.assertTrue(issubclass(Decimal, numbers.Number)) + self.assertTrue(not issubclass(Decimal, numbers.Real)) + self.assertTrue(isinstance(Decimal(0), numbers.Number)) + self.assertTrue(not isinstance(Decimal(0), numbers.Real)) def test_pickle(self): d = Decimal('-3.141590000') @@ -1411,6 +1555,11 @@ r = d.to_integral(ROUND_DOWN) self.assertEqual(Decimal(int(d)), r) + self.assertRaises(ValueError, int, Decimal('-nan')) + self.assertRaises(ValueError, int, Decimal('snan')) + self.assertRaises(OverflowError, int, Decimal('inf')) + self.assertRaises(OverflowError, int, Decimal('-inf')) + def test_trunc(self): for x in range(-250, 250): s = '%0.2f' % (x / 100.0) @@ -1432,9 +1581,9 @@ '0.1000000000000000055511151231257827021181583404541015625') bigint = 12345678901234567890123456789 self.assertEqual(MyDecimal.from_float(bigint), MyDecimal(bigint)) - self.assert_(MyDecimal.from_float(float('nan')).is_qnan()) - self.assert_(MyDecimal.from_float(float('inf')).is_infinite()) - self.assert_(MyDecimal.from_float(float('-inf')).is_infinite()) + self.assertTrue(MyDecimal.from_float(float('nan')).is_qnan()) + self.assertTrue(MyDecimal.from_float(float('inf')).is_infinite()) + self.assertTrue(MyDecimal.from_float(float('-inf')).is_infinite()) self.assertEqual(str(MyDecimal.from_float(float('nan'))), str(Decimal('NaN'))) self.assertEqual(str(MyDecimal.from_float(float('inf'))), @@ -1481,8 +1630,8 @@ self.assertEqual(v1, v2) def test_equality_with_other_types(self): - self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}]) - self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}]) + self.assertTrue(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}]) + self.assertTrue(Decimal(10) not in ['a', 1.0, (1,2), {}]) def test_copy(self): # All copies should be deep @@ -1502,9 +1651,9 @@ with localcontext() as enter_ctx: set_ctx = getcontext() final_ctx = getcontext() - self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') - self.assert_(orig_ctx is not set_ctx, 'did not copy the context') - self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly') + self.assertTrue(orig_ctx is not set_ctx, 'did not copy the context') + self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context') def test_localcontextarg(self): # Use a copy of the supplied context in the block @@ -1513,10 +1662,10 @@ with localcontext(new_ctx) as enter_ctx: set_ctx = getcontext() final_ctx = getcontext() - self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') - self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context') - self.assert_(new_ctx is not set_ctx, 'did not copy the context') - self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly') + self.assertTrue(set_ctx.prec == new_ctx.prec, 'did not set correct context') + self.assertTrue(new_ctx is not set_ctx, 'did not copy the context') + self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context') class ContextFlags(unittest.TestCase): def test_flags_irrelevant(self): From python-checkins at python.org Tue Oct 20 13:33:42 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 11:33:42 -0000 Subject: [Python-checkins] r75559 - in sandbox/trunk/decimal/decimal_in_c: deccoeff.c decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 20 13:33:41 2009 New Revision: 75559 Log: Remove _Decimal type from deccoeff extension Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c sandbox/trunk/decimal/decimal_in_c/decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Tue Oct 20 13:33:41 2009 @@ -1,17 +1,12 @@ /* - * 'deccoeff' is a Python extension module that exports two classes: - * _Decimal and Deccoeff. - * - * deccoeff._Decimal is a skeletal base class for the decimal.Decimal class. - * As time goes on, the aim is to move more and more code from the Python - * decimal.py file to the _Decimal class, and eventually rename _Decimal - * to Decimal. + * 'deccoeff' is a Python extension module that exports two a single class, + * 'Deccoeff'. * * deccoeff.Deccoeff is a class implementing arbitrary-precision unsigned * integer arithmetic in a decimal base. In addition to the usual arithmetic * operations, Deccoeff instances support slicing and element access, for * retrieving individual digits or sequences of digits. As the name suggests, - * Deccoeff instances are intended to be used as the coefficients for _Decimal + * Deccoeff instances are intended to be used as the coefficients for Decimal * instances. * * Author: Mark Dickinson (dickinsm at gmail.com). @@ -897,46 +892,6 @@ return false; } -/* - variant of limbs_from_string that accepts a string where all but one of the - characters is a decimal digit, and ignores the specified character. - (Typically, the character to be ignored is a decimal point.) - - On entry, s is a pointer to a character array of length s_len + 1, 0 <= - int_len <= s_len, s[0] through s[int_len-1] and s[int_len+1] through - s[s_len] contain decimal digits. The result is then identical to - limbs_from_string applied to the concatenation of s[:int_len] and - s[int_len+1:]. No checking is performed, and there is no return value. - - This function is used when parsing _Decimal instances. - */ - -static void -limbs_from_pointed_unicode(limb_t *a, const Py_UNICODE *s, Py_ssize_t s_len, - Py_ssize_t int_len) -{ - Py_ssize_t i, k, digits_in_limb; - limb_t acc; - Py_UNICODE c; - -#define GET_DIGIT(i) ((i) < int_len ? s[(i)] : s[(i)+1]) - - k = (s_len+LIMB_DIGITS-1) / LIMB_DIGITS; - digits_in_limb = (s_len+LIMB_DIGITS-1) % LIMB_DIGITS + 1; - acc = LIMB_ZERO; - for (i = 0; i < s_len; i++) { - c = GET_DIGIT(i); - limb_lshift(&acc, acc, 1, wdigit_to_limb(c)); - digits_in_limb--; - if (digits_in_limb == 0) { - digits_in_limb = LIMB_DIGITS; - a[--k] = acc; - acc = LIMB_ZERO; - } - } - assert(digits_in_limb == LIMB_DIGITS); -} - /* Base conversion, from base PyLong_BASE to base LIMB_BASE. Convert an array of digits for a Python long to an array of limbs @@ -1371,33 +1326,6 @@ return deccoeff_normalize(z); } -/* Variant of the above that converts an array of unicode digits containing a - decimal point at position int_len (but no sign). The decimal point is - simply ignored. This is used to parse the coefficient of a Decimal - instance. */ - -static deccoeff * -_deccoeff_from_pointed_unicode_and_size(const Py_UNICODE *s, Py_ssize_t s_len, - Py_ssize_t int_len) { - Py_ssize_t z_size; - deccoeff *z; - - if (s_len > MAX_DIGITS) { - PyErr_SetString(PyExc_OverflowError, - "too many digits"); - return NULL; - } - - z_size = (s_len + LIMB_DIGITS - 1) / LIMB_DIGITS; - z = _deccoeff_new(z_size); - if (z == NULL) - return NULL; - - limbs_from_pointed_unicode(z->ob_limbs, s, s_len, int_len); - return deccoeff_normalize(z); -} - - /*********************************** * Deccoeff <-> PyLong conversions * ***********************************/ @@ -2437,705 +2365,6 @@ }; -/***************** - * _Decimal type * - *****************/ - -/* class name */ -#define DECIMAL_NAME "_Decimal" - -/* A finite decimal object needs a sign, a coefficient and an exponent. An - infinity has a sign and nothing more; the coefficient and exponent are - ignored. A (quiet or signalling) nan has a sign, and may carry additional - information (the payload) in the coefficient. The exponent is not used. */ - -#define DEC_FLAGS_NEG (1<<0) -#define DEC_FLAGS_NONZERO (1<<1) /* currently unused; may want this later */ -#define DEC_FLAGS_SPECIAL (1<<2) -#define DEC_FLAGS_INF (1<<3) -#define DEC_FLAGS_NAN (1<<4) -#define DEC_FLAGS_SNAN (1<<5) -#define DEC_FLAGS_QNAN (1<<6) - -#define FINITE_FLAGS 0 -#define INF_FLAGS (DEC_FLAGS_SPECIAL | DEC_FLAGS_INF) -#define QNAN_FLAGS (DEC_FLAGS_SPECIAL | DEC_FLAGS_NAN | DEC_FLAGS_QNAN) -#define SNAN_FLAGS (DEC_FLAGS_SPECIAL | DEC_FLAGS_NAN | DEC_FLAGS_SNAN) - -/* note that FINITE_FLAGS < INF_FLAGS < SNAN_FLAGS < QNAN_FLAGS, - corresponding to the standard total ordering of Decimals */ - -typedef int dec_flag_t; -typedef Py_ssize_t exp_t; - -typedef struct { - PyObject_HEAD - deccoeff *dec_coeff; /* coefficient, or NaN payload; NULL for infinity */ - PyLongObject *dec_exp; /* exponent: NULL for an infinity or NaN */ - dec_flag_t dec_flags; /* flags describing sign and number class */ -} _Decimal; - -static PyTypeObject deccoeff__DecimalType; - -/* create new _Decimal (or instance of a subclass of _Decimal); no - validation or conversion---just allocate memory and fill the slots */ - -static _Decimal * -__Decimal_new(PyTypeObject *type, dec_flag_t flags, deccoeff *coeff, - PyLongObject *exp) -{ - _Decimal *self; - - /* sanity checks */ - assert( - ((flags | 1) == (FINITE_FLAGS | 1)) || /* finite (poss. zero) */ - ((flags | 1) == (INF_FLAGS | 1)) || /* infinity */ - ((flags | 1) == (QNAN_FLAGS | 1)) || /* quiet nan */ - ((flags | 1) == (SNAN_FLAGS | 1))); /* signaling nan */ - - /* incref coefficient and exponent, but only if they're non-NULL */ - if (flags & DEC_FLAGS_INF) - assert(coeff == NULL); - else { - assert(coeff != NULL); - Py_INCREF(coeff); - } - if (flags & DEC_FLAGS_SPECIAL) - assert(exp == NULL); - else { - assert(exp != NULL); - Py_INCREF(exp); - } - - self = (_Decimal *)type->tp_alloc(type, 0); - if (self == NULL) - return NULL; - self->dec_flags = flags; - self->dec_coeff = coeff; - self->dec_exp = exp; - return self; -} - -/* deallocate _Decimal instance */ - -static void -_Decimal_dealloc(PyObject *self) -{ - _Decimal *dec; - dec = (_Decimal *)self; - /* coefficient should be present iff decimal instance is not infinite */ - if (dec->dec_flags & DEC_FLAGS_INF) - assert(dec->dec_coeff == NULL); - else { - assert(dec->dec_coeff != NULL); - Py_DECREF(dec->dec_coeff); - } - /* exponent is present only for finite numbers */ - if (dec->dec_flags & DEC_FLAGS_SPECIAL) - assert(dec->dec_exp == NULL); - else { - assert(dec->dec_exp != NULL); - Py_DECREF(dec->dec_exp); - } - self->ob_type->tp_free(self); -} - -/* Macros to create finite, infinite, qnan, and snan _Decimal instances */ - -#define FINITE_DECIMAL(type, sign, coeff, exp) \ - (__Decimal_new(type, sign, coeff, exp)) -#define INF_DECIMAL(type, sign) \ - (__Decimal_new(type, sign | INF_FLAGS, NULL, NULL)) -#define QNAN_DECIMAL(type, sign, payload) \ - (__Decimal_new(type, sign | QNAN_FLAGS, payload, NULL)) -#define SNAN_DECIMAL(type, sign, payload) \ - (__Decimal_new(type, sign | SNAN_FLAGS, payload, NULL)) - -/* create a new finite _Decimal instance */ - -static PyObject * -_Decimal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - /* create a new finite _Decimal instance, given a sequence consisting - of its sign (an integer), coefficient and exponent */ - - PyObject *ocoeff, *oexp; - deccoeff *coeff; - PyLongObject *exp; - int sign; - static char *kwlist[] = {"sign", "coeff", "exp", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO:" DECIMAL_NAME, kwlist, - &sign, &ocoeff, &oexp)) - return NULL; - if (!(sign == 0 || sign == 1)) { - PyErr_SetString(PyExc_ValueError, "sign should be 0 or 1"); - return NULL; - } - if (ocoeff->ob_type != &deccoeff_DeccoeffType) { - PyErr_SetString(PyExc_TypeError, "coeff should have type " CLASS_NAME); - return NULL; - } - coeff = (deccoeff *)ocoeff; - if (oexp->ob_type != &PyLong_Type) { - PyErr_SetString(PyExc_TypeError, "exp should have type int"); - return NULL; - } - exp = (PyLongObject *)oexp; - return (PyObject *)FINITE_DECIMAL(type, sign, coeff, exp); -} - -/* Create a _Decimal instance directly from a string; classmethod */ - -static PyObject * -_Decimal_from_str(PyTypeObject *cls, PyObject *arg) -{ - PyObject *result=NULL; - deccoeff *coeff; - Py_ssize_t ndigits; - Py_UNICODE *coeff_start, *coeff_end, *s_end, *int_end, *exp_start, *s; - int sign = 0, exp_sign = 0; - PyObject *exp, *temp, *frac_digits; - deccoeff *duexp; - - if (!PyUnicode_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "Expected str instance"); - return NULL; - } - s = PyUnicode_AS_UNICODE(arg); - s_end = s + PyUnicode_GET_SIZE(arg); - - /* Stage 1: parse and validate the string, identifying the points - where the coefficients and exponent start and stop */ - - /* optional sign */ - if (*s == '+') - s++; - else if (*s == '-') { - s++; - sign = 1; - } - - switch(*s) { - case 'n': - case 'N': - /* nan */ - s++; - if (*s == 'a' || *s == 'A') - s++; - else - goto parse_error; - if (*s == 'n' || *s == 'N') - s++; - else - goto parse_error; - coeff_start = s; - while ('0' <= *s && *s <= '9') - s++; - if (s != s_end) - goto parse_error; - - coeff = _deccoeff_from_unicode_and_size(coeff_start, s-coeff_start); - if (coeff != NULL) { - result = (PyObject *)QNAN_DECIMAL(cls, sign, coeff); - Py_DECREF(coeff); - } - break; - case 's': - case 'S': - /* snan */ - s++; - if (*s == 'n' || *s == 'N') - s++; - else - goto parse_error; - if (*s == 'a' || *s == 'A') - s++; - else - goto parse_error; - if (*s == 'n' || *s == 'N') - s++; - else - goto parse_error; - coeff_start = s; - while ('0' <= *s && *s <= '9') - s++; - if (s != s_end) - goto parse_error; - - coeff = _deccoeff_from_unicode_and_size(coeff_start, s-coeff_start); - if (coeff != NULL) { - result = (PyObject *)SNAN_DECIMAL(cls, sign, coeff); - Py_DECREF(coeff); - } - break; - case 'i': - case 'I': - /* inf[inity] */ - s++; - if (*s == 'n' || *s == 'N') - s++; - else - goto parse_error; - if (*s == 'f' || *s == 'F') - s++; - else - goto parse_error; - if (*s == 'i' || *s == 'I') { - s++; - if (*s == 'n' || *s == 'N') - s++; - else - goto parse_error; - if (*s == 'i' || *s == 'I') - s++; - else - goto parse_error; - if (*s == 't' || *s == 'T') - s++; - else - goto parse_error; - if (*s == 'y' || *s == 'Y') - s++; - else - goto parse_error; - } - /* end of string */ - if (s != s_end) - goto parse_error; - - result = (PyObject *)INF_DECIMAL(cls, sign); - break; - default: - /* numeric part: at least one digit, with an optional decimal point */ - coeff_start = s; - while ('0' <= *s && *s <= '9') - s++; - int_end = s; - if (*s == '.') { - s++; - while ('0' <= *s && *s <= '9') - s++; - coeff_end = s-1; - } - else - coeff_end= s; - - ndigits = coeff_end - coeff_start; - if (ndigits == 0) - goto parse_error; - - /* [e ] */ - if (*s == 'e' || *s == 'E') { - s++; - if (*s == '+') - s++; - else if (*s == '-') { - s++; - exp_sign = 1; - } - exp_start = s; - if (!('0' <= *s && *s <= '9')) - goto parse_error; - s++; - while ('0' <= *s && *s <= '9') - s++; - } - else - exp_start = s; - - /* end of string */ - if (s != s_end) - goto parse_error; - - /* parse exponent (without sign), returning a deccoeff */ - duexp = _deccoeff_from_unicode_and_size(exp_start, s-exp_start); - if (duexp == NULL) - return NULL; - - /* REF: duexp */ - - /* Later we'll allow negative deccoeffs, and have the exponent - be a deccoeff. Later :) - For now we have to convert this to a Python long */ - exp = (PyObject *)deccoeff_long(duexp); - Py_DECREF(duexp); - if (exp == NULL) - return NULL; - - /* REF: exp */ - - /* adjust exponent: include sign, and adjust by length - of fractional part of input */ - if (exp_sign == 1) { - /* negate exp */ - temp = PyNumber_Negative(exp); - Py_DECREF(exp); - exp = temp; - if (exp == NULL) - return NULL; - } - - /* REF: exp */ - - /* subtract frac_digits */ - frac_digits = PyLong_FromSize_t(coeff_end - int_end); - if (frac_digits == NULL) { - Py_DECREF(exp); - return NULL; - } - - /* REF: exp, frac_digits */ - - temp = PyNumber_Subtract(exp, frac_digits); - Py_DECREF(frac_digits); - Py_DECREF(exp); - exp = temp; - if (exp == NULL) - return NULL; - - /* REF: exp */ - - /* get coefficient */ - coeff = _deccoeff_from_pointed_unicode_and_size(coeff_start, - coeff_end - coeff_start, int_end - coeff_start); - - if (coeff == NULL) { - Py_DECREF(exp); - return NULL; - } - - result = (PyObject *)FINITE_DECIMAL(cls, sign, coeff, - (PyLongObject *)exp); - Py_DECREF(coeff); - Py_DECREF(exp); - } - return result; - - parse_error: - PyErr_SetString(PyExc_ValueError, - "invalid numeric string"); - return NULL; - -} - -/* Create a new finite _Decimal instance; classmethod */ - -static PyObject * -_Decimal_finite(PyTypeObject *cls, PyObject *args) -{ - PyObject *ocoeff, *oexp; - deccoeff *coeff; - PyLongObject *exp; - int sign; - - if (!PyArg_ParseTuple(args, "iOO:" DECIMAL_NAME, &sign, &ocoeff, &oexp)) - return NULL; - if (ocoeff->ob_type != &deccoeff_DeccoeffType) { - PyErr_SetString(PyExc_TypeError, "coeff should have type " CLASS_NAME); - return NULL; - } - coeff = (deccoeff *)ocoeff; - if (oexp->ob_type != &PyLong_Type) { - PyErr_SetString(PyExc_TypeError, "exp should have type int"); - return NULL; - } - exp = (PyLongObject *)oexp; - if (!(sign == 0 || sign == 1)) { - PyErr_SetString(PyExc_ValueError, "sign should be 0 or 1"); - return NULL; - } - return (PyObject *)FINITE_DECIMAL(cls, sign, coeff, exp); -} - -/* Create a qNaN; classmethod */ - -static PyObject * -_Decimal_qNaN(PyTypeObject *cls, PyObject *args) { - PyObject *opayload; - deccoeff *payload; - int sign; - - if (!PyArg_ParseTuple(args, "iO:" DECIMAL_NAME, &sign, &opayload)) - return NULL; - if (opayload->ob_type != &deccoeff_DeccoeffType) { - PyErr_SetString(PyExc_TypeError, - "payload should have type " CLASS_NAME); - return NULL; - } - payload = (deccoeff *)opayload; - if (!(sign == 0 || sign == 1)) { - PyErr_SetString(PyExc_ValueError, "sign should be 0 or 1"); - return NULL; - } - return (PyObject *)QNAN_DECIMAL(cls, sign, payload); -} - -/* Create an sNaN; classmethod */ - -static PyObject * -_Decimal_sNaN(PyTypeObject *cls, PyObject *args) { - PyObject *opayload; - deccoeff *payload; - int sign; - - if (!PyArg_ParseTuple(args, "iO:" DECIMAL_NAME, &sign, &opayload)) - return NULL; - if (opayload->ob_type != &deccoeff_DeccoeffType) { - PyErr_SetString(PyExc_TypeError, - "payload should have type " CLASS_NAME); - return NULL; - } - payload = (deccoeff *)opayload; - if (!(sign == 0 || sign == 1)) { - PyErr_SetString(PyExc_ValueError, "sign should be 0 or 1"); - return NULL; - } - return (PyObject *)SNAN_DECIMAL(cls, sign, payload); -} - -/* Create an infinity; classmethod */ - -static PyObject * -_Decimal_inf(PyTypeObject *cls, PyObject *args) { - int sign; - - if (!PyArg_ParseTuple(args, "i:" DECIMAL_NAME, &sign)) - return NULL; - if (!(sign == 0 || sign == 1)) { - PyErr_SetString(PyExc_ValueError, "sign should be 0 or 1"); - return NULL; - } - return (PyObject *)INF_DECIMAL(cls, sign); -} - -/* Return the sign of any _Decimal instance */ - -static PyObject * -_Decimal_getsign(_Decimal *self, void *closure) -{ - long sign; - sign = (long)(self->dec_flags) & DEC_FLAGS_NEG; - return PyLong_FromLong(sign); -} - -/* Return the coefficient of a finite _Decimal */ - -static PyObject * -_Decimal_getcoeff(_Decimal *self, void *closure) -{ - if (self->dec_flags & DEC_FLAGS_SPECIAL) { - PyErr_SetString(PyExc_ValueError, - "infinity or NaN has no coefficient"); - return NULL; - } - Py_INCREF(self->dec_coeff); - return (PyObject *)self->dec_coeff; -} - -/* Return the payload of a NaN */ - -static PyObject * -_Decimal_getpayload(_Decimal *self, void *closure) -{ - if (self->dec_flags & DEC_FLAGS_NAN) { - Py_INCREF(self->dec_coeff); - return (PyObject *)self->dec_coeff; - } - else { - PyErr_SetString(PyExc_ValueError, - "argument is not a NaN"); - return NULL; - } -} - -/* Return the exponent of a finite _Decimal instance */ - -static PyObject * -_Decimal_getexp(_Decimal *self, void *closure) -{ - if (self->dec_flags & DEC_FLAGS_SPECIAL) { - PyErr_SetString(PyExc_ValueError, - "infinity or NaN has no exponent"); - return NULL; - } - Py_INCREF(self->dec_exp); - return (PyObject *)(self->dec_exp); -} - -/* Return True if the given Decimal is special (an infinity or NaN), - False otherwise. */ - -static PyObject * -_Decimal_getspecial(_Decimal *self, void *closure) -{ - if (self->dec_flags & DEC_FLAGS_SPECIAL) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - - -static PyObject * -_Decimal_is_finite(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_SPECIAL) - Py_RETURN_FALSE; - else - Py_RETURN_TRUE; -} - -static PyObject * -_Decimal_is_infinite(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_INF) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -_Decimal_is_nan(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_NAN) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -_Decimal_is_qnan(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_QNAN) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -_Decimal_is_snan(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_SNAN) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -_Decimal_is_signed(_Decimal *self) -{ - if (self->dec_flags & DEC_FLAGS_NEG) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -_Decimal_is_zero(_Decimal *self) -{ - if ((self->dec_flags & DEC_FLAGS_SPECIAL) || - deccoeff_bool(self->dec_coeff)) - Py_RETURN_FALSE; - else - Py_RETURN_TRUE; -} - -static _Decimal * -_Decimal_copy(_Decimal *self) -{ - return __Decimal_new(&deccoeff__DecimalType, self->dec_flags, - self->dec_coeff, self->dec_exp); -} - -static _Decimal * -_Decimal_copy_negate(_Decimal *self) -{ - return __Decimal_new(&deccoeff__DecimalType, self->dec_flags ^ 1, - self->dec_coeff, self->dec_exp); -} - -static _Decimal * -_Decimal_copy_abs(_Decimal *self) -{ - return __Decimal_new(&deccoeff__DecimalType, self->dec_flags & (~1), - self->dec_coeff, self->dec_exp); -} - -static PyMethodDef _Decimal_methods[] = { - {"_finite", (PyCFunction)_Decimal_finite, METH_VARARGS|METH_CLASS, " "}, - {"_qnan", (PyCFunction)_Decimal_qNaN, METH_VARARGS|METH_CLASS, " "}, - {"_snan", (PyCFunction)_Decimal_sNaN, METH_VARARGS|METH_CLASS, " "}, - {"_inf", (PyCFunction)_Decimal_inf, METH_VARARGS|METH_CLASS, " "}, - {"from_str", (PyCFunction)_Decimal_from_str, METH_O|METH_CLASS, " "}, - {"is_finite", (PyCFunction)_Decimal_is_finite, METH_NOARGS, " "}, - {"is_infinite", (PyCFunction)_Decimal_is_infinite, METH_NOARGS, " "}, - {"is_nan", (PyCFunction)_Decimal_is_nan, METH_NOARGS, " "}, - {"is_qnan", (PyCFunction)_Decimal_is_qnan, METH_NOARGS, " "}, - {"is_snan", (PyCFunction)_Decimal_is_snan, METH_NOARGS, " "}, - {"is_signed", (PyCFunction)_Decimal_is_signed, METH_NOARGS, " "}, - {"is_zero", (PyCFunction)_Decimal_is_zero, METH_NOARGS, " "}, - {"copy", (PyCFunction)_Decimal_copy, METH_NOARGS, " "}, - {"copy_negate", (PyCFunction)_Decimal_copy_negate, METH_NOARGS, " "}, - {"copy_abs", (PyCFunction)_Decimal_copy_abs, METH_NOARGS, " "}, - {NULL, NULL} -}; - -static PyGetSetDef _Decimal_getsetters[] = { - {"_sign", (getter)_Decimal_getsign, NULL, "sign", NULL}, - {"_int", (getter)_Decimal_getcoeff, NULL, - "coefficient (invalid for NaNs and infinites)", NULL}, - {"_exp", (getter)_Decimal_getexp, NULL, - "exponent (invalid for NaNs and infinities)", NULL}, - {"_payload", (getter)_Decimal_getpayload, NULL, - "payload of a NaN (invalid for non-NaNs)", NULL}, - {"_is_special", (getter)_Decimal_getspecial, NULL, - "True for infinities and NaNs, false otherwise", NULL}, - {NULL} -}; - -static PyTypeObject deccoeff__DecimalType = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - MODULE_NAME "." DECIMAL_NAME, /* tp_name */ - sizeof(_Decimal), /* tp_basicsize */ - 0, /* tp_itemsize */ - _Decimal_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "support for Decimal type", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - _Decimal_methods, /* tp_methods */ - 0, /* tp_members */ - _Decimal_getsetters, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - _Decimal_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - static PyMethodDef deccoeff_module_methods[] = { {NULL, NULL} }; @@ -3169,9 +2398,6 @@ if (PyType_Ready(&deccoeff_DeccoeffType) < 0) return NULL; - if (PyType_Ready(&deccoeff__DecimalType) < 0) - return NULL; - m = PyModule_Create(&deccoeff_module); if (m == NULL) return NULL; @@ -3182,11 +2408,6 @@ if (check == -1) return NULL; - Py_INCREF(&deccoeff__DecimalType); - check = PyModule_AddObject(m, DECIMAL_NAME, - (PyObject *) &deccoeff__DecimalType); - if (check == -1) - return NULL; check = PyModule_AddIntMacro(m, LIMB_DIGITS); if (check == -1) return NULL; Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Tue Oct 20 13:33:41 2009 @@ -132,7 +132,7 @@ 'setcontext', 'getcontext', 'localcontext' ] -from deccoeff import Deccoeff, _Decimal +from deccoeff import Deccoeff import copy as _copy import math as _math @@ -216,7 +216,7 @@ """ def handle(self, context, *args): if args: - ans = Decimal._qnan(args[0]._sign, args[0]._payload) + ans = _dec_from_triple(args[0]._sign, args[0]._int, 'n', True) return ans._fix_nan(context) return NaN @@ -549,7 +549,7 @@ # (because Decimals are not interoperable with floats). See the notes in # numbers.py for more detail. -class Decimal(_Decimal): +class Decimal(object): """Floating point class for decimal arithmetic.""" # Generally, the value of the Decimal instance is given by @@ -575,40 +575,67 @@ # From a string # REs insist on real strings, so we can too. if isinstance(value, str): - try: - m = cls.from_str(value.strip()) - except ValueError: + self = object.__new__(cls) + + m = _parser(value.strip()) + if m is None: if context is None: context = getcontext() return context._raise_error(ConversionSyntax, - "Invalid literal for Decimal: %r" % value) - return m + "Invalid literal for Decimal: %r" % value) - # From another decimal - if isinstance(value, _Decimal): - if value._is_special: - if value.is_infinite(): - return cls._inf(value._sign) - elif value.is_qnan(): - return cls._qnan(value._sign, value._payload) - elif value.is_snan(): - return cls._snan(value._sign, value._payload) - else: - assert False, "never get here" + if m.group('sign') == "-": + self._sign = 1 else: - return cls._finite(value._sign, value._int, value._exp) + self._sign = 0 + intpart = m.group('int') + if intpart is not None: + # finite number + fracpart = m.group('frac') or '' + exp = int(m.group('exp') or '0') + self._int = Deccoeff(intpart+fracpart) + self._exp = exp - len(fracpart) + self._is_special = False + else: + diag = m.group('diag') + if diag is not None: + # NaN + self._int = Deccoeff(diag) + if m.group('signal'): + self._exp = 'N' + else: + self._exp = 'n' + else: + # infinity + self._int = Deccoeff(0) + self._exp = 'F' + self._is_special = True + return self # From an integer if isinstance(value, int): + self = object.__new__(cls) if value >= 0: - _sign = 0 + self._sign = 0 else: - _sign = 1 - _int = Deccoeff(abs(value)) - return cls._finite(_sign, _int, 0) + self._sign = 1 + self._exp = 0 + self._int = Deccoeff(abs(value)) + self._is_special = False + return self + + # From another decimal + if isinstance(value, Decimal): + self = object.__new__(cls) + self._exp = value._exp + self._sign = value._sign + self._int = value._int + self._is_special = value._is_special + return self # tuple/list conversion (possibly from as_tuple()) if isinstance(value, (list,tuple)): + self = object.__new__(cls) if len(value) != 3: raise ValueError('Invalid tuple size in creation of Decimal ' 'from list or tuple. The list or tuple ' @@ -618,10 +645,12 @@ raise ValueError("Invalid sign. The first value in the tuple " "should be an integer; either 0 for a " "positive number or 1 for a negative number.") - _sign = value[0] + self._sign = value[0] if value[2] == 'F': # infinity: value[1] is ignored - return cls._inf(_sign) + self._int = Deccoeff(0) + self._exp = value[2] + self._is_special = True else: # process and validate the digits in value[1] digits = [] @@ -632,17 +661,20 @@ raise ValueError("The second value in the tuple must " "be composed of integers in the range " "0 through 9.") - _int = Deccoeff(''.join(digits)) - if value[2] == 'n': - return cls._qnan(_sign, _int) - elif value[2] == 'N': - return cls._snan(_sign, _int) + self._int = Deccoeff(''.join(digits)) + self._exp = value[2] + if value[2] in ('n', 'N'): + # NaN + self._is_special = True elif isinstance(value[2], int): - return cls._finite(_sign, _int, value[2]) + # finite number + self._is_special = False else: raise ValueError("The third value in the tuple must " "be an integer, or one of the " "strings 'F', 'n', 'N'.") + return self + if isinstance(value, float): raise TypeError("Cannot convert float to Decimal. " + @@ -749,13 +781,6 @@ other) return 0 - def __bool__(self): - """Return True if self is nonzero; otherwise return False. - - NaNs and infinities are considered nonzero. - """ - return self._is_special or bool(self._int) - def _cmp(self, other): """Compare the two non-NaN decimal instances self and other. @@ -949,8 +974,8 @@ coeff = (0,) exp = 'F' else: # NaN - if self._payload: - coeff = tuple(int(x) for x in str(self._payload)) + if self._int: + coeff = tuple(int(x) for x in str(self._int)) else: coeff = () if self.is_qnan(): @@ -983,15 +1008,15 @@ if self.is_infinite(): return sign + 'Infinity' elif self.is_qnan(): - if not self._payload: + if not self._int: return sign + 'NaN' else: - return sign + 'NaN' + str(self._payload) + return sign + 'NaN' + str(self._int) else: - if not self._payload: + if not self._int: return sign + 'sNaN' else: - return sign + 'sNaN' + str(self._payload) + return sign + 'sNaN' + str(self._int) # number of digits of self._int to left of decimal point si = str(self._int) @@ -1038,15 +1063,15 @@ if self.is_infinite(): return sign + 'Infinity' elif self.is_qnan(): - if not self._payload: + if not self._int: return sign + 'NaN' else: - return sign + 'NaN' + str(self._payload) + return sign + 'NaN' + str(self._int) else: # self.is_snan() - if not self._payload: + if not self._int: return sign + 'sNaN' else: - return sign + 'sNaN' + str(self._payload) + return sign + 'sNaN' + str(self._int) # deal independently with case of 0 if self._int: @@ -1624,8 +1649,7 @@ def _fix_nan(self, context): """Decapitate the payload of a NaN to fit the context""" assert self.is_nan() - - payload = self._payload + payload = self._int # maximum length of payload is precision if _clamp=0, # precision-1 if _clamp=1. @@ -1633,11 +1657,7 @@ if payload.digit_length() > max_payload_len: # if payload is too long, take *low order* digits payload = payload[:max_payload_len] - if self.is_qnan(): - return Decimal._qnan(self._sign, payload) - else: - return Decimal._snan(self._sign, payload) - + return _dec_from_triple(self._sign, payload, 'n', True) return Decimal(self) def _fix(self, context, rounding=None): @@ -2817,8 +2837,8 @@ return 0 else: #self_type in (2, 3): # nans are ordered by payload - if self._payload != other._payload: - return [1, -1][self._payload < other._payload] + if self._int != other._int: + return [1, -1][self._int < other._int] else: return 0 @@ -2842,15 +2862,18 @@ def _copy(self): """Return a copy of self.""" - return Decimal(_Decimal.copy(self)) + return _dec_from_triple(self._sign, self._int, self._exp, self._is_special) def copy_abs(self): """Returns a copy with the sign set to 0. """ - return Decimal(_Decimal.copy_abs(self)) + return _dec_from_triple(0, self._int, self._exp, self._is_special) def copy_negate(self): """Returns a copy with the sign inverted.""" - return Decimal(_Decimal.copy_negate(self)) + if self._sign: + return _dec_from_triple(0, self._int, self._exp, self._is_special) + else: + return _dec_from_triple(1, self._int, self._exp, self._is_special) def copy_sign(self, other): """Returns self with the sign of other.""" @@ -2930,6 +2953,13 @@ return ans + def __bool__(self): + """Return True if self is nonzero; otherwise return False. + + NaNs and infinities are considered nonzero. + """ + return self._is_special or bool(self._int) + def is_canonical(self): """Return True if self is canonical; otherwise return False. @@ -2938,22 +2968,54 @@ """ return True + def is_finite(self): + """Return True if self is finite; otherwise return False. + + A Decimal instance is considered finite if it is neither + infinite nor a NaN. + """ + return not self._is_special + + def is_infinite(self): + """Return True if self is infinite; otherwise return False.""" + return self._exp == 'F' + + def is_nan(self): + """Return True if self is a qNaN or sNaN; otherwise return False.""" + return self._exp in ('n', 'N') + def is_normal(self, context=None): """Return True if self is a normal number; otherwise return False.""" - if self._is_special or not self: + if self._is_special or not bool(self._int): return False if context is None: context = getcontext() - return context.Emin <= self.adjusted() <= context.Emax + return self.adjusted() >= context.Emin + + def is_qnan(self): + """Return True if self is a quiet NaN; otherwise return False.""" + return self._exp == 'n' + + def is_signed(self): + """Return True if self is negative; otherwise return False.""" + return self._sign == 1 + + def is_snan(self): + """Return True if self is a signaling NaN; otherwise return False.""" + return self._exp == 'N' def is_subnormal(self, context=None): """Return True if self is subnormal; otherwise return False.""" - if self._is_special or not self: + if self._is_special or not bool(self._int): return False if context is None: context = getcontext() return self.adjusted() < context.Emin + def is_zero(self): + """Return True if self is a zero; otherwise return False.""" + return not self._is_special and not self._int + def _ln_exp_bound(self): """Compute a lower bound for the adjusted exponent of self.ln(). In other words, compute r such that self.ln() >= 10**r. Assumes @@ -3610,10 +3672,14 @@ This function is for *internal use only*. """ - assert type(coefficient) is Deccoeff - assert not special - return Decimal._finite(sign, coefficient, exponent) + self = object.__new__(Decimal) + self._sign = sign + self._int = coefficient + self._exp = exponent + self._is_special = special + + return self # Register Decimal as a kind of Number (an abstract base class). # However, do not register it as Real (because Decimals are not @@ -3788,7 +3854,7 @@ "no trailing or leading whitespace is " "permitted.") d = Decimal(num, context=self) - if d.is_nan() and d._payload.digit_length() + self._clamp > self.prec: + if d.is_nan() and d._int.digit_length() + self._clamp > self.prec: return self._raise_error(ConversionSyntax, "diagnostic info too long in NaN") return d._fix(self) @@ -5438,6 +5504,29 @@ # As the flag UNICODE is not enabled here, we're explicitly avoiding any # other meaning for \d than the numbers [0-9]. +import re +_parser = re.compile(r""" # A numeric string consists of: +# \s* + (?P[-+])? # an optional sign, followed by either... + ( + (?=\d|\.\d) # ...a number (with at least one digit) + (?P\d*) # having a (possibly empty) integer part + (\.(?P\d*))? # followed by an optional fractional part + (E(?P[-+]?\d+))? # followed by an optional exponent, or... + | + Inf(inity)? # ...an infinity, or... + | + (?Ps)? # ...an (optionally signaling) + NaN # NaN + (?P\d*) # with (possibly empty) diagnostic info. + ) +# \s* + \Z +""", re.VERBOSE | re.IGNORECASE).match + +_all_zeros = re.compile('0*$').match +_exact_half = re.compile('50*$').match + ##### PEP3101 support functions ############################################## # The functions parse_format_specifier and format_align have little to do # with the Decimal class, and could potentially be reused for other pure @@ -5448,8 +5537,6 @@ # [[fill]align][sign][0][minimumwidth][.precision][type] # -import re - _parse_format_specifier_regex = re.compile(r"""\A (?: (?P.)? From python-checkins at python.org Tue Oct 20 15:21:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:21:05 -0000 Subject: [Python-checkins] r75560 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:21:05 2009 New Revision: 75560 Log: Various minor code cleanups Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Tue Oct 20 15:21:05 2009 @@ -40,27 +40,50 @@ #endif /* + General defines + + #define DECCOEFF_SLOW_BASECASE_MUL if you want to use the usual + long-multiplication algorithm for basecase multiplication; if + DECCOEFF_SLOW_BASECASE_MUL is undefined then a slightly more + complicated algorithm is used which cuts down significantly on the + number of divisions performed. + + #define DECCOEFF_DEBUG to enable complilation of some debugging + code. Currently all this does is provide a function + deccoeff_printf for printing the current internal state of a + Deccoeff instance. +*/ +/* #define DECCOEFF_SLOW_BASECASE_MUL 1 */ +/* #define DECCOEFF_DEBUG 1 */ + +/* Platform-specific defines A Deccoeff instance is stored in base LIMB_BASE = 10**LIMB_DIGITS as an array of limbs (least significant first). The value of LIMB_DIGITS depends on what C types are available. - limb_t is an integer type that can hold any integer in the range [0, - LIMB_BASE); LIMB_BASE itself should also be representable. double_limb_t - can hold any integer in [0, LIMB_BASE*LIMB_BASE). Type digit_limb_t is used - for Deccoeff <-> PyLong conversions and should be able to hold any integer - in [0, LIMB_BASE * PyLong_BASE). -*/ + limb_t is an unsigned integer type that can hold any integer in the range + [0, 2*LIMB_BASE). The '2*' gives us some extra freedom when implementing + limb addition and subtraction; the code could easily be modified to require + only that limb_t contain [0, LIMB_BASE). + + double_limb_t is an unsigned integer type that can hold any integer in [0, + LIMB_BASE*LIMB_BASE). + + digit_limb_t is an unsigned integer type used for Deccoeff <-> PyLong + conversions. It should be able to hold any integer in [0, LIMB_BASE * + PyLong_BASE). + + XXX now that PyLONG_SHIFT could be either 15 or 30, we should check the size + of PyLong_BASE and verify that digit_limb_t is big enough. */ #if (defined(UINT64_MAX) || defined(uint64_t)) && \ (defined(HAVE___UINT128_T)) -/* if a 128-bit unsigned integer type is available, use a 64-bit limb with 18 - digits to a limb. It *is* possible to squeeze 19 decimal digits into a - 128-bit unsigned integer type, but that leaves little room for maneuver. - Using 18 decimal digits instead makes the basic multiplication algorithm - significantly faster, by saving on the number of divisions necessary. */ +/* If a 128-bit unsigned integer type is available, use a 64-bit limb with 18 + digits to a limb. Note that this may well slow arithmetic down, even on a + 64-bit machine. */ typedef uint64_t limb_t; typedef __uint128_t double_limb_t; @@ -138,14 +161,28 @@ abort(); } -/* add with carry: compute a + b + c; put sum in *r and return new carry. */ +/* add with carry: compute a + b + c; put sum in *r and return new carry. + +Note for language lawyers: if we're trying to be strictly +standards-conformant, we have to worry about undefined behaviour arising from +signed overflow. It's possible in theory (but highly unlikely in practice) +for the precisions (in the sense of C99 6.2.6.2, p.6) of int and limb_t to be +identical. In that case, an arithmetic operand of type limb_t is promoted to +int (C99 6.3.1.1) and hence the addition a+b below is an addition of ints, +which could overflow, giving undefined behaviour. + +Here we're okay, because 0 <= a+b+carry <= 2*LIMB_MAX+1, and 2*LIMB_MAX+1 fits +in a limb_t (by assumption), hence also fits in an int in the case that limb_t +gets promoted to int. Another way to fix this is to write '0U + a + b' +instead of 'a + b'; this forces the additions to be additions of unsigned type +(either unsigned int or limb_t). */ static bool limb_adc(limb_t *r, limb_t a, limb_t b, bool c) { limb_t sum; sum = a + b + (c ? LIMB_ONE : LIMB_ZERO); - if (sum >= LIMB_BASE || sum < a) { + if (sum >= LIMB_BASE) { *r = sum - LIMB_BASE; return true; } @@ -161,15 +198,14 @@ static bool limb_sbb(limb_t *r, limb_t a, limb_t b, bool c) { - limb_t diff; - diff = a - b - (c ? LIMB_ONE : LIMB_ZERO); - if (diff > a) { - *r = diff + LIMB_BASE; - return true; + b += c ? LIMB_ONE : LIMB_ZERO; + if (b <= a) { + *r = a - b; + return false; } else { - *r = diff; - return false; + *r = a + LIMB_BASE - b; + return true; } } @@ -184,8 +220,8 @@ return (limb_t)(hilo/LIMB_BASE); } -/* division: divide high*BASE+low by c. Return the quotient and stored - remainder in *rem. Requires that high < c. */ +/* division: divide high*BASE+low by c. Return the quotient and store the + remainder in *rem. Requires high < c (and hence also c != 0). */ static limb_t limb_div(limb_t *rem, limb_t high, limb_t low, limb_t c) { @@ -227,6 +263,8 @@ return (digit)(hilo & PyLong_MASK); } +/* reverse of digit_limb_swap */ + static limb_t limb_digit_swap(digit *a, limb_t c, digit d) { @@ -300,6 +338,7 @@ } /* true if a <= b, else false */ +/* Not currently used anywhere */ static bool limb_le(limb_t a, limb_t b) @@ -384,6 +423,8 @@ return (Py_UNICODE)'0' + (Py_UNICODE)digit_limb_swap(&dummy, 0, b); } +#ifndef DECCOEFF_SLOW_BASECASE_MUL + /********************************** * Faster basecase multiplication * **********************************/ @@ -415,7 +456,7 @@ a_size). */ static void -limbs_fastmultiply_init(limb_t *res, const limb_t *a, Py_ssize_t a_size, +limbs_multiply_init(limb_t *res, const limb_t *a, Py_ssize_t a_size, const limb_t *b, Py_ssize_t b_size) { double_limb_t acc = 0; @@ -449,7 +490,7 @@ still assuming b_size <= MIN(MAX_PARTIALS, a_size) */ static void -limbs_fastmultiply_add(limb_t *res, const limb_t *a, Py_ssize_t a_size, +limbs_multiply_add(limb_t *res, const limb_t *a, Py_ssize_t a_size, const limb_t *b, Py_ssize_t b_size) { double_limb_t acc = 0; @@ -482,7 +523,7 @@ limbs_mul. */ static void -limbs_fastmultiply(limb_t *res, const limb_t *a, Py_ssize_t a_size, +limbs_multiply(limb_t *res, const limb_t *a, Py_ssize_t a_size, const limb_t *b, Py_ssize_t b_size) { /* reduce to case where a_size >= b_size */ @@ -495,24 +536,27 @@ assert(b_size <= a_size); if (b_size < MAX_PARTIALS) - limbs_fastmultiply_init(res, a, a_size, b, b_size); + limbs_multiply_init(res, a, a_size, b, b_size); else { /* break b up into chunks of size <= MAX_PARTIALS, and do a separate multiply for each chunk */ - limbs_fastmultiply_init(res, a, a_size, b, MAX_PARTIALS); + limbs_multiply_init(res, a, a_size, b, MAX_PARTIALS); b_size -= MAX_PARTIALS; b += MAX_PARTIALS; res += MAX_PARTIALS; while (b_size >= MAX_PARTIALS) { - limbs_fastmultiply_add(res, a, a_size, b, MAX_PARTIALS); + limbs_multiply_add(res, a, a_size, b, MAX_PARTIALS); b_size -= MAX_PARTIALS; b += MAX_PARTIALS; res += MAX_PARTIALS; } - limbs_fastmultiply_add(res, a, a_size, b, b_size); + limbs_multiply_add(res, a, a_size, b, b_size); } } +#endif /* DECCOEFF_SLOW_BASECASE_MUL */ + + /********************************* * Arithmetic on arrays of limbs * *********************************/ @@ -650,9 +694,11 @@ return high; } +#ifdef DECCOEFF_SLOW_BASECASE_MUL + /* multiply a by b, getting (a_size + b_size)-limb result res. This is the - usual algorithm, now redundant: we use the faster limbs_fastmultiply - instead. This code left in for testing and debugging purposes. */ + * standard algorithm, and is used only if DECCOEFF_SLOW_BASECASE_MUL is + * defined. */ static void limbs_multiply(limb_t *res, const limb_t *a, Py_ssize_t a_size, @@ -670,6 +716,8 @@ } } +#endif /* DECCOEFF_SLOW_BASECASE_MUL */ + /* divide a_size-limb number a by single nonzero limb x, giving a_size-limb quotient res and returning the (single limb) remainder. If the input high is nonzero, it's treated as digit a_size of a. */ @@ -937,8 +985,29 @@ return b_size; } +#ifdef DECCOEFF_DEBUG + /* print a limb array; debugging aid */ +#if LIMB_DIGITS == 4 +#define PRI_LIMB "%04u" +#elif LIMB_DIGITS == 9 +# ifdef PRIu32 +# define PRI_LIMB ("%09" PRIu32) +# else +# define PRI_LIMB "%09u" +# endif +#elif LIMB_DIGITS == 18 +# ifdef PRIu64 +# define PRI_LIMB ("%018" PRIu64) +# else +# define PRI_LIMB "%018llu" +# endif +#else +# error "unrecognised value for LIMB_DIGITS" +#endif + + static void limbs_printf(const char *name, const limb_t *a, Py_ssize_t a_size) { @@ -948,11 +1017,13 @@ for (i=0; iob_limbs, a->ob_limbs, a_size, b->ob_limbs, b_size); + limbs_multiply(z->ob_limbs, a->ob_limbs, a_size, b->ob_limbs, b_size); /* w = z % c */ w = _deccoeff_remainder(z, c); Py_DECREF(z); From python-checkins at python.org Tue Oct 20 15:33:03 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:33:03 -0000 Subject: [Python-checkins] r75561 - in python/trunk: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Misc/NEWS Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:33:03 2009 New Revision: 75561 Log: Issue #7099: Decimal.is_normal should return True for all nonzero finite non-subnormal values, even those with exponent > Emax. Modified: python/trunk/Lib/decimal.py python/trunk/Lib/test/decimaltestdata/extra.decTest python/trunk/Misc/NEWS Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Tue Oct 20 15:33:03 2009 @@ -2917,7 +2917,7 @@ return False if context is None: context = getcontext() - return context.Emin <= self.adjusted() <= context.Emax + return context.Emin <= self.adjusted() def is_qnan(self): """Return True if self is a quiet NaN; otherwise return False.""" Modified: python/trunk/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/extra.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/extra.decTest Tue Oct 20 15:33:03 2009 @@ -1128,10 +1128,10 @@ bool0933 isnormal -1E+998 -> 1 bool0934 isnormal 1E+999 -> 1 bool0935 isnormal -1E+999 -> 1 -bool0936 isnormal 1E+1000 -> 0 -bool0937 isnormal -1E+1000 -> 0 -bool0938 isnormal 1E+2000 -> 0 -bool0939 isnormal -1E+2000 -> 0 +bool0936 isnormal 1E+1000 -> 1 +bool0937 isnormal -1E+1000 -> 1 +bool0938 isnormal 1E+2000 -> 1 +bool0939 isnormal -1E+2000 -> 1 bool0940 isnormal 9E-2000 -> 0 bool0941 isnormal -9E-2000 -> 0 bool0942 isnormal 9E-1008 -> 0 @@ -1178,10 +1178,10 @@ bool0983 isnormal -9E+998 -> 1 bool0984 isnormal 9E+999 -> 1 bool0985 isnormal -9E+999 -> 1 -bool0986 isnormal 9E+1000 -> 0 -bool0987 isnormal -9E+1000 -> 0 -bool0988 isnormal 9E+2000 -> 0 -bool0989 isnormal -9E+2000 -> 0 +bool0986 isnormal 9E+1000 -> 1 +bool0987 isnormal -9E+1000 -> 1 +bool0988 isnormal 9E+2000 -> 1 +bool0989 isnormal -9E+2000 -> 1 bool0990 isnormal 9.99999999E-2000 -> 0 bool0991 isnormal -9.99999999E-2000 -> 0 bool0992 isnormal 9.99999999E-1008 -> 0 @@ -1228,10 +1228,10 @@ bool1033 isnormal -9.99999999E+998 -> 1 bool1034 isnormal 9.99999999E+999 -> 1 bool1035 isnormal -9.99999999E+999 -> 1 -bool1036 isnormal 9.99999999E+1000 -> 0 -bool1037 isnormal -9.99999999E+1000 -> 0 -bool1038 isnormal 9.99999999E+2000 -> 0 -bool1039 isnormal -9.99999999E+2000 -> 0 +bool1036 isnormal 9.99999999E+1000 -> 1 +bool1037 isnormal -9.99999999E+1000 -> 1 +bool1038 isnormal 9.99999999E+2000 -> 1 +bool1039 isnormal -9.99999999E+2000 -> 1 bool1040 isnormal Infinity -> 0 bool1041 isnormal -Infinity -> 0 bool1042 isnormal NaN -> 0 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Oct 20 15:33:03 2009 @@ -414,6 +414,9 @@ Library ------- +- Issue #7099: Decimal.is_normal now returns True for numbers with exponent + larger than emax. + - Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. From python-checkins at python.org Tue Oct 20 15:38:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:38:04 -0000 Subject: [Python-checkins] r75562 - in python/branches/py3k: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Misc/NEWS Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:38:04 2009 New Revision: 75562 Log: Merged revisions 75561 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75561 | mark.dickinson | 2009-10-20 14:33:03 +0100 (Tue, 20 Oct 2009) | 3 lines Issue #7099: Decimal.is_normal should return True for all nonzero finite non-subnormal values, even those with exponent > Emax. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/decimaltestdata/extra.decTest python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Tue Oct 20 15:38:04 2009 @@ -3000,7 +3000,7 @@ return False if context is None: context = getcontext() - return context.Emin <= self.adjusted() <= context.Emax + return context.Emin <= self.adjusted() def is_qnan(self): """Return True if self is a quiet NaN; otherwise return False.""" Modified: python/branches/py3k/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/extra.decTest Tue Oct 20 15:38:04 2009 @@ -1128,10 +1128,10 @@ bool0933 isnormal -1E+998 -> 1 bool0934 isnormal 1E+999 -> 1 bool0935 isnormal -1E+999 -> 1 -bool0936 isnormal 1E+1000 -> 0 -bool0937 isnormal -1E+1000 -> 0 -bool0938 isnormal 1E+2000 -> 0 -bool0939 isnormal -1E+2000 -> 0 +bool0936 isnormal 1E+1000 -> 1 +bool0937 isnormal -1E+1000 -> 1 +bool0938 isnormal 1E+2000 -> 1 +bool0939 isnormal -1E+2000 -> 1 bool0940 isnormal 9E-2000 -> 0 bool0941 isnormal -9E-2000 -> 0 bool0942 isnormal 9E-1008 -> 0 @@ -1178,10 +1178,10 @@ bool0983 isnormal -9E+998 -> 1 bool0984 isnormal 9E+999 -> 1 bool0985 isnormal -9E+999 -> 1 -bool0986 isnormal 9E+1000 -> 0 -bool0987 isnormal -9E+1000 -> 0 -bool0988 isnormal 9E+2000 -> 0 -bool0989 isnormal -9E+2000 -> 0 +bool0986 isnormal 9E+1000 -> 1 +bool0987 isnormal -9E+1000 -> 1 +bool0988 isnormal 9E+2000 -> 1 +bool0989 isnormal -9E+2000 -> 1 bool0990 isnormal 9.99999999E-2000 -> 0 bool0991 isnormal -9.99999999E-2000 -> 0 bool0992 isnormal 9.99999999E-1008 -> 0 @@ -1228,10 +1228,10 @@ bool1033 isnormal -9.99999999E+998 -> 1 bool1034 isnormal 9.99999999E+999 -> 1 bool1035 isnormal -9.99999999E+999 -> 1 -bool1036 isnormal 9.99999999E+1000 -> 0 -bool1037 isnormal -9.99999999E+1000 -> 0 -bool1038 isnormal 9.99999999E+2000 -> 0 -bool1039 isnormal -9.99999999E+2000 -> 0 +bool1036 isnormal 9.99999999E+1000 -> 1 +bool1037 isnormal -9.99999999E+1000 -> 1 +bool1038 isnormal 9.99999999E+2000 -> 1 +bool1039 isnormal -9.99999999E+2000 -> 1 bool1040 isnormal Infinity -> 0 bool1041 isnormal -Infinity -> 0 bool1042 isnormal NaN -> 0 Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Oct 20 15:38:04 2009 @@ -100,6 +100,9 @@ Library ------- +- Issue #7099: Decimal.is_normal now returns True for numbers with exponent + larger than emax. + - Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows platforms, and assorted locale fixes by Derk Drukker. From python-checkins at python.org Tue Oct 20 15:40:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:40:26 -0000 Subject: [Python-checkins] r75563 - in python/branches/release31-maint: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Misc/NEWS Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:40:25 2009 New Revision: 75563 Log: Merged revisions 75562 via svnmerge from svn+ssh://pythondev at www.python.org/python/branches/py3k ................ r75562 | mark.dickinson | 2009-10-20 14:38:04 +0100 (Tue, 20 Oct 2009) | 10 lines Merged revisions 75561 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75561 | mark.dickinson | 2009-10-20 14:33:03 +0100 (Tue, 20 Oct 2009) | 3 lines Issue #7099: Decimal.is_normal should return True for all nonzero finite non-subnormal values, even those with exponent > Emax. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/decimal.py python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/decimal.py ============================================================================== --- python/branches/release31-maint/Lib/decimal.py (original) +++ python/branches/release31-maint/Lib/decimal.py Tue Oct 20 15:40:25 2009 @@ -3000,7 +3000,7 @@ return False if context is None: context = getcontext() - return context.Emin <= self.adjusted() <= context.Emax + return context.Emin <= self.adjusted() def is_qnan(self): """Return True if self is a quiet NaN; otherwise return False.""" Modified: python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest Tue Oct 20 15:40:25 2009 @@ -1128,10 +1128,10 @@ bool0933 isnormal -1E+998 -> 1 bool0934 isnormal 1E+999 -> 1 bool0935 isnormal -1E+999 -> 1 -bool0936 isnormal 1E+1000 -> 0 -bool0937 isnormal -1E+1000 -> 0 -bool0938 isnormal 1E+2000 -> 0 -bool0939 isnormal -1E+2000 -> 0 +bool0936 isnormal 1E+1000 -> 1 +bool0937 isnormal -1E+1000 -> 1 +bool0938 isnormal 1E+2000 -> 1 +bool0939 isnormal -1E+2000 -> 1 bool0940 isnormal 9E-2000 -> 0 bool0941 isnormal -9E-2000 -> 0 bool0942 isnormal 9E-1008 -> 0 @@ -1178,10 +1178,10 @@ bool0983 isnormal -9E+998 -> 1 bool0984 isnormal 9E+999 -> 1 bool0985 isnormal -9E+999 -> 1 -bool0986 isnormal 9E+1000 -> 0 -bool0987 isnormal -9E+1000 -> 0 -bool0988 isnormal 9E+2000 -> 0 -bool0989 isnormal -9E+2000 -> 0 +bool0986 isnormal 9E+1000 -> 1 +bool0987 isnormal -9E+1000 -> 1 +bool0988 isnormal 9E+2000 -> 1 +bool0989 isnormal -9E+2000 -> 1 bool0990 isnormal 9.99999999E-2000 -> 0 bool0991 isnormal -9.99999999E-2000 -> 0 bool0992 isnormal 9.99999999E-1008 -> 0 @@ -1228,10 +1228,10 @@ bool1033 isnormal -9.99999999E+998 -> 1 bool1034 isnormal 9.99999999E+999 -> 1 bool1035 isnormal -9.99999999E+999 -> 1 -bool1036 isnormal 9.99999999E+1000 -> 0 -bool1037 isnormal -9.99999999E+1000 -> 0 -bool1038 isnormal 9.99999999E+2000 -> 0 -bool1039 isnormal -9.99999999E+2000 -> 0 +bool1036 isnormal 9.99999999E+1000 -> 1 +bool1037 isnormal -9.99999999E+1000 -> 1 +bool1038 isnormal 9.99999999E+2000 -> 1 +bool1039 isnormal -9.99999999E+2000 -> 1 bool1040 isnormal Infinity -> 0 bool1041 isnormal -Infinity -> 0 bool1042 isnormal NaN -> 0 Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Tue Oct 20 15:40:25 2009 @@ -30,6 +30,9 @@ Library ------- +- Issue #7099: Decimal.is_normal now returns True for numbers with exponent + larger than emax. + - Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows platforms, and assorted locale fixes by Derk Drukker. From python-checkins at python.org Tue Oct 20 15:45:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:45:21 -0000 Subject: [Python-checkins] r75564 - sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:45:20 2009 New Revision: 75564 Log: Update extra.decTest to match py3k Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest Tue Oct 20 15:45:20 2009 @@ -1128,10 +1128,10 @@ bool0933 isnormal -1E+998 -> 1 bool0934 isnormal 1E+999 -> 1 bool0935 isnormal -1E+999 -> 1 -bool0936 isnormal 1E+1000 -> 0 -bool0937 isnormal -1E+1000 -> 0 -bool0938 isnormal 1E+2000 -> 0 -bool0939 isnormal -1E+2000 -> 0 +bool0936 isnormal 1E+1000 -> 1 +bool0937 isnormal -1E+1000 -> 1 +bool0938 isnormal 1E+2000 -> 1 +bool0939 isnormal -1E+2000 -> 1 bool0940 isnormal 9E-2000 -> 0 bool0941 isnormal -9E-2000 -> 0 bool0942 isnormal 9E-1008 -> 0 @@ -1178,10 +1178,10 @@ bool0983 isnormal -9E+998 -> 1 bool0984 isnormal 9E+999 -> 1 bool0985 isnormal -9E+999 -> 1 -bool0986 isnormal 9E+1000 -> 0 -bool0987 isnormal -9E+1000 -> 0 -bool0988 isnormal 9E+2000 -> 0 -bool0989 isnormal -9E+2000 -> 0 +bool0986 isnormal 9E+1000 -> 1 +bool0987 isnormal -9E+1000 -> 1 +bool0988 isnormal 9E+2000 -> 1 +bool0989 isnormal -9E+2000 -> 1 bool0990 isnormal 9.99999999E-2000 -> 0 bool0991 isnormal -9.99999999E-2000 -> 0 bool0992 isnormal 9.99999999E-1008 -> 0 @@ -1228,10 +1228,10 @@ bool1033 isnormal -9.99999999E+998 -> 1 bool1034 isnormal 9.99999999E+999 -> 1 bool1035 isnormal -9.99999999E+999 -> 1 -bool1036 isnormal 9.99999999E+1000 -> 0 -bool1037 isnormal -9.99999999E+1000 -> 0 -bool1038 isnormal 9.99999999E+2000 -> 0 -bool1039 isnormal -9.99999999E+2000 -> 0 +bool1036 isnormal 9.99999999E+1000 -> 1 +bool1037 isnormal -9.99999999E+1000 -> 1 +bool1038 isnormal 9.99999999E+2000 -> 1 +bool1039 isnormal -9.99999999E+2000 -> 1 bool1040 isnormal Infinity -> 0 bool1041 isnormal -Infinity -> 0 bool1042 isnormal NaN -> 0 From python-checkins at python.org Tue Oct 20 15:55:46 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 13:55:46 -0000 Subject: [Python-checkins] r75565 - sandbox/trunk/decimal/decimal_in_c/decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 20 15:55:45 2009 New Revision: 75565 Log: Merge logb fix (r75276) from py3k Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Tue Oct 20 15:55:45 2009 @@ -3199,7 +3199,8 @@ # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. - return Decimal(self.adjusted()) + ans = Decimal(self.adjusted()) + return ans._fix(context) def _is_logical(self): if self._is_special: From python-checkins at python.org Tue Oct 20 16:10:28 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 14:10:28 -0000 Subject: [Python-checkins] r75566 - sandbox/trunk/decimal/decimal_in_c/decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 20 16:10:27 2009 New Revision: 75566 Log: merge alignment fix (r74725) from py3k Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Tue Oct 20 16:10:27 2009 @@ -5589,7 +5589,10 @@ fill = '0' align = '=' format_dict['fill'] = fill or ' ' - format_dict['align'] = align or '<' + # PEP 3101 originally specified that the default alignment should + # be left; it was later agreed that right-aligned makes more sense + # for numeric types. See http://bugs.python.org/issue6857. + format_dict['align'] = align or '>' if format_dict['sign'] is None: format_dict['sign'] = '-' From python-checkins at python.org Tue Oct 20 16:16:30 2009 From: python-checkins at python.org (phillip.eby) Date: Tue, 20 Oct 2009 14:16:30 -0000 Subject: [Python-checkins] r75567 - sandbox/branches/setuptools-0.6/ez_setup.py Message-ID: Author: phillip.eby Date: Tue Oct 20 16:16:29 2009 New Revision: 75567 Log: Update MD5's Modified: sandbox/branches/setuptools-0.6/ez_setup.py Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Tue Oct 20 16:16:29 2009 @@ -32,6 +32,10 @@ 'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4', 'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7', 'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5', + 'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de', + 'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b', + 'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2', + 'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', From python-checkins at python.org Tue Oct 20 16:24:23 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 14:24:23 -0000 Subject: [Python-checkins] r75568 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Tue Oct 20 16:24:23 2009 New Revision: 75568 Log: Allow unicode digits in Deccoeff constructor Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Tue Oct 20 16:24:23 2009 @@ -909,17 +909,17 @@ } -/* Convert a character array to an array of limbs. Returns false on success, - true if any of the characters was not a valid digit; in the latter case, - the contents of a are undefined. a should provide ceiling(slen / +/* Convert a character array to an array of limbs. Returns 0 on success, 1 if + any of the characters was not a valid digit; in the latter case, the + contents of a are undefined. a should provide at least ceiling(slen / LIMB_DIGITS) limbs. */ -static bool -limbs_from_unicode(limb_t *a, const Py_UNICODE *s, Py_ssize_t s_len) +static int +limbs_from_string(limb_t *a, const char *s, Py_ssize_t s_len) { Py_ssize_t i, k, digits_in_limb; limb_t acc; - Py_UNICODE c; + char c; k = (s_len+LIMB_DIGITS-1) / LIMB_DIGITS; digits_in_limb = (s_len+LIMB_DIGITS-1) % LIMB_DIGITS + 1; @@ -1374,23 +1374,35 @@ ValueError if the array is invalid. */ static deccoeff * -_deccoeff_from_unicode_and_size(const Py_UNICODE *s, Py_ssize_t s_len) { +_deccoeff_from_unicode_and_size(Py_UNICODE *s, Py_ssize_t s_len) { Py_ssize_t z_size; deccoeff *z; - bool invalid; + int invalid; + char *buffer; + + buffer = (char *)PyMem_MALLOC(s_len+1); + if (buffer == NULL) + return NULL; + + /* resulting buffer should have the same length as the original unicode: + each valid character is encoded as a single byte. */ + invalid = PyUnicode_EncodeDecimal(s, s_len, buffer, NULL); + if (invalid) { + PyMem_FREE(buffer); + return NULL; + } if (s_len > MAX_DIGITS) { PyErr_SetString(PyExc_OverflowError, "too many digits"); return NULL; } - z_size = (s_len + LIMB_DIGITS - 1) / LIMB_DIGITS; z = _deccoeff_new(z_size); if (z == NULL) return NULL; - invalid = limbs_from_unicode(z->ob_limbs, s, s_len); + invalid = limbs_from_string(z->ob_limbs, buffer, s_len); if (invalid) { Py_DECREF(z); PyErr_SetString(PyExc_ValueError, From python-checkins at python.org Tue Oct 20 16:40:36 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 14:40:36 -0000 Subject: [Python-checkins] r75569 - sandbox/trunk/decimal/decimal_in_c/decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 20 16:40:35 2009 New Revision: 75569 Log: Make int(NaN) raise ValueError; optimize int to use Deccoeff shifts Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Tue Oct 20 16:40:35 2009 @@ -1617,18 +1617,17 @@ """Converts self to an int, truncating if necessary.""" if self._is_special: if self.is_nan(): - context = getcontext() - # XXX this makes no sense: why InvalidContext? - return context._raise_error(InvalidContext) + raise ValueError("Cannot convert NaN to integer") elif self.is_infinite(): raise OverflowError("Cannot convert infinity to long") if not self: return 0 s = (-1)**self._sign if self._exp >= 0: - return s*int(str(self._int) or '0')*10**self._exp + return s*int(self._int << self._exp) else: - return s*int(str(self._int)[:self._exp] or '0') + # exponent less than zero; so just shift + return s*int(self._int >> -self._exp) __trunc__ = __int__ From python-checkins at python.org Tue Oct 20 23:29:38 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 21:29:38 -0000 Subject: [Python-checkins] r75570 - in python/trunk: Lib/test/test_threading.py Misc/ACKS Misc/NEWS Modules/main.c Python/pythonrun.c Message-ID: Author: antoine.pitrou Date: Tue Oct 20 23:29:37 2009 New Revision: 75570 Log: Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. Modified: python/trunk/Lib/test/test_threading.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS python/trunk/Modules/main.c python/trunk/Python/pythonrun.c Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Tue Oct 20 23:29:37 2009 @@ -306,6 +306,30 @@ self.assertFalse(rc == 2, "interpreted was blocked") self.assertTrue(rc == 0, "Unexpected error") + def test_join_nondaemon_on_shutdown(self): + # Issue 1722344 + # Raising SystemExit skipped threading._shutdown + import subprocess + p = subprocess.Popen([sys.executable, "-c", """if 1: + import threading + from time import sleep + + def child(): + sleep(1) + # As a non-daemon thread we SHOULD wake up and nothing + # should be torn down yet + print "Woke up, sleep function is:", sleep + + threading.Thread(target=child).start() + raise SystemExit + """], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + self.assertEqual(stdout, "Woke up, sleep function is: \n") + self.assertEqual(stderr, "") + + def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Tue Oct 20 23:29:37 2009 @@ -540,6 +540,7 @@ Tim O'Malley Pascal Oberndoerfer Jeffrey Ollie +Adam Olsen Grant Olson Piet van Oostrum Jason Orendorff Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Oct 20 23:29:37 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which + fixes the problem of some exceptions being thrown at shutdown when the + interpreter is killed. Patch by Adam Olsen. + - Issue #7168: Document PyFloat_AsString and PyFloat_AsReprString, and note that they are unsafe and deprecated. Modified: python/trunk/Modules/main.c ============================================================================== --- python/trunk/Modules/main.c (original) +++ python/trunk/Modules/main.c Tue Oct 20 23:29:37 2009 @@ -222,33 +222,6 @@ } -/* Wait until threading._shutdown completes, provided - the threading module was imported in the first place. - The shutdown routine will wait until all non-daemon - "threading" threads have completed. */ -#include "abstract.h" -static void -WaitForThreadShutdown(void) -{ -#ifdef WITH_THREAD - PyObject *result; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, - "threading"); - if (threading == NULL) { - /* threading not imported */ - PyErr_Clear(); - return; - } - result = PyObject_CallMethod(threading, "_shutdown", ""); - if (result == NULL) - PyErr_WriteUnraisable(threading); - else - Py_DECREF(result); - Py_DECREF(threading); -#endif -} - /* Main program */ int @@ -624,8 +597,6 @@ sts = PyRun_AnyFileFlags(stdin, "", &cf) != 0; } - WaitForThreadShutdown(); - Py_Finalize(); #ifdef RISCOS if (Py_RISCOSWimpFlag) Modified: python/trunk/Python/pythonrun.c ============================================================================== --- python/trunk/Python/pythonrun.c (original) +++ python/trunk/Python/pythonrun.c Tue Oct 20 23:29:37 2009 @@ -17,6 +17,7 @@ #include "ast.h" #include "eval.h" #include "marshal.h" +#include "abstract.h" #ifdef HAVE_SIGNAL_H #include @@ -61,6 +62,7 @@ PyCompilerFlags *); static void err_input(perrdetail *); static void initsigs(void); +static void wait_for_thread_shutdown(void); static void call_sys_exitfunc(void); static void call_ll_exitfuncs(void); extern void _PyUnicode_Init(void); @@ -390,6 +392,8 @@ if (!initialized) return; + wait_for_thread_shutdown(); + /* The interpreter is still entirely intact at this point, and the * exit funcs may be relying on that. In particular, if some thread * or exit func is still waiting to do an import, the import machinery @@ -1666,6 +1670,32 @@ #include "pythread.h" #endif +/* Wait until threading._shutdown completes, provided + the threading module was imported in the first place. + The shutdown routine will wait until all non-daemon + "threading" threads have completed. */ +static void +wait_for_thread_shutdown(void) +{ +#ifdef WITH_THREAD + PyObject *result; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, + "threading"); + if (threading == NULL) { + /* threading not imported */ + PyErr_Clear(); + return; + } + result = PyObject_CallMethod(threading, "_shutdown", ""); + if (result == NULL) + PyErr_WriteUnraisable(threading); + else + Py_DECREF(result); + Py_DECREF(threading); +#endif +} + #define NEXITFUNCS 32 static void (*exitfuncs[NEXITFUNCS])(void); static int nexitfuncs = 0; From python-checkins at python.org Tue Oct 20 23:52:48 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 21:52:48 -0000 Subject: [Python-checkins] r75571 - in python/branches/py3k: Lib/test/test_threading.py Misc/ACKS Misc/NEWS Modules/main.c Python/pythonrun.c Message-ID: Author: antoine.pitrou Date: Tue Oct 20 23:52:47 2009 New Revision: 75571 Log: Merged revisions 75570 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75570 | antoine.pitrou | 2009-10-20 23:29:37 +0200 (mar., 20 oct. 2009) | 6 lines Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_threading.py python/branches/py3k/Misc/ACKS python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/main.c python/branches/py3k/Python/pythonrun.c Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Tue Oct 20 23:52:47 2009 @@ -300,6 +300,28 @@ self.assertFalse(rc == 2, "interpreted was blocked") self.assertTrue(rc == 0, "Unexpected error") + def test_join_nondaemon_on_shutdown(self): + # Issue 1722344 + # Raising SystemExit skipped threading._shutdown + import subprocess + p = subprocess.Popen([sys.executable, "-c", """if 1: + import threading + from time import sleep + + def child(): + sleep(1) + # As a non-daemon thread we SHOULD wake up and nothing + # should be torn down yet + print("Woke up, sleep function is:", sleep) + + threading.Thread(target=child).start() + raise SystemExit + """], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + self.assertEqual(stdout, b"Woke up, sleep function is: \n") + self.assertEqual(stderr, b"") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Tue Oct 20 23:52:47 2009 @@ -544,6 +544,7 @@ Tim O'Malley Pascal Oberndoerfer Jeffrey Ollie +Adam Olsen Grant Olson Piet van Oostrum Jason Orendorff Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Oct 20 23:52:47 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which + fixes the problem of some exceptions being thrown at shutdown when the + interpreter is killed. Patch by Adam Olsen. + - Issue #7147: Remove support for compiling Python without complex number support. Modified: python/branches/py3k/Modules/main.c ============================================================================== --- python/branches/py3k/Modules/main.c (original) +++ python/branches/py3k/Modules/main.c Tue Oct 20 23:52:47 2009 @@ -253,33 +253,6 @@ } -/* Wait until threading._shutdown completes, provided - the threading module was imported in the first place. - The shutdown routine will wait until all non-daemon - "threading" threads have completed. */ -#include "abstract.h" -static void -WaitForThreadShutdown(void) -{ -#ifdef WITH_THREAD - PyObject *result; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, - "threading"); - if (threading == NULL) { - /* threading not imported */ - PyErr_Clear(); - return; - } - result = PyObject_CallMethod(threading, "_shutdown", ""); - if (result == NULL) - PyErr_WriteUnraisable(threading); - else - Py_DECREF(result); - Py_DECREF(threading); -#endif -} - /* Main program */ int @@ -647,8 +620,6 @@ sts = PyRun_AnyFileFlags(stdin, "", &cf) != 0; } - WaitForThreadShutdown(); - Py_Finalize(); #ifdef __INSURE__ Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Tue Oct 20 23:52:47 2009 @@ -18,6 +18,7 @@ #include "eval.h" #include "marshal.h" #include "osdefs.h" +#include "abstract.h" #ifdef HAVE_SIGNAL_H #include @@ -66,6 +67,7 @@ static void err_input(perrdetail *); static void initsigs(void); static void call_py_exitfuncs(void); +static void wait_for_thread_shutdown(void); static void call_ll_exitfuncs(void); extern void _PyUnicode_Init(void); extern void _PyUnicode_Fini(void); @@ -363,6 +365,8 @@ if (!initialized) return; + wait_for_thread_shutdown(); + /* The interpreter is still entirely intact at this point, and the * exit funcs may be relying on that. In particular, if some thread * or exit func is still waiting to do an import, the import machinery @@ -2059,6 +2063,34 @@ PyErr_Clear(); } +/* Wait until threading._shutdown completes, provided + the threading module was imported in the first place. + The shutdown routine will wait until all non-daemon + "threading" threads have completed. */ +static void +wait_for_thread_shutdown(void) +{ +#ifdef WITH_THREAD + PyObject *result; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, + "threading"); + if (threading == NULL) { + /* threading not imported */ + PyErr_Clear(); + return; + } + result = PyObject_CallMethod(threading, "_shutdown", ""); + if (result == NULL) { + PyErr_WriteUnraisable(threading); + } + else { + Py_DECREF(result); + } + Py_DECREF(threading); +#endif +} + #define NEXITFUNCS 32 static void (*exitfuncs[NEXITFUNCS])(void); static int nexitfuncs = 0; From python-checkins at python.org Tue Oct 20 23:55:17 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 20 Oct 2009 21:55:17 -0000 Subject: [Python-checkins] r75572 - python/trunk/Doc/library/io.rst Message-ID: Author: benjamin.peterson Date: Tue Oct 20 23:55:17 2009 New Revision: 75572 Log: clarify buffer arg #7178 Modified: python/trunk/Doc/library/io.rst Modified: python/trunk/Doc/library/io.rst ============================================================================== --- python/trunk/Doc/library/io.rst (original) +++ python/trunk/Doc/library/io.rst Tue Oct 20 23:55:17 2009 @@ -108,8 +108,8 @@ *buffering* is an optional integer used to set the buffering policy. By default full buffering is on. Pass 0 to switch buffering off (only allowed - in binary mode), 1 to set line buffering, and an integer > 1 for full - buffering. + in binary mode), 1 to set line buffering, and an integer > 1 to indicate the + size of the buffer. *encoding* is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform From python-checkins at python.org Tue Oct 20 23:56:19 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 20 Oct 2009 21:56:19 -0000 Subject: [Python-checkins] r75573 - python/branches/py3k/Doc/library/functions.rst Message-ID: Author: benjamin.peterson Date: Tue Oct 20 23:56:16 2009 New Revision: 75573 Log: clarify the buffer arg Modified: python/branches/py3k/Doc/library/functions.rst Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Tue Oct 20 23:56:16 2009 @@ -718,8 +718,8 @@ *buffering* is an optional integer used to set the buffering policy. By default full buffering is on. Pass 0 to switch buffering off (only allowed - in binary mode), 1 to set line buffering, and an integer > 1 for full - buffering. + in binary mode), 1 to set line buffering, and an integer > 1 to indicate the + size of the buffer. *encoding* is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform From python-checkins at python.org Tue Oct 20 23:59:26 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 21:59:26 -0000 Subject: [Python-checkins] r75574 - python/trunk/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Tue Oct 20 23:59:25 2009 New Revision: 75574 Log: Test wouldn't work in debug mode. We probably need a function in test_support to handle this. Modified: python/trunk/Lib/test/test_threading.py Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Tue Oct 20 23:59:25 2009 @@ -327,6 +327,7 @@ stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(stdout, "Woke up, sleep function is: \n") + stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") From python-checkins at python.org Wed Oct 21 00:00:23 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 20 Oct 2009 22:00:23 -0000 Subject: [Python-checkins] r75575 - sandbox/trunk/decimal/decimal_in_c/decimal.py Message-ID: Author: mark.dickinson Date: Wed Oct 21 00:00:22 2009 New Revision: 75575 Log: Update formatting code to match py3k Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Wed Oct 21 00:00:22 2009 @@ -2754,8 +2754,6 @@ assert self._isinteger() return self._int[-self._exp] in even_digits - #return str(self._int)[-1+self._exp] in '02468' - def adjusted(self): """Return the adjusted exponent of self""" if self._is_special: @@ -3572,18 +3570,16 @@ return self # My components are also immutable return self.__class__(str(self)) - # PEP 3101 support. See also _parse_format_specifier and _format_align - def __format__(self, specifier, context=None): + # PEP 3101 support. the _localeconv keyword argument should be + # considered private: it's provided for ease of testing only. + def __format__(self, specifier, context=None, _localeconv=None): """Format a Decimal instance according to the given specifier. The specifier should be a standard format specifier, with the form described in PEP 3101. Formatting types 'e', 'E', 'f', - 'F', 'g', 'G', and '%' are supported. If the formatting type - is omitted it defaults to 'g' or 'G', depending on the value - of context.capitals. - - At this time the 'n' format specifier type (which is supposed - to use the current locale) is not supported. + 'F', 'g', 'G', 'n' and '%' are supported. If the formatting + type is omitted it defaults to 'g' or 'G', depending on the + value of context.capitals. """ # Note: PEP 3101 says that if the type is not present then @@ -3594,76 +3590,71 @@ if context is None: context = getcontext() - spec = _parse_format_specifier(specifier) + spec = _parse_format_specifier(specifier, _localeconv=_localeconv) - # special values don't care about the type or precision... + # special values don't care about the type or precision if self._is_special: - return _format_align(str(self), spec) + sign = _format_sign(self._sign, spec) + body = str(self.copy_abs()) + return _format_align(sign, body, spec) # a type of None defaults to 'g' or 'G', depending on context - # if type is '%', adjust exponent of self accordingly if spec['type'] is None: spec['type'] = ['g', 'G'][context.capitals] - elif spec['type'] == '%': + + # if type is '%', adjust exponent of self accordingly + if spec['type'] == '%': self = _dec_from_triple(self._sign, self._int, self._exp+2) + str_coeff = str(self._int) + # round if necessary, taking rounding mode from the context rounding = context.rounding precision = spec['precision'] if precision is not None: if spec['type'] in 'eE': self = self._round(precision+1, rounding) - elif spec['type'] in 'gG': - if self._int.digit_length() > precision: - self = self._round(precision, rounding) elif spec['type'] in 'fF%': self = self._rescale(-precision, rounding) + elif spec['type'] in 'gG' and len(str_coeff) > precision: + self = self._round(precision, rounding) # special case: zeros with a positive exponent can't be # represented in fixed point; rescale them to 0e0. - elif not self and self._exp > 0 and spec['type'] in 'fF%': + if not self and self._exp > 0 and spec['type'] in 'fF%': self = self._rescale(0, rounding) + str_coeff = str(self._int) + # figure out placement of the decimal point - if self._int: - coeff = str(self._int) - else: - coeff = '0' - leftdigits = self._exp + len(coeff) - if spec['type'] in 'fF%': - dotplace = leftdigits - elif spec['type'] in 'eE': + leftdigits = self._exp + len(str_coeff) + if spec['type'] in 'eE': if not self and precision is not None: dotplace = 1 - precision else: dotplace = 1 + elif spec['type'] in 'fF%': + dotplace = leftdigits elif spec['type'] in 'gG': if self._exp <= 0 and leftdigits > -6: dotplace = leftdigits else: dotplace = 1 - # figure out main part of numeric string... - if dotplace <= 0: - num = '0.' + '0'*(-dotplace) + coeff - elif dotplace >= len(coeff): - # make sure we're not padding a '0' with extra zeros on the right - assert dotplace==len(coeff) or coeff != '0' - num = coeff + '0'*(dotplace-len(coeff)) - else: - num = coeff[:dotplace] + '.' + coeff[dotplace:] - - # ...then the trailing exponent, or trailing '%' - if leftdigits != dotplace or spec['type'] in 'eE': - echar = {'E': 'E', 'e': 'e', 'G': 'E', 'g': 'e'}[spec['type']] - num = num + "{0}{1:+}".format(echar, leftdigits-dotplace) - elif spec['type'] == '%': - num = num + '%' - - # add sign - if self._sign == 1: - num = '-' + num - return _format_align(num, spec) - + # find digits before and after decimal point, and get exponent + if dotplace < 0: + intpart = '0' + fracpart = '0'*(-dotplace) + str_coeff + elif dotplace > len(str_coeff): + intpart = str_coeff + '0'*(dotplace-len(str_coeff)) + fracpart = '' + else: + intpart = str_coeff[:dotplace] or '0' + fracpart = str_coeff[dotplace:] + exp = leftdigits-dotplace + + # done with the decimal-specific stuff; hand over the rest + # of the formatting to the _format_number function + return _format_number(self._sign, intpart, fracpart, exp, spec) def _dec_from_triple(sign, coefficient, exponent, special=False): """Create a decimal instance directly, without any validation, @@ -5535,7 +5526,6 @@ # A format specifier for Decimal looks like: # # [[fill]align][sign][0][minimumwidth][.precision][type] -# _parse_format_specifier_regex = re.compile(r"""\A (?: @@ -5545,14 +5535,23 @@ (?P[-+ ])? (?P0)? (?P(?!0)\d+)? +(?P,)? (?:\.(?P0|(?!0)\d+))? -(?P[eEfFgG%])? +(?P[eEfFgGn%])? \Z """, re.VERBOSE) del re -def _parse_format_specifier(format_spec): +# The locale module is only needed for the 'n' format specifier. The +# rest of the PEP 3101 code functions quite happily without it, so we +# don't care too much if locale isn't present. +try: + import locale as _locale +except ImportError: + pass + +def _parse_format_specifier(format_spec, _localeconv=None): """Parse and validate a format specifier. Turns a standard numeric format specifier into a dict, with the @@ -5562,9 +5561,13 @@ align: alignment type, either '<', '>', '=' or '^' sign: either '+', '-' or ' ' minimumwidth: nonnegative integer giving minimum width + zeropad: boolean, indicating whether to pad with zeros + thousands_sep: string to use as thousands separator, or '' + grouping: grouping for thousands separators, in format + used by localeconv + decimal_point: string to use for decimal point precision: nonnegative integer giving precision, or None type: one of the characters 'eEfFgG%', or None - unicode: either True or False (always True for Python 3.x) """ m = _parse_format_specifier_regex.match(format_spec) @@ -5574,29 +5577,28 @@ # get the dictionary format_dict = m.groupdict() - # defaults for fill and alignment + # zeropad; defaults for fill and alignment. If zero padding + # is requested, the fill and align fields should be absent. fill = format_dict['fill'] align = format_dict['align'] - if format_dict.pop('zeropad') is not None: - # in the face of conflict, refuse the temptation to guess - if fill is not None and fill != '0': + format_dict['zeropad'] = (format_dict['zeropad'] is not None) + if format_dict['zeropad']: + if fill is not None: raise ValueError("Fill character conflicts with '0'" " in format specifier: " + format_spec) - if align is not None and align != '=': + if align is not None: raise ValueError("Alignment conflicts with '0' in " "format specifier: " + format_spec) - fill = '0' - align = '=' format_dict['fill'] = fill or ' ' # PEP 3101 originally specified that the default alignment should # be left; it was later agreed that right-aligned makes more sense # for numeric types. See http://bugs.python.org/issue6857. format_dict['align'] = align or '>' + # default sign handling: '-' for negative, '' for positive if format_dict['sign'] is None: format_dict['sign'] = '-' - # turn minimumwidth and precision entries into integers. # minimumwidth defaults to 0; precision remains None if not given format_dict['minimumwidth'] = int(format_dict['minimumwidth'] or '0') if format_dict['precision'] is not None: @@ -5605,54 +5607,164 @@ # if format type is 'g' or 'G' then a precision of 0 makes little # sense; convert it to 1. Same if format type is unspecified. if format_dict['precision'] == 0: - if format_dict['type'] in 'gG' or format_dict['type'] is None: + if format_dict['type'] is None or format_dict['type'] in 'gG': format_dict['precision'] = 1 + # determine thousands separator, grouping, and decimal separator, and + # add appropriate entries to format_dict + if format_dict['type'] == 'n': + # apart from separators, 'n' behaves just like 'g' + format_dict['type'] = 'g' + if _localeconv is None: + _localeconv = _locale.localeconv() + if format_dict['thousands_sep'] is not None: + raise ValueError("Explicit thousands separator conflicts with " + "'n' type in format specifier: " + format_spec) + format_dict['thousands_sep'] = _localeconv['thousands_sep'] + format_dict['grouping'] = _localeconv['grouping'] + format_dict['decimal_point'] = _localeconv['decimal_point'] + else: + if format_dict['thousands_sep'] is None: + format_dict['thousands_sep'] = '' + format_dict['grouping'] = [3, 0] + format_dict['decimal_point'] = '.' + return format_dict -def _format_align(body, spec_dict): - """Given an unpadded, non-aligned numeric string, add padding and - aligment to conform with the given format specifier dictionary (as - output from parse_format_specifier). - - It's assumed that if body is negative then it starts with '-'. - Any leading sign ('-' or '+') is stripped from the body before - applying the alignment and padding rules, and replaced in the - appropriate position. +def _format_align(sign, body, spec): + """Given an unpadded, non-aligned numeric string 'body' and sign + string 'sign', add padding and aligment conforming to the given + format specifier dictionary 'spec' (as produced by + parse_format_specifier). """ - # figure out the sign; we only examine the first character, so if - # body has leading whitespace the results may be surprising. - if len(body) > 0 and body[0] in '-+': - sign = body[0] - body = body[1:] - else: - sign = '' - - if sign != '-': - if spec_dict['sign'] in ' +': - sign = spec_dict['sign'] - else: - sign = '' - # how much extra space do we have to play with? - minimumwidth = spec_dict['minimumwidth'] - fill = spec_dict['fill'] - padding = fill*(max(minimumwidth - (len(sign+body)), 0)) + minimumwidth = spec['minimumwidth'] + fill = spec['fill'] + padding = fill*(minimumwidth - len(sign) - len(body)) - align = spec_dict['align'] + align = spec['align'] if align == '<': - result = padding + sign + body - elif align == '>': result = sign + body + padding + elif align == '>': + result = padding + sign + body elif align == '=': result = sign + padding + body - else: #align == '^' + elif align == '^': half = len(padding)//2 result = padding[:half] + sign + body + padding[half:] + else: + raise ValueError('Unrecognised alignment field') return result +def _group_lengths(grouping): + """Convert a localeconv-style grouping into a (possibly infinite) + iterable of integers representing group lengths. + + """ + # The result from localeconv()['grouping'], and the input to this + # function, should be a list of integers in one of the + # following three forms: + # + # (1) an empty list, or + # (2) nonempty list of positive integers + [0] + # (3) list of positive integers + [locale.CHAR_MAX], or + + from itertools import chain, repeat + if not grouping: + return [] + elif grouping[-1] == 0 and len(grouping) >= 2: + return chain(grouping[:-1], repeat(grouping[-2])) + elif grouping[-1] == _locale.CHAR_MAX: + return grouping[:-1] + else: + raise ValueError('unrecognised format for grouping') + +def _insert_thousands_sep(digits, spec, min_width=1): + """Insert thousands separators into a digit string. + + spec is a dictionary whose keys should include 'thousands_sep' and + 'grouping'; typically it's the result of parsing the format + specifier using _parse_format_specifier. + + The min_width keyword argument gives the minimum length of the + result, which will be padded on the left with zeros if necessary. + + If necessary, the zero padding adds an extra '0' on the left to + avoid a leading thousands separator. For example, inserting + commas every three digits in '123456', with min_width=8, gives + '0,123,456', even though that has length 9. + + """ + + sep = spec['thousands_sep'] + grouping = spec['grouping'] + + groups = [] + for l in _group_lengths(grouping): + if l <= 0: + raise ValueError("group length should be positive") + # max(..., 1) forces at least 1 digit to the left of a separator + l = min(max(len(digits), min_width, 1), l) + groups.append('0'*(l - len(digits)) + digits[-l:]) + digits = digits[:-l] + min_width -= l + if not digits and min_width <= 0: + break + min_width -= len(sep) + else: + l = max(len(digits), min_width, 1) + groups.append('0'*(l - len(digits)) + digits[-l:]) + return sep.join(reversed(groups)) + +def _format_sign(is_negative, spec): + """Determine sign character.""" + + if is_negative: + return '-' + elif spec['sign'] in ' +': + return spec['sign'] + else: + return '' + +def _format_number(is_negative, intpart, fracpart, exp, spec): + """Format a number, given the following data: + + is_negative: true if the number is negative, else false + intpart: string of digits that must appear before the decimal point + fracpart: string of digits that must come after the point + exp: exponent, as an integer + spec: dictionary resulting from parsing the format specifier + + This function uses the information in spec to: + insert separators (decimal separator and thousands separators) + format the sign + format the exponent + add trailing '%' for the '%' type + zero-pad if necessary + fill and align if necessary + """ + + sign = _format_sign(is_negative, spec) + + if fracpart: + fracpart = spec['decimal_point'] + fracpart + + if exp != 0 or spec['type'] in 'eE': + echar = {'E': 'E', 'e': 'e', 'G': 'E', 'g': 'e'}[spec['type']] + fracpart += "{0}{1:+}".format(echar, exp) + if spec['type'] == '%': + fracpart += '%' + + if spec['zeropad']: + min_width = spec['minimumwidth'] - len(fracpart) - len(sign) + else: + min_width = 0 + intpart = _insert_thousands_sep(intpart, spec, min_width) + + return _format_align(sign, intpart+fracpart, spec) + ##### Useful Constants (internal use only) ################################ # Reusable defaults From python-checkins at python.org Wed Oct 21 00:02:30 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 22:02:30 -0000 Subject: [Python-checkins] r75576 - in python/branches/py3k: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Wed Oct 21 00:02:29 2009 New Revision: 75576 Log: Merged revisions 75574 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75574 | antoine.pitrou | 2009-10-20 23:59:25 +0200 (mar., 20 oct. 2009) | 4 lines Test wouldn't work in debug mode. We probably need a function in test_support to handle this. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_threading.py Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Wed Oct 21 00:02:29 2009 @@ -321,6 +321,7 @@ stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(stdout, b"Woke up, sleep function is: \n") + stderr = re.sub(br"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, b"") def test_enumerate_after_join(self): From python-checkins at python.org Wed Oct 21 00:05:38 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 22:05:38 -0000 Subject: [Python-checkins] r75577 - python/branches/py3k/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Wed Oct 21 00:05:38 2009 New Revision: 75577 Log: Another futile error in the previous commit :-( Modified: python/branches/py3k/Lib/test/test_threading.py Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Wed Oct 21 00:05:38 2009 @@ -321,7 +321,7 @@ stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(stdout, b"Woke up, sleep function is: \n") - stderr = re.sub(br"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() + stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip() self.assertEqual(stderr, b"") def test_enumerate_after_join(self): From python-checkins at python.org Wed Oct 21 00:08:37 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 22:08:37 -0000 Subject: [Python-checkins] r75578 - in python/branches/release31-maint: Lib/test/test_threading.py Misc/ACKS Misc/NEWS Modules/main.c Python/pythonrun.c Message-ID: Author: antoine.pitrou Date: Wed Oct 21 00:08:36 2009 New Revision: 75578 Log: Merged revisions 75571,75576-75577 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75571 | antoine.pitrou | 2009-10-20 23:52:47 +0200 (mar., 20 oct. 2009) | 11 lines Merged revisions 75570 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75570 | antoine.pitrou | 2009-10-20 23:29:37 +0200 (mar., 20 oct. 2009) | 6 lines Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. ........ ................ r75576 | antoine.pitrou | 2009-10-21 00:02:29 +0200 (mer., 21 oct. 2009) | 10 lines Merged revisions 75574 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75574 | antoine.pitrou | 2009-10-20 23:59:25 +0200 (mar., 20 oct. 2009) | 4 lines Test wouldn't work in debug mode. We probably need a function in test_support to handle this. ........ ................ r75577 | antoine.pitrou | 2009-10-21 00:05:38 +0200 (mer., 21 oct. 2009) | 3 lines Another futile error in the previous commit :-( ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_threading.py python/branches/release31-maint/Misc/ACKS python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/main.c python/branches/release31-maint/Python/pythonrun.c Modified: python/branches/release31-maint/Lib/test/test_threading.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_threading.py (original) +++ python/branches/release31-maint/Lib/test/test_threading.py Wed Oct 21 00:08:36 2009 @@ -286,6 +286,29 @@ self.assertFalse(rc == 2, "interpreted was blocked") self.assertTrue(rc == 0, "Unexpected error") + def test_join_nondaemon_on_shutdown(self): + # Issue 1722344 + # Raising SystemExit skipped threading._shutdown + import subprocess + p = subprocess.Popen([sys.executable, "-c", """if 1: + import threading + from time import sleep + + def child(): + sleep(1) + # As a non-daemon thread we SHOULD wake up and nothing + # should be torn down yet + print("Woke up, sleep function is:", sleep) + + threading.Thread(target=child).start() + raise SystemExit + """], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + self.assertEqual(stdout, b"Woke up, sleep function is: \n") + stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip() + self.assertEqual(stderr, b"") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in Modified: python/branches/release31-maint/Misc/ACKS ============================================================================== --- python/branches/release31-maint/Misc/ACKS (original) +++ python/branches/release31-maint/Misc/ACKS Wed Oct 21 00:08:36 2009 @@ -539,6 +539,7 @@ Tim O'Malley Pascal Oberndoerfer Jeffrey Ollie +Adam Olsen Grant Olson Piet van Oostrum Jason Orendorff Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Wed Oct 21 00:08:36 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which + fixes the problem of some exceptions being thrown at shutdown when the + interpreter is killed. Patch by Adam Olsen. + - Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when using byte values greater than 127. Patch by Derk Drukker. Modified: python/branches/release31-maint/Modules/main.c ============================================================================== --- python/branches/release31-maint/Modules/main.c (original) +++ python/branches/release31-maint/Modules/main.c Wed Oct 21 00:08:36 2009 @@ -253,33 +253,6 @@ } -/* Wait until threading._shutdown completes, provided - the threading module was imported in the first place. - The shutdown routine will wait until all non-daemon - "threading" threads have completed. */ -#include "abstract.h" -static void -WaitForThreadShutdown(void) -{ -#ifdef WITH_THREAD - PyObject *result; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, - "threading"); - if (threading == NULL) { - /* threading not imported */ - PyErr_Clear(); - return; - } - result = PyObject_CallMethod(threading, "_shutdown", ""); - if (result == NULL) - PyErr_WriteUnraisable(threading); - else - Py_DECREF(result); - Py_DECREF(threading); -#endif -} - /* Main program */ int @@ -647,8 +620,6 @@ sts = PyRun_AnyFileFlags(stdin, "", &cf) != 0; } - WaitForThreadShutdown(); - Py_Finalize(); #ifdef __INSURE__ Modified: python/branches/release31-maint/Python/pythonrun.c ============================================================================== --- python/branches/release31-maint/Python/pythonrun.c (original) +++ python/branches/release31-maint/Python/pythonrun.c Wed Oct 21 00:08:36 2009 @@ -18,6 +18,7 @@ #include "eval.h" #include "marshal.h" #include "osdefs.h" +#include "abstract.h" #ifdef HAVE_SIGNAL_H #include @@ -66,6 +67,7 @@ static void err_input(perrdetail *); static void initsigs(void); static void call_py_exitfuncs(void); +static void wait_for_thread_shutdown(void); static void call_ll_exitfuncs(void); extern void _PyUnicode_Init(void); extern void _PyUnicode_Fini(void); @@ -363,6 +365,8 @@ if (!initialized) return; + wait_for_thread_shutdown(); + /* The interpreter is still entirely intact at this point, and the * exit funcs may be relying on that. In particular, if some thread * or exit func is still waiting to do an import, the import machinery @@ -2059,6 +2063,34 @@ PyErr_Clear(); } +/* Wait until threading._shutdown completes, provided + the threading module was imported in the first place. + The shutdown routine will wait until all non-daemon + "threading" threads have completed. */ +static void +wait_for_thread_shutdown(void) +{ +#ifdef WITH_THREAD + PyObject *result; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, + "threading"); + if (threading == NULL) { + /* threading not imported */ + PyErr_Clear(); + return; + } + result = PyObject_CallMethod(threading, "_shutdown", ""); + if (result == NULL) { + PyErr_WriteUnraisable(threading); + } + else { + Py_DECREF(result); + } + Py_DECREF(threading); +#endif +} + #define NEXITFUNCS 32 static void (*exitfuncs[NEXITFUNCS])(void); static int nexitfuncs = 0; From rdmurray at bitdance.com Wed Oct 21 00:41:22 2009 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 20 Oct 2009 18:41:22 -0400 (EDT) Subject: [Python-checkins] r75574 - python/trunk/Lib/test/test_threading.py In-Reply-To: <20091020221143.4B3A3164AF1@kimball.webabinitio.net> References: <20091020221143.4B3A3164AF1@kimball.webabinitio.net> Message-ID: On Tue, 20 Oct 2009 at 18:11, antoine.pitrou wrote: > Author: antoine.pitrou > Date: Tue Oct 20 23:59:25 2009 > New Revision: 75574 > > Log: > Test wouldn't work in debug mode. > We probably need a function in test_support to handle this. [...] > + stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() Well, there are at least three places in the codebase that do this now, (here, regrtest and test_subprocess)), so it seems like it is time :) --David From python-checkins at python.org Wed Oct 21 01:04:44 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 20 Oct 2009 23:04:44 -0000 Subject: [Python-checkins] r75579 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Wed Oct 21 01:04:43 2009 New Revision: 75579 Log: Add a possible test, and add the regex test to the default tests Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Wed Oct 21 01:04:43 2009 @@ -81,8 +81,14 @@ # Taken from the `inspect` module pat = re.compile(r'^(\s*def\s)|(.*(? Author: georg.brandl Date: Wed Oct 21 09:15:59 2009 New Revision: 75580 Log: #7170: fix explanation about non-weakrefable builtin types. Modified: python/trunk/Doc/library/weakref.rst Modified: python/trunk/Doc/library/weakref.rst ============================================================================== --- python/trunk/Doc/library/weakref.rst (original) +++ python/trunk/Doc/library/weakref.rst Wed Oct 21 09:15:59 2009 @@ -76,6 +76,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable +Other built-in types such as :class:`tuple` and :class:`long` do not support +weak references even when subclassed (those types implemented as a +:ctype:`PyVarObject`). + Extension types can easily be made to support weak references; see :ref:`weakref-support`. From python-checkins at python.org Wed Oct 21 09:17:48 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 21 Oct 2009 07:17:48 -0000 Subject: [Python-checkins] r75581 - in python/branches/py3k: Doc/library/weakref.rst Message-ID: Author: georg.brandl Date: Wed Oct 21 09:17:48 2009 New Revision: 75581 Log: Merged revisions 75580 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75580 | georg.brandl | 2009-10-21 09:15:59 +0200 (Mi, 21 Okt 2009) | 1 line #7170: fix explanation about non-weakrefable builtin types. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/weakref.rst Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Wed Oct 21 09:17:48 2009 @@ -72,6 +72,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable +Other built-in types such as :class:`tuple` and :class:`int` do not support +weak references even when subclassed (those types implemented as a +:ctype:`PyVarObject`). + Extension types can easily be made to support weak references; see :ref:`weakref-support`. From nnorwitz at gmail.com Wed Oct 21 11:47:43 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 21 Oct 2009 05:47:43 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091021094743.GA8384@python.psfb.org> More important issues: ---------------------- test_urllib2_localnet leaked [0, 0, 282] references, sum=282 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_smtplib leaked [160, -250, 90] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Wed Oct 21 18:03:20 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 21 Oct 2009 16:03:20 -0000 Subject: [Python-checkins] r75582 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Wed Oct 21 18:03:19 2009 New Revision: 75582 Log: Fix typo. Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Wed Oct 21 18:03:19 2009 @@ -1,6 +1,5 @@ /* - * 'deccoeff' is a Python extension module that exports two a single class, - * 'Deccoeff'. + * 'deccoeff' is a Python extension module that exports the 'Deccoeff' class. * * deccoeff.Deccoeff is a class implementing arbitrary-precision unsigned * integer arithmetic in a decimal base. In addition to the usual arithmetic From python-checkins at python.org Wed Oct 21 18:08:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 21 Oct 2009 16:08:15 -0000 Subject: [Python-checkins] r75583 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Wed Oct 21 18:08:14 2009 New Revision: 75583 Log: Fix random hang at benchmark startup under Windows. Patch by Kristj?n. Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Wed Oct 21 18:08:14 2009 @@ -206,13 +206,18 @@ end_event, do_yield=False)) return results + started = False + ready_cond = threading.Condition() start_cond = threading.Condition() ready = [] def run(): - ready.append(None) + with ready_cond: + ready.append(None) + ready_cond.notify() with start_cond: - start_cond.wait() + while not started: + start_cond.wait() results.append(loop(start_time, THROUGHPUT_DURATION, end_event, do_yield=True)) @@ -223,10 +228,12 @@ t.start() # We don't want measurements to include thread startup overhead, # so we arrange for timing to start after all threads are ready. - while len(ready) < nthreads: - time.sleep(0.1) + with ready_cond: + while len(ready) < nthreads: + ready_cond.wait() with start_cond: start_time = time.time() + started = True start_cond.notify(nthreads) for t in threads: t.join() @@ -299,6 +306,7 @@ threads = [] end_event = [] start_cond = threading.Condition() + started = False if nthreads > 0: # Warm up func(*args) @@ -306,11 +314,15 @@ results = [] loop = TimedLoop(func, args) ready = [] + ready_cond = threading.Condition() def run(): - ready.append(None) + with ready_cond: + ready.append(None) + ready_cond.notify() with start_cond: - start_cond.wait() + while not started: + start_cond.wait() loop(start_time, duration * 1.5, end_event, do_yield=False) for i in range(nthreads): @@ -318,8 +330,9 @@ for t in threads: t.start() # Wait for threads to be ready - while len(ready) < nthreads: - time.sleep(0.1) + with ready_cond: + while len(ready) < nthreads: + ready_cond.wait() # Run the client and wait for the first ping(s) to arrive before # unblocking the background threads. @@ -331,6 +344,7 @@ with start_cond: start_time = _time() + started = True start_cond.notify(nthreads) while LAT_END not in s: From python-checkins at python.org Wed Oct 21 19:44:38 2009 From: python-checkins at python.org (raymond.hettinger) Date: Wed, 21 Oct 2009 17:44:38 -0000 Subject: [Python-checkins] r75584 - python/branches/release26-maint/Doc/tutorial/datastructures.rst Message-ID: Author: raymond.hettinger Date: Wed Oct 21 19:44:38 2009 New Revision: 75584 Log: Update advice on how to implement a queue. Modified: python/branches/release26-maint/Doc/tutorial/datastructures.rst Modified: python/branches/release26-maint/Doc/tutorial/datastructures.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/datastructures.rst (original) +++ python/branches/release26-maint/Doc/tutorial/datastructures.rst Wed Oct 21 19:44:38 2009 @@ -138,21 +138,25 @@ .. sectionauthor:: Ka-Ping Yee +It is also possible to use a list as a queue, where the first element added is +the first element retrieved ("first-in, first-out"); however, lists are not +efficient for this purpose. While appends and pops from the end of list are +fast, doing inserts or pops from the beginning of a list is slow (because all +of the other elements have to be shifted by one). -You can also use a list conveniently as a queue, where the first element added -is the first element retrieved ("first-in, first-out"). To add an item to the -back of the queue, use :meth:`append`. To retrieve an item from the front of -the queue, use :meth:`pop` with ``0`` as the index. For example:: +To implement a queue, use :class:`collections.deque` which was designed to +have fast appends and pops from both ends. For example:: - >>> queue = ["Eric", "John", "Michael"] + >>> from collections import deque + >>> queue = deque(["Eric", "John", "Michael"]) >>> queue.append("Terry") # Terry arrives >>> queue.append("Graham") # Graham arrives - >>> queue.pop(0) + >>> queue.popleft() # The first to arrive now leaves 'Eric' - >>> queue.pop(0) + >>> queue.popleft() # The second to arrive now leaves 'John' - >>> queue - ['Michael', 'Terry', 'Graham'] + >>> queue # Remaining queue in order of arrival + deque(['Michael', 'Terry', 'Graham']) .. _tut-functional: From python-checkins at python.org Wed Oct 21 20:36:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 21 Oct 2009 18:36:05 -0000 Subject: [Python-checkins] r75585 - in sandbox/trunk/decimal/decimal_in_c: Makefile README configure configure.ac deccoeff.c deccoeff_config.h.in deccoeffrepr.h Message-ID: Author: mark.dickinson Date: Wed Oct 21 20:36:04 2009 New Revision: 75585 Log: Configuration cleanups: remove need for configure script Added: sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Removed: sandbox/trunk/decimal/decimal_in_c/configure sandbox/trunk/decimal/decimal_in_c/configure.ac sandbox/trunk/decimal/decimal_in_c/deccoeff_config.h.in Modified: sandbox/trunk/decimal/decimal_in_c/Makefile sandbox/trunk/decimal/decimal_in_c/README sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/Makefile ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/Makefile (original) +++ sandbox/trunk/decimal/decimal_in_c/Makefile Wed Oct 21 20:36:04 2009 @@ -8,12 +8,11 @@ -rm -fr build/ -rm deccoeff.o deccoeff.so -rm *.pyc - -rm config.status config.log deccoeff_config.h + -rm config.status config.log -rm -fr autom4te.cache/ -rm telco/telco.out distclean: clean - -rm deccoeff_config.h.in -rm configure test: deccoeff.so Modified: sandbox/trunk/decimal/decimal_in_c/README ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/README (original) +++ sandbox/trunk/decimal/decimal_in_c/README Wed Oct 21 20:36:04 2009 @@ -18,22 +18,12 @@ (1) Edit the top line of the Makefile to point to a Python 3.x executable. -(2) ./configure && make +(2) make (3) make install (4) make test (runs the entire decimal test-suite) -To use a 64-bit limb on 64-bit platforms, you'll probably need to set -CFLAGS or CPPFLAGS when running configure. For example, on my Core 2 -Duo MacBook, with a 64-bit version of Python 3 already installed, I -type: - -CFLAGS='-arch x86_64' ./configure - -This lets the configure script find the __uint128_t type provided by -gcc. - Usage ----- Deleted: sandbox/trunk/decimal/decimal_in_c/configure ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/configure Wed Oct 21 20:36:04 2009 +++ (empty file) @@ -1,4670 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for deccoeff 0.2. -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell autoconf at gnu.org about your system, - echo including any error possibly output before this - echo message -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Identity of this package. -PACKAGE_NAME='deccoeff' -PACKAGE_TARNAME='deccoeff' -PACKAGE_VERSION='0.2' -PACKAGE_STRING='deccoeff 0.2' -PACKAGE_BUGREPORT='' - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -CPPFLAGS -ac_ct_CC -EXEEXT -OBJEXT -CPP -GREP -EGREP -LIBOBJS -LTLIBOBJS' -ac_subst_files='' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=\$ac_optarg ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute directory names. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures deccoeff 0.2 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/deccoeff] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of deccoeff 0.2:";; - esac - cat <<\_ACEOF - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -deccoeff configure 0.2 -generated by GNU Autoconf 2.61 - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by deccoeff $as_me 0.2, which was -generated by GNU Autoconf 2.61. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args '$ac_arg'" - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" -elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" -else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" -fi -shift -for ac_site_file -do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - - - - - - - - - - - - - - - - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_config_headers="$ac_config_headers deccoeff_config.h" - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf at gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf at gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf at gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf at gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -# -# List of possible output files, starting from the most likely. -# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) -# only as a last resort. b.out is created by i960 compilers. -ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' -# -# The IRIX 6 linker writes into existing files which may not be -# executable, retaining their permissions. Remove them first so a -# subsequent execution test works. -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { (ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi - -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } -if test -z "$ac_file"; then - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } -{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6; } - -{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_prog_cc_c89=$ac_arg -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6; } ;; - xno) - { echo "$as_me:$LINENO: result: unsupported" >&5 -echo "${ECHO_T}unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; -esac - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi - -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi - -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Extract the first word of "grep ggrep" to use in msg output -if test -z "$GREP"; then -set dummy grep ggrep; ac_prog_name=$2 -if test "${ac_cv_path_GREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_GREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue - # Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_GREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -GREP="$ac_cv_path_GREP" -if test -z "$GREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_GREP=$GREP -fi - - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -echo "${ECHO_T}$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - # Extract the first word of "egrep" to use in msg output -if test -z "$EGREP"; then -set dummy egrep; ac_prog_name=$2 -if test "${ac_cv_path_EGREP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_path_EGREP_found=false -# Loop through the user's path and test for each of PROGNAME-LIST -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue - # Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - - $ac_path_EGREP_found && break 3 - done -done - -done -IFS=$as_save_IFS - - -fi - -EGREP="$ac_cv_path_EGREP" -if test -z "$EGREP"; then - { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } -fi - -else - ac_cv_path_EGREP=$EGREP -fi - - - fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 -echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" -#endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - -int -main () -{ - - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_header_stdbool_h=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdbool_h=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 -echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } -{ echo "$as_me:$LINENO: checking for _Bool" >&5 -echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } -if test "${ac_cv_type__Bool+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -typedef _Bool ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_type__Bool=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type__Bool=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 -echo "${ECHO_T}$ac_cv_type__Bool" >&6; } -if test $ac_cv_type__Bool = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE__BOOL 1 -_ACEOF - - -fi - -if test $ac_cv_header_stdbool_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_STDBOOL_H 1 -_ACEOF - -fi - - -for ac_header in stdint.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - { echo "$as_me:$LINENO: checking for uint32_t" >&5 -echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint32_t=no - for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - case $ac_type in - uint32_t) ac_cv_c_uint32_t=yes ;; - *) ac_cv_c_uint32_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint32_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint32_t" >&6; } - case $ac_cv_c_uint32_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<\_ACEOF -#define _UINT32_T 1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define uint32_t $ac_cv_c_uint32_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for uint64_t" >&5 -echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint64_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint64_t=no - for ac_type in 'uint64_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (64 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - case $ac_type in - uint64_t) ac_cv_c_uint64_t=yes ;; - *) ac_cv_c_uint64_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint64_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint64_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint64_t" >&6; } - case $ac_cv_c_uint64_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<\_ACEOF -#define _UINT64_T 1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define uint64_t $ac_cv_c_uint64_t -_ACEOF -;; - esac - - - -{ echo "$as_me:$LINENO: checking for __uint128_t" >&5 -echo $ECHO_N "checking for __uint128_t... $ECHO_C" >&6; } -if test "${ac_cv_type___uint128_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -typedef __uint128_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_type___uint128_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type___uint128_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type___uint128_t" >&5 -echo "${ECHO_T}$ac_cv_type___uint128_t" >&6; } -if test $ac_cv_type___uint128_t = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE___UINT128_T 1 -_ACEOF - - -fi - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 - -# Save the log message, to keep $[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by deccoeff $as_me 0.2, which was -generated by GNU Autoconf 2.61. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# Files that config.status was made for. -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration headers: -$config_headers - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -deccoeff config.status 0.2 -configured by $0, generated by GNU Autoconf 2.61, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2006 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - { echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL - export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "deccoeff_config.h") CONFIG_HEADERS="$CONFIG_HEADERS deccoeff_config.h" ;; - - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - - -for ac_tag in :H $CONFIG_HEADERS -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - ac_file_inputs="$ac_file_inputs $ac_f" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - fi - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - - :H) - # - # CONFIG_HEADER - # -_ACEOF - -# Transform confdefs.h into a sed script `conftest.defines', that -# substitutes the proper values into config.h.in to produce config.h. -rm -f conftest.defines conftest.tail -# First, append a space to every undef/define line, to ease matching. -echo 's/$/ /' >conftest.defines -# Then, protect against being on the right side of a sed subst, or in -# an unquoted here document, in config.status. If some macros were -# called several times there might be several #defines for the same -# symbol, which is useless. But do not sort them, since the last -# AC_DEFINE must be honored. -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where -# NAME is the cpp macro being defined, VALUE is the value it is being given. -# PARAMS is the parameter list in the macro definition--in most cases, it's -# just an empty string. -ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' -ac_dB='\\)[ (].*,\\1define\\2' -ac_dC=' ' -ac_dD=' ,' - -uniq confdefs.h | - sed -n ' - t rset - :rset - s/^[ ]*#[ ]*define[ ][ ]*// - t ok - d - :ok - s/[\\&,]/\\&/g - s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p - s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p - ' >>conftest.defines - -# Remove the space that was appended to ease matching. -# Then replace #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -# (The regexp can be short, since the line contains either #define or #undef.) -echo 's/ $// -s,^[ #]*u.*,/* & */,' >>conftest.defines - -# Break up conftest.defines: -ac_max_sed_lines=50 - -# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" -# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" -# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" -# et cetera. -ac_in='$ac_file_inputs' -ac_out='"$tmp/out1"' -ac_nxt='"$tmp/out2"' - -while : -do - # Write a here document: - cat >>$CONFIG_STATUS <<_ACEOF - # First, check the format of the line: - cat >"\$tmp/defines.sed" <<\\CEOF -/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def -/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def -b -:def -_ACEOF - sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS - echo 'CEOF - sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS - ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in - sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail - grep . conftest.tail >/dev/null || break - rm -f conftest.defines - mv conftest.tail conftest.defines -done -rm -f conftest.defines conftest.tail - -echo "ac_result=$ac_in" >>$CONFIG_STATUS -cat >>$CONFIG_STATUS <<\_ACEOF - if test x"$ac_file" != x-; then - echo "/* $configure_input */" >"$tmp/config.h" - cat "$ac_result" >>"$tmp/config.h" - if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f $ac_file - mv "$tmp/config.h" $ac_file - fi - else - echo "/* $configure_input */" - cat "$ac_result" - fi - rm -f "$tmp/out12" - ;; - - - esac - -done # for ac_tag - - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - - Deleted: sandbox/trunk/decimal/decimal_in_c/configure.ac ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/configure.ac Wed Oct 21 20:36:04 2009 +++ (empty file) @@ -1,26 +0,0 @@ -AC_PREREQ(2.61) -AC_INIT(deccoeff, 0.2) - -AC_CONFIG_HEADERS(deccoeff_config.h) - -dnl checks for header files - -AC_HEADER_STDBOOL -AC_CHECK_HEADERS(stdint.h) - -dnl ideally, we'd like to use uint32_t for our Deccoeff limbs, which -dnl means that we also need uint64_t to hold intermediate results when -dnl doing multiplications and divisions. But these types aren't part -dnl of C89, so we need to check for them (and provide fallbacks if -dnl they don't exist). - -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T - -dnl check for 128-bit unsigned integer type; gcc makes it available as -dnl __uint128_t on x86-64. - -AC_CHECK_TYPES([__uint128_t]) - -AC_OUTPUT - Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Wed Oct 21 20:36:04 2009 @@ -13,33 +13,31 @@ */ #include "Python.h" +#include "deccoeffrepr.h" #include "longintrepr.h" -#include "deccoeff_config.h" #include /* for offsetof */ -/* We use the C99 'bool' type for carries, so we need to include stdbool.h if - present, else define substitutes for bool, true and false. We also need to - include stdint.h and inttypes.h for uint32_t and the like. */ +/* We use the C99 'bool' type for carries, so define bool, true and false. */ -#if defined(HAVE_STDINT_H) -#include -#endif -#if defined(HAVE_INTTYPES_H) -#include -#endif -#if defined(HAVE_STDBOOL_H) -# include +#ifdef HAVE_C99_BOOL +# define bool _Bool #else -# ifndef HAVE__BOOL -# define _Bool signed char; -# endif -# define bool _Bool; -# define false 0; -# define true 1; +# define bool signed char; #endif +#define false (bool)0 +#define true (bool)1 /* - General defines + Defines + ------- + + #define LIMB_DIGITS to the number of digits to use per limb. Valid + values are 4, 9 and 18. If LIMB_DIGITS is undefined then it's set + to 9 on 64-bit systems and 4 on 32-bit systems. LIMB_DIGITS = 9 + requires the availability of a 64-bit integer type. LIMB_DIGITS = + 18 requires the availability of a 128-bit integer type. In + addition, for LIMB_DIGITS = 18 you'll need to set PY_UINT128_T to a + suitable 128-bit unsigned integer type, and define HAVE_UINT128_T. #define DECCOEFF_SLOW_BASECASE_MUL if you want to use the usual long-multiplication algorithm for basecase multiplication; if @@ -52,67 +50,10 @@ deccoeff_printf for printing the current internal state of a Deccoeff instance. */ + /* #define DECCOEFF_SLOW_BASECASE_MUL 1 */ /* #define DECCOEFF_DEBUG 1 */ -/* - Platform-specific defines - - A Deccoeff instance is stored in base LIMB_BASE = 10**LIMB_DIGITS as an - array of limbs (least significant first). The value of LIMB_DIGITS - depends on what C types are available. - - limb_t is an unsigned integer type that can hold any integer in the range - [0, 2*LIMB_BASE). The '2*' gives us some extra freedom when implementing - limb addition and subtraction; the code could easily be modified to require - only that limb_t contain [0, LIMB_BASE). - - double_limb_t is an unsigned integer type that can hold any integer in [0, - LIMB_BASE*LIMB_BASE). - - digit_limb_t is an unsigned integer type used for Deccoeff <-> PyLong - conversions. It should be able to hold any integer in [0, LIMB_BASE * - PyLong_BASE). - - XXX now that PyLONG_SHIFT could be either 15 or 30, we should check the size - of PyLong_BASE and verify that digit_limb_t is big enough. */ - -#if (defined(UINT64_MAX) || defined(uint64_t)) && \ - (defined(HAVE___UINT128_T)) - -/* If a 128-bit unsigned integer type is available, use a 64-bit limb with 18 - digits to a limb. Note that this may well slow arithmetic down, even on a - 64-bit machine. */ - -typedef uint64_t limb_t; -typedef __uint128_t double_limb_t; -typedef __uint128_t digit_limb_t; -#define LIMB_DIGITS 18 -#define LIMB_MAX ((limb_t)999999999999999999) /* 10**LIMB_DIGITS - 1 */ - -#elif (defined(UINT32_MAX) || defined(uint32_t)) && \ - (defined(UINT64_MAX) || defined(uint64_t)) - -/* ... else if uint32_t and uint64_t are available, use those, - with 9 digits to a limb ... */ - -typedef uint32_t limb_t; -typedef uint64_t double_limb_t; -typedef uint64_t digit_limb_t; -#define LIMB_DIGITS 9 -#define LIMB_MAX ((limb_t)999999999) /* 10**LIMB_DIGITS - 1 */ - -#else - -/* ... else fall back to short and long, and make LIMB_DIGITS 4. */ - -typedef unsigned short limb_t; -typedef unsigned long double_limb_t; -typedef unsigned long digit_limb_t; -#define LIMB_DIGITS 4 -#define LIMB_MAX ((limb_t)9999) - -#endif /* powers_of_ten contains 10**0 through 10**(LIMB_DIGITS-1). It's filled during module initialization. */ Deleted: sandbox/trunk/decimal/decimal_in_c/deccoeff_config.h.in ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff_config.h.in Wed Oct 21 20:36:04 2009 +++ (empty file) @@ -1,73 +0,0 @@ -/* deccoeff_config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if stdbool.h conforms to C99. */ -#undef HAVE_STDBOOL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if the system has the type `_Bool'. */ -#undef HAVE__BOOL - -/* Define to 1 if the system has the type `__uint128_t'. */ -#undef HAVE___UINT128_T - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define for Solaris 2.5.1 so the uint32_t typedef from , - , or is not used. If the typedef was allowed, the - #define below would cause a syntax error. */ -#undef _UINT32_T - -/* Define for Solaris 2.5.1 so the uint64_t typedef from , - , or is not used. If the typedef was allowed, the - #define below would cause a syntax error. */ -#undef _UINT64_T - -/* Define to the type of an unsigned integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -#undef uint32_t - -/* Define to the type of an unsigned integer type of width exactly 64 bits if - such a type exists and the standard includes do not define it. */ -#undef uint64_t Added: sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h ============================================================================== --- (empty file) +++ sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Wed Oct 21 20:36:04 2009 @@ -0,0 +1,70 @@ +/* Choose a value for LIMB_DIGITS if none has been given. If + integrated with the Python core, this code would belong in + pyport.h. We use 9 digits per limb on 64-bit systems (provided + that uint64_t is available) and 4 digit per limb otherwise. This + matches the default behaviour of Python longs, which use 30 bits + per digit on 64-bit machines and 15 bit per digit otherwise. */ +#ifndef LIMB_DIGITS +# if (defined HAVE_UINT64_T && defined HAVE_UINT32_T && SIZEOF_VOID_P >= 8) +# define LIMB_DIGITS 9 +# else +# define LIMB_DIGITS 4 +# endif +#endif + +/* + Parameters of the Deccoeff representation. + + A Deccoeff instance is stored in base LIMB_BASE = 10**LIMB_DIGITS as an + array of limbs (least significant first). The value of LIMB_DIGITS + depends on what C types are available. + + limb_t is an unsigned integer type that can hold any integer in the range + [0, 2*LIMB_BASE). The '2*' gives us some extra freedom when implementing + limb addition and subtraction; the code could easily be modified to require + only that limb_t contain [0, LIMB_BASE). + + double_limb_t is an unsigned integer type that can hold any integer in [0, + LIMB_BASE*LIMB_BASE). + + digit_limb_t is an unsigned integer type used for Deccoeff <-> PyLong + conversions. It should be able to hold any integer in [0, LIMB_BASE * + PyLong_BASE). +*/ + +/* Currently PyLongObjects have either 15 bits or 30 bits per digit. If + that ever changes, then the typedefs for digit_limb_t may need to + be rethought. */ +#if !(PYLONG_BITS_IN_DIGIT == 15 || PYLONG_BITS_IN_DIGIT == 30) +#error "Expected PYLONG_BITS_IN_DIGIT to be 15 or 30" +#endif + +/* Current valid values for LIMB_DIGITS are 18, 9 and 4. */ +#if LIMB_DIGITS == 18 +# if !(defined HAVE_UINT128_T && defined HAVE_UINT64_T) +# error "18-digit limbs requested, but the necessary types are not available" +# endif +typedef PY_UINT64_T limb_t; +typedef PY_UINT128_T double_limb_t; +typedef PY_UINT128_T digit_limb_t; +#define LIMB_MAX ((limb_t)999999999999999999) /* 10**LIMB_DIGITS - 1 */ +#elif LIMB_DIGITS == 9 +# if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T) +# error "9-digit limbs requested, but the necessary types are not available" +# endif +typedef PY_UINT32_T limb_t; +typedef PY_UINT64_T double_limb_t; +typedef PY_UINT64_T digit_limb_t; +#define LIMB_MAX ((limb_t)999999999) /* 10**LIMB_DIGITS - 1 */ +#elif LIMB_DIGITS == 4 +typedef unsigned short limb_t; +typedef unsigned long double_limb_t; +#if PYLONG_BITS_IN_DIGIT == 15 +typedef unsigned long digit_limb_t; +#elif PYLONG_BIGS_IN_DIGIT = 30 +typedef PY_UINT64_T digit_limb_t; +#endif +#define LIMB_MAX ((limb_t)9999) /* 10**LIMB_DIGITS - 1 */ +#else +#error "LIMB_DIGITS should be 4, 9 or 18" +#endif From python-checkins at python.org Wed Oct 21 22:22:14 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 21 Oct 2009 20:22:14 -0000 Subject: [Python-checkins] r75586 - in python: branches/py3k/Lib/logging/handlers.py branches/py3k/Misc/NEWS trunk/Lib/logging/handlers.py trunk/Misc/NEWS Message-ID: Author: vinay.sajip Date: Wed Oct 21 22:22:14 2009 New Revision: 75586 Log: Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. Modified: python/branches/py3k/Lib/logging/handlers.py python/branches/py3k/Misc/NEWS python/trunk/Lib/logging/handlers.py python/trunk/Misc/NEWS Modified: python/branches/py3k/Lib/logging/handlers.py ============================================================================== --- python/branches/py3k/Lib/logging/handlers.py (original) +++ python/branches/py3k/Lib/logging/handlers.py Wed Oct 21 22:22:14 2009 @@ -779,6 +779,10 @@ self.encodePriority(self.facility, self.mapPriority(record.levelname)), msg) + #Message is a string. Convert to bytes as required by RFC 5424 + msg = msg.encode('utf-8') + if codecs: + msg = codecs.BOM_UTF8 + msg try: if self.unixsocket: try: Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 21 22:22:14 2009 @@ -104,6 +104,8 @@ Library ------- +- Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. + - Issue #7099: Decimal.is_normal now returns True for numbers with exponent larger than emax. Modified: python/trunk/Lib/logging/handlers.py ============================================================================== --- python/trunk/Lib/logging/handlers.py (original) +++ python/trunk/Lib/logging/handlers.py Wed Oct 21 22:22:14 2009 @@ -31,6 +31,11 @@ import codecs except ImportError: codecs = None +try: + unicode + _unicode = True +except NameError: + _unicode = False # # Some constants... @@ -779,6 +784,11 @@ self.encodePriority(self.facility, self.mapPriority(record.levelname)), msg) + # Treat unicode messages as required by RFC 5424 + if _unicode and type(msg) is unicode: + msg = msg.encode('utf-8') + if codecs: + msg = codecs.BOM_UTF8 + msg try: if self.unixsocket: try: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 21 22:22:14 2009 @@ -418,6 +418,8 @@ Library ------- +- Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. + - Issue #7099: Decimal.is_normal now returns True for numbers with exponent larger than emax. From python-checkins at python.org Wed Oct 21 23:49:49 2009 From: python-checkins at python.org (georg.brandl) Date: Wed, 21 Oct 2009 21:49:49 -0000 Subject: [Python-checkins] r75587 - in sandbox/trunk/decimal/decimal_in_c: deccoeff.c deccoeffrepr.h Message-ID: Author: georg.brandl Date: Wed Oct 21 23:49:48 2009 New Revision: 75587 Log: Fixes to make it compile here. Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Wed Oct 21 23:49:48 2009 @@ -962,7 +962,7 @@ printf("]\n"); } -#endif DECCOEFF_DEBUG +#endif /* DECCOEFF_DEBUG */ /**************************** * Karatsuba multiplication * Modified: sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Wed Oct 21 23:49:48 2009 @@ -61,7 +61,7 @@ typedef unsigned long double_limb_t; #if PYLONG_BITS_IN_DIGIT == 15 typedef unsigned long digit_limb_t; -#elif PYLONG_BIGS_IN_DIGIT = 30 +#elif PYLONG_BIGS_IN_DIGIT == 30 typedef PY_UINT64_T digit_limb_t; #endif #define LIMB_MAX ((limb_t)9999) /* 10**LIMB_DIGITS - 1 */ From jimjjewett at gmail.com Thu Oct 22 00:48:49 2009 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 21 Oct 2009 18:48:49 -0400 Subject: [Python-checkins] r75553 - peps/trunk/pep-0391.txt In-Reply-To: <4add70d1.0767f10a.2dfd.ffffa08bSMTPIN_ADDED@mx.google.com> References: <4add70d1.0767f10a.2dfd.ffffa08bSMTPIN_ADDED@mx.google.com> Message-ID: On Tue, Oct 20, 2009 at 4:12 AM, vinay.sajip wrote: > Author: vinay.sajip > Date: Tue Oct 20 10:11:52 2009 > New Revision: 75553 > +The literal string ``'int://handlers.file'`` will be resolved in an > +analogous way to the strings with the ``ext://`` prefix, but looking > +in the configuration itself rather than the import namespace. Is "int" too strongly identified with "integer" rather than "internal"? Is there some concern about a possible URI scheme starting with int: or ext:? > +``'int://handlers.email[subject]'``. ?The latter form only needs to be > +used if the key contains spaces or non-alphanumeric characters. ?If an > +index value consists only of decimal digits, access will be attempted > +using the corresponding integer value, falling back to the string > +value if needed. Are you saying that the key can be handlers.myspace.123 and that handlers.myspace[123] would first look for the 123rd entry in myspace as a sequence, then would look in handlers myspace with 123 as a key, then would look in handlers myspace with "123" as a key? ------------------------- And as long as I looked at the PEP anyhow, I have a few other comments. I would reorder the API list dictConfig first, and then explicitly note that the other two are not needed to use the API; only to customize it. Also, does dictConfig return anything, or does it just store "the" newly constructed DictConfigurator (or replacement) in an internal location? Is it specified whether calls to dictConfig (or even the default class) will be additive, or must they re-send previous information? This may be determined by the optional top-level key incremental, but I'm not certain. I'm also not certain how values like like "zap" and "" (true and false in boolean context but not "is" True or False) are handled. I also wasn't sure I understood the part about ignoring formatters, filters, and handlers. Does this mean that the config must be in a single dict when passed to the logger, so if there are several sources of logging requirements (corporate, department, toolX), then the app must combine them programmatically before calling dictConfig? From python-checkins at python.org Thu Oct 22 01:05:29 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 21 Oct 2009 23:05:29 -0000 Subject: [Python-checkins] r75588 - sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Message-ID: Author: mark.dickinson Date: Thu Oct 22 01:05:28 2009 New Revision: 75588 Log: Fix typo Modified: sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Modified: sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeffrepr.h Thu Oct 22 01:05:28 2009 @@ -61,7 +61,7 @@ typedef unsigned long double_limb_t; #if PYLONG_BITS_IN_DIGIT == 15 typedef unsigned long digit_limb_t; -#elif PYLONG_BIGS_IN_DIGIT == 30 +#elif PYLONG_BITS_IN_DIGIT == 30 typedef PY_UINT64_T digit_limb_t; #endif #define LIMB_MAX ((limb_t)9999) /* 10**LIMB_DIGITS - 1 */ From python-checkins at python.org Thu Oct 22 04:26:48 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 22 Oct 2009 02:26:48 -0000 Subject: [Python-checkins] r75589 - python/trunk/Objects/descrobject.c Message-ID: Author: benjamin.peterson Date: Thu Oct 22 04:26:47 2009 New Revision: 75589 Log: whitespace Modified: python/trunk/Objects/descrobject.c Modified: python/trunk/Objects/descrobject.c ============================================================================== --- python/trunk/Objects/descrobject.c (original) +++ python/trunk/Objects/descrobject.c Thu Oct 22 04:26:47 2009 @@ -1282,7 +1282,7 @@ PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); if (get_doc != NULL) { /* get_doc already INCREF'd by GetAttr */ - if (Py_TYPE(self)==&PyProperty_Type) { + if (Py_TYPE(self) == &PyProperty_Type) { Py_XDECREF(prop->prop_doc); prop->prop_doc = get_doc; } else { From python-checkins at python.org Thu Oct 22 04:36:47 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 22 Oct 2009 02:36:47 -0000 Subject: [Python-checkins] r75590 - python/trunk/Doc/library/weakref.rst Message-ID: Author: benjamin.peterson Date: Thu Oct 22 04:36:47 2009 New Revision: 75590 Log: rewrite to be nice to other implementations Modified: python/trunk/Doc/library/weakref.rst Modified: python/trunk/Doc/library/weakref.rst ============================================================================== --- python/trunk/Doc/library/weakref.rst (original) +++ python/trunk/Doc/library/weakref.rst Thu Oct 22 04:36:47 2009 @@ -77,8 +77,8 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable Other built-in types such as :class:`tuple` and :class:`long` do not support -weak references even when subclassed (those types implemented as a -:ctype:`PyVarObject`). +weak references even when subclassed (This is an implementation detail and may +be different across various Python implementations.). Extension types can easily be made to support weak references; see :ref:`weakref-support`. From python-checkins at python.org Thu Oct 22 04:50:39 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 22 Oct 2009 02:50:39 -0000 Subject: [Python-checkins] r75591 - python/trunk/Objects/descrobject.c Message-ID: Author: benjamin.peterson Date: Thu Oct 22 04:50:38 2009 New Revision: 75591 Log: rewrite for style, clarify, and comments Also, use the hasattr() like scheme of allowing BaseException exceptions through. Modified: python/trunk/Objects/descrobject.c Modified: python/trunk/Objects/descrobject.c ============================================================================== --- python/trunk/Objects/descrobject.c (original) +++ python/trunk/Objects/descrobject.c Thu Oct 22 04:50:38 2009 @@ -1280,26 +1280,29 @@ /* if no docstring given and the getter has one, use that one */ if ((doc == NULL || doc == Py_None) && get != NULL) { PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); - if (get_doc != NULL) { - /* get_doc already INCREF'd by GetAttr */ + if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { Py_XDECREF(prop->prop_doc); prop->prop_doc = get_doc; - } else { - /* Put __doc__ in dict of the subclass instance instead, - otherwise it gets shadowed by class's __doc__. */ - if (PyObject_SetAttrString(self, "__doc__", get_doc) != 0) - { - /* DECREF for props handled by _dealloc */ - Py_DECREF(get_doc); + } + else { + /* If this is a property subclass, put __doc__ + in dict of the subclass instance instead, + otherwise it gets shadowed by __doc__ in the + class's dict. */ + int err = PyObject_SetAttrString(self, "__doc__", get_doc); + Py_DECREF(get_doc); + if (err < 0) return -1; - } - Py_DECREF(get_doc); } prop->getter_doc = 1; - } else { + } + else if (PyErr_ExceptionMatches(PyExc_Exception)) { PyErr_Clear(); } + else { + return -1; + } } return 0; From python-checkins at python.org Thu Oct 22 09:05:48 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 07:05:48 -0000 Subject: [Python-checkins] r75592 - in python/trunk: Doc/library/curses.rst Doc/library/signal.rst Doc/library/weakref.rst Lib/ctypes/wintypes.py Message-ID: Author: georg.brandl Date: Thu Oct 22 09:05:48 2009 New Revision: 75592 Log: Fix punctuation. Modified: python/trunk/Doc/library/curses.rst python/trunk/Doc/library/signal.rst python/trunk/Doc/library/weakref.rst python/trunk/Lib/ctypes/wintypes.py Modified: python/trunk/Doc/library/curses.rst ============================================================================== --- python/trunk/Doc/library/curses.rst (original) +++ python/trunk/Doc/library/curses.rst Thu Oct 22 09:05:48 2009 @@ -1,9 +1,9 @@ - :mod:`curses` --- Terminal handling for character-cell displays =============================================================== .. module:: curses - :synopsis: An interface to the curses library, providing portable terminal handling. + :synopsis: An interface to the curses library, providing portable terminal + handling. .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond Modified: python/trunk/Doc/library/signal.rst ============================================================================== --- python/trunk/Doc/library/signal.rst (original) +++ python/trunk/Doc/library/signal.rst Thu Oct 22 09:05:48 2009 @@ -157,7 +157,7 @@ The old values are returned as a tuple: (delay, interval). - Attempting to pass an invalid interval timer will cause a + Attempting to pass an invalid interval timer will cause an :exc:`ItimerError`. .. versionadded:: 2.6 Modified: python/trunk/Doc/library/weakref.rst ============================================================================== --- python/trunk/Doc/library/weakref.rst (original) +++ python/trunk/Doc/library/weakref.rst Thu Oct 22 09:05:48 2009 @@ -77,8 +77,8 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable Other built-in types such as :class:`tuple` and :class:`long` do not support -weak references even when subclassed (This is an implementation detail and may -be different across various Python implementations.). +weak references even when subclassed (this is an implementation detail and may +be different across various Python implementations). Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/trunk/Lib/ctypes/wintypes.py ============================================================================== --- python/trunk/Lib/ctypes/wintypes.py (original) +++ python/trunk/Lib/ctypes/wintypes.py Thu Oct 22 09:05:48 2009 @@ -179,7 +179,7 @@ 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT', - 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', + 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE'] From python-checkins at python.org Thu Oct 22 09:06:50 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 07:06:50 -0000 Subject: [Python-checkins] r75593 - python/trunk/Lib/ctypes/wintypes.py Message-ID: Author: georg.brandl Date: Thu Oct 22 09:06:49 2009 New Revision: 75593 Log: Revert unintended change. Modified: python/trunk/Lib/ctypes/wintypes.py Modified: python/trunk/Lib/ctypes/wintypes.py ============================================================================== --- python/trunk/Lib/ctypes/wintypes.py (original) +++ python/trunk/Lib/ctypes/wintypes.py Thu Oct 22 09:06:49 2009 @@ -179,7 +179,7 @@ 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT', - 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', + 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE'] From python-checkins at python.org Thu Oct 22 09:56:03 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 07:56:03 -0000 Subject: [Python-checkins] r75594 - python/trunk/Doc/library/curses.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 09:56:02 2009 New Revision: 75594 Log: Fix markup. Modified: python/trunk/Doc/library/curses.rst Modified: python/trunk/Doc/library/curses.rst ============================================================================== --- python/trunk/Doc/library/curses.rst (original) +++ python/trunk/Doc/library/curses.rst Thu Oct 22 09:56:02 2009 @@ -3,7 +3,7 @@ .. module:: curses :synopsis: An interface to the curses library, providing portable terminal - handling. + handling. .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond From python-checkins at python.org Thu Oct 22 09:56:56 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 07:56:56 -0000 Subject: [Python-checkins] r75595 - python/trunk/Doc/faq/extending.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 09:56:56 2009 New Revision: 75595 Log: Fix duplicate target. Modified: python/trunk/Doc/faq/extending.rst Modified: python/trunk/Doc/faq/extending.rst ============================================================================== --- python/trunk/Doc/faq/extending.rst (original) +++ python/trunk/Doc/faq/extending.rst Thu Oct 22 09:56:56 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`__, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping From python-checkins at python.org Thu Oct 22 10:05:04 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 08:05:04 -0000 Subject: [Python-checkins] r75596 - in python/trunk/Doc: library/weakref.rst tools/sphinxext/pyspecific.py tools/sphinxext/static/basic.css Message-ID: Author: georg.brandl Date: Thu Oct 22 10:05:04 2009 New Revision: 75596 Log: Add a new directive marking up implementation details and start using it. Modified: python/trunk/Doc/library/weakref.rst python/trunk/Doc/tools/sphinxext/pyspecific.py python/trunk/Doc/tools/sphinxext/static/basic.css Modified: python/trunk/Doc/library/weakref.rst ============================================================================== --- python/trunk/Doc/library/weakref.rst (original) +++ python/trunk/Doc/library/weakref.rst Thu Oct 22 10:05:04 2009 @@ -1,4 +1,3 @@ - :mod:`weakref` --- Weak references ================================== @@ -76,9 +75,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable -Other built-in types such as :class:`tuple` and :class:`long` do not support -weak references even when subclassed (this is an implementation detail and may -be different across various Python implementations). +.. impl-detail:: + + Other built-in types such as :class:`tuple` and :class:`long` do not support + weak references even when subclassed. Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/trunk/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/trunk/Doc/tools/sphinxext/pyspecific.py (original) +++ python/trunk/Doc/tools/sphinxext/pyspecific.py Thu Oct 22 10:05:04 2009 @@ -35,6 +35,8 @@ HTMLTranslator.visit_versionmodified = new_visit_versionmodified +# Support for marking up and linking to bugs.python.org issues + def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): issue = utils.unescape(text) text = 'issue ' + issue @@ -42,6 +44,25 @@ return [refnode], [] +# Support for marking up implementation details + +from sphinx.util.compat import Directive + +class ImplementationDetail(Directive): + + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = True + + def run(self): + pnode = nodes.compound(classes=['impl-detail']) + content = self.content + content[0] = '**CPython implementation detail:** ' + content[0] + self.state.nested_parse(content, self.content_offset, pnode) + return [pnode] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -110,10 +131,12 @@ finally: f.close() + # Support for checking for suspicious markup import suspicious + # Support for documenting Opcodes import re @@ -136,6 +159,7 @@ def setup(app): app.add_role('issue', issue_role) + app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', Modified: python/trunk/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/trunk/Doc/tools/sphinxext/static/basic.css (original) +++ python/trunk/Doc/tools/sphinxext/static/basic.css Thu Oct 22 10:05:04 2009 @@ -345,6 +345,17 @@ background-color: #ffa } +.impl-detail { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; + border: 1px solid #ccc; +} + +.impl-detail p { + margin: 0; +} + /* -- code displays --------------------------------------------------------- */ pre { From python-checkins at python.org Thu Oct 22 10:06:15 2009 From: python-checkins at python.org (vinay.sajip) Date: Thu, 22 Oct 2009 08:06:15 -0000 Subject: [Python-checkins] r75597 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Thu Oct 22 10:06:15 2009 New Revision: 75597 Log: Incorporated comments by Jim Jewett. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Thu Oct 22 10:06:15 2009 @@ -92,24 +92,13 @@ The logging.config module will have the following additions: -* A class, called ``DictConfigurator``, whose constructor is passed - the dictionary used for configuration, and which has a - ``configure()`` method. - -* A callable, called ``dictConfigClass``, which will (by default) be - set to ``DictConfigurator``. This is provided so that if desired, - ``DictConfigurator`` can be replaced with a suitable user-defined - implementation. - * A function, called ``dictConfig()``, which takes a single argument - - the dictionary holding the configuration. This function will - call ``dictConfigClass`` passing the specified dictionary, and then - call the ``configure()`` method on the returned object to actually - put the configuration into effect:: - - def dictConfig(config): - dictConfigClass(config).configure() + - the dictionary holding the configuration. Nothing will be + returned, though exceptions will be raised if there are errors + while processing the dictionary. +It will be possible to customize this API - see the section on API +customization. Dictionary Schema - Overview ---------------------------- @@ -333,6 +322,17 @@ using the corresponding integer value, falling back to the string value if needed. +Given a string ``int://handlers.myhandler.mykey.123``, this will +resolve to ``config_dict['handlers']['myhandler']['mykey']['123']``. +If the string is specified as ``int://handlers.myhandler.mykey[123]``, +the system will attempt to retrieve the value from +``config_dict['handlers']['myhandler']['mykey'][123]``, ad fall back +to ``config_dict['handlers']['myhandler']['mykey']['123']`` if that +fails. + +Note: the ``ext`` and ``int`` prefixes are provisional. If better +alternatives are suggested during the PEP review process, they will be +used. Dictionary Schema - Detail -------------------------- @@ -520,6 +520,49 @@ ``level`` and ``propagate`` settings in the ``loggers`` and ``root`` entries. +It's certainly possible to provide incremental configuration by other +means, for example making ``dictConfig()`` take an ``incremental`` +keyword argument which defaults to ``False``. The reason for +suggesting that a flag in the configuration dict be used is that it +allows for configurations to be sent over the wire as pickled dicts +to a socket listener. Thus, the logging verbosity of a long-running +application can be altered over time with no need to stop and +restart the application. + +Note: Feedback on incremental configuration needs based on your +practical experience will be particularly welcome. + + +API Customization +================= + +The bare-bones ``dictConfig()`` API will not be sufficient for all +use cases. Provision for customization of the API will be made by +providing the following: + +* A class, called ``DictConfigurator``, whose constructor is passed + the dictionary used for configuration, and which has a + ``configure()`` method. + +* A callable, called ``dictConfigClass``, which will (by default) be + set to ``DictConfigurator``. This is provided so that if desired, + ``DictConfigurator`` can be replaced with a suitable user-defined + implementation. + +The ``dictConfig()`` function will call ``dictConfigClass`` passing +the specified dictionary, and then call the ``configure()`` method on +the returned object to actually put the configuration into effect:: + + def dictConfig(config): + dictConfigClass(config).configure() + +This should cater to all customization needs. For example, a subclass +of ``DictConfigurator`` could call ``DictConfigurator.__init__()`` in +its own ``__init__()``, then set up custom prefixes which would be +usable in the subsequent ``configure() call``. The ``dictConfigClass`` +would be bound to the subclass, and then ``dictConfig()`` could be +called exactly as in the default, uncustomized state. + Configuration Errors ==================== @@ -540,6 +583,7 @@ * Inability to resolve to an internal or external object + References ========== From python-checkins at python.org Thu Oct 22 10:10:22 2009 From: python-checkins at python.org (vinay.sajip) Date: Thu, 22 Oct 2009 08:10:22 -0000 Subject: [Python-checkins] r75598 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Thu Oct 22 10:10:22 2009 New Revision: 75598 Log: Fixed whitespace which caused HTML rendering problem in rst2html. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Thu Oct 22 10:10:22 2009 @@ -568,7 +568,7 @@ ==================== If an error is encountered during configuration, the system will raise -a ``ValueError``,``TypeError``, ``AttributeError`` or ``ImportError`` +a ``ValueError``, ``TypeError``, ``AttributeError`` or ``ImportError`` with a suitably descriptive message. The following is a (possibly incomplete) list of conditions which will raise an error: From python-checkins at python.org Thu Oct 22 10:37:16 2009 From: python-checkins at python.org (vinay.sajip) Date: Thu, 22 Oct 2009 08:37:16 -0000 Subject: [Python-checkins] r75599 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Thu Oct 22 10:37:16 2009 New Revision: 75599 Log: Added internal hyperlink. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Thu Oct 22 10:37:16 2009 @@ -97,8 +97,8 @@ returned, though exceptions will be raised if there are errors while processing the dictionary. -It will be possible to customize this API - see the section on API -customization. +It will be possible to customize this API - see the section on `API +Customization`_. Dictionary Schema - Overview ---------------------------- From python-checkins at python.org Thu Oct 22 13:01:47 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 11:01:47 -0000 Subject: [Python-checkins] r75600 - python/trunk/Doc/tools/sphinxext/pyspecific.py Message-ID: Author: georg.brandl Date: Thu Oct 22 13:01:46 2009 New Revision: 75600 Log: Make it more robust. Modified: python/trunk/Doc/tools/sphinxext/pyspecific.py Modified: python/trunk/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/trunk/Doc/tools/sphinxext/pyspecific.py (original) +++ python/trunk/Doc/tools/sphinxext/pyspecific.py Thu Oct 22 13:01:46 2009 @@ -58,8 +58,14 @@ def run(self): pnode = nodes.compound(classes=['impl-detail']) content = self.content - content[0] = '**CPython implementation detail:** ' + content[0] + add_text = nodes.strong('CPython implementation detail:', + 'CPython implementation detail:') self.state.nested_parse(content, self.content_offset, pnode) + if pnode.children and isinstance(pnode[0], nodes.paragraph): + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) + else: + pnode.insert(0, nodes.paragraph('', '', add_text)) return [pnode] From python-checkins at python.org Thu Oct 22 13:22:50 2009 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 22 Oct 2009 11:22:50 -0000 Subject: [Python-checkins] r75601 - in python/branches/py3k: Lib/test/test_peepholer.py Misc/NEWS Python/peephole.c Message-ID: Author: raymond.hettinger Date: Thu Oct 22 13:22:50 2009 New Revision: 75601 Log: Peephole constant folding had missed UNARY_POSITIVE. Modified: python/branches/py3k/Lib/test/test_peepholer.py python/branches/py3k/Misc/NEWS python/branches/py3k/Python/peephole.c Modified: python/branches/py3k/Lib/test/test_peepholer.py ============================================================================== --- python/branches/py3k/Lib/test/test_peepholer.py (original) +++ python/branches/py3k/Lib/test/test_peepholer.py Thu Oct 22 13:22:50 2009 @@ -150,6 +150,7 @@ for line, elem in ( ('-0.5', '(-0.5)'), # unary negative ('~-2', '(1)'), # unary invert + ('+1', '(1)'), # unary positive ): asm = dis_single(line) self.assertTrue(elem in asm, asm) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Oct 22 13:22:50 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Peephole constant folding had missed UNARY_POSITIVE. + - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. Modified: python/branches/py3k/Python/peephole.c ============================================================================== --- python/branches/py3k/Python/peephole.c (original) +++ python/branches/py3k/Python/peephole.c Thu Oct 22 13:22:50 2009 @@ -197,6 +197,9 @@ case UNARY_INVERT: newconst = PyNumber_Invert(v); break; + case UNARY_POSITIVE: + newconst = PyNumber_Positive(v); + break; default: /* Called with an unknown opcode */ PyErr_Format(PyExc_SystemError, @@ -500,6 +503,7 @@ LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ case UNARY_NEGATIVE: case UNARY_INVERT: + case UNARY_POSITIVE: if (lastlc >= 1 && ISBASICBLOCK(blocks, i-3, 4) && fold_unaryops_on_constants(&codestr[i-3], consts)) { From python-checkins at python.org Thu Oct 22 13:28:07 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 11:28:07 -0000 Subject: [Python-checkins] r75602 - python/trunk/Doc/documenting/markup.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 13:28:06 2009 New Revision: 75602 Log: Document new directive. Modified: python/trunk/Doc/documenting/markup.rst Modified: python/trunk/Doc/documenting/markup.rst ============================================================================== --- python/trunk/Doc/documenting/markup.rst (original) +++ python/trunk/Doc/documenting/markup.rst Thu Oct 22 13:28:06 2009 @@ -626,6 +626,24 @@ -------------- +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + .. describe:: seealso Many sections include a list of references to module documentation or From python-checkins at python.org Thu Oct 22 13:28:23 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 11:28:23 -0000 Subject: [Python-checkins] r75603 - python/trunk/Doc/tools/sphinxext/pyspecific.py Message-ID: Author: georg.brandl Date: Thu Oct 22 13:28:23 2009 New Revision: 75603 Log: Allow short form with text as argument. Modified: python/trunk/Doc/tools/sphinxext/pyspecific.py Modified: python/trunk/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/trunk/Doc/tools/sphinxext/pyspecific.py (original) +++ python/trunk/Doc/tools/sphinxext/pyspecific.py Thu Oct 22 13:28:23 2009 @@ -60,6 +60,9 @@ content = self.content add_text = nodes.strong('CPython implementation detail:', 'CPython implementation detail:') + if self.arguments: + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.append(nodes.paragraph('', '', *(n + m))) self.state.nested_parse(content, self.content_offset, pnode) if pnode.children and isinstance(pnode[0], nodes.paragraph): pnode[0].insert(0, add_text) From python-checkins at python.org Thu Oct 22 13:36:50 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 11:36:50 -0000 Subject: [Python-checkins] r75604 - python/trunk/Doc/tools/sphinxext/static/basic.css Message-ID: Author: georg.brandl Date: Thu Oct 22 13:36:50 2009 New Revision: 75604 Log: Fix stylesheet for multi-paragraph impl-details. Modified: python/trunk/Doc/tools/sphinxext/static/basic.css Modified: python/trunk/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/trunk/Doc/tools/sphinxext/static/basic.css (original) +++ python/trunk/Doc/tools/sphinxext/static/basic.css Thu Oct 22 13:36:50 2009 @@ -352,8 +352,12 @@ border: 1px solid #ccc; } -.impl-detail p { - margin: 0; +.impl-detail .compound-first { + margin-top: 0; +} + +.impl-detail .compound-last { + margin-bottom: 0; } /* -- code displays --------------------------------------------------------- */ From python-checkins at python.org Thu Oct 22 13:48:11 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 11:48:11 -0000 Subject: [Python-checkins] r75605 - in python/trunk/Doc: library/__builtin__.rst library/functions.rst library/inspect.rst library/math.rst library/platform.rst library/stdtypes.rst library/sys.rst library/types.rst reference/datamodel.rst reference/executionmodel.rst reference/expressions.rst reference/simple_stmts.rst using/cmdline.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 13:48:10 2009 New Revision: 75605 Log: Use "impl-detail" directive where applicable. Modified: python/trunk/Doc/library/__builtin__.rst python/trunk/Doc/library/functions.rst python/trunk/Doc/library/inspect.rst python/trunk/Doc/library/math.rst python/trunk/Doc/library/platform.rst python/trunk/Doc/library/stdtypes.rst python/trunk/Doc/library/sys.rst python/trunk/Doc/library/types.rst python/trunk/Doc/reference/datamodel.rst python/trunk/Doc/reference/executionmodel.rst python/trunk/Doc/reference/expressions.rst python/trunk/Doc/reference/simple_stmts.rst python/trunk/Doc/using/cmdline.rst Modified: python/trunk/Doc/library/__builtin__.rst ============================================================================== --- python/trunk/Doc/library/__builtin__.rst (original) +++ python/trunk/Doc/library/__builtin__.rst Thu Oct 22 13:48:10 2009 @@ -33,9 +33,10 @@ # ... -As an implementation detail, most modules have the name ``__builtins__`` (note -the ``'s'``) made available as part of their globals. The value of -``__builtins__`` is normally either this module or the value of this modules's -:attr:`__dict__` attribute. Since this is an implementation detail, it may not -be used by alternate implementations of Python. +.. impl-detail:: + Most modules have the name ``__builtins__`` (note the ``'s'``) made available + as part of their globals. The value of ``__builtins__`` is normally either + this module or the value of this modules's :attr:`__dict__` attribute. Since + this is an implementation detail, it may not be used by alternate + implementations of Python. Modified: python/trunk/Doc/library/functions.rst ============================================================================== --- python/trunk/Doc/library/functions.rst (original) +++ python/trunk/Doc/library/functions.rst Thu Oct 22 13:48:10 2009 @@ -523,8 +523,10 @@ Return the "identity" of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. - Two objects with non-overlapping lifetimes may have the same :func:`id` value. - (Implementation note: this is the address of the object.) + Two objects with non-overlapping lifetimes may have the same :func:`id` + value. + + .. impl-detail:: This is the address of the object. .. function:: input([prompt]) @@ -1384,14 +1386,15 @@ elements are never used (such as when the loop is usually terminated with :keyword:`break`). - .. note:: + .. impl-detail:: - :func:`xrange` is intended to be simple and fast. Implementations may impose - restrictions to achieve this. The C implementation of Python restricts all - arguments to native C longs ("short" Python integers), and also requires that - the number of elements fit in a native C long. If a larger range is needed, - an alternate version can be crafted using the :mod:`itertools` module: - ``islice(count(start, step), (stop-start+step-1)//step)``. + :func:`xrange` is intended to be simple and fast. Implementations may + impose restrictions to achieve this. The C implementation of Python + restricts all arguments to native C longs ("short" Python integers), and + also requires that the number of elements fit in a native C long. If a + larger range is needed, an alternate version can be crafted using the + :mod:`itertools` module: ``islice(count(start, step), + (stop-start+step-1)//step)``. .. function:: zip([iterable, ...]) Modified: python/trunk/Doc/library/inspect.rst ============================================================================== --- python/trunk/Doc/library/inspect.rst (original) +++ python/trunk/Doc/library/inspect.rst Thu Oct 22 13:48:10 2009 @@ -353,9 +353,11 @@ Return true if the object is a getset descriptor. - getsets are attributes defined in extension modules via ``PyGetSetDef`` - structures. For Python implementations without such types, this method will - always return ``False``. + .. impl-detail:: + + getsets are attributes defined in extension modules via + :ctype:`PyGetSetDef` structures. For Python implementations without such + types, this method will always return ``False``. .. versionadded:: 2.5 @@ -364,9 +366,11 @@ Return true if the object is a member descriptor. - Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, - this method will always return ``False``. + .. impl-detail:: + + Member descriptors are attributes defined in extension modules via + :ctype:`PyMemberDef` structures. For Python implementations without such + types, this method will always return ``False``. .. versionadded:: 2.5 @@ -567,10 +571,12 @@ Return the frame object for the caller's stack frame. - This function relies on Python stack frame support in the interpreter, which - isn't guaranteed to exist in all implementations of Python. If running in - an implementation without Python stack frame support this function returns - ``None``. + .. impl-detail:: + + This function relies on Python stack frame support in the interpreter, + which isn't guaranteed to exist in all implementations of Python. If + running in an implementation without Python stack frame support this + function returns ``None``. .. function:: stack([context]) Modified: python/trunk/Doc/library/math.rst ============================================================================== --- python/trunk/Doc/library/math.rst (original) +++ python/trunk/Doc/library/math.rst Thu Oct 22 13:48:10 2009 @@ -331,7 +331,7 @@ The mathematical constant *e*. -.. note:: +.. impl-detail:: The :mod:`math` module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified Modified: python/trunk/Doc/library/platform.rst ============================================================================== --- python/trunk/Doc/library/platform.rst (original) +++ python/trunk/Doc/library/platform.rst Thu Oct 22 13:48:10 2009 @@ -98,7 +98,7 @@ .. function:: python_implementation() Returns a string identifying the Python implementation. Possible return values - are: 'CPython', 'IronPython', 'Jython' + are: 'CPython', 'IronPython', 'Jython'. .. versionadded:: 2.6 Modified: python/trunk/Doc/library/stdtypes.rst ============================================================================== --- python/trunk/Doc/library/stdtypes.rst (original) +++ python/trunk/Doc/library/stdtypes.rst Thu Oct 22 13:48:10 2009 @@ -195,9 +195,11 @@ :meth:`__cmp__` method. Refer to :ref:`customization`) for information on the use of this method to effect object comparisons. -**Implementation note:** Objects of different types except numbers are ordered -by their type names; objects of the same types that don't support proper -comparison are ordered by their address. +.. impl-detail:: + + Objects of different types except numbers are ordered by their type names; + objects of the same types that don't support proper comparison are ordered by + their address. .. index:: operator: in @@ -796,13 +798,15 @@ If *k* is ``None``, it is treated like ``1``. (6) - If *s* and *t* are both strings, some Python implementations such as CPython can - usually perform an in-place optimization for assignments of the form ``s=s+t`` - or ``s+=t``. When applicable, this optimization makes quadratic run-time much - less likely. This optimization is both version and implementation dependent. - For performance sensitive code, it is preferable to use the :meth:`str.join` - method which assures consistent linear concatenation performance across versions - and implementations. + .. impl-detail:: + + If *s* and *t* are both strings, some Python implementations such as + CPython can usually perform an in-place optimization for assignments of + the form ``s = s + t`` or ``s += t``. When applicable, this optimization + makes quadratic run-time much less likely. This optimization is both + version and implementation dependent. For performance sensitive code, it + is preferable to use the :meth:`str.join` method which assures consistent + linear concatenation performance across versions and implementations. .. versionchanged:: 2.4 Formerly, string concatenation never occurred in-place. @@ -1629,10 +1633,13 @@ example, sort by department, then by salary grade). (10) - While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation of Python 2.3 and newer - makes the list appear empty for the duration, and raises :exc:`ValueError` if it - can detect that the list has been mutated during a sort. + .. impl-detail:: + + While a list is being sorted, the effect of attempting to mutate, or even + inspect, the list is undefined. The C implementation of Python 2.3 and + newer makes the list appear empty for the duration, and raises + :exc:`ValueError` if it can detect that the list has been mutated during a + sort. .. _types-set: @@ -2006,20 +2013,21 @@ Return a copy of the dictionary's list of ``(key, value)`` pairs. - .. note:: + .. impl-detail:: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's - history of insertions and deletions. If :meth:`items`, :meth:`keys`, - :meth:`values`, :meth:`iteritems`, :meth:`iterkeys`, and - :meth:`itervalues` are called with no intervening modifications to the - dictionary, the lists will directly correspond. This allows the - creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = - zip(d.values(), d.keys())``. The same relationship holds for the - :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs = - zip(d.itervalues(), d.iterkeys())`` provides the same value for - ``pairs``. Another way to create the same list is ``pairs = [(v, k) for - (k, v) in d.iteritems()]``. + history of insertions and deletions. + + If :meth:`items`, :meth:`keys`, :meth:`values`, :meth:`iteritems`, + :meth:`iterkeys`, and :meth:`itervalues` are called with no intervening + modifications to the dictionary, the lists will directly correspond. This + allows the creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = + zip(d.values(), d.keys())``. The same relationship holds for the + :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs = + zip(d.itervalues(), d.iterkeys())`` provides the same value for + ``pairs``. Another way to create the same list is ``pairs = [(v, k) for + (k, v) in d.iteritems()]``. .. method:: iteritems() Modified: python/trunk/Doc/library/sys.rst ============================================================================== --- python/trunk/Doc/library/sys.rst (original) +++ python/trunk/Doc/library/sys.rst Thu Oct 22 13:48:10 2009 @@ -417,8 +417,10 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. It - is not guaranteed to exist in all implementations of Python. + .. impl-detail:: + + This function should be used for internal and specialized purposes only. + It is not guaranteed to exist in all implementations of Python. .. function:: getprofile() @@ -440,12 +442,12 @@ Get the trace function as set by :func:`settrace`. - .. note:: + .. impl-detail:: The :func:`gettrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, - and thus may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. versionadded:: 2.6 @@ -830,12 +832,12 @@ For more information on code and frame objects, refer to :ref:`types`. - .. note:: + .. impl-detail:: The :func:`settrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, and thus - may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: settscdump(on_flag) Modified: python/trunk/Doc/library/types.rst ============================================================================== --- python/trunk/Doc/library/types.rst (original) +++ python/trunk/Doc/library/types.rst Thu Oct 22 13:48:10 2009 @@ -241,8 +241,11 @@ as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the :class:`property` type, but for classes defined in extension modules. - In other implementations of Python, this type may be identical to - ``GetSetDescriptorType``. + + .. impl-detail:: + + In other implementations of Python, this type may be identical to + ``GetSetDescriptorType``. .. versionadded:: 2.5 Modified: python/trunk/Doc/reference/datamodel.rst ============================================================================== --- python/trunk/Doc/reference/datamodel.rst (original) +++ python/trunk/Doc/reference/datamodel.rst Thu Oct 22 13:48:10 2009 @@ -56,13 +56,16 @@ they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether --- it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that -are still reachable. (Implementation note: CPython currently uses a -reference-counting scheme with (optional) delayed detection of cyclically linked -garbage, which collects most objects as soon as they become unreachable, but is -not guaranteed to collect garbage containing circular references. See the -documentation of the :mod:`gc` module for information on controlling the -collection of cyclic garbage. Other implementations act differently and CPython -may change.) +are still reachable. + +.. impl-detail:: + + CPython currently uses a reference-counting scheme with (optional) delayed + detection of cyclically linked garbage, which collects most objects as soon + as they become unreachable, but is not guaranteed to collect garbage + containing circular references. See the documentation of the :mod:`gc` + module for information on controlling the collection of cyclic garbage. + Other implementations act differently and CPython may change. Note that the use of the implementation's tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching Modified: python/trunk/Doc/reference/executionmodel.rst ============================================================================== --- python/trunk/Doc/reference/executionmodel.rst (original) +++ python/trunk/Doc/reference/executionmodel.rst Thu Oct 22 13:48:10 2009 @@ -128,7 +128,7 @@ itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. -.. note:: +.. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should Modified: python/trunk/Doc/reference/expressions.rst ============================================================================== --- python/trunk/Doc/reference/expressions.rst (original) +++ python/trunk/Doc/reference/expressions.rst Thu Oct 22 13:48:10 2009 @@ -663,13 +663,13 @@ raised. Otherwise, the list of filled slots is used as the argument list for the call. -.. note:: +.. impl-detail:: - An implementation may provide built-in functions whose positional parameters do - not have names, even if they are 'named' for the purpose of documentation, and - which therefore cannot be supplied by keyword. In CPython, this is the case for - functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their - arguments. + An implementation may provide built-in functions whose positional parameters + do not have names, even if they are 'named' for the purpose of documentation, + and which therefore cannot be supplied by keyword. In CPython, this is the + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to + parse their arguments. If there are more positional arguments than there are formal parameter slots, a :exc:`TypeError` exception is raised, unless a formal parameter using the syntax Modified: python/trunk/Doc/reference/simple_stmts.rst ============================================================================== --- python/trunk/Doc/reference/simple_stmts.rst (original) +++ python/trunk/Doc/reference/simple_stmts.rst Thu Oct 22 13:48:10 2009 @@ -219,9 +219,11 @@ the length of the assigned sequence, thus changing the length of the target sequence, if the object allows it. -(In the current implementation, the syntax for targets is taken to be the same -as for expressions, and invalid syntax is rejected during the code generation -phase, causing less detailed error messages.) +.. impl-detail:: + + In the current implementation, the syntax for targets is taken to be the same + as for expressions, and invalid syntax is rejected during the code generation + phase, causing less detailed error messages. WARNING: Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are 'safe' (for example ``a, b = b, a`` @@ -946,9 +948,11 @@ parameters or in a :keyword:`for` loop control target, :keyword:`class` definition, function definition, or :keyword:`import` statement. -(The current implementation does not enforce the latter two restrictions, but -programs should not abuse this freedom, as future implementations may enforce -them or silently change the meaning of the program.) +.. impl-detail:: + + The current implementation does not enforce the latter two restrictions, but + programs should not abuse this freedom, as future implementations may enforce + them or silently change the meaning of the program. .. index:: statement: exec Modified: python/trunk/Doc/using/cmdline.rst ============================================================================== --- python/trunk/Doc/using/cmdline.rst (original) +++ python/trunk/Doc/using/cmdline.rst Thu Oct 22 13:48:10 2009 @@ -8,7 +8,7 @@ The CPython interpreter scans the command line and the environment for various settings. -.. note:: +.. impl-detail:: Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. From python-checkins at python.org Thu Oct 22 17:00:07 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:00:07 -0000 Subject: [Python-checkins] r75606 - in python/trunk/Doc/reference: datamodel.rst expressions.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:00:06 2009 New Revision: 75606 Log: #6324: membership test tries iteration via __iter__. Modified: python/trunk/Doc/reference/datamodel.rst python/trunk/Doc/reference/expressions.rst Modified: python/trunk/Doc/reference/datamodel.rst ============================================================================== --- python/trunk/Doc/reference/datamodel.rst (original) +++ python/trunk/Doc/reference/datamodel.rst Thu Oct 22 17:00:06 2009 @@ -1888,12 +1888,16 @@ supply the following special method with a more efficient implementation, which also does not require the object be a sequence. - .. method:: object.__contains__(self, item) - Called to implement membership test operators. Should return true if *item* is - in *self*, false otherwise. For mapping objects, this should consider the keys - of the mapping rather than the values or the key-item pairs. + Called to implement membership test operators. Should return true if *item* + is in *self*, false otherwise. For mapping objects, this should consider the + keys of the mapping rather than the values or the key-item pairs. + + For objects that don't define :meth:`__contains__`, the membership test first + tries iteration via :meth:`__iter__`, then the old sequence iteration + protocol via :meth:`__getitem__`, see :ref:`this section in the language + reference `. .. _sequence-methods: Modified: python/trunk/Doc/reference/expressions.rst ============================================================================== --- python/trunk/Doc/reference/expressions.rst (original) +++ python/trunk/Doc/reference/expressions.rst Thu Oct 22 17:00:06 2009 @@ -1068,6 +1068,8 @@ another one is made arbitrarily but consistently within one execution of a program. +.. _membership-test-details: + The operators :keyword:`in` and :keyword:`not in` test for collection membership. ``x in s`` evaluates to true if *x* is a member of the collection *s*, and false otherwise. ``x not in s`` returns the negation of ``x in s``. @@ -1092,7 +1094,12 @@ For user-defined classes which define the :meth:`__contains__` method, ``x in y`` is true if and only if ``y.__contains__(x)`` is true. -For user-defined classes which do not define :meth:`__contains__` and do define +For user-defined classes which do not define :meth:`__contains__` but do define +:meth:`__iter__`, ``x in y`` is true if some value ``z`` with ``x == z`` is +produced while iterating over ``y``. If an exception is raised during the +iteration, it is as if :keyword:`in` raised that exception. + +Lastly, the old-style iteration protocol is tried: if a class defines :meth:`__getitem__`, ``x in y`` is true if and only if there is a non-negative integer index *i* such that ``x == y[i]``, and all lower integer indices do not raise :exc:`IndexError` exception. (If any other exception is raised, it is as From python-checkins at python.org Thu Oct 22 17:04:10 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:04:10 -0000 Subject: [Python-checkins] r75607 - python/trunk/Doc/library/signal.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:04:09 2009 New Revision: 75607 Log: #7088: document new functions in signal as Unix-only. Modified: python/trunk/Doc/library/signal.rst Modified: python/trunk/Doc/library/signal.rst ============================================================================== --- python/trunk/Doc/library/signal.rst (original) +++ python/trunk/Doc/library/signal.rst Thu Oct 22 17:04:09 2009 @@ -158,7 +158,7 @@ The old values are returned as a tuple: (delay, interval). Attempting to pass an invalid interval timer will cause an - :exc:`ItimerError`. + :exc:`ItimerError`. Availability: Unix. .. versionadded:: 2.6 @@ -166,6 +166,7 @@ .. function:: getitimer(which) Returns current value of a given interval timer specified by *which*. + Availability: Unix. .. versionadded:: 2.6 @@ -186,14 +187,14 @@ .. function:: siginterrupt(signalnum, flag) - Change system call restart behaviour: if *flag* is :const:`False`, system calls - will be restarted when interrupted by signal *signalnum*, otherwise system calls will - be interrupted. Returns nothing. Availability: Unix (see the man page - :manpage:`siginterrupt(3)` for further information). - - Note that installing a signal handler with :func:`signal` will reset the restart - behaviour to interruptible by implicitly calling :cfunc:`siginterrupt` with a true *flag* - value for the given signal. + Change system call restart behaviour: if *flag* is :const:`False`, system + calls will be restarted when interrupted by signal *signalnum*, otherwise + system calls will be interrupted. Returns nothing. Availability: Unix (see + the man page :manpage:`siginterrupt(3)` for further information). + + Note that installing a signal handler with :func:`signal` will reset the + restart behaviour to interruptible by implicitly calling + :cfunc:`siginterrupt` with a true *flag* value for the given signal. .. versionadded:: 2.6 From python-checkins at python.org Thu Oct 22 17:14:34 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:14:34 -0000 Subject: [Python-checkins] r75608 - peps/trunk/pep-3099.txt Message-ID: Author: georg.brandl Date: Thu Oct 22 17:14:34 2009 New Revision: 75608 Log: Add for/else entry. Modified: peps/trunk/pep-3099.txt Modified: peps/trunk/pep-3099.txt ============================================================================== --- peps/trunk/pep-3099.txt (original) +++ peps/trunk/pep-3099.txt Thu Oct 22 17:14:34 2009 @@ -146,6 +146,12 @@ Thread: "No Container Literals", http://mail.python.org/pipermail/python-3000/2006-July/002550.html +* The ``else`` clause in ``while`` and ``for`` loops will not change + semantics, or be removed. + + Thread: "for/except/else syntax" + http://mail.python.org/pipermail/python-ideas/2009-October/006083.html + Builtins ======== From python-checkins at python.org Thu Oct 22 17:16:26 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:16:26 -0000 Subject: [Python-checkins] r75609 - python/branches/py3k/Doc/library/socket.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:16:26 2009 New Revision: 75609 Log: #7137: fix makefile() documentation to match the new parameters. Modified: python/branches/py3k/Doc/library/socket.rst Modified: python/branches/py3k/Doc/library/socket.rst ============================================================================== --- python/branches/py3k/Doc/library/socket.rst (original) +++ python/branches/py3k/Doc/library/socket.rst Thu Oct 22 17:16:26 2009 @@ -564,17 +564,17 @@ is system-dependent (usually 5). -.. method:: socket.makefile([mode[, bufsize]]) +.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, newline=None) .. index:: single: I/O control; buffering Return a :dfn:`file object` associated with the socket. (File objects are - described in :ref:`bltin-file-objects`.) The file object - references a :cfunc:`dup`\ ped version of the socket file descriptor, so the - file object and socket object may be closed or garbage-collected independently. - The socket must be in blocking mode (it can not have a timeout). The optional - *mode* and *bufsize* arguments are interpreted the same way as by the built-in - :func:`file` function. + described in :ref:`bltin-file-objects`.) The file object references a + :cfunc:`dup`\ ped version of the socket file descriptor, so the file object + and socket object may be closed or garbage-collected independently. The + socket must be in blocking mode (it can not have a timeout). The optional + arguments are interpreted the same way as by the built-in :func:`open` + function. .. method:: socket.recv(bufsize[, flags]) From python-checkins at python.org Thu Oct 22 17:27:25 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:27:25 -0000 Subject: [Python-checkins] r75610 - python/trunk/Doc/reference/datamodel.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:27:24 2009 New Revision: 75610 Log: Reorder __slots__ fine print and add a clarification. Modified: python/trunk/Doc/reference/datamodel.rst Modified: python/trunk/Doc/reference/datamodel.rst ============================================================================== --- python/trunk/Doc/reference/datamodel.rst (original) +++ python/trunk/Doc/reference/datamodel.rst Thu Oct 22 17:27:24 2009 @@ -1675,15 +1675,15 @@ *__slots__*; otherwise, the class attribute would overwrite the descriptor assignment. +* The action of a *__slots__* declaration is limited to the class where it is + defined. As a result, subclasses will have a *__dict__* unless they also define + *__slots__* (which must only contain names of any *additional* slots). + * If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this. -* The action of a *__slots__* declaration is limited to the class where it is - defined. As a result, subclasses will have a *__dict__* unless they also define - *__slots__*. - * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`long`, :class:`str` and :class:`tuple`. From python-checkins at python.org Thu Oct 22 17:42:32 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:42:32 -0000 Subject: [Python-checkins] r75611 - in python/trunk: Doc/library/codecs.rst Python/codecs.c Message-ID: Author: georg.brandl Date: Thu Oct 22 17:42:32 2009 New Revision: 75611 Log: #7035: improve docs of the various _errors() functions, and give them docstrings. Modified: python/trunk/Doc/library/codecs.rst python/trunk/Python/codecs.c Modified: python/trunk/Doc/library/codecs.rst ============================================================================== --- python/trunk/Doc/library/codecs.rst (original) +++ python/trunk/Doc/library/codecs.rst Thu Oct 22 17:42:32 2009 @@ -54,7 +54,7 @@ *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: - ``factory(errors='strict')`` + ``factory(errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, @@ -63,20 +63,24 @@ *streamreader* and *streamwriter*: These have to be factory functions providing the following interface: - ``factory(stream, errors='strict')`` + ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. - Possible values for errors are ``'strict'`` (raise an exception in case of an - encoding error), ``'replace'`` (replace malformed data with a suitable - replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and - continue without further notice), ``'xmlcharrefreplace'`` (replace with the - appropriate XML character reference (for encoding only)) and - ``'backslashreplace'`` (replace with backslashed escape sequences (for encoding - only)) as well as any other error handling name defined via - :func:`register_error`. + Possible values for errors are + + * ``'strict'``: raise an exception in case of an encoding error + * ``'replace'``: replace malformed data with a suitable replacement marker, + such as ``'?'`` or ``'\ufffd'`` + * ``'ignore'``: ignore malformed data and continue without further notice + * ``'xmlcharrefreplace'``: replace with the appropriate XML character + reference (for encoding only) + * ``'backslashreplace'``: replace with backslashed escape sequences (for + encoding only + + as well as any other error handling name defined via :func:`register_error`. In case a search function cannot find a given encoding, it should return ``None``. @@ -177,27 +181,33 @@ .. function:: strict_errors(exception) - Implements the ``strict`` error handling. + Implements the ``strict`` error handling: each encoding or decoding error + raises a :exc:`UnicodeError`. .. function:: replace_errors(exception) - Implements the ``replace`` error handling. + Implements the ``replace`` error handling: malformed data is replaced with a + suitable replacement character such as ``'?'`` in bytestrings and + ``'\ufffd'`` in Unicode strings. .. function:: ignore_errors(exception) - Implements the ``ignore`` error handling. + Implements the ``ignore`` error handling: malformed data is ignored and + encoding or decoding is continued without further notice. .. function:: xmlcharrefreplace_errors(exception) - Implements the ``xmlcharrefreplace`` error handling. + Implements the ``xmlcharrefreplace`` error handling (for encoding only): the + unencodable character is replaced by an appropriate XML character reference. .. function:: backslashreplace_errors(exception) - Implements the ``backslashreplace`` error handling. + Implements the ``backslashreplace`` error handling (for encoding only): the + unencodable character is replaced by a backslashed escape sequence. To simplify working with encoded files or stream, the module also defines these utility functions: Modified: python/trunk/Python/codecs.c ============================================================================== --- python/trunk/Python/codecs.c (original) +++ python/trunk/Python/codecs.c Thu Oct 22 17:42:32 2009 @@ -774,7 +774,9 @@ { "strict_errors", strict_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'strict' error handling, which " + "raises a UnicodeError on coding errors.") } }, #ifdef Py_USING_UNICODE @@ -783,7 +785,9 @@ { "ignore_errors", ignore_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'ignore' error handling, which " + "ignores malformed data and continues.") } }, { @@ -791,7 +795,9 @@ { "replace_errors", replace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'replace' error handling, which " + "replaces malformed data with a replacement marker.") } }, { @@ -799,7 +805,10 @@ { "xmlcharrefreplace_errors", xmlcharrefreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'xmlcharrefreplace' error handling, " + "which replaces an unencodable character with the " + "appropriate XML character reference.") } }, { @@ -807,7 +816,10 @@ { "backslashreplace_errors", backslashreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'backslashreplace' error handling, " + "which replaces an unencodable character with a " + "backslashed escape sequence.") } } #endif From python-checkins at python.org Thu Oct 22 17:52:15 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:52:15 -0000 Subject: [Python-checkins] r75612 - python/trunk/Doc/library/curses.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:52:15 2009 New Revision: 75612 Log: #7156: document curses as Unix-only. Modified: python/trunk/Doc/library/curses.rst Modified: python/trunk/Doc/library/curses.rst ============================================================================== --- python/trunk/Doc/library/curses.rst (original) +++ python/trunk/Doc/library/curses.rst Thu Oct 22 17:52:15 2009 @@ -4,10 +4,10 @@ .. module:: curses :synopsis: An interface to the curses library, providing portable terminal handling. + :platform: Unix .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond - .. versionchanged:: 1.6 Added support for the ``ncurses`` library and converted to a package. From python-checkins at python.org Thu Oct 22 17:54:36 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 15:54:36 -0000 Subject: [Python-checkins] r75613 - python/trunk/Doc/library/getopt.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 17:54:35 2009 New Revision: 75613 Log: #6977: getopt does not support optional option arguments. Modified: python/trunk/Doc/library/getopt.rst Modified: python/trunk/Doc/library/getopt.rst ============================================================================== --- python/trunk/Doc/library/getopt.rst (original) +++ python/trunk/Doc/library/getopt.rst Thu Oct 22 17:54:35 2009 @@ -30,19 +30,20 @@ .. note:: - Unlike GNU :cfunc:`getopt`, after a non-option argument, all further arguments - are considered also non-options. This is similar to the way non-GNU Unix systems - work. + Unlike GNU :cfunc:`getopt`, after a non-option argument, all further + arguments are considered also non-options. This is similar to the way + non-GNU Unix systems work. *long_options*, if specified, must be a list of strings with the names of the - long options which should be supported. The leading ``'-``\ ``-'`` characters - should not be included in the option name. Long options which require an - argument should be followed by an equal sign (``'='``). To accept only long - options, *options* should be an empty string. Long options on the command line - can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *long_options* is - ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, - but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. + long options which should be supported. The leading ``'-``\ ``-'`` + characters should not be included in the option name. Long options which + require an argument should be followed by an equal sign (``'='``). Optional + arguments are not supported. To accept only long options, *options* should + be an empty string. Long options on the command line can be recognized so + long as they provide a prefix of the option name that matches exactly one of + the accepted options. For example, if *long_options* is ``['foo', 'frob']``, + the option :option:`--fo` will match as :option:`--foo`, but :option:`--f` + will not match uniquely, so :exc:`GetoptError` will be raised. The return value consists of two elements: the first is a list of ``(option, value)`` pairs; the second is the list of program arguments left after the From python-checkins at python.org Thu Oct 22 18:03:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 22 Oct 2009 16:03:51 -0000 Subject: [Python-checkins] r75614 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Thu Oct 22 18:03:51 2009 New Revision: 75614 Log: Remove support for alternative limb representations Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Thu Oct 22 18:03:51 2009 @@ -75,22 +75,9 @@ * Primitive operations on limbs * *********************************/ -/* The idea behind this section is that it should be easy to change the - underlying representation of a limb without greatly affecting the rest of - the code. For example, one might want to use alternative encodings like - binary-coded decimal or densely packed decimal. In that case, only this - section should have to be changed, provided that all following code uses - only these primitive operations to operate on limbs. - - Ideally, later code should not assume that limbs can be operated on using - the usual arithmetic operators, or that they are comparable with < or == - (some encodings may not be monotonic, or may have redundant encodings of - the same integer, or may not even be encoded as a C integer type). -*/ - #define LIMB_ZERO ((limb_t)0) #define LIMB_ONE ((limb_t)1) -#define LIMB_BASE (LIMB_MAX+LIMB_ONE) +#define LIMB_BASE ((limb_t)(LIMB_MAX+LIMB_ONE)) /* limb_error is called for internal errors */ @@ -173,14 +160,6 @@ return (limb_t)(hilo/c); } -/* return true if the limb is nonzero, else false */ - -static bool -limb_bool(limb_t a) -{ - return a != 0; -} - /* The following two functions are the primitive operations needed for base conversion. Any value n in the range [0, LIMB_BASE * PyLong_BASE) can be written either in the form @@ -242,52 +221,6 @@ are provided for convenience. There is no need to change these if/when the representation of a limb_t changes. */ -/* comparison: -1 if a < b, 0 if a == b, 1 if a > b */ - -static int -limb_cmp(limb_t a, limb_t b) -{ - bool carry; - limb_t diff; - carry = limb_sbb(&diff, a, b, false); - if (limb_bool(diff)) - return carry ? -1 : 1; - else - return 0; -} - -/* true if a == b, else false */ - -static bool -limb_eq(limb_t a, limb_t b) -{ - /* a == b iff a - b is zero */ - limb_t diff; - limb_sbb(&diff, a, b, false); - return !limb_bool(diff); -} - -/* true if a < b, else false */ - -static bool -limb_lt(limb_t a, limb_t b) -{ - /* a < b iff a - b overflows */ - limb_t dummy; - return limb_sbb(&dummy, a, b, false); -} - -/* true if a <= b, else false */ -/* Not currently used anywhere */ - -static bool -limb_le(limb_t a, limb_t b) -{ - /* a <= b iff a - b - 1 overflows */ - limb_t dummy; - return limb_sbb(&dummy, a, b, true); -} - /* extract bottom n digits of a limb */ static limb_t @@ -296,7 +229,7 @@ if (!(0 <= n && n <= LIMB_DIGITS)) limb_error("limb_mask: invalid count"); if (n < LIMB_DIGITS) - limb_div(&a, LIMB_ZERO, a, powers_of_ten[n]); + (void)limb_div(&a, LIMB_ZERO, a, powers_of_ten[n]); return a; } @@ -598,7 +531,7 @@ bool carry, neg; /* reduce to case where top limbs differ */ - while (n > 0 && limb_eq(a[n-1], b[n-1])) { + while (n > 0 && a[n-1] == b[n-1]) { res[n-1] = LIMB_ZERO; n--; } @@ -606,7 +539,7 @@ return false; /* now reduce to case a > b */ - neg = limb_lt(a[n-1], b[n-1]); + neg = a[n-1] < b[n-1]; if (neg) { const limb_t *temp; temp = a; a = b; b = temp; @@ -688,7 +621,7 @@ /* top limb of b should be nonzero; a should contain at least as many limbs as b */ - assert(a_size >= b_size && b_size > 0 && limb_bool(b[b_size-1])); + assert(a_size >= b_size && b_size > 0 && b[b_size-1] != LIMB_ZERO); /* compute scale factor for normalization: floor(LIMB_BASE / (b_top+1)) */ @@ -701,13 +634,13 @@ /* scale a and b */ top = limbs_mul1(w, b, b_size, scale); bb = w; - assert(!limb_bool(top)); + assert(top == LIMB_ZERO); top = limbs_mul1(w+b_size, a, a_size, scale); aa = w+b_size; /* catch most cases where quotient only needs a_size-b_size limbs */ - if (!limb_bool(top) && limb_lt(aa[a_size-1], bb[b_size-1])) + if (top == LIMB_ZERO && aa[a_size-1] < bb[b_size-1]) quot[a_size-b_size] = LIMB_ZERO; else { aa[a_size] = top; @@ -721,7 +654,7 @@ a_top = aa[b_size]; assert(limb_le(a_top, b_top)); /* quotient q = aa / bb; may be overestimate */ - if (limb_lt(a_top, b_top)) + if (a_top < b_top) q = limb_div(&dummy, a_top, aa[b_size-1], b_top); else q = LIMB_MAX; @@ -732,7 +665,7 @@ assert(!carry); assert(limb_le(a_top, top)); /* correct if necessary */ - while (limb_lt(a_top, top)) { + while (a_top < top) { carry = limbs_add(aa, aa, bb, b_size); carry = limb_adc(&a_top, a_top, LIMB_ZERO, carry); assert(!carry); @@ -742,7 +675,7 @@ quot[j] = q; } top = limbs_div1(rem, aa, b_size, LIMB_ZERO, scale); - assert(!limb_bool(top)); + assert(top == LIMB_ZERO); } /* shift a_size-limb number left n digits (shifting zeros in); i.e., multiply @@ -759,7 +692,7 @@ for (i = 0; i < n_limbs; i++) res[i] = LIMB_ZERO; high = limbs_mul1(res+n_limbs, a, a_size, powers_of_ten[n_digits]); - assert(limb_lt(high, powers_of_ten[n_digits])); + assert(high < powers_of_ten[n_digits]); if (n_digits != 0) res[n_limbs + a_size] = high; } @@ -919,7 +852,7 @@ high = a[i]; for (j = 0; j < b_size; j++) b[j] = digit_limb_swap(&high, b[j], high); - while (limb_bool(high)) + while (high != LIMB_ZERO) b[b_size++] = digit_limb_swap(&high, 0, high); } return b_size; @@ -1235,7 +1168,7 @@ { Py_ssize_t v_size; v_size = Py_SIZE(v); - while (v_size > 0 && !limb_bool(v->ob_limbs[v_size-1])) + while (v_size > 0 && v->ob_limbs[v_size-1] == LIMB_ZERO) --v_size; Py_SIZE(v) = v_size; return v; @@ -1751,10 +1684,10 @@ goto fail2; while (true) { /* invariant quantity: apow**b*acc == a**bb. */ - lowbit = limbs_div1(b_limbs, b_limbs, b_size, LIMB_ZERO, 2); - if (!limb_bool(b_limbs[b_size-1])) + lowbit = limbs_div1(b_limbs, b_limbs, b_size, LIMB_ZERO, (limb_t)2); + if (b_limbs[b_size-1] == LIMB_ZERO) b_size--; - if (limb_bool(lowbit)) { + if (lowbit != LIMB_ZERO) { /* acc *= apow */ if (c == NULL) temp = _deccoeff_multiply(apow, acc); @@ -2054,17 +1987,14 @@ static int _deccoeff_compare(deccoeff *a, deccoeff *b) { - int c; Py_ssize_t a_size, b_size, i; a_size = Py_SIZE(a); b_size = Py_SIZE(b); if (a_size != b_size) return a_size < b_size ? -1 : 1; - for (i = a_size-1; i >= 0; i--) { - c = limb_cmp(a->ob_limbs[i], b->ob_limbs[i]); - if (c != 0) - return c; - } + for (i = a_size-1; i >= 0; i--) + if (a->ob_limbs[i] != b->ob_limbs[i]) + return a->ob_limbs[i] < b->ob_limbs[i] ? -1 : 1; return 0; } From python-checkins at python.org Thu Oct 22 18:08:10 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 16:08:10 -0000 Subject: [Python-checkins] r75615 - in python/branches/py3k/Doc/reference: compound_stmts.rst datamodel.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 18:08:10 2009 New Revision: 75615 Log: #6927: fix wrong word. Modified: python/branches/py3k/Doc/reference/compound_stmts.rst python/branches/py3k/Doc/reference/datamodel.rst Modified: python/branches/py3k/Doc/reference/compound_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/compound_stmts.rst (original) +++ python/branches/py3k/Doc/reference/compound_stmts.rst Thu Oct 22 18:08:10 2009 @@ -610,9 +610,9 @@ .. [#] The exception is propagated to the invocation stack only if there is no :keyword:`finally` clause that negates the exception. -.. [#] Currently, control "flows off the end" except in the case of an exception or the - execution of a :keyword:`return`, :keyword:`continue`, or :keyword:`break` - statement. +.. [#] Currently, control "flows off the end" except in the case of an exception + or the execution of a :keyword:`return`, :keyword:`continue`, or + :keyword:`break` statement. .. [#] A string literal appearing as the first statement in the function body is transformed into the function's ``__doc__`` attribute and therefore the Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Thu Oct 22 18:08:10 2009 @@ -1532,7 +1532,7 @@ The appropriate metaclass is determined by the following precedence rules: -* If the ``metaclass`` keyword argument is based with the bases, it is used. +* If the ``metaclass`` keyword argument is passed with the bases, it is used. * Otherwise, if there is at least one base class, its metaclass is used. From python-checkins at python.org Thu Oct 22 18:17:06 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 16:17:06 -0000 Subject: [Python-checkins] r75616 - python/trunk/Doc/tutorial/index.rst Message-ID: Author: georg.brandl Date: Thu Oct 22 18:17:05 2009 New Revision: 75616 Log: Add proper references. Modified: python/trunk/Doc/tutorial/index.rst Modified: python/trunk/Doc/tutorial/index.rst ============================================================================== --- python/trunk/Doc/tutorial/index.rst (original) +++ python/trunk/Doc/tutorial/index.rst Thu Oct 22 18:17:05 2009 @@ -28,18 +28,17 @@ interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. -For a description of standard objects and modules, see the Python Library -Reference document. The Python Reference Manual gives a more formal definition -of the language. To write extensions in C or C++, read Extending and Embedding -the Python Interpreter and Python/C API Reference. There are also several books -covering Python in depth. +For a description of standard objects and modules, see :ref:`library-index`. +:ref:`reference-index` gives a more formal definition of the language. To write +extensions in C or C++, read :ref:`extending-index` and +:ref:`c-api-index`. There are also several books covering Python in depth. This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the -various Python library modules described in the Python Library Reference. +various Python library modules described in :ref:`library-index`. The :ref:`glossary` is also worth going through. From python-checkins at python.org Thu Oct 22 18:20:55 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 22 Oct 2009 16:20:55 -0000 Subject: [Python-checkins] r75617 - python/trunk/Doc/tools/sphinxext/static/basic.css Message-ID: Author: georg.brandl Date: Thu Oct 22 18:20:55 2009 New Revision: 75617 Log: Make printout margin important. Modified: python/trunk/Doc/tools/sphinxext/static/basic.css Modified: python/trunk/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/trunk/Doc/tools/sphinxext/static/basic.css (original) +++ python/trunk/Doc/tools/sphinxext/static/basic.css Thu Oct 22 18:20:55 2009 @@ -420,7 +420,7 @@ div.document, div.documentwrapper, div.bodywrapper { - margin: 0; + margin: 0 !important; width: 100%; } From python-checkins at python.org Thu Oct 22 20:53:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 22 Oct 2009 18:53:09 -0000 Subject: [Python-checkins] r75618 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Thu Oct 22 20:53:08 2009 New Revision: 75618 Log: Fix two more uses of limb_le Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Thu Oct 22 20:53:08 2009 @@ -652,7 +652,7 @@ for (j = a_size-b_size-1; j >= 0; j--) { aa--; a_top = aa[b_size]; - assert(limb_le(a_top, b_top)); + assert(a_top <= b_top); /* quotient q = aa / bb; may be overestimate */ if (a_top < b_top) q = limb_div(&dummy, a_top, aa[b_size-1], b_top); @@ -663,7 +663,7 @@ carry = limbs_sub(aa, aa, rem, b_size); carry = limb_adc(&top, top, LIMB_ZERO, carry); assert(!carry); - assert(limb_le(a_top, top)); + assert(atop <= top); /* correct if necessary */ while (a_top < top) { carry = limbs_add(aa, aa, bb, b_size); From python-checkins at python.org Thu Oct 22 21:04:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 22 Oct 2009 19:04:51 -0000 Subject: [Python-checkins] r75619 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Thu Oct 22 21:04:51 2009 New Revision: 75619 Log: Fix extra semicolon Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Thu Oct 22 21:04:51 2009 @@ -22,7 +22,7 @@ #ifdef HAVE_C99_BOOL # define bool _Bool #else -# define bool signed char; +# define bool signed char #endif #define false (bool)0 #define true (bool)1 From python-checkins at python.org Thu Oct 22 22:13:15 2009 From: python-checkins at python.org (eric.smith) Date: Thu, 22 Oct 2009 20:13:15 -0000 Subject: [Python-checkins] r75620 - python/trunk/Lib/ctypes/util.py Message-ID: Author: eric.smith Date: Thu Oct 22 22:13:14 2009 New Revision: 75620 Log: Per the discussion in issue6882, backport the try/finally work that was done to the py3k version (mostly in r59477, I think). Modified: python/trunk/Lib/ctypes/util.py Modified: python/trunk/Lib/ctypes/util.py ============================================================================== --- python/trunk/Lib/ctypes/util.py (original) +++ python/trunk/Lib/ctypes/util.py Thu Oct 22 22:13:14 2009 @@ -96,8 +96,10 @@ '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name try: f = os.popen(cmd) - trace = f.read() - rv = f.close() + try: + trace = f.read() + finally: + rv = f.close() finally: try: os.unlink(ccout) @@ -118,7 +120,12 @@ if not f: return None cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f - res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data) if not res: return None return res.group(1) @@ -134,7 +141,12 @@ rv = f.close() if rv == 10: raise OSError, 'objdump command not found' - res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(r'\sSONAME\s+([^\s]+)', data) if not res: return None return res.group(1) @@ -157,8 +169,12 @@ def find_library(name): ename = re.escape(name) expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename) - res = re.findall(expr, - os.popen('/sbin/ldconfig -r 2>/dev/null').read()) + f = os.popen('/sbin/ldconfig -r 2>/dev/null') + try: + data = f.read() + finally: + f.close() + res = re.findall(expr, data) if not res: return _get_soname(_findLib_gcc(name)) res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y))) @@ -169,12 +185,21 @@ def _findLib_ldconfig(name): # XXX assuming GLIBC's ldconfig (with option -p) expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) - res = re.search(expr, - os.popen('/sbin/ldconfig -p 2>/dev/null').read()) + f = os.popen('/sbin/ldconfig -p 2>/dev/null') + try: + data = f.read() + finally: + f.close() + res = re.search(expr, data) if not res: # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable - res = re.search(expr, os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(expr, data) if not res: return None return res.group(0) @@ -197,8 +222,12 @@ # XXX assuming GLIBC's ldconfig (with option -p) expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \ % (abi_type, re.escape(name)) - res = re.search(expr, - os.popen('/sbin/ldconfig -p 2>/dev/null').read()) + f = os.popen('/sbin/ldconfig -p 2>/dev/null') + try: + data = f.read() + finally: + f.close() + res = re.search(expr, data) if not res: return None return res.group(1) From python-checkins at python.org Thu Oct 22 22:41:35 2009 From: python-checkins at python.org (eric.smith) Date: Thu, 22 Oct 2009 20:41:35 -0000 Subject: [Python-checkins] r75621 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Thu Oct 22 22:41:34 2009 New Revision: 75621 Log: Blocked revisions 75620 via svnmerge ........ r75620 | eric.smith | 2009-10-22 16:13:14 -0400 (Thu, 22 Oct 2009) | 1 line Per the discussion in issue6882, backport the try/finally work that was done to the py3k version (mostly in r59477, I think). ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Thu Oct 22 22:48:54 2009 From: python-checkins at python.org (eric.smith) Date: Thu, 22 Oct 2009 20:48:54 -0000 Subject: [Python-checkins] r75622 - python/branches/py3k Message-ID: Author: eric.smith Date: Thu Oct 22 22:48:54 2009 New Revision: 75622 Log: Blocked revisions 75620 via svnmerge ........ r75620 | eric.smith | 2009-10-22 16:13:14 -0400 (Thu, 22 Oct 2009) | 1 line Per the discussion in issue6882, backport the try/finally work that was done to the py3k version (mostly in r59477, I think). ........ Modified: python/branches/py3k/ (props changed) From nnorwitz at gmail.com Fri Oct 23 00:36:18 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 22 Oct 2009 18:36:18 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091022223618.GA27395@python.psfb.org> More important issues: ---------------------- test_itertools leaked [0, 32, 0] references, sum=32 test_ssl leaked [420, 0, 0] references, sum=420 Less important issues: ---------------------- test_cmd_line leaked [-25, 25, 0] references, sum=0 test_smtplib leaked [0, 88, 0] references, sum=88 test_socketserver leaked [84, -84, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Fri Oct 23 10:14:45 2009 From: python-checkins at python.org (georg.brandl) Date: Fri, 23 Oct 2009 08:14:45 -0000 Subject: [Python-checkins] r75623 - python/trunk/Doc/library/configparser.rst Message-ID: Author: georg.brandl Date: Fri Oct 23 10:14:44 2009 New Revision: 75623 Log: #7188: fix optionxform() docs. Modified: python/trunk/Doc/library/configparser.rst Modified: python/trunk/Doc/library/configparser.rst ============================================================================== --- python/trunk/Doc/library/configparser.rst (original) +++ python/trunk/Doc/library/configparser.rst Fri Oct 23 10:14:44 2009 @@ -334,12 +334,20 @@ .. method:: RawConfigParser.optionxform(option) - Transforms the option name *option* as found in an input file or as passed in by - client code to the form that should be used in the internal structures. The - default implementation returns a lower-case version of *option*; subclasses may - override this or client code can set an attribute of this name on instances to - affect this behavior. Setting this to :func:`str`, for example, would make - option names case sensitive. + Transforms the option name *option* as found in an input file or as passed in + by client code to the form that should be used in the internal structures. + The default implementation returns a lower-case version of *option*; + subclasses may override this or client code can set an attribute of this name + on instances to affect this behavior. + + You don't necessarily need to subclass a ConfigParser to use this method, you + can also re-set it on an instance, to a function that takes a string + argument. Setting it to ``str``, for example, would make option names case + sensitive:: + + cfgparser = ConfigParser() + ... + cfgparser.optionxform = str .. _configparser-objects: From nnorwitz at gmail.com Fri Oct 23 11:47:37 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 23 Oct 2009 05:47:37 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091023094737.GA22674@python.psfb.org> More important issues: ---------------------- test_ssl leaked [26, -26, 339] references, sum=339 test_urllib2_localnet leaked [-282, 0, 0] references, sum=-282 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_smtplib leaked [8, -102, 6] references, sum=-88 test_threading leaked [48, 48, 48] references, sum=144 test_zipimport_support leaked [-25, 25, 0] references, sum=0 From python-checkins at python.org Fri Oct 23 14:01:14 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 12:01:14 -0000 Subject: [Python-checkins] r75624 - python/trunk/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 14:01:13 2009 New Revision: 75624 Log: Fix Windows buildbot failure Modified: python/trunk/Lib/test/test_threading.py Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Fri Oct 23 14:01:13 2009 @@ -326,12 +326,11 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() - self.assertEqual(stdout, "Woke up, sleep function is: \n") + self.assertEqual(stdout.strip(), + "Woke up, sleep function is: ") stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() self.assertEqual(stderr, "") - - def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in # threading.enumerate() after it has been join()ed. From python-checkins at python.org Fri Oct 23 14:56:11 2009 From: python-checkins at python.org (eric.smith) Date: Fri, 23 Oct 2009 12:56:11 -0000 Subject: [Python-checkins] r75625 - python/branches/py3k/Lib/ctypes/util.py Message-ID: Author: eric.smith Date: Fri Oct 23 14:56:11 2009 New Revision: 75625 Log: Changed try/finally to contextlib.closing, as discussed in issue 6882. Modified: python/branches/py3k/Lib/ctypes/util.py Modified: python/branches/py3k/Lib/ctypes/util.py ============================================================================== --- python/branches/py3k/Lib/ctypes/util.py (original) +++ python/branches/py3k/Lib/ctypes/util.py Fri Oct 23 14:56:11 2009 @@ -1,4 +1,5 @@ import sys, os +import contextlib # find_library(name) returns the pathname of a library, or None. if os.name == "nt": @@ -117,11 +118,8 @@ if not f: return None cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f - f = os.popen(cmd) - try: + with contextlib.closing(os.popen(cmd)) as f: data = f.read() - finally: - f.close() res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data) if not res: return None @@ -138,11 +136,8 @@ rv = f.close() if rv == 10: raise OSError('objdump command not found') - f = os.popen(cmd) - try: + with contextlib.closing(os.popen(cmd)) as f: data = f.read() - finally: - f.close() res = re.search(r'\sSONAME\s+([^\s]+)', data) if not res: return None @@ -166,11 +161,8 @@ def find_library(name): ename = re.escape(name) expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename) - f = os.popen('/sbin/ldconfig -r 2>/dev/null') - try: + with contextlib.closing(os.popen('/sbin/ldconfig -r 2>/dev/null')) as f: data = f.read() - finally: - f.close() res = re.findall(expr, data) if not res: return _get_soname(_findLib_gcc(name)) @@ -182,20 +174,14 @@ def _findLib_ldconfig(name): # XXX assuming GLIBC's ldconfig (with option -p) expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) - f = os.popen('/sbin/ldconfig -p 2>/dev/null') - try: + with contextlib.closing(os.popen('/sbin/ldconfig -p 2>/dev/null')) as f: data = f.read() - finally: - f.close() res = re.search(expr, data) if not res: # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable - f = os.popen(cmd) - try: + with contextlib.closing(os.popen(cmd)) as f: data = f.read() - finally: - f.close() res = re.search(expr, data) if not res: return None @@ -219,11 +205,8 @@ # XXX assuming GLIBC's ldconfig (with option -p) expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \ % (abi_type, re.escape(name)) - f = os.popen('/sbin/ldconfig -p 2>/dev/null') - try: + with contextlib.closing(os.popen('/sbin/ldconfig -p 2>/dev/null')) as f: data = f.read() - finally: - f.close() res = re.search(expr, data) if not res: return None From python-checkins at python.org Fri Oct 23 14:57:15 2009 From: python-checkins at python.org (eric.smith) Date: Fri, 23 Oct 2009 12:57:15 -0000 Subject: [Python-checkins] r75626 - python/branches/release31-maint Message-ID: Author: eric.smith Date: Fri Oct 23 14:57:15 2009 New Revision: 75626 Log: Blocked revisions 75625 via svnmerge ........ r75625 | eric.smith | 2009-10-23 08:56:11 -0400 (Fri, 23 Oct 2009) | 1 line Changed try/finally to contextlib.closing, as discussed in issue 6882. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Fri Oct 23 15:04:52 2009 From: python-checkins at python.org (fred.drake) Date: Fri, 23 Oct 2009 13:04:52 -0000 Subject: [Python-checkins] r75627 - python/trunk/Doc/library/configparser.rst Message-ID: Author: fred.drake Date: Fri Oct 23 15:04:51 2009 New Revision: 75627 Log: add further note about what's passed to optionxform Modified: python/trunk/Doc/library/configparser.rst Modified: python/trunk/Doc/library/configparser.rst ============================================================================== --- python/trunk/Doc/library/configparser.rst (original) +++ python/trunk/Doc/library/configparser.rst Fri Oct 23 15:04:51 2009 @@ -349,6 +349,9 @@ ... cfgparser.optionxform = str + Note that when reading configuration files, whitespace around the + option names are stripped before :meth:``optionxform`` is called. + .. _configparser-objects: From python-checkins at python.org Fri Oct 23 19:13:38 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 17:13:38 -0000 Subject: [Python-checkins] r75628 - sandbox/trunk/newgil Message-ID: Author: antoine.pitrou Date: Fri Oct 23 19:13:38 2009 New Revision: 75628 Log: New branch for a GIL rewrite Added: sandbox/trunk/newgil/ - copied from r75627, /python/branches/py3k/ From python-checkins at python.org Fri Oct 23 19:20:30 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 17:20:30 -0000 Subject: [Python-checkins] r75629 - sandbox/trunk/newgil Message-ID: Author: antoine.pitrou Date: Fri Oct 23 19:20:30 2009 New Revision: 75629 Log: Initialized merge tracking via "svnmerge" with revisions "1-75627" from svn+ssh://pythondev at svn.python.org/python/branches/py3k Modified: sandbox/trunk/newgil/ (props changed) From python-checkins at python.org Fri Oct 23 19:22:12 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 17:22:12 -0000 Subject: [Python-checkins] r75630 - sandbox/trunk/newgil Message-ID: Author: antoine.pitrou Date: Fri Oct 23 19:22:12 2009 New Revision: 75630 Log: Try to fix the svnmerge property Modified: sandbox/trunk/newgil/ (props changed) From python-checkins at python.org Fri Oct 23 19:38:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 17:38:15 -0000 Subject: [Python-checkins] r75631 - in sandbox/trunk/newgil: Include/ceval.h Makefile.pre.in Modules/_io/fileio.c Modules/_multiprocessing/connection.h Modules/_multiprocessing/pipe_connection.c Modules/_multiprocessing/socket_connection.c Modules/_ssl.c Modules/bz2module.c Modules/posixmodule.c Modules/selectmodule.c Modules/socketmodule.c Objects/longobject.c Python/ceval.c Python/ceval_pthread.h Python/pystate.c Message-ID: Author: antoine.pitrou Date: Fri Oct 23 19:38:14 2009 New Revision: 75631 Log: Commit initial patch (from personal hg repo). Only POSIX-compatible for now. I plan to try and make it working on Windows. Added: sandbox/trunk/newgil/Python/ceval_pthread.h (contents, props changed) Modified: sandbox/trunk/newgil/Include/ceval.h sandbox/trunk/newgil/Makefile.pre.in sandbox/trunk/newgil/Modules/_io/fileio.c sandbox/trunk/newgil/Modules/_multiprocessing/connection.h sandbox/trunk/newgil/Modules/_multiprocessing/pipe_connection.c sandbox/trunk/newgil/Modules/_multiprocessing/socket_connection.c sandbox/trunk/newgil/Modules/_ssl.c sandbox/trunk/newgil/Modules/bz2module.c sandbox/trunk/newgil/Modules/posixmodule.c sandbox/trunk/newgil/Modules/selectmodule.c sandbox/trunk/newgil/Modules/socketmodule.c sandbox/trunk/newgil/Objects/longobject.c sandbox/trunk/newgil/Python/ceval.c sandbox/trunk/newgil/Python/pystate.c Modified: sandbox/trunk/newgil/Include/ceval.h ============================================================================== --- sandbox/trunk/newgil/Include/ceval.h (original) +++ sandbox/trunk/newgil/Include/ceval.h Fri Oct 23 19:38:14 2009 @@ -113,7 +113,7 @@ PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); /* this used to be handled on a per-thread basis - now just two globals */ -PyAPI_DATA(volatile int) _Py_Ticker; +// PyAPI_DATA(volatile int) _Py_Ticker; PyAPI_DATA(int) _Py_CheckInterval; /* Interface for threads. @@ -163,6 +163,7 @@ PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); +PyAPI_FUNC(void) PyEval_RestoreThreadPrio(PyThreadState *, int prio); #ifdef WITH_THREAD @@ -181,6 +182,8 @@ #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ } +#define Py_END_ALLOW_THREADS_PRIO(x) PyEval_RestoreThreadPrio(_save, (x)); \ + } #else /* !WITH_THREAD */ @@ -192,6 +195,7 @@ #endif /* !WITH_THREAD */ PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); +PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void); #ifdef __cplusplus Modified: sandbox/trunk/newgil/Makefile.pre.in ============================================================================== --- sandbox/trunk/newgil/Makefile.pre.in (original) +++ sandbox/trunk/newgil/Makefile.pre.in Fri Oct 23 19:38:14 2009 @@ -596,7 +596,7 @@ $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES) $(OPCODETARGETGEN) $(OPCODETARGETS_H) -Python/ceval.o: $(OPCODETARGETS_H) +Python/ceval.o: $(OPCODETARGETS_H) Python/ceval_pthread.h Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \ $(BYTESTR_DEPS) \ Modified: sandbox/trunk/newgil/Modules/_io/fileio.c ============================================================================== --- sandbox/trunk/newgil/Modules/_io/fileio.c (original) +++ sandbox/trunk/newgil/Modules/_io/fileio.c Fri Oct 23 19:38:14 2009 @@ -476,7 +476,7 @@ Py_BEGIN_ALLOW_THREADS errno = 0; n = read(self->fd, pbuf.buf, pbuf.len); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) } else n = -1; PyBuffer_Release(&pbuf); @@ -559,7 +559,7 @@ n = read(self->fd, PyBytes_AS_STRING(result) + total, newsize - total); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) if (n == 0) break; if (n < 0) { @@ -615,7 +615,7 @@ Py_BEGIN_ALLOW_THREADS errno = 0; n = read(self->fd, ptr, size); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) } else n = -1; Modified: sandbox/trunk/newgil/Modules/_multiprocessing/connection.h ============================================================================== --- sandbox/trunk/newgil/Modules/_multiprocessing/connection.h (original) +++ sandbox/trunk/newgil/Modules/_multiprocessing/connection.h Fri Oct 23 19:38:14 2009 @@ -367,7 +367,7 @@ Py_BEGIN_ALLOW_THREADS res = conn_poll(self, timeout, _save); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == TRUE) switch (res) { case TRUE: Modified: sandbox/trunk/newgil/Modules/_multiprocessing/pipe_connection.c ============================================================================== --- sandbox/trunk/newgil/Modules/_multiprocessing/pipe_connection.c (original) +++ sandbox/trunk/newgil/Modules/_multiprocessing/pipe_connection.c Fri Oct 23 19:38:14 2009 @@ -49,7 +49,7 @@ Py_BEGIN_ALLOW_THREADS ret = ReadFile(conn->handle, buffer, MIN(buflength, maxlength), &length, NULL); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(ret) if (ret) return length; @@ -75,7 +75,7 @@ Py_BEGIN_ALLOW_THREADS ret = ReadFile(conn->handle, *newbuffer+length, left, &length, NULL); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(ret) if (ret) { assert(length == left); return full_length; Modified: sandbox/trunk/newgil/Modules/_multiprocessing/socket_connection.c ============================================================================== --- sandbox/trunk/newgil/Modules/_multiprocessing/socket_connection.c (original) +++ sandbox/trunk/newgil/Modules/_multiprocessing/socket_connection.c Fri Oct 23 19:38:14 2009 @@ -124,7 +124,7 @@ Py_BEGIN_ALLOW_THREADS res = _conn_recvall(conn->handle, (char*)&ulength, 4); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == MP_SUCCESS) if (res < 0) return res; @@ -135,7 +135,7 @@ if (ulength <= buflength) { Py_BEGIN_ALLOW_THREADS res = _conn_recvall(conn->handle, buffer, (size_t)ulength); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == MP_SUCCESS) return res < 0 ? res : ulength; } else { *newbuffer = PyMem_Malloc((size_t)ulength); @@ -143,7 +143,7 @@ return MP_MEMORY_ERROR; Py_BEGIN_ALLOW_THREADS res = _conn_recvall(conn->handle, *newbuffer, (size_t)ulength); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == MP_SUCCESS) return res < 0 ? (Py_ssize_t)res : (Py_ssize_t)ulength; } } Modified: sandbox/trunk/newgil/Modules/_ssl.c ============================================================================== --- sandbox/trunk/newgil/Modules/_ssl.c (original) +++ sandbox/trunk/newgil/Modules/_ssl.c Fri Oct 23 19:38:14 2009 @@ -24,6 +24,9 @@ #define PySSL_UNBLOCK_THREADS if (_ssl_locks_count>0){_save = PyEval_SaveThread()}; #define PySSL_END_ALLOW_THREADS if (_ssl_locks_count>0){PyEval_RestoreThread(_save);} \ } +#define PySSL_END_ALLOW_THREADS_PRIO(x) \ + if (_ssl_locks_count>0){PyEval_RestoreThreadPrio(_save, (x));} \ + } #else /* no WITH_THREAD */ @@ -31,6 +34,7 @@ #define PySSL_BLOCK_THREADS #define PySSL_UNBLOCK_THREADS #define PySSL_END_ALLOW_THREADS +#define PySSL_END_ALLOW_THREADS_PRIO(x) #endif @@ -1110,7 +1114,7 @@ timeout = (int)(s->sock_timeout * 1000 + 0.5); PySSL_BEGIN_ALLOW_THREADS rc = poll(&pollfd, 1, timeout); - PySSL_END_ALLOW_THREADS + PySSL_END_ALLOW_THREADS_PRIO(rc > 0) goto normal_return; } @@ -1134,7 +1138,7 @@ rc = select(s->sock_fd+1, NULL, &fds, NULL, &tv); else rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv); - PySSL_END_ALLOW_THREADS + PySSL_END_ALLOW_THREADS_PRIO(rc > 0) #ifdef HAVE_POLL normal_return: @@ -1294,7 +1298,7 @@ /* first check if there are bytes ready to be read */ PySSL_BEGIN_ALLOW_THREADS count = SSL_pending(self->ssl); - PySSL_END_ALLOW_THREADS + PySSL_END_ALLOW_THREADS_PRIO(count > 0) if (!count) { sockstate = check_socket_and_wait_for_timeout(sock, 0); @@ -1316,7 +1320,7 @@ PySSL_BEGIN_ALLOW_THREADS count = SSL_read(self->ssl, mem, len); err = SSL_get_error(self->ssl, count); - PySSL_END_ALLOW_THREADS + PySSL_END_ALLOW_THREADS_PRIO(count > 0) if (PyErr_CheckSignals()) goto error; if (err == SSL_ERROR_WANT_READ) { Modified: sandbox/trunk/newgil/Modules/bz2module.c ============================================================================== --- sandbox/trunk/newgil/Modules/bz2module.c (original) +++ sandbox/trunk/newgil/Modules/bz2module.c Fri Oct 23 19:38:14 2009 @@ -248,7 +248,8 @@ break; *buf++ = c; } while (bzerror == BZ_OK && c != '\n' && buf != end); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(bzerror == BZ_STREAM_END || + bzerror == BZ_OK) if (bzerror == BZ_STREAM_END) { f->size = f->pos; f->mode = MODE_READ_EOF; @@ -322,7 +323,8 @@ } Py_BEGIN_ALLOW_THREADS chunksize = BZ2_bzRead(&bzerror, f->fp, f->f_buf, bufsize); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(bzerror == BZ_STREAM_END || + bzerror == BZ_OK) f->pos += chunksize; if (bzerror == BZ_STREAM_END) { f->size = f->pos; @@ -443,7 +445,8 @@ BUF(ret)+bytesread, buffersize-bytesread); self->pos += chunksize; - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(bzerror == BZ_STREAM_END || + bzerror == BZ_OK) bytesread += chunksize; if (bzerror == BZ_STREAM_END) { self->size = self->pos; @@ -576,7 +579,8 @@ nread = BZ2_bzRead(&bzerror, self->fp, buffer+nfilled, buffersize-nfilled); self->pos += nread; - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(bzerror == BZ_STREAM_END || + bzerror == BZ_OK) if (bzerror == BZ_STREAM_END) { self->size = self->pos; self->mode = MODE_READ_EOF; @@ -933,7 +937,9 @@ chunksize = BZ2_bzRead(&bzerror, self->fp, buffer, buffersize); self->pos += chunksize; - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO( + bzerror == BZ_STREAM_END || + bzerror == BZ_OK) bytesread += chunksize; if (bzerror == BZ_STREAM_END) { @@ -992,7 +998,8 @@ Py_BEGIN_ALLOW_THREADS chunksize = BZ2_bzRead(&bzerror, self->fp, buffer, readsize); self->pos += chunksize; - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(bzerror == BZ_STREAM_END || + bzerror == BZ_OK) bytesread += chunksize; if (bzerror == BZ_STREAM_END) { self->size = self->pos; Modified: sandbox/trunk/newgil/Modules/posixmodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/posixmodule.c (original) +++ sandbox/trunk/newgil/Modules/posixmodule.c Fri Oct 23 19:38:14 2009 @@ -2197,7 +2197,7 @@ } Py_BEGIN_ALLOW_THREADS result = FindNextFileW(hFindFile, &wFileData); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(result) /* FindNextFile sets error to ERROR_NO_MORE_FILES if it got to the end of the directory. */ if (!result && GetLastError() != ERROR_NO_MORE_FILES) { @@ -2270,7 +2270,7 @@ } Py_BEGIN_ALLOW_THREADS result = FindNextFile(hFindFile, &FileData); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(result) /* FindNextFile sets error to ERROR_NO_MORE_FILES if it got to the end of the directory. */ if (!result && GetLastError() != ERROR_NO_MORE_FILES) { @@ -2395,7 +2395,7 @@ errno = 0; Py_BEGIN_ALLOW_THREADS ep = readdir(dirp); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(ep || !errno) if (ep == NULL) { if (errno == 0) { break; @@ -4461,7 +4461,7 @@ Py_BEGIN_ALLOW_THREADS pid = wait3(&status, options, &ru); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(pid > 0) return wait_helper(pid, WAIT_STATUS_INT(status), &ru); } @@ -4486,7 +4486,7 @@ Py_BEGIN_ALLOW_THREADS pid = wait4(pid, &status, options, &ru); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(pid > 0) return wait_helper(pid, WAIT_STATUS_INT(status), &ru); } @@ -4509,7 +4509,7 @@ return NULL; Py_BEGIN_ALLOW_THREADS pid = waitpid(pid, &status, options); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(pid > 0) if (pid == -1) return posix_error(); @@ -4533,7 +4533,7 @@ return NULL; Py_BEGIN_ALLOW_THREADS pid = _cwait(&status, pid, options); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(pid > 0) if (pid == -1) return posix_error(); @@ -4556,7 +4556,7 @@ Py_BEGIN_ALLOW_THREADS pid = wait(&status); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(pid > 0) if (pid == -1) return posix_error(); @@ -5037,7 +5037,7 @@ return posix_error(); Py_BEGIN_ALLOW_THREADS n = read(fd, PyBytes_AS_STRING(buffer), size); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) if (n < 0) { Py_DECREF(buffer); return posix_error(); Modified: sandbox/trunk/newgil/Modules/selectmodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/selectmodule.c (original) +++ sandbox/trunk/newgil/Modules/selectmodule.c Fri Oct 23 19:38:14 2009 @@ -273,7 +273,7 @@ Py_BEGIN_ALLOW_THREADS n = select(max, &ifdset, &ofdset, &efdset, tvp); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) #ifdef MS_WINDOWS if (n == SOCKET_ERROR) { @@ -532,7 +532,7 @@ /* call poll() */ Py_BEGIN_ALLOW_THREADS poll_result = poll(self->ufds, self->ufd_len, timeout); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(poll_result > 0) if (poll_result < 0) { PyErr_SetFromErrno(SelectError); @@ -1023,7 +1023,7 @@ Py_BEGIN_ALLOW_THREADS nfds = epoll_wait(self->epfd, evs, maxevents, timeout); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(nfds > 0) if (nfds < 0) { PyErr_SetFromErrno(PyExc_IOError); goto error; @@ -1578,7 +1578,7 @@ Py_BEGIN_ALLOW_THREADS gotevents = kevent(self->kqfd, chl, nchanges, evl, nevents, ptimeoutspec); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(gotevents > 0) if (gotevents == -1) { PyErr_SetFromErrno(PyExc_OSError); Modified: sandbox/trunk/newgil/Modules/socketmodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/socketmodule.c (original) +++ sandbox/trunk/newgil/Modules/socketmodule.c Fri Oct 23 19:38:14 2009 @@ -1591,7 +1591,7 @@ timeout = internal_select(s, 0); if (!timeout) newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(!timeout) if (timeout == 1) { PyErr_SetString(socket_timeout, "timed out"); @@ -1967,7 +1967,7 @@ Py_BEGIN_ALLOW_THREADS res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == 0) if (timeout == 1) { PyErr_SetString(socket_timeout, "timed out"); @@ -2001,7 +2001,7 @@ Py_BEGIN_ALLOW_THREADS res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(res == 0) /* Signals are not errors (though they may raise exceptions). Adapted from PyErr_SetFromErrnoWithFilenameObject(). */ @@ -2155,7 +2155,7 @@ timeout = internal_select(s, 0); if (!timeout) outlen = recv(s->sock_fd, cbuf, len, flags); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(outlen > 0) if (timeout == 1) { PyErr_SetString(socket_timeout, "timed out"); @@ -2186,7 +2186,7 @@ timeout = internal_select(s, 0); if (!timeout) nread = recv(s->sock_fd, read_buf, segment, flags); - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(nread > 0) if (timeout == 1) { PyErr_SetString(socket_timeout, "timed out"); @@ -2370,7 +2370,7 @@ SAS2SA(&addrbuf), &addrlen); #endif } - Py_END_ALLOW_THREADS + Py_END_ALLOW_THREADS_PRIO(n > 0) if (timeout == 1) { PyErr_SetString(socket_timeout, "timed out"); Modified: sandbox/trunk/newgil/Objects/longobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/longobject.c (original) +++ sandbox/trunk/newgil/Objects/longobject.c Fri Oct 23 19:38:14 2009 @@ -95,11 +95,16 @@ #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) +#if 0 #define SIGCHECK(PyTryBlock) \ if (--_Py_Ticker < 0) { \ _Py_Ticker = _Py_CheckInterval; \ if (PyErr_CheckSignals()) PyTryBlock \ } +#endif + +#define SIGCHECK(PyTryBlock) \ + if (PyErr_CheckSignals()) PyTryBlock \ /* forward declaration */ static int bits_in_digit(digit d); Modified: sandbox/trunk/newgil/Python/ceval.c ============================================================================== --- sandbox/trunk/newgil/Python/ceval.c (original) +++ sandbox/trunk/newgil/Python/ceval.c Fri Oct 23 19:38:14 2009 @@ -198,6 +198,28 @@ #endif +#define COMPUTE_EVAL_BREAKER() \ + (eval_breaker = gil_drop_request | pendingcalls_to_do | pending_async_exc) + +#define SET_GIL_DROP_REQUEST() \ + do { gil_drop_request = 1; eval_breaker = 1; } while (0) + +#define RESET_GIL_DROP_REQUEST() \ + do { gil_drop_request = 0; COMPUTE_EVAL_BREAKER(); } while (0) + +#define SIGNAL_PENDING_CALLS() \ + do { pendingcalls_to_do = 1; eval_breaker = 1; } while (0) + +#define UNSIGNAL_PENDING_CALLS() \ + do { pendingcalls_to_do = 0; COMPUTE_EVAL_BREAKER(); } while (0) + +#define SIGNAL_ASYNC_EXC() \ + do { pending_async_exc = 1; eval_breaker = 1; } while (0) + +#define UNSIGNAL_ASYNC_EXC() \ + do { pending_async_exc = 0; COMPUTE_EVAL_BREAKER(); } while (0) + + #ifdef WITH_THREAD #ifdef HAVE_ERRNO_H @@ -205,36 +227,54 @@ #endif #include "pythread.h" -static PyThread_type_lock interpreter_lock = 0; /* This is the GIL */ static PyThread_type_lock pending_lock = 0; /* for pending calls */ static long main_thread = 0; +/* This single variable consolidates all requests to break out of the fast path + in the eval loop. */ +static volatile int eval_breaker = 0; +/* Request for droppping the GIL */ +static volatile int gil_drop_request = 0; +/* Request for running pending calls */ +static volatile int pendingcalls_to_do = 0; +static volatile int pending_async_exc = 0; + +#include "ceval_pthread.h" int PyEval_ThreadsInitialized(void) { - return interpreter_lock != 0; + return gil_created(); } void PyEval_InitThreads(void) { - if (interpreter_lock) + if (gil_created()) return; - interpreter_lock = PyThread_allocate_lock(); - PyThread_acquire_lock(interpreter_lock, 1); + create_gil(); + take_gil(PyThreadState_GET()); main_thread = PyThread_get_thread_ident(); + if (!pending_lock) + pending_lock = PyThread_allocate_lock(); } void PyEval_AcquireLock(void) { - PyThread_acquire_lock(interpreter_lock, 1); + PyThreadState *tstate = PyThreadState_GET(); + if (tstate == NULL) + Py_FatalError("PyEval_AcquireLock: current thread state is NULL"); + take_gil(tstate); } void PyEval_ReleaseLock(void) { - PyThread_release_lock(interpreter_lock); + /* This function must succeed when the current thread state is NULL, + therefore we avoid PyThreadState_GET() which prints a fatal error + in debug mode. + */ + drop_gil(_PyThreadState_Current); } void @@ -243,8 +283,8 @@ if (tstate == NULL) Py_FatalError("PyEval_AcquireThread: NULL new thread state"); /* Check someone has called PyEval_InitThreads() to create the lock */ - assert(interpreter_lock); - PyThread_acquire_lock(interpreter_lock, 1); + assert(gil_created()); + take_gil(tstate); if (PyThreadState_Swap(tstate) != NULL) Py_FatalError( "PyEval_AcquireThread: non-NULL old thread state"); @@ -257,7 +297,7 @@ Py_FatalError("PyEval_ReleaseThread: NULL thread state"); if (PyThreadState_Swap(NULL) != tstate) Py_FatalError("PyEval_ReleaseThread: wrong thread state"); - PyThread_release_lock(interpreter_lock); + drop_gil(tstate); } /* This function is called from PyOS_AfterFork to ensure that newly @@ -269,17 +309,17 @@ PyEval_ReInitThreads(void) { PyObject *threading, *result; - PyThreadState *tstate; + PyThreadState *tstate = PyThreadState_GET(); - if (!interpreter_lock) + if (!gil_created()) return; /*XXX Can't use PyThread_free_lock here because it does too much error-checking. Doing this cleanly would require adding a new function to each thread_*.h. Instead, just create a new lock and waste a little bit of memory */ - interpreter_lock = PyThread_allocate_lock(); + recreate_gil(); pending_lock = PyThread_allocate_lock(); - PyThread_acquire_lock(interpreter_lock, 1); + take_gil(tstate); main_thread = PyThread_get_thread_ident(); /* Update the threading module with the new state. @@ -299,7 +339,21 @@ Py_DECREF(result); Py_DECREF(threading); } -#endif + +#else +static int eval_breaker = 0; +static int gil_drop_request = 0; +static int pending_async_exc = 0; +#endif /* WITH_THREAD */ + +/* This function is used to signal that async exceptions are waiting to be + raised, therefore it is also useful in non-threaded builds. */ + +void +_PyEval_SignalAsyncExc(void) +{ + SIGNAL_ASYNC_EXC(); +} /* Functions save_thread and restore_thread are always defined so dynamically loaded modules needn't be compiled separately for use @@ -312,27 +366,36 @@ if (tstate == NULL) Py_FatalError("PyEval_SaveThread: NULL tstate"); #ifdef WITH_THREAD - if (interpreter_lock) - PyThread_release_lock(interpreter_lock); + if (gil_created()) + drop_gil(tstate); #endif return tstate; } void -PyEval_RestoreThread(PyThreadState *tstate) +PyEval_RestoreThreadPrio(PyThreadState *tstate, int prio) { if (tstate == NULL) Py_FatalError("PyEval_RestoreThread: NULL tstate"); #ifdef WITH_THREAD - if (interpreter_lock) { + if (gil_created()) { int err = errno; - PyThread_acquire_lock(interpreter_lock, 1); + if (prio) + take_gil_prio(tstate); + else + take_gil(tstate); errno = err; } #endif PyThreadState_Swap(tstate); } +void +PyEval_RestoreThread(PyThreadState *tstate) +{ + PyEval_RestoreThreadPrio(tstate, 0); +} + /* Mechanism whereby asynchronously executing callbacks (e.g. UNIX signal handlers or Mac I/O completion routines) can schedule calls @@ -372,7 +435,6 @@ } pendingcalls[NPENDINGCALLS]; static int pendingfirst = 0; static int pendinglast = 0; -static volatile int pendingcalls_to_do = 1; /* trigger initialization of lock */ static char pendingbusy = 0; int @@ -411,8 +473,8 @@ pendinglast = j; } /* signal main loop */ - _Py_Ticker = 0; - pendingcalls_to_do = 1; +// _Py_Ticker = 0; + SIGNAL_PENDING_CALLS(); if (lock != NULL) PyThread_release_lock(lock); return result; @@ -454,7 +516,11 @@ arg = pendingcalls[j].arg; pendingfirst = (j + 1) % NPENDINGCALLS; } - pendingcalls_to_do = pendingfirst != pendinglast; + if (pendingfirst != pendinglast) + SIGNAL_PENDING_CALLS(); + else + UNSIGNAL_PENDING_CALLS(); +// pendingcalls_to_do = pendingfirst != pendinglast; PyThread_release_lock(pending_lock); /* having released the lock, perform the callback */ if (func == NULL) @@ -520,8 +586,7 @@ pendingcalls[i].arg = arg; pendinglast = j; - _Py_Ticker = 0; - pendingcalls_to_do = 1; /* Signal main loop */ + SIGNAL_PENDING_CALLS(); busy = 0; /* XXX End critical section */ return 0; @@ -534,7 +599,7 @@ if (busy) return 0; busy = 1; - pendingcalls_to_do = 0; + UNSIGNAL_PENDING_CALLS(); for (;;) { int i; int (*func)(void *); @@ -547,7 +612,7 @@ pendingfirst = (i + 1) % NPENDINGCALLS; if (func(arg) < 0) { busy = 0; - pendingcalls_to_do = 1; /* We're not done yet */ + SIGNAL_PENDING_CALLS(); /* We're not done yet */ return -1; } } @@ -642,8 +707,10 @@ /* for manipulating the thread switch and periodic "stuff" - used to be per thread, now just a pair o' globals */ -int _Py_CheckInterval = 100; -volatile int _Py_Ticker = 0; /* so that we hit a "tick" first thing */ +int _Py_CheckInterval = 1000; +// volatile int _Py_Ticker = 0; /* so that we hit a "tick" first thing */ + + PyObject * PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) @@ -773,10 +840,7 @@ #define DISPATCH() \ { \ - /* Avoid multiple loads from _Py_Ticker despite `volatile` */ \ - int _tick = _Py_Ticker - 1; \ - _Py_Ticker = _tick; \ - if (_tick >= 0) { \ + if (!eval_breaker) { \ FAST_DISPATCH(); \ } \ continue; \ @@ -1150,13 +1214,14 @@ async I/O handler); see Py_AddPendingCall() and Py_MakePendingCalls() above. */ - if (--_Py_Ticker < 0) { +// if (--_Py_Ticker < 0) { + if (eval_breaker) { if (*next_instr == SETUP_FINALLY) { /* Make the last opcode before a try: finally: block uninterruptable. */ goto fast_next_opcode; } - _Py_Ticker = _Py_CheckInterval; +// _Py_Ticker = _Py_CheckInterval; tstate->tick_counter++; #ifdef WITH_TSC ticked = 1; @@ -1166,39 +1231,38 @@ why = WHY_EXCEPTION; goto on_error; } - if (pendingcalls_to_do) +// if (pendingcalls_to_do) /* MakePendingCalls() didn't succeed. Force early re-execution of this "periodic" code, possibly after a thread switch */ - _Py_Ticker = 0; +// _Py_Ticker = 0; } +// } + if (gil_drop_request) { #ifdef WITH_THREAD - if (interpreter_lock) { /* Give another thread a chance */ - if (PyThreadState_Swap(NULL) != tstate) Py_FatalError("ceval: tstate mix-up"); - PyThread_release_lock(interpreter_lock); - + drop_gil(tstate); + /* Other threads may run now */ - - PyThread_acquire_lock(interpreter_lock, 1); + + take_gil(tstate); if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate"); - - /* Check for thread interrupts */ - - if (tstate->async_exc != NULL) { - x = tstate->async_exc; - tstate->async_exc = NULL; - PyErr_SetNone(x); - Py_DECREF(x); - why = WHY_EXCEPTION; - goto on_error; - } - } #endif + } + /* Check for asynchronous exceptions. */ + if (tstate->async_exc != NULL) { + x = tstate->async_exc; + tstate->async_exc = NULL; + UNSIGNAL_ASYNC_EXC(); + PyErr_SetNone(x); + Py_DECREF(x); + why = WHY_EXCEPTION; + goto on_error; + } } fast_next_opcode: Added: sandbox/trunk/newgil/Python/ceval_pthread.h ============================================================================== --- (empty file) +++ sandbox/trunk/newgil/Python/ceval_pthread.h Fri Oct 23 19:38:14 2009 @@ -0,0 +1,258 @@ +/* + * Implementation of the Global Interpreter Lock (GIL) for POSIX pthreads. + */ + +#include +#include +#include + +/* We assume all modern POSIX systems have gettimeofday() */ +#ifdef GETTIMEOFDAY_NO_TZ +#define GETTIMEOFDAY(ptv) gettimeofday(ptv) +#else +#define GETTIMEOFDAY(ptv) gettimeofday(ptv, (struct timezone *)NULL) +#endif + +#define ADD_MILLISECONDS(tv, interval) \ +do { \ + tv.tv_usec += interval * 1000; \ + tv.tv_sec += tv.tv_usec / 1000000; \ + tv.tv_usec %= 1000000; \ +} while (0) + +/* milliseconds */ +#define INTERVAL 5 + +/* Enable if you want to force the switching of threads at least every INTERVAL */ +#undef FORCE_SWITCHING +#define FORCE_SWITCHING + + +#undef TRACE_PRIO +// #define TRACE_PRIO + +#define YIELD_IF_PRIO_REQUEST() \ +do { \ + if (prio_request) { \ + if (pthread_mutex_lock(&prio_mutex)) \ + Py_FatalError("pthread_mutex_lock(&prio_mutex) failed"); \ + if (pthread_mutex_unlock(&prio_mutex)) \ + Py_FatalError("pthread_mutex_unlock(&prio_mutex) failed"); \ + } \ +} while (0) + +/* Whether the GIL is already taken (-1 if uninitialized) */ +static volatile int gil_locked = -1; +/* Number of GIL switches since the beginning */ +static unsigned long gil_switch_number = 0; +/* Last thread holding / having held the GIL */ +static PyThreadState *gil_last_holder = NULL; + +/* This condition variable allows to put threads to sleep. + In addition, the mutex also protects the above variables. */ +static pthread_cond_t gil_cond; +static pthread_mutex_t gil_mutex; +/* This mutex is taken when a priority request is made, and released when + it is finally honoured. + Other threads can sleep by trying to lock the mutex. */ +static pthread_mutex_t prio_mutex; +/* The thread making the prio request, or NULL. */ +static volatile PyThreadState *prio_request = NULL; + +#ifdef FORCE_SWITCHING +/* This condition variable forces the GIL-releasing thread to wait for + the scheduling of a GIL-awaiting thread, if any. */ +static pthread_cond_t switch_cond; +static pthread_mutex_t switch_mutex; +#endif + +static int gil_created(void) +{ + return gil_locked >= 0; +} + +static void create_gil(void) +{ + if (pthread_mutex_init(&gil_mutex, NULL) + || pthread_mutex_init(&prio_mutex, NULL) +#ifdef FORCE_SWITCHING + || pthread_mutex_init(&switch_mutex, NULL) +#endif + ) + Py_FatalError("create_gil: pthread_mutex_init() failed"); + if (pthread_cond_init(&gil_cond, NULL) +#ifdef FORCE_SWITCHING + || pthread_cond_init(&switch_cond, NULL) +#endif + ) + Py_FatalError("create_gil: pthread_cond_init() failed"); + gil_locked = 0; + gil_last_holder = NULL; + prio_request = NULL; +} + +static void recreate_gil(void) +{ + create_gil(); +} + +static void drop_gil(PyThreadState *tstate) +{ + /* NOTE: tstate is allowed to be NULL. */ + if (!gil_locked) + Py_FatalError("drop_gil: GIL is not locked"); + if (tstate != NULL && tstate != gil_last_holder) + Py_FatalError("drop_gil: wrong thread state"); + + if (pthread_mutex_lock(&gil_mutex)) + Py_FatalError("drop_gil: pthread_mutex_lock() failed"); + gil_locked = 0; + if (pthread_cond_signal(&gil_cond)) + Py_FatalError("drop_gil: pthread_cond_signal() failed"); + if (pthread_mutex_unlock(&gil_mutex)) + Py_FatalError("drop_gil: pthread_mutex_unlock() failed"); + +#ifdef FORCE_SWITCHING + if (gil_drop_request) { + if (pthread_mutex_lock(&switch_mutex)) + Py_FatalError("drop_gil: pthread_mutex_lock(&switch_mutex) failed"); + /* Not switched yet => wait */ + if (gil_last_holder == tstate && + pthread_cond_wait(&switch_cond, &switch_mutex)) + Py_FatalError("drop_gil: pthread_cond_wait(&switch_cond) failed"); + if (pthread_mutex_unlock(&switch_mutex)) + Py_FatalError("drop_gil: pthread_mutex_unlock(&switch_mutex) failed"); + } +#endif +} + +static void _take_gil(PyThreadState *tstate, int prio) +{ + int err; + if (tstate == NULL) + Py_FatalError("take_gil: NULL tstate"); + + /* If another thread is requesting priority, give it a chance to run + before we take the mutex. + */ + YIELD_IF_PRIO_REQUEST(); + + err = errno; + if (pthread_mutex_lock(&gil_mutex)) + Py_FatalError("take_gil: pthread_mutex_lock() failed"); + + if (!gil_locked) { + prio = 0; + goto _ready; + } + + if (prio) { +#ifdef TRACE_PRIO + struct timeval tv; + GETTIMEOFDAY(&tv); + printf("trying to take gil with prio: %.3f <--\n", + tv.tv_sec + tv.tv_usec / 1000000.0); +#endif + if (!prio_request) { + if (pthread_mutex_lock(&prio_mutex)) + Py_FatalError("take_gil: pthread_mutex_lock(&prio_mutex) failed"); + prio_request = tstate; + } + else + prio = 0; + } + while (gil_locked) { + int r; + unsigned long saved_switchnum; + struct timespec ts; + struct timeval now, deadline; + + if (prio_request) { + /* Tell the eval loop the GIL must be dropped as soon as possible */ + SET_GIL_DROP_REQUEST(); + if (!prio) { + /* If another thread is making the prio_request, give it a + chance to run and take the mutex. */ + pthread_mutex_unlock(&gil_mutex); + YIELD_IF_PRIO_REQUEST(); + pthread_mutex_lock(&gil_mutex); + } + } + + GETTIMEOFDAY(&now); + deadline = now; + ADD_MILLISECONDS(deadline, INTERVAL); + ts.tv_sec = deadline.tv_sec; + ts.tv_nsec = deadline.tv_usec * 1000; + + saved_switchnum = gil_switch_number; + r = pthread_cond_timedwait(&gil_cond, &gil_mutex, &ts); + + if (r == ETIMEDOUT) { + /* If no switch occurred in the meantime, it is time to ask + the GIL-holding thread to drop it. */ + if (gil_locked && gil_switch_number == saved_switchnum) { + SET_GIL_DROP_REQUEST(); + } + } + else if (r) + Py_FatalError("take_gil: pthread_cond_timedwait() failed"); + else { + /* We were woken up for no reason, ignore. */ + } + } +_ready: +#ifdef FORCE_SWITCHING + /* This mutex must be taken before modifying gil_last_holder (see drop_gil()). */ + if (pthread_mutex_lock(&switch_mutex)) + Py_FatalError("take_gil: pthread_mutex_lock() failed"); +#endif + /* We now hold the GIL */ + gil_locked = 1; + + if (tstate != gil_last_holder) { + gil_last_holder = tstate; + ++gil_switch_number; +#ifdef TRACE_PRIO + if (prio) { + struct timeval tv; + GETTIMEOFDAY(&tv); + printf("gil taken with prio: %.3f\n", + tv.tv_sec + tv.tv_usec / 1000000.0); + } +#endif + } +#ifdef FORCE_SWITCHING + if (pthread_cond_signal(&switch_cond)) + Py_FatalError("take_gil: pthread_cond_signal() failed"); + if (pthread_mutex_unlock(&switch_mutex)) + Py_FatalError("take_gil: pthread_mutex_unlock() failed"); +#endif + if (prio) { + /* The prio request was granted. */ + prio_request = NULL; + if (pthread_mutex_unlock(&prio_mutex)) + Py_FatalError("take_gil: pthread_mutex_unlock(&prio_mutex) failed"); + } + if (gil_drop_request && !prio_request) { + /* No prio_request pending. */ + RESET_GIL_DROP_REQUEST(); + } + if (tstate->async_exc != NULL) { + _PyEval_SignalAsyncExc(); + } + + if (pthread_mutex_unlock(&gil_mutex)) + Py_FatalError("take_gil: pthread_mutex_unlock() failed"); + errno = err; +} + +static void take_gil(PyThreadState *tstate) +{ + _take_gil(tstate, 0); +} + +static void take_gil_prio(PyThreadState *tstate) +{ + _take_gil(tstate, 1); +} Modified: sandbox/trunk/newgil/Python/pystate.c ============================================================================== --- sandbox/trunk/newgil/Python/pystate.c (original) +++ sandbox/trunk/newgil/Python/pystate.c Fri Oct 23 19:38:14 2009 @@ -434,6 +434,7 @@ p->async_exc = exc; HEAD_UNLOCK(); Py_XDECREF(old_exc); + _PyEval_SignalAsyncExc(); return 1; } } From python-checkins at python.org Fri Oct 23 19:56:42 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 17:56:42 -0000 Subject: [Python-checkins] r75632 - in sandbox/trunk/newgil: Include/ceval.h Include/pystate.h Include/sysmodule.h Objects/longobject.c Python/ceval.c Python/sysmodule.c Message-ID: Author: antoine.pitrou Date: Fri Oct 23 19:56:41 2009 New Revision: 75632 Log: _Py_Ticker was not quite dead Modified: sandbox/trunk/newgil/Include/ceval.h sandbox/trunk/newgil/Include/pystate.h sandbox/trunk/newgil/Include/sysmodule.h sandbox/trunk/newgil/Objects/longobject.c sandbox/trunk/newgil/Python/ceval.c sandbox/trunk/newgil/Python/sysmodule.c Modified: sandbox/trunk/newgil/Include/ceval.h ============================================================================== --- sandbox/trunk/newgil/Include/ceval.h (original) +++ sandbox/trunk/newgil/Include/ceval.h Fri Oct 23 19:56:41 2009 @@ -112,10 +112,6 @@ PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); -/* this used to be handled on a per-thread basis - now just two globals */ -// PyAPI_DATA(volatile int) _Py_Ticker; -PyAPI_DATA(int) _Py_CheckInterval; - /* Interface for threads. A module that plans to do a blocking system call (or something else Modified: sandbox/trunk/newgil/Include/pystate.h ============================================================================== --- sandbox/trunk/newgil/Include/pystate.h (original) +++ sandbox/trunk/newgil/Include/pystate.h Fri Oct 23 19:56:41 2009 @@ -88,6 +88,8 @@ PyObject *dict; /* Stores per-thread state */ + /* XXX doesn't mean anything anymore (the comment below is obsolete) + => deprecate or remove? */ /* tick_counter is incremented whenever the check_interval ticker * reaches zero. The purpose is to give a useful measure of the number * of interpreted bytecode instructions in a given thread. This Modified: sandbox/trunk/newgil/Include/sysmodule.h ============================================================================== --- sandbox/trunk/newgil/Include/sysmodule.h (original) +++ sandbox/trunk/newgil/Include/sysmodule.h Fri Oct 23 19:56:41 2009 @@ -18,7 +18,6 @@ Py_GCC_ATTRIBUTE((format(printf, 1, 2))); PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc; -PyAPI_DATA(int) _PySys_CheckInterval; PyAPI_FUNC(void) PySys_ResetWarnOptions(void); PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *); Modified: sandbox/trunk/newgil/Objects/longobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/longobject.c (original) +++ sandbox/trunk/newgil/Objects/longobject.c Fri Oct 23 19:56:41 2009 @@ -95,14 +95,6 @@ #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) -#if 0 -#define SIGCHECK(PyTryBlock) \ - if (--_Py_Ticker < 0) { \ - _Py_Ticker = _Py_CheckInterval; \ - if (PyErr_CheckSignals()) PyTryBlock \ - } -#endif - #define SIGCHECK(PyTryBlock) \ if (PyErr_CheckSignals()) PyTryBlock \ Modified: sandbox/trunk/newgil/Python/ceval.c ============================================================================== --- sandbox/trunk/newgil/Python/ceval.c (original) +++ sandbox/trunk/newgil/Python/ceval.c Fri Oct 23 19:56:41 2009 @@ -236,6 +236,7 @@ static volatile int gil_drop_request = 0; /* Request for running pending calls */ static volatile int pendingcalls_to_do = 0; +/* Request for looking at the `async_exc` field of the current thread state */ static volatile int pending_async_exc = 0; #include "ceval_pthread.h" @@ -270,8 +271,8 @@ void PyEval_ReleaseLock(void) { - /* This function must succeed when the current thread state is NULL, - therefore we avoid PyThreadState_GET() which prints a fatal error + /* This function must succeed when the current thread state is NULL. + We therefore avoid PyThreadState_GET() which dumps a fatal error in debug mode. */ drop_gil(_PyThreadState_Current); @@ -473,7 +474,6 @@ pendinglast = j; } /* signal main loop */ -// _Py_Ticker = 0; SIGNAL_PENDING_CALLS(); if (lock != NULL) PyThread_release_lock(lock); @@ -520,7 +520,6 @@ SIGNAL_PENDING_CALLS(); else UNSIGNAL_PENDING_CALLS(); -// pendingcalls_to_do = pendingfirst != pendinglast; PyThread_release_lock(pending_lock); /* having released the lock, perform the callback */ if (func == NULL) @@ -705,11 +704,6 @@ fast_next_opcode*/ static int _Py_TracingPossible = 0; -/* for manipulating the thread switch and periodic "stuff" - used to be - per thread, now just a pair o' globals */ -int _Py_CheckInterval = 1000; -// volatile int _Py_Ticker = 0; /* so that we hit a "tick" first thing */ - PyObject * @@ -1214,14 +1208,12 @@ async I/O handler); see Py_AddPendingCall() and Py_MakePendingCalls() above. */ -// if (--_Py_Ticker < 0) { if (eval_breaker) { if (*next_instr == SETUP_FINALLY) { /* Make the last opcode before a try: finally: block uninterruptable. */ goto fast_next_opcode; } -// _Py_Ticker = _Py_CheckInterval; tstate->tick_counter++; #ifdef WITH_TSC ticked = 1; @@ -1231,14 +1223,7 @@ why = WHY_EXCEPTION; goto on_error; } -// if (pendingcalls_to_do) - /* MakePendingCalls() didn't succeed. - Force early re-execution of this - "periodic" code, possibly after - a thread switch */ -// _Py_Ticker = 0; } -// } if (gil_drop_request) { #ifdef WITH_THREAD /* Give another thread a chance */ Modified: sandbox/trunk/newgil/Python/sysmodule.c ============================================================================== --- sandbox/trunk/newgil/Python/sysmodule.c (original) +++ sandbox/trunk/newgil/Python/sysmodule.c Fri Oct 23 19:56:41 2009 @@ -441,6 +441,9 @@ return temp; } +/* TODO: deprecate */ +static int _check_interval = 100; + PyDoc_STRVAR(getprofile_doc, "getprofile()\n\ \n\ @@ -451,7 +454,7 @@ static PyObject * sys_setcheckinterval(PyObject *self, PyObject *args) { - if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) + if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval)) return NULL; Py_INCREF(Py_None); return Py_None; @@ -467,7 +470,7 @@ static PyObject * sys_getcheckinterval(PyObject *self, PyObject *args) { - return PyLong_FromLong(_Py_CheckInterval); + return PyLong_FromLong(_check_interval); } PyDoc_STRVAR(getcheckinterval_doc, From mal at egenix.com Fri Oct 23 20:07:23 2009 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 23 Oct 2009 20:07:23 +0200 Subject: [Python-checkins] r75631 - in sandbox/trunk/newgil: Include/ceval.h Makefile.pre.in Modules/_io/fileio.c Modules/_multiprocessing/connection.h Modules/_multiprocessing/pipe_connection.c Modules/_multiprocessing/socket_connection.c Modules/_ssl.c Modules/bz2module.c Modules/posixmodule.c Modules/selectmodule.c Modules/socketmodule.c Objects/longobject.c Python/ceval.c Python/ceval_pthread.h Python/pystate.c In-Reply-To: <20091023173823.00421405085@mail.egenix.com> References: <20091023173823.00421405085@mail.egenix.com> Message-ID: <4AE1F0DB.1030703@egenix.com> antoine.pitrou wrote: > Author: antoine.pitrou > Date: Fri Oct 23 19:38:14 2009 > New Revision: 75631 > > Log: > Commit initial patch (from personal hg repo). > > Only POSIX-compatible for now. I plan to try and make it working on Windows. ... > /* this used to be handled on a per-thread basis - now just two globals */ > -PyAPI_DATA(volatile int) _Py_Ticker; > +// PyAPI_DATA(volatile int) _Py_Ticker; It's better not to let C++ comment sneak into the code :-) > Added: sandbox/trunk/newgil/Python/ceval_pthread.h > ============================================================================== > --- (empty file) > +++ sandbox/trunk/newgil/Python/ceval_pthread.h Fri Oct 23 19:38:14 2009 > @@ -0,0 +1,258 @@ > +/* > + * Implementation of the Global Interpreter Lock (GIL) for POSIX pthreads. > + */ > + > +#include > +#include > +#include > + > +/* We assume all modern POSIX systems have gettimeofday() */ > +#ifdef GETTIMEOFDAY_NO_TZ > +#define GETTIMEOFDAY(ptv) gettimeofday(ptv) > +#else > +#define GETTIMEOFDAY(ptv) gettimeofday(ptv, (struct timezone *)NULL) > +#endif > + > +#define ADD_MILLISECONDS(tv, interval) \ > +do { \ > + tv.tv_usec += interval * 1000; \ > + tv.tv_sec += tv.tv_usec / 1000000; \ > + tv.tv_usec %= 1000000; \ > +} while (0) > + > +/* milliseconds */ > +#define INTERVAL 5 If you want to use a more accurate timer, you should have a look at clock_gettime() which is available on more recent POSIX compatible systems. The API provides access to several high precision timers. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 23 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From python-checkins at python.org Fri Oct 23 20:32:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 18:32:15 -0000 Subject: [Python-checkins] r75633 - python/trunk/Lib/test/test_thread.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 20:32:15 2009 New Revision: 75633 Log: Issue #7194: test_thread could try to release an unacquired mutex (and fail). Modified: python/trunk/Lib/test/test_thread.py Modified: python/trunk/Lib/test/test_thread.py ============================================================================== --- python/trunk/Lib/test/test_thread.py (original) +++ python/trunk/Lib/test/test_thread.py Fri Oct 23 20:32:15 2009 @@ -26,6 +26,7 @@ self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() + self.created = 0 self.running = 0 self.next_ident = 0 @@ -37,6 +38,7 @@ self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) + self.created += 1 self.running += 1 def task(self, ident): @@ -47,7 +49,7 @@ verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 - if self.running == 0: + if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): @@ -89,6 +91,7 @@ for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 + self.created = 0 for i in range(NUMTASKS): self.newtask() From python-checkins at python.org Fri Oct 23 20:34:17 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 18:34:17 -0000 Subject: [Python-checkins] r75634 - in python/branches/py3k: Lib/test/test_thread.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 20:34:17 2009 New Revision: 75634 Log: Merged revisions 75633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75633 | antoine.pitrou | 2009-10-23 20:32:15 +0200 (ven., 23 oct. 2009) | 3 lines Issue #7194: test_thread could try to release an unacquired mutex (and fail). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_thread.py Modified: python/branches/py3k/Lib/test/test_thread.py ============================================================================== --- python/branches/py3k/Lib/test/test_thread.py (original) +++ python/branches/py3k/Lib/test/test_thread.py Fri Oct 23 20:34:17 2009 @@ -24,6 +24,7 @@ self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() + self.created = 0 self.running = 0 self.next_ident = 0 @@ -35,6 +36,7 @@ self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) + self.created += 1 self.running += 1 def task(self, ident): @@ -45,7 +47,7 @@ verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 - if self.running == 0: + if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): @@ -87,6 +89,7 @@ for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 + self.created = 0 for i in range(NUMTASKS): self.newtask() From python-checkins at python.org Fri Oct 23 20:35:18 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 18:35:18 -0000 Subject: [Python-checkins] r75635 - in python/branches/release31-maint: Lib/test/test_thread.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 20:35:18 2009 New Revision: 75635 Log: Merged revisions 75634 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75634 | antoine.pitrou | 2009-10-23 20:34:17 +0200 (ven., 23 oct. 2009) | 9 lines Merged revisions 75633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75633 | antoine.pitrou | 2009-10-23 20:32:15 +0200 (ven., 23 oct. 2009) | 3 lines Issue #7194: test_thread could try to release an unacquired mutex (and fail). ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_thread.py Modified: python/branches/release31-maint/Lib/test/test_thread.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_thread.py (original) +++ python/branches/release31-maint/Lib/test/test_thread.py Fri Oct 23 20:35:18 2009 @@ -24,6 +24,7 @@ self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() + self.created = 0 self.running = 0 self.next_ident = 0 @@ -35,6 +36,7 @@ self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) + self.created += 1 self.running += 1 def task(self, ident): @@ -45,7 +47,7 @@ verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 - if self.running == 0: + if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): @@ -87,6 +89,7 @@ for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 + self.created = 0 for i in range(NUMTASKS): self.newtask() From solipsis at pitrou.net Fri Oct 23 20:42:57 2009 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 23 Oct 2009 18:42:57 +0000 (UTC) Subject: [Python-checkins] =?utf-8?q?r75631_-_in_sandbox/trunk/newgil=3A_I?= =?utf-8?q?nclude/ceval=2Eh_Makefile=2Epre=2Ein_Modules/=5Fio/filei?= =?utf-8?q?o=2Ec=09Modules/=5Fmultiprocessing/connection=2EhModules?= =?utf-8?q?/=5Fmultiprocessing/pipe=5Fconnection=2Ec=09Modules/=5Fm?= =?utf-8?q?ultiprocessing/socket=5Fconnection=2EcModules/=5Fssl=2Ec?= =?utf-8?q?=09Modules/bz2module=2EcModules/posixmodule=2Ec=09Module?= =?utf-8?q?s/selectmodule=2EcModules/socketmodule=2Ec=09Objects/lon?= =?utf-8?q?gobject=2Ec_Python/ceval=2Ec_Python/ceval=5Fpthread=2Eh_?= =?utf-8?q?Python/pystate=2Ec?= References: <20091023173823.00421405085@mail.egenix.com> <4AE1F0DB.1030703@egenix.com> Message-ID: M.-A. Lemburg egenix.com> writes: > > > /* this used to be handled on a per-thread basis - now just two globals */ > > -PyAPI_DATA(volatile int) _Py_Ticker; > > +// PyAPI_DATA(volatile int) _Py_Ticker; > > It's better not to let C++ comment sneak into the code This is dead code anyway, it has been removed in a subsequent commit. I may have a couple of C++-style comments remaining, I will fix them. > > +#define ADD_MILLISECONDS(tv, interval) \ > > +do { \ > > + tv.tv_usec += interval * 1000; \ > > + tv.tv_sec += tv.tv_usec / 1000000; \ > > + tv.tv_usec %= 1000000; \ > > +} while (0) > > + > > +/* milliseconds */ > > +#define INTERVAL 5 > > If you want to use a more accurate timer, you should have a look > at clock_gettime() which is available on more recent POSIX compatible > systems. Microseconds are enough for this chunk of code :) Besides, while clock_gettime() provides a theoretically higher precision (nanoseconds instead of microseconds), the actual precision doesn't seem to be higher under Linux. And it would probably need a detection check, and a fallback to gettimeofday()... Regards Antoine. From python-checkins at python.org Fri Oct 23 20:43:48 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 18:43:48 -0000 Subject: [Python-checkins] r75636 - in sandbox/trunk/newgil: Lib/test/test_thread.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 20:43:47 2009 New Revision: 75636 Log: Merged revisions 75634 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k (the bug itself was discovered with this branch) ................ r75634 | antoine.pitrou | 2009-10-23 20:34:17 +0200 (ven., 23 oct. 2009) | 9 lines Merged revisions 75633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75633 | antoine.pitrou | 2009-10-23 20:32:15 +0200 (ven., 23 oct. 2009) | 3 lines Issue #7194: test_thread could try to release an unacquired mutex (and fail). ........ ................ Modified: sandbox/trunk/newgil/ (props changed) sandbox/trunk/newgil/Lib/test/test_thread.py Modified: sandbox/trunk/newgil/Lib/test/test_thread.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_thread.py (original) +++ sandbox/trunk/newgil/Lib/test/test_thread.py Fri Oct 23 20:43:47 2009 @@ -24,6 +24,7 @@ self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() + self.created = 0 self.running = 0 self.next_ident = 0 @@ -35,6 +36,7 @@ self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) + self.created += 1 self.running += 1 def task(self, ident): @@ -45,7 +47,7 @@ verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 - if self.running == 0: + if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): @@ -87,6 +89,7 @@ for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 + self.created = 0 for i in range(NUMTASKS): self.newtask() From python-checkins at python.org Fri Oct 23 20:45:53 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 18:45:53 -0000 Subject: [Python-checkins] r75637 - sandbox/trunk/newgil/Python/ceval_pthread.h Message-ID: Author: antoine.pitrou Date: Fri Oct 23 20:45:53 2009 New Revision: 75637 Log: Fix C++-style comment Modified: sandbox/trunk/newgil/Python/ceval_pthread.h Modified: sandbox/trunk/newgil/Python/ceval_pthread.h ============================================================================== --- sandbox/trunk/newgil/Python/ceval_pthread.h (original) +++ sandbox/trunk/newgil/Python/ceval_pthread.h Fri Oct 23 20:45:53 2009 @@ -29,7 +29,7 @@ #undef TRACE_PRIO -// #define TRACE_PRIO +/* #define TRACE_PRIO */ #define YIELD_IF_PRIO_REQUEST() \ do { \ From python-checkins at python.org Fri Oct 23 21:24:38 2009 From: python-checkins at python.org (mark.dickinson) Date: Fri, 23 Oct 2009 19:24:38 -0000 Subject: [Python-checkins] r75638 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Fri Oct 23 21:24:38 2009 New Revision: 75638 Log: Use consistent brace style for functions Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Fri Oct 23 21:24:38 2009 @@ -140,7 +140,8 @@ the low part of the result in *low, and return the high part. */ static limb_t -limb_fmaa(limb_t *low, limb_t a, limb_t b, limb_t c, limb_t d) { +limb_fmaa(limb_t *low, limb_t a, limb_t b, limb_t c, limb_t d) +{ double_limb_t hilo; hilo = (double_limb_t)a * b + c + d; *low = (limb_t)(hilo%LIMB_BASE); @@ -151,7 +152,8 @@ remainder in *rem. Requires high < c (and hence also c != 0). */ static limb_t -limb_div(limb_t *rem, limb_t high, limb_t low, limb_t c) { +limb_div(limb_t *rem, limb_t high, limb_t low, limb_t c) +{ double_limb_t hilo; if (high >= c) limb_error("limb_div: invalid division"); @@ -196,14 +198,16 @@ /* get a hash value from a limb */ static long -limb_hash(limb_t x) { +limb_hash(limb_t x) +{ return (long)(x % LONG_MAX); } /* smallest nonnegative i such that x < 10**i; undefined if x == 0 */ static Py_ssize_t -limb_len(limb_t x) { +limb_len(limb_t x) +{ Py_ssize_t i; if (x == 0) limb_error("limb_len: zero argument"); @@ -236,7 +240,8 @@ /* *res = a << n + b, b < 10**n. Returns part shifted out. */ static limb_t -limb_lshift(limb_t *res, limb_t a, Py_ssize_t n, limb_t b) { +limb_lshift(limb_t *res, limb_t a, Py_ssize_t n, limb_t b) +{ if (!(0 <= n && n <= LIMB_DIGITS)) limb_error("limb_lshift: invalid shift index"); if (b != limb_mask(b, n)) @@ -252,7 +257,8 @@ /* *res = (a + b*LIMB_BASE) >> n, b < 10**n. Returns part shifted out. */ static limb_t -limb_rshift(limb_t *res, limb_t a, Py_ssize_t n, limb_t b) { +limb_rshift(limb_t *res, limb_t a, Py_ssize_t n, limb_t b) +{ limb_t rem; if (!(0 <= n && n <= LIMB_DIGITS)) limb_error("limb_rshift: invalid shift index"); @@ -1247,7 +1253,8 @@ ValueError if the array is invalid. */ static deccoeff * -_deccoeff_from_unicode_and_size(Py_UNICODE *s, Py_ssize_t s_len) { +_deccoeff_from_unicode_and_size(Py_UNICODE *s, Py_ssize_t s_len) +{ Py_ssize_t z_size; deccoeff *z; int invalid; @@ -1316,7 +1323,8 @@ n is nonnegative, and that (q-1)*(p+1) <= PY_SSIZE_T_MAX. */ static Py_ssize_t -scale_Py_ssize_t(Py_ssize_t n, int p, int q) { +scale_Py_ssize_t(Py_ssize_t n, int p, int q) +{ Py_ssize_t hi, low; assert (n >= 0); hi = n/q; @@ -1555,7 +1563,8 @@ ZeroDivisionError on division by zero. */ static deccoeff * -_deccoeff_division(deccoeff **r, deccoeff *a, deccoeff *b) { +_deccoeff_division(deccoeff **r, deccoeff *a, deccoeff *b) +{ deccoeff *w, *rem, *quot; Py_ssize_t a_size, b_size; a_size = Py_SIZE(a); @@ -1607,7 +1616,8 @@ /* remainder: raises ZeroDivisionError if b is zero */ static deccoeff * -_deccoeff_remainder(deccoeff *a, deccoeff *b) { +_deccoeff_remainder(deccoeff *a, deccoeff *b) +{ deccoeff *quot, *rem; quot = _deccoeff_division(&rem, a, b); if (rem == NULL) @@ -1639,7 +1649,8 @@ /* divmod: raises ZeroDivisionError if b is zero */ static PyObject * -_deccoeff_divmod(deccoeff *a, deccoeff *b) { +_deccoeff_divmod(deccoeff *a, deccoeff *b) +{ deccoeff *quot, *rem; quot = _deccoeff_division(&rem, a, b); @@ -1818,7 +1829,8 @@ */ static PyObject * -deccoeff_lshift(PyObject *v, PyObject *b) { +deccoeff_lshift(PyObject *v, PyObject *b) +{ Py_ssize_t n, a_size; deccoeff *z, *a; @@ -1857,7 +1869,8 @@ Raises ValueError if second operand is negative. */ static PyObject * -deccoeff_rshift(PyObject *v, PyObject *b) { +deccoeff_rshift(PyObject *v, PyObject *b) +{ Py_ssize_t n, a_size, shift; deccoeff *z, *a; @@ -1972,7 +1985,8 @@ /* floor division: raise ZeroDivisionError if b is 0 */ static deccoeff * -_deccoeff_floor_divide(deccoeff *a, deccoeff *b) { +_deccoeff_floor_divide(deccoeff *a, deccoeff *b) +{ deccoeff *quot, *rem; quot = _deccoeff_division(&rem, a, b); if (quot == NULL) From python-checkins at python.org Fri Oct 23 21:30:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Fri, 23 Oct 2009 19:30:54 -0000 Subject: [Python-checkins] r75639 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Fri Oct 23 21:30:54 2009 New Revision: 75639 Log: Remove unnecessary abstractions Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Fri Oct 23 21:30:54 2009 @@ -254,26 +254,6 @@ return limb_fmaa(res, a, powers_of_ten[n], b, LIMB_ZERO); } -/* *res = (a + b*LIMB_BASE) >> n, b < 10**n. Returns part shifted out. */ - -static limb_t -limb_rshift(limb_t *res, limb_t a, Py_ssize_t n, limb_t b) -{ - limb_t rem; - if (!(0 <= n && n <= LIMB_DIGITS)) - limb_error("limb_rshift: invalid shift index"); - if (b != limb_mask(b, n)) - limb_error("limb_rshift: b out of range"); - if (LIMB_DIGITS == n) { - *res = b; - return a; - } - else { - *res = limb_div(&rem, b, a, powers_of_ten[n]); - return rem; - } -} - /* retrieve the value of a particular digit, as a limb_t */ static limb_t @@ -286,22 +266,6 @@ return limb_mask(q, 1); } -/* convert a character in the range '0' through '9' into a limb and back */ - -static limb_t -wdigit_to_limb(Py_UNICODE d) -{ - digit dummy; - return limb_digit_swap(&dummy, LIMB_ZERO, (digit)(d - (Py_UNICODE)'0')); -} - -static Py_UNICODE -limb_to_wdigit(limb_t b) -{ - limb_t dummy; - return (Py_UNICODE)'0' + (Py_UNICODE)digit_limb_swap(&dummy, 0, b); -} - #ifndef DECCOEFF_SLOW_BASECASE_MUL /********************************** @@ -776,13 +740,17 @@ s += s_len; for (j=0; j < nlimbs; j++) { limb = a[j]; - for (i=0; i < LIMB_DIGITS; i++) - *--s = limb_to_wdigit(limb_rshift(&limb, limb, 1, LIMB_ZERO)); + for (i=0; i < LIMB_DIGITS; i++) { + *--s = '0' + limb % 10; + limb /= 10; + } } /* most significant limb */ limb = a[nlimbs]; - for (i=0; i < ndigits; i++) - *--s = limb_to_wdigit(limb_rshift(&limb, limb, 1, LIMB_ZERO)); + for (i=0; i < ndigits; i++) { + *--s = '0' + limb % 10; + limb /= 10; + } assert(s == s_store); } @@ -807,7 +775,7 @@ c = s[i]; if (c < '0' || c > '9') return true; - limb_lshift(&acc, acc, 1, wdigit_to_limb(c)); + limb_lshift(&acc, acc, 1, c - '0'); digits_in_limb--; if (digits_in_limb == 0) { digits_in_limb = LIMB_DIGITS; From python-checkins at python.org Fri Oct 23 21:58:18 2009 From: python-checkins at python.org (neil.schemenauer) Date: Fri, 23 Oct 2009 19:58:18 -0000 Subject: [Python-checkins] r75640 - python/trunk/Lib/warnings.py Message-ID: Author: neil.schemenauer Date: Fri Oct 23 21:58:17 2009 New Revision: 75640 Log: Improve some docstrings in the 'warnings' module. Modified: python/trunk/Lib/warnings.py Modified: python/trunk/Lib/warnings.py ============================================================================== --- python/trunk/Lib/warnings.py (original) +++ python/trunk/Lib/warnings.py Fri Oct 23 21:58:17 2009 @@ -46,7 +46,14 @@ append=0): """Insert an entry into the list of warnings filters (at the front). - Use assertions to check that all arguments have the right type.""" + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'message' -- a regex that the warning message must match + 'category' -- a class that the warning must be a subclass of + 'module' -- a regex that the module name must match + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters + """ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) @@ -68,6 +75,11 @@ """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'category' -- a class that the warning must be a subclass of + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters """ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) From python-checkins at python.org Fri Oct 23 23:55:37 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 21:55:37 -0000 Subject: [Python-checkins] r75641 - in python/branches/py3k: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Fri Oct 23 23:55:36 2009 New Revision: 75641 Log: Merged revisions 75624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75624 | antoine.pitrou | 2009-10-23 14:01:13 +0200 (ven., 23 oct. 2009) | 3 lines Fix Windows buildbot failure ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_threading.py Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Fri Oct 23 23:55:36 2009 @@ -320,7 +320,8 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() - self.assertEqual(stdout, b"Woke up, sleep function is: \n") + self.assertEqual(stdout.strip(), + b"Woke up, sleep function is: ") stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip() self.assertEqual(stderr, b"") From python-checkins at python.org Sat Oct 24 00:06:37 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 22:06:37 -0000 Subject: [Python-checkins] r75642 - in python/branches/release31-maint: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Sat Oct 24 00:06:37 2009 New Revision: 75642 Log: Merged revisions 75641 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75641 | antoine.pitrou | 2009-10-23 23:55:36 +0200 (ven., 23 oct. 2009) | 9 lines Merged revisions 75624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75624 | antoine.pitrou | 2009-10-23 14:01:13 +0200 (ven., 23 oct. 2009) | 3 lines Fix Windows buildbot failure ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_threading.py Modified: python/branches/release31-maint/Lib/test/test_threading.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_threading.py (original) +++ python/branches/release31-maint/Lib/test/test_threading.py Sat Oct 24 00:06:37 2009 @@ -306,7 +306,8 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() - self.assertEqual(stdout, b"Woke up, sleep function is: \n") + self.assertEqual(stdout.strip(), + b"Woke up, sleep function is: ") stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip() self.assertEqual(stderr, b"") From python-checkins at python.org Sat Oct 24 00:51:28 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 22:51:28 -0000 Subject: [Python-checkins] r75643 - in sandbox/trunk/newgil: Lib/unittest/runner.py Python/ceval_pthread.h Message-ID: Author: antoine.pitrou Date: Sat Oct 24 00:51:28 2009 New Revision: 75643 Log: Addition of Windows support. Beware: I witnessed very strange behaviour by test_multiprocessing which tried to pickle the unittest runner, and had to patch unittest to avoid the subsequent failures Modified: sandbox/trunk/newgil/Lib/unittest/runner.py sandbox/trunk/newgil/Python/ceval_pthread.h Modified: sandbox/trunk/newgil/Lib/unittest/runner.py ============================================================================== --- sandbox/trunk/newgil/Lib/unittest/runner.py (original) +++ sandbox/trunk/newgil/Lib/unittest/runner.py Sat Oct 24 00:51:28 2009 @@ -8,8 +8,14 @@ class _WritelnDecorator(object): """Used to decorate file-like objects with a handy 'writeln' method""" - def __init__(self,stream): + def __new__(cls, stream): + self = object.__new__(cls) self.stream = stream + return self + + # XXX for test_multiprocessing (!) + def __getnewargs__(self): + return self.stream, def __getattr__(self, attr): return getattr(self.stream,attr) Modified: sandbox/trunk/newgil/Python/ceval_pthread.h ============================================================================== --- sandbox/trunk/newgil/Python/ceval_pthread.h (original) +++ sandbox/trunk/newgil/Python/ceval_pthread.h Sat Oct 24 00:51:28 2009 @@ -4,21 +4,9 @@ #include #include -#include -/* We assume all modern POSIX systems have gettimeofday() */ -#ifdef GETTIMEOFDAY_NO_TZ -#define GETTIMEOFDAY(ptv) gettimeofday(ptv) -#else -#define GETTIMEOFDAY(ptv) gettimeofday(ptv, (struct timezone *)NULL) -#endif -#define ADD_MILLISECONDS(tv, interval) \ -do { \ - tv.tv_usec += interval * 1000; \ - tv.tv_sec += tv.tv_usec / 1000000; \ - tv.tv_usec %= 1000000; \ -} while (0) +/* First some general settings */ /* milliseconds */ #define INTERVAL 5 @@ -27,20 +15,149 @@ #undef FORCE_SWITCHING #define FORCE_SWITCHING - #undef TRACE_PRIO /* #define TRACE_PRIO */ -#define YIELD_IF_PRIO_REQUEST() \ + +#ifndef _POSIX_THREADS +/* This means pthreads are not implemented in libc headers, hence the macro + not present in unistd.h. But they still can be implemented as an external + library (e.g. gnu pth in pthread emulation) */ +# ifdef HAVE_PTHREAD_H +# include /* _POSIX_THREADS */ +# endif +#endif + + +#ifdef _POSIX_THREADS + +/* + * POSIX support + */ + +#include + +#define ADD_MILLISECONDS(tv, interval) \ do { \ - if (prio_request) { \ - if (pthread_mutex_lock(&prio_mutex)) \ - Py_FatalError("pthread_mutex_lock(&prio_mutex) failed"); \ - if (pthread_mutex_unlock(&prio_mutex)) \ - Py_FatalError("pthread_mutex_unlock(&prio_mutex) failed"); \ - } \ + tv.tv_usec += interval * 1000; \ + tv.tv_sec += tv.tv_usec / 1000000; \ + tv.tv_usec %= 1000000; \ } while (0) +/* We assume all modern POSIX systems have gettimeofday() */ +#ifdef GETTIMEOFDAY_NO_TZ +#define GETTIMEOFDAY(ptv) gettimeofday(ptv) +#else +#define GETTIMEOFDAY(ptv) gettimeofday(ptv, (struct timezone *)NULL) +#endif + +#define MUTEX_T pthread_mutex_t +#define MUTEX_INIT(mut) \ + if (pthread_mutex_init(&mut, NULL)) { \ + Py_FatalError("pthread_mutex_init(" #mut ") failed"); }; +#define MUTEX_LOCK(mut) \ + if (pthread_mutex_lock(&mut)) { \ + Py_FatalError("pthread_mutex_lock(" #mut ") failed"); }; +#define MUTEX_UNLOCK(mut) \ + if (pthread_mutex_unlock(&mut)) { \ + Py_FatalError("pthread_mutex_unlock(" #mut ") failed"); }; + +#define COND_T pthread_cond_t +#define COND_INIT(cond) \ + if (pthread_cond_init(&cond, NULL)) { \ + Py_FatalError("pthread_cond_init(" #cond ") failed"); }; +#define COND_PREPARE(cond) +#define COND_SIGNAL(cond) \ + if (pthread_cond_signal(&cond)) { \ + Py_FatalError("pthread_cond_signal(" #cond ") failed"); }; +#define COND_WAIT(cond, mut) \ + if (pthread_cond_wait(&cond, &mut)) { \ + Py_FatalError("pthread_cond_wait(" #cond ") failed"); }; +#define COND_TIMED_WAIT(cond, mut, milliseconds, timeout_result) \ + { \ + int r; \ + struct timespec ts; \ + struct timeval deadline; \ + \ + GETTIMEOFDAY(&deadline); \ + ADD_MILLISECONDS(deadline, INTERVAL); \ + ts.tv_sec = deadline.tv_sec; \ + ts.tv_nsec = deadline.tv_usec * 1000; \ + \ + r = pthread_cond_timedwait(&cond, &mut, &ts); \ + if (r == ETIMEDOUT) \ + timeout_result = 1; \ + else if (r) \ + Py_FatalError("pthread_cond_timedwait(" #cond ") failed"); \ + else \ + timeout_result = 0; \ + } \ + +#elif defined(NT_THREADS) + +/* + * Windows (2000 and later, as well as (hopefully) CE) support + */ + +#include + +#define MUTEX_T HANDLE +#define MUTEX_INIT(mut) \ + if (!(mut = CreateMutex(NULL, FALSE, NULL))) { \ + Py_FatalError("CreateMutex(" #mut ") failed"); }; +#define MUTEX_LOCK(mut) \ + if (WaitForSingleObject(mut, INFINITE) != WAIT_OBJECT_0) { \ + Py_FatalError("WaitForSingleObject(" #mut ") failed"); }; +#define MUTEX_UNLOCK(mut) \ + if (!ReleaseMutex(mut)) { \ + Py_FatalError("ReleaseMutex(" #mut ") failed"); }; + +/* We emulate condition variables with events. It is sufficient here. + (WaitForMultipleObjects() allows the event to be reset and the mutex + to be taken atomically) */ +#define COND_T HANDLE +#define COND_INIT(cond) \ + /* auto-reset, non-signalled */ \ + if (!(cond = CreateEvent(NULL, FALSE, FALSE, NULL))) { \ + Py_FatalError("CreateMutex(" #cond ") failed"); }; +#define COND_PREPARE(cond) \ + if (!ResetEvent(cond)) { \ + Py_FatalError("ResetEvent(" #cond ") failed"); }; +#define COND_SIGNAL(cond) \ + if (!SetEvent(cond)) { \ + Py_FatalError("SetEvent(" #cond ") failed"); }; +#define COND_WAIT(cond, mut) \ + { \ + DWORD r; \ + HANDLE objects[2] = { cond, mut }; \ + MUTEX_UNLOCK(mut); \ + r = WaitForMultipleObjects(2, objects, TRUE, INFINITE); \ + if (r != WAIT_OBJECT_0) \ + Py_FatalError("WaitForSingleObject(" #cond ") failed"); \ + } +#define COND_TIMED_WAIT(cond, mut, milliseconds, timeout_result) \ + { \ + DWORD r; \ + HANDLE objects[2] = { cond, mut }; \ + MUTEX_UNLOCK(mut); \ + r = WaitForMultipleObjects(2, objects, TRUE, milliseconds); \ + if (r == WAIT_TIMEOUT) { \ + MUTEX_LOCK(mut); \ + timeout_result = 1; \ + } \ + else if (r != WAIT_OBJECT_0) \ + Py_FatalError("WaitForSingleObject(" #cond ") failed"); \ + else \ + timeout_result = 0; \ + } + +#else + +#error You need either a POSIX-compatible or a Windows system! + +#endif /* _POSIX_THREADS, NT_THREADS */ + + /* Whether the GIL is already taken (-1 if uninitialized) */ static volatile int gil_locked = -1; /* Number of GIL switches since the beginning */ @@ -50,22 +167,33 @@ /* This condition variable allows to put threads to sleep. In addition, the mutex also protects the above variables. */ -static pthread_cond_t gil_cond; -static pthread_mutex_t gil_mutex; +static COND_T gil_cond; +static MUTEX_T gil_mutex; /* This mutex is taken when a priority request is made, and released when it is finally honoured. Other threads can sleep by trying to lock the mutex. */ -static pthread_mutex_t prio_mutex; +static MUTEX_T prio_mutex; /* The thread making the prio request, or NULL. */ static volatile PyThreadState *prio_request = NULL; #ifdef FORCE_SWITCHING /* This condition variable forces the GIL-releasing thread to wait for the scheduling of a GIL-awaiting thread, if any. */ -static pthread_cond_t switch_cond; -static pthread_mutex_t switch_mutex; +static COND_T switch_cond; +static MUTEX_T switch_mutex; #endif + +#define YIELD_IF_PRIO_REQUEST() \ +do { \ + if (prio_request) { \ + MUTEX_LOCK(prio_mutex); \ + MUTEX_UNLOCK(prio_mutex); \ + } \ +} while (0) + + + static int gil_created(void) { return gil_locked >= 0; @@ -73,19 +201,15 @@ static void create_gil(void) { - if (pthread_mutex_init(&gil_mutex, NULL) - || pthread_mutex_init(&prio_mutex, NULL) + MUTEX_INIT(gil_mutex); + MUTEX_INIT(prio_mutex); #ifdef FORCE_SWITCHING - || pthread_mutex_init(&switch_mutex, NULL) + MUTEX_INIT(switch_mutex); #endif - ) - Py_FatalError("create_gil: pthread_mutex_init() failed"); - if (pthread_cond_init(&gil_cond, NULL) + COND_INIT(gil_cond); #ifdef FORCE_SWITCHING - || pthread_cond_init(&switch_cond, NULL) + COND_INIT(switch_cond); #endif - ) - Py_FatalError("create_gil: pthread_cond_init() failed"); gil_locked = 0; gil_last_holder = NULL; prio_request = NULL; @@ -104,24 +228,21 @@ if (tstate != NULL && tstate != gil_last_holder) Py_FatalError("drop_gil: wrong thread state"); - if (pthread_mutex_lock(&gil_mutex)) - Py_FatalError("drop_gil: pthread_mutex_lock() failed"); + MUTEX_LOCK(gil_mutex); gil_locked = 0; - if (pthread_cond_signal(&gil_cond)) - Py_FatalError("drop_gil: pthread_cond_signal() failed"); - if (pthread_mutex_unlock(&gil_mutex)) - Py_FatalError("drop_gil: pthread_mutex_unlock() failed"); + COND_SIGNAL(gil_cond); +#ifdef FORCE_SWITCHING + COND_PREPARE(switch_cond); +#endif + MUTEX_UNLOCK(gil_mutex); #ifdef FORCE_SWITCHING if (gil_drop_request) { - if (pthread_mutex_lock(&switch_mutex)) - Py_FatalError("drop_gil: pthread_mutex_lock(&switch_mutex) failed"); + MUTEX_LOCK(switch_mutex); /* Not switched yet => wait */ - if (gil_last_holder == tstate && - pthread_cond_wait(&switch_cond, &switch_mutex)) - Py_FatalError("drop_gil: pthread_cond_wait(&switch_cond) failed"); - if (pthread_mutex_unlock(&switch_mutex)) - Py_FatalError("drop_gil: pthread_mutex_unlock(&switch_mutex) failed"); + if (gil_last_holder == tstate) + COND_WAIT(switch_cond, switch_mutex); + MUTEX_UNLOCK(switch_mutex); } #endif } @@ -138,14 +259,15 @@ YIELD_IF_PRIO_REQUEST(); err = errno; - if (pthread_mutex_lock(&gil_mutex)) - Py_FatalError("take_gil: pthread_mutex_lock() failed"); + MUTEX_LOCK(gil_mutex); if (!gil_locked) { prio = 0; goto _ready; } + COND_PREPARE(gil_cond); + if (prio) { #ifdef TRACE_PRIO struct timeval tv; @@ -154,18 +276,15 @@ tv.tv_sec + tv.tv_usec / 1000000.0); #endif if (!prio_request) { - if (pthread_mutex_lock(&prio_mutex)) - Py_FatalError("take_gil: pthread_mutex_lock(&prio_mutex) failed"); + MUTEX_LOCK(prio_mutex); prio_request = tstate; } else prio = 0; } while (gil_locked) { - int r; + int timed_out = 0; unsigned long saved_switchnum; - struct timespec ts; - struct timeval now, deadline; if (prio_request) { /* Tell the eval loop the GIL must be dropped as soon as possible */ @@ -173,39 +292,24 @@ if (!prio) { /* If another thread is making the prio_request, give it a chance to run and take the mutex. */ - pthread_mutex_unlock(&gil_mutex); + MUTEX_UNLOCK(gil_mutex); YIELD_IF_PRIO_REQUEST(); - pthread_mutex_lock(&gil_mutex); + MUTEX_LOCK(gil_mutex); } } - GETTIMEOFDAY(&now); - deadline = now; - ADD_MILLISECONDS(deadline, INTERVAL); - ts.tv_sec = deadline.tv_sec; - ts.tv_nsec = deadline.tv_usec * 1000; - saved_switchnum = gil_switch_number; - r = pthread_cond_timedwait(&gil_cond, &gil_mutex, &ts); - - if (r == ETIMEDOUT) { - /* If no switch occurred in the meantime, it is time to ask - the GIL-holding thread to drop it. */ - if (gil_locked && gil_switch_number == saved_switchnum) { - SET_GIL_DROP_REQUEST(); - } - } - else if (r) - Py_FatalError("take_gil: pthread_cond_timedwait() failed"); - else { - /* We were woken up for no reason, ignore. */ + COND_TIMED_WAIT(gil_cond, gil_mutex, INTERVAL, timed_out); + /* If we timed out and no switch occurred in the meantime, it is time + to ask the GIL-holding thread to drop it. */ + if (timed_out && gil_locked && gil_switch_number == saved_switchnum) { + SET_GIL_DROP_REQUEST(); } } _ready: #ifdef FORCE_SWITCHING /* This mutex must be taken before modifying gil_last_holder (see drop_gil()). */ - if (pthread_mutex_lock(&switch_mutex)) - Py_FatalError("take_gil: pthread_mutex_lock() failed"); + MUTEX_LOCK(switch_mutex); #endif /* We now hold the GIL */ gil_locked = 1; @@ -223,16 +327,13 @@ #endif } #ifdef FORCE_SWITCHING - if (pthread_cond_signal(&switch_cond)) - Py_FatalError("take_gil: pthread_cond_signal() failed"); - if (pthread_mutex_unlock(&switch_mutex)) - Py_FatalError("take_gil: pthread_mutex_unlock() failed"); + COND_SIGNAL(switch_cond); + MUTEX_UNLOCK(switch_mutex); #endif if (prio) { /* The prio request was granted. */ prio_request = NULL; - if (pthread_mutex_unlock(&prio_mutex)) - Py_FatalError("take_gil: pthread_mutex_unlock(&prio_mutex) failed"); + MUTEX_UNLOCK(prio_mutex); } if (gil_drop_request && !prio_request) { /* No prio_request pending. */ @@ -242,8 +343,7 @@ _PyEval_SignalAsyncExc(); } - if (pthread_mutex_unlock(&gil_mutex)) - Py_FatalError("take_gil: pthread_mutex_unlock() failed"); + MUTEX_UNLOCK(gil_mutex); errno = err; } From python-checkins at python.org Sat Oct 24 00:57:42 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 22:57:42 -0000 Subject: [Python-checkins] r75644 - in sandbox/trunk/newgil: Makefile.pre.in Python/ceval.c Python/ceval_gil.h Python/ceval_pthread.h Message-ID: Author: antoine.pitrou Date: Sat Oct 24 00:57:41 2009 New Revision: 75644 Log: Rename file, since it is no longer posix-specific. Added: sandbox/trunk/newgil/Python/ceval_gil.h - copied, changed from r75643, /sandbox/trunk/newgil/Python/ceval_pthread.h Removed: sandbox/trunk/newgil/Python/ceval_pthread.h Modified: sandbox/trunk/newgil/Makefile.pre.in sandbox/trunk/newgil/Python/ceval.c Modified: sandbox/trunk/newgil/Makefile.pre.in ============================================================================== --- sandbox/trunk/newgil/Makefile.pre.in (original) +++ sandbox/trunk/newgil/Makefile.pre.in Sat Oct 24 00:57:41 2009 @@ -596,7 +596,7 @@ $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES) $(OPCODETARGETGEN) $(OPCODETARGETS_H) -Python/ceval.o: $(OPCODETARGETS_H) Python/ceval_pthread.h +Python/ceval.o: $(OPCODETARGETS_H) Python/ceval_gil.h Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \ $(BYTESTR_DEPS) \ Modified: sandbox/trunk/newgil/Python/ceval.c ============================================================================== --- sandbox/trunk/newgil/Python/ceval.c (original) +++ sandbox/trunk/newgil/Python/ceval.c Sat Oct 24 00:57:41 2009 @@ -239,7 +239,7 @@ /* Request for looking at the `async_exc` field of the current thread state */ static volatile int pending_async_exc = 0; -#include "ceval_pthread.h" +#include "ceval_gil.h" int PyEval_ThreadsInitialized(void) Copied: sandbox/trunk/newgil/Python/ceval_gil.h (from r75643, /sandbox/trunk/newgil/Python/ceval_pthread.h) ============================================================================== --- /sandbox/trunk/newgil/Python/ceval_pthread.h (original) +++ sandbox/trunk/newgil/Python/ceval_gil.h Sat Oct 24 00:57:41 2009 @@ -1,5 +1,5 @@ /* - * Implementation of the Global Interpreter Lock (GIL) for POSIX pthreads. + * Implementation of the Global Interpreter Lock (GIL). */ #include Deleted: sandbox/trunk/newgil/Python/ceval_pthread.h ============================================================================== --- sandbox/trunk/newgil/Python/ceval_pthread.h Sat Oct 24 00:57:41 2009 +++ (empty file) @@ -1,358 +0,0 @@ -/* - * Implementation of the Global Interpreter Lock (GIL) for POSIX pthreads. - */ - -#include -#include - - -/* First some general settings */ - -/* milliseconds */ -#define INTERVAL 5 - -/* Enable if you want to force the switching of threads at least every INTERVAL */ -#undef FORCE_SWITCHING -#define FORCE_SWITCHING - -#undef TRACE_PRIO -/* #define TRACE_PRIO */ - - -#ifndef _POSIX_THREADS -/* This means pthreads are not implemented in libc headers, hence the macro - not present in unistd.h. But they still can be implemented as an external - library (e.g. gnu pth in pthread emulation) */ -# ifdef HAVE_PTHREAD_H -# include /* _POSIX_THREADS */ -# endif -#endif - - -#ifdef _POSIX_THREADS - -/* - * POSIX support - */ - -#include - -#define ADD_MILLISECONDS(tv, interval) \ -do { \ - tv.tv_usec += interval * 1000; \ - tv.tv_sec += tv.tv_usec / 1000000; \ - tv.tv_usec %= 1000000; \ -} while (0) - -/* We assume all modern POSIX systems have gettimeofday() */ -#ifdef GETTIMEOFDAY_NO_TZ -#define GETTIMEOFDAY(ptv) gettimeofday(ptv) -#else -#define GETTIMEOFDAY(ptv) gettimeofday(ptv, (struct timezone *)NULL) -#endif - -#define MUTEX_T pthread_mutex_t -#define MUTEX_INIT(mut) \ - if (pthread_mutex_init(&mut, NULL)) { \ - Py_FatalError("pthread_mutex_init(" #mut ") failed"); }; -#define MUTEX_LOCK(mut) \ - if (pthread_mutex_lock(&mut)) { \ - Py_FatalError("pthread_mutex_lock(" #mut ") failed"); }; -#define MUTEX_UNLOCK(mut) \ - if (pthread_mutex_unlock(&mut)) { \ - Py_FatalError("pthread_mutex_unlock(" #mut ") failed"); }; - -#define COND_T pthread_cond_t -#define COND_INIT(cond) \ - if (pthread_cond_init(&cond, NULL)) { \ - Py_FatalError("pthread_cond_init(" #cond ") failed"); }; -#define COND_PREPARE(cond) -#define COND_SIGNAL(cond) \ - if (pthread_cond_signal(&cond)) { \ - Py_FatalError("pthread_cond_signal(" #cond ") failed"); }; -#define COND_WAIT(cond, mut) \ - if (pthread_cond_wait(&cond, &mut)) { \ - Py_FatalError("pthread_cond_wait(" #cond ") failed"); }; -#define COND_TIMED_WAIT(cond, mut, milliseconds, timeout_result) \ - { \ - int r; \ - struct timespec ts; \ - struct timeval deadline; \ - \ - GETTIMEOFDAY(&deadline); \ - ADD_MILLISECONDS(deadline, INTERVAL); \ - ts.tv_sec = deadline.tv_sec; \ - ts.tv_nsec = deadline.tv_usec * 1000; \ - \ - r = pthread_cond_timedwait(&cond, &mut, &ts); \ - if (r == ETIMEDOUT) \ - timeout_result = 1; \ - else if (r) \ - Py_FatalError("pthread_cond_timedwait(" #cond ") failed"); \ - else \ - timeout_result = 0; \ - } \ - -#elif defined(NT_THREADS) - -/* - * Windows (2000 and later, as well as (hopefully) CE) support - */ - -#include - -#define MUTEX_T HANDLE -#define MUTEX_INIT(mut) \ - if (!(mut = CreateMutex(NULL, FALSE, NULL))) { \ - Py_FatalError("CreateMutex(" #mut ") failed"); }; -#define MUTEX_LOCK(mut) \ - if (WaitForSingleObject(mut, INFINITE) != WAIT_OBJECT_0) { \ - Py_FatalError("WaitForSingleObject(" #mut ") failed"); }; -#define MUTEX_UNLOCK(mut) \ - if (!ReleaseMutex(mut)) { \ - Py_FatalError("ReleaseMutex(" #mut ") failed"); }; - -/* We emulate condition variables with events. It is sufficient here. - (WaitForMultipleObjects() allows the event to be reset and the mutex - to be taken atomically) */ -#define COND_T HANDLE -#define COND_INIT(cond) \ - /* auto-reset, non-signalled */ \ - if (!(cond = CreateEvent(NULL, FALSE, FALSE, NULL))) { \ - Py_FatalError("CreateMutex(" #cond ") failed"); }; -#define COND_PREPARE(cond) \ - if (!ResetEvent(cond)) { \ - Py_FatalError("ResetEvent(" #cond ") failed"); }; -#define COND_SIGNAL(cond) \ - if (!SetEvent(cond)) { \ - Py_FatalError("SetEvent(" #cond ") failed"); }; -#define COND_WAIT(cond, mut) \ - { \ - DWORD r; \ - HANDLE objects[2] = { cond, mut }; \ - MUTEX_UNLOCK(mut); \ - r = WaitForMultipleObjects(2, objects, TRUE, INFINITE); \ - if (r != WAIT_OBJECT_0) \ - Py_FatalError("WaitForSingleObject(" #cond ") failed"); \ - } -#define COND_TIMED_WAIT(cond, mut, milliseconds, timeout_result) \ - { \ - DWORD r; \ - HANDLE objects[2] = { cond, mut }; \ - MUTEX_UNLOCK(mut); \ - r = WaitForMultipleObjects(2, objects, TRUE, milliseconds); \ - if (r == WAIT_TIMEOUT) { \ - MUTEX_LOCK(mut); \ - timeout_result = 1; \ - } \ - else if (r != WAIT_OBJECT_0) \ - Py_FatalError("WaitForSingleObject(" #cond ") failed"); \ - else \ - timeout_result = 0; \ - } - -#else - -#error You need either a POSIX-compatible or a Windows system! - -#endif /* _POSIX_THREADS, NT_THREADS */ - - -/* Whether the GIL is already taken (-1 if uninitialized) */ -static volatile int gil_locked = -1; -/* Number of GIL switches since the beginning */ -static unsigned long gil_switch_number = 0; -/* Last thread holding / having held the GIL */ -static PyThreadState *gil_last_holder = NULL; - -/* This condition variable allows to put threads to sleep. - In addition, the mutex also protects the above variables. */ -static COND_T gil_cond; -static MUTEX_T gil_mutex; -/* This mutex is taken when a priority request is made, and released when - it is finally honoured. - Other threads can sleep by trying to lock the mutex. */ -static MUTEX_T prio_mutex; -/* The thread making the prio request, or NULL. */ -static volatile PyThreadState *prio_request = NULL; - -#ifdef FORCE_SWITCHING -/* This condition variable forces the GIL-releasing thread to wait for - the scheduling of a GIL-awaiting thread, if any. */ -static COND_T switch_cond; -static MUTEX_T switch_mutex; -#endif - - -#define YIELD_IF_PRIO_REQUEST() \ -do { \ - if (prio_request) { \ - MUTEX_LOCK(prio_mutex); \ - MUTEX_UNLOCK(prio_mutex); \ - } \ -} while (0) - - - -static int gil_created(void) -{ - return gil_locked >= 0; -} - -static void create_gil(void) -{ - MUTEX_INIT(gil_mutex); - MUTEX_INIT(prio_mutex); -#ifdef FORCE_SWITCHING - MUTEX_INIT(switch_mutex); -#endif - COND_INIT(gil_cond); -#ifdef FORCE_SWITCHING - COND_INIT(switch_cond); -#endif - gil_locked = 0; - gil_last_holder = NULL; - prio_request = NULL; -} - -static void recreate_gil(void) -{ - create_gil(); -} - -static void drop_gil(PyThreadState *tstate) -{ - /* NOTE: tstate is allowed to be NULL. */ - if (!gil_locked) - Py_FatalError("drop_gil: GIL is not locked"); - if (tstate != NULL && tstate != gil_last_holder) - Py_FatalError("drop_gil: wrong thread state"); - - MUTEX_LOCK(gil_mutex); - gil_locked = 0; - COND_SIGNAL(gil_cond); -#ifdef FORCE_SWITCHING - COND_PREPARE(switch_cond); -#endif - MUTEX_UNLOCK(gil_mutex); - -#ifdef FORCE_SWITCHING - if (gil_drop_request) { - MUTEX_LOCK(switch_mutex); - /* Not switched yet => wait */ - if (gil_last_holder == tstate) - COND_WAIT(switch_cond, switch_mutex); - MUTEX_UNLOCK(switch_mutex); - } -#endif -} - -static void _take_gil(PyThreadState *tstate, int prio) -{ - int err; - if (tstate == NULL) - Py_FatalError("take_gil: NULL tstate"); - - /* If another thread is requesting priority, give it a chance to run - before we take the mutex. - */ - YIELD_IF_PRIO_REQUEST(); - - err = errno; - MUTEX_LOCK(gil_mutex); - - if (!gil_locked) { - prio = 0; - goto _ready; - } - - COND_PREPARE(gil_cond); - - if (prio) { -#ifdef TRACE_PRIO - struct timeval tv; - GETTIMEOFDAY(&tv); - printf("trying to take gil with prio: %.3f <--\n", - tv.tv_sec + tv.tv_usec / 1000000.0); -#endif - if (!prio_request) { - MUTEX_LOCK(prio_mutex); - prio_request = tstate; - } - else - prio = 0; - } - while (gil_locked) { - int timed_out = 0; - unsigned long saved_switchnum; - - if (prio_request) { - /* Tell the eval loop the GIL must be dropped as soon as possible */ - SET_GIL_DROP_REQUEST(); - if (!prio) { - /* If another thread is making the prio_request, give it a - chance to run and take the mutex. */ - MUTEX_UNLOCK(gil_mutex); - YIELD_IF_PRIO_REQUEST(); - MUTEX_LOCK(gil_mutex); - } - } - - saved_switchnum = gil_switch_number; - COND_TIMED_WAIT(gil_cond, gil_mutex, INTERVAL, timed_out); - /* If we timed out and no switch occurred in the meantime, it is time - to ask the GIL-holding thread to drop it. */ - if (timed_out && gil_locked && gil_switch_number == saved_switchnum) { - SET_GIL_DROP_REQUEST(); - } - } -_ready: -#ifdef FORCE_SWITCHING - /* This mutex must be taken before modifying gil_last_holder (see drop_gil()). */ - MUTEX_LOCK(switch_mutex); -#endif - /* We now hold the GIL */ - gil_locked = 1; - - if (tstate != gil_last_holder) { - gil_last_holder = tstate; - ++gil_switch_number; -#ifdef TRACE_PRIO - if (prio) { - struct timeval tv; - GETTIMEOFDAY(&tv); - printf("gil taken with prio: %.3f\n", - tv.tv_sec + tv.tv_usec / 1000000.0); - } -#endif - } -#ifdef FORCE_SWITCHING - COND_SIGNAL(switch_cond); - MUTEX_UNLOCK(switch_mutex); -#endif - if (prio) { - /* The prio request was granted. */ - prio_request = NULL; - MUTEX_UNLOCK(prio_mutex); - } - if (gil_drop_request && !prio_request) { - /* No prio_request pending. */ - RESET_GIL_DROP_REQUEST(); - } - if (tstate->async_exc != NULL) { - _PyEval_SignalAsyncExc(); - } - - MUTEX_UNLOCK(gil_mutex); - errno = err; -} - -static void take_gil(PyThreadState *tstate) -{ - _take_gil(tstate, 0); -} - -static void take_gil_prio(PyThreadState *tstate) -{ - _take_gil(tstate, 1); -} From python-checkins at python.org Sat Oct 24 01:09:20 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 23 Oct 2009 23:09:20 -0000 Subject: [Python-checkins] r75645 - sandbox/trunk/newgil/Python/ceval_gil.h Message-ID: Author: antoine.pitrou Date: Sat Oct 24 01:09:19 2009 New Revision: 75645 Log: A slightly more accurate explanation Modified: sandbox/trunk/newgil/Python/ceval_gil.h Modified: sandbox/trunk/newgil/Python/ceval_gil.h ============================================================================== --- sandbox/trunk/newgil/Python/ceval_gil.h (original) +++ sandbox/trunk/newgil/Python/ceval_gil.h Sat Oct 24 01:09:19 2009 @@ -113,7 +113,7 @@ Py_FatalError("ReleaseMutex(" #mut ") failed"); }; /* We emulate condition variables with events. It is sufficient here. - (WaitForMultipleObjects() allows the event to be reset and the mutex + (WaitForMultipleObjects() allows the event to be caught and the mutex to be taken atomically) */ #define COND_T HANDLE #define COND_INIT(cond) \ From python-checkins at python.org Sat Oct 24 10:10:31 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 08:10:31 -0000 Subject: [Python-checkins] r75646 - in sandbox/trunk/newgil: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Sat Oct 24 10:10:31 2009 New Revision: 75646 Log: Merged revisions 75641 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75641 | antoine.pitrou | 2009-10-23 23:55:36 +0200 (ven., 23 oct. 2009) | 9 lines Merged revisions 75624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75624 | antoine.pitrou | 2009-10-23 14:01:13 +0200 (ven., 23 oct. 2009) | 3 lines Fix Windows buildbot failure ........ ................ Modified: sandbox/trunk/newgil/ (props changed) sandbox/trunk/newgil/Lib/test/test_threading.py Modified: sandbox/trunk/newgil/Lib/test/test_threading.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_threading.py (original) +++ sandbox/trunk/newgil/Lib/test/test_threading.py Sat Oct 24 10:10:31 2009 @@ -320,7 +320,8 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() - self.assertEqual(stdout, b"Woke up, sleep function is: \n") + self.assertEqual(stdout.strip(), + b"Woke up, sleep function is: ") stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip() self.assertEqual(stderr, b"") From python-checkins at python.org Sat Oct 24 12:04:19 2009 From: python-checkins at python.org (georg.brandl) Date: Sat, 24 Oct 2009 10:04:19 -0000 Subject: [Python-checkins] r75647 - python/trunk/Doc/library/configparser.rst Message-ID: Author: georg.brandl Date: Sat Oct 24 12:04:19 2009 New Revision: 75647 Log: Fix markup. Modified: python/trunk/Doc/library/configparser.rst Modified: python/trunk/Doc/library/configparser.rst ============================================================================== --- python/trunk/Doc/library/configparser.rst (original) +++ python/trunk/Doc/library/configparser.rst Sat Oct 24 12:04:19 2009 @@ -350,7 +350,7 @@ cfgparser.optionxform = str Note that when reading configuration files, whitespace around the - option names are stripped before :meth:``optionxform`` is called. + option names are stripped before :meth:`optionxform` is called. .. _configparser-objects: From python-checkins at python.org Sat Oct 24 13:47:17 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 11:47:17 -0000 Subject: [Python-checkins] r75648 - python/trunk/Misc/ACKS Message-ID: Author: mark.dickinson Date: Sat Oct 24 13:47:17 2009 New Revision: 75648 Log: Acknowledge Ned Deily (extensive bug hunting and testing on OS X) Modified: python/trunk/Misc/ACKS Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Sat Oct 24 13:47:17 2009 @@ -170,6 +170,7 @@ Ben Darnell Jonathan Dasteel John DeGood +Ned Deily Vincent Delft Arnaud Delobelle Erik Demaine From python-checkins at python.org Sat Oct 24 13:49:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 11:49:04 -0000 Subject: [Python-checkins] r75649 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 13:49:04 2009 New Revision: 75649 Log: Recorded merge of revisions 75648 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75648 | mark.dickinson | 2009-10-24 12:47:17 +0100 (Sat, 24 Oct 2009) | 1 line Acknowledge Ned Deily (extensive bug hunting and testing on OS X) ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 13:59:41 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 11:59:41 -0000 Subject: [Python-checkins] r75650 - in python/trunk: Lib/test/test_memoryio.py Modules/_io/bytesio.c Modules/_io/stringio.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 13:59:41 2009 New Revision: 75650 Log: Manual py3k backport: [svn r74155] Issue #6242: Fix deallocator of io.StringIO and io.BytesIO Modified: python/trunk/Lib/test/test_memoryio.py python/trunk/Modules/_io/bytesio.c python/trunk/Modules/_io/stringio.c Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Sat Oct 24 13:59:41 2009 @@ -345,6 +345,13 @@ self.assertEqual(test1(), buf) self.assertEqual(test2(), buf) + def test_instance_dict_leak(self): + # Test case for issue #6242. + # This will be caught by regrtest.py -R if this leak. + for _ in range(100): + memio = self.ioclass() + memio.foo = 1 + class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase): Modified: python/trunk/Modules/_io/bytesio.c ============================================================================== --- python/trunk/Modules/_io/bytesio.c (original) +++ python/trunk/Modules/_io/bytesio.c Sat Oct 24 13:59:41 2009 @@ -616,11 +616,14 @@ static void bytesio_dealloc(bytesio *self) { + _PyObject_GC_UNTRACK(self); if (self->buf != NULL) { PyMem_Free(self->buf); self->buf = NULL; } - Py_TYPE(self)->tp_clear((PyObject *)self); + Py_CLEAR(self->dict); + if (self->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); Py_TYPE(self)->tp_free(self); } @@ -674,7 +677,6 @@ bytesio_traverse(bytesio *self, visitproc visit, void *arg) { Py_VISIT(self->dict); - Py_VISIT(self->weakreflist); return 0; } @@ -682,8 +684,6 @@ bytesio_clear(bytesio *self) { Py_CLEAR(self->dict); - if (self->weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *)self); return 0; } Modified: python/trunk/Modules/_io/stringio.c ============================================================================== --- python/trunk/Modules/_io/stringio.c (original) +++ python/trunk/Modules/_io/stringio.c Sat Oct 24 13:59:41 2009 @@ -515,11 +515,15 @@ stringio_dealloc(stringio *self) { _PyObject_GC_UNTRACK(self); + self->ok = 0; + if (self->buf) { + PyMem_Free(self->buf); + self->buf = NULL; + } Py_CLEAR(self->readnl); Py_CLEAR(self->writenl); Py_CLEAR(self->decoder); - if (self->buf) - PyMem_Free(self->buf); + Py_CLEAR(self->dict); if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); Py_TYPE(self)->tp_free(self); From python-checkins at python.org Sat Oct 24 14:13:31 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 12:13:31 -0000 Subject: [Python-checkins] r75651 - in python/trunk: Doc/license.rst Include/Python.h Include/dtoa.h Makefile.pre.in PCbuild/pythoncore.vcproj Python/dtoa.c Message-ID: Author: mark.dickinson Date: Sat Oct 24 14:13:30 2009 New Revision: 75651 Log: Issue #7117: Prepare for backport of py3k float repr. Add the Python/dtoa.c file containing the main algorithms; add corresponding include file and include in Python.h; include license information for Python/dtoa.c; add dtoa.c and dtoa.h to Makefile. Added: python/trunk/Include/dtoa.h python/trunk/Python/dtoa.c Modified: python/trunk/Doc/license.rst python/trunk/Include/Python.h python/trunk/Makefile.pre.in python/trunk/PCbuild/pythoncore.vcproj Modified: python/trunk/Doc/license.rst ============================================================================== --- python/trunk/Doc/license.rst (original) +++ python/trunk/Doc/license.rst Sat Oct 24 14:13:30 2009 @@ -708,3 +708,35 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +strtod and dtoa +--------------- + +The file :file:`Python/dtoa.c`, which supplies C functions dtoa and +strtod for conversion of C doubles to and from strings, is derived +from the file of the same name by David M. Gay, currently available +from http://www.netlib.org/fp/. The original file, as retrieved on +March 16, 2009, contains the following copyright and licensing +notice:: + + /**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + + Modified: python/trunk/Include/Python.h ============================================================================== --- python/trunk/Include/Python.h (original) +++ python/trunk/Include/Python.h Sat Oct 24 14:13:30 2009 @@ -137,6 +137,7 @@ #include "pyctype.h" #include "pystrtod.h" #include "pystrcmp.h" +#include "dtoa.h" /* _Py_Mangle is defined in compile.c */ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); Added: python/trunk/Include/dtoa.h ============================================================================== --- (empty file) +++ python/trunk/Include/dtoa.h Sat Oct 24 14:13:30 2009 @@ -0,0 +1,15 @@ +#ifndef PY_NO_SHORT_FLOAT_REPR +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); +PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); + + +#ifdef __cplusplus +} +#endif +#endif Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Sat Oct 24 14:13:30 2009 @@ -290,6 +290,7 @@ Python/getopt.o \ Python/pystrcmp.o \ Python/pystrtod.o \ + Python/dtoa.o \ Python/formatter_unicode.o \ Python/formatter_string.o \ Python/$(DYNLOADFILE) \ @@ -606,6 +607,7 @@ Include/complexobject.h \ Include/descrobject.h \ Include/dictobject.h \ + Include/dtoa.h \ Include/enumobject.h \ Include/errcode.h \ Include/eval.h \ Modified: python/trunk/PCbuild/pythoncore.vcproj ============================================================================== --- python/trunk/PCbuild/pythoncore.vcproj (original) +++ python/trunk/PCbuild/pythoncore.vcproj Sat Oct 24 14:13:30 2009 @@ -903,6 +903,10 @@ > + + @@ -1799,6 +1803,10 @@ > + + Added: python/trunk/Python/dtoa.c ============================================================================== --- (empty file) +++ python/trunk/Python/dtoa.c Sat Oct 24 14:13:30 2009 @@ -0,0 +1,2609 @@ +/**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + +/**************************************************************** + * This is dtoa.c by David M. Gay, downloaded from + * http://www.netlib.org/fp/dtoa.c on April 15, 2009 and modified for + * inclusion into the Python core by Mark E. T. Dickinson and Eric V. Smith. + * + * Please remember to check http://www.netlib.org/fp regularly (and especially + * before any Python release) for bugfixes and updates. + * + * The major modifications from Gay's original code are as follows: + * + * 0. The original code has been specialized to Python's needs by removing + * many of the #ifdef'd sections. In particular, code to support VAX and + * IBM floating-point formats, hex NaNs, hex floats, locale-aware + * treatment of the decimal point, and setting of the inexact flag have + * been removed. + * + * 1. We use PyMem_Malloc and PyMem_Free in place of malloc and free. + * + * 2. The public functions strtod, dtoa and freedtoa all now have + * a _Py_dg_ prefix. + * + * 3. Instead of assuming that PyMem_Malloc always succeeds, we thread + * PyMem_Malloc failures through the code. The functions + * + * Balloc, multadd, s2b, i2b, mult, pow5mult, lshift, diff, d2b + * + * of return type *Bigint all return NULL to indicate a malloc failure. + * Similarly, rv_alloc and nrv_alloc (return type char *) return NULL on + * failure. bigcomp now has return type int (it used to be void) and + * returns -1 on failure and 0 otherwise. _Py_dg_dtoa returns NULL + * on failure. _Py_dg_strtod indicates failure due to malloc failure + * by returning -1.0, setting errno=ENOMEM and *se to s00. + * + * 4. The static variable dtoa_result has been removed. Callers of + * _Py_dg_dtoa are expected to call _Py_dg_freedtoa to free + * the memory allocated by _Py_dg_dtoa. + * + * 5. The code has been reformatted to better fit with Python's + * C style guide (PEP 7). + * + * 6. A bug in the memory allocation has been fixed: to avoid FREEing memory + * that hasn't been MALLOC'ed, private_mem should only be used when k <= + * Kmax. + * + * 7. _Py_dg_strtod has been modified so that it doesn't accept strings with + * leading whitespace. + * + ***************************************************************/ + +/* Please send bug reports for the original dtoa.c code to David M. Gay (dmg + * at acm dot org, with " at " changed at "@" and " dot " changed to "."). + * Please report bugs for this modified version using the Python issue tracker + * (http://bugs.python.org). */ + +/* On a machine with IEEE extended-precision registers, it is + * necessary to specify double-precision (53-bit) rounding precision + * before invoking strtod or dtoa. If the machine uses (the equivalent + * of) Intel 80x87 arithmetic, the call + * _control87(PC_53, MCW_PC); + * does this with many compilers. Whether this or another call is + * appropriate depends on the compiler; for this to work, it may be + * necessary to #include "float.h" or another system-dependent header + * file. + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* Linking of Python's #defines to Gay's #defines starts here. */ + +#include "Python.h" + +/* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile + the following code */ +#ifndef PY_NO_SHORT_FLOAT_REPR + +#include "float.h" + +#define MALLOC PyMem_Malloc +#define FREE PyMem_Free + +/* This code should also work for ARM mixed-endian format on little-endian + machines, where doubles have byte order 45670123 (in increasing address + order, 0 being the least significant byte). */ +#ifdef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +# define IEEE_8087 +#endif +#if defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) || \ + defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +# define IEEE_MC68k +#endif +#if defined(IEEE_8087) + defined(IEEE_MC68k) != 1 +#error "Exactly one of IEEE_8087 or IEEE_MC68k should be defined." +#endif + +/* The code below assumes that the endianness of integers matches the + endianness of the two 32-bit words of a double. Check this. */ +#if defined(WORDS_BIGENDIAN) && (defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) || \ + defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)) +#error "doubles and ints have incompatible endianness" +#endif + +#if !defined(WORDS_BIGENDIAN) && defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) +#error "doubles and ints have incompatible endianness" +#endif + + +#if defined(HAVE_UINT32_T) && defined(HAVE_INT32_T) +typedef PY_UINT32_T ULong; +typedef PY_INT32_T Long; +#else +#error "Failed to find an exact-width 32-bit integer type" +#endif + +#if defined(HAVE_UINT64_T) +#define ULLong PY_UINT64_T +#else +#undef ULLong +#endif + +#undef DEBUG +#ifdef Py_DEBUG +#define DEBUG +#endif + +/* End Python #define linking */ + +#ifdef DEBUG +#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#ifndef PRIVATE_MEM +#define PRIVATE_MEM 2304 +#endif +#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) +static double private_mem[PRIVATE_mem], *pmem_next = private_mem; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union { double d; ULong L[2]; } U; + +#ifdef IEEE_8087 +#define word0(x) (x)->L[1] +#define word1(x) (x)->L[0] +#else +#define word0(x) (x)->L[0] +#define word1(x) (x)->L[1] +#endif +#define dval(x) (x)->d + +#ifndef STRTOD_DIGLIM +#define STRTOD_DIGLIM 40 +#endif + +#ifdef DIGLIM_DEBUG +extern int strtod_diglim; +#else +#define strtod_diglim STRTOD_DIGLIM +#endif + +/* The following definition of Storeinc is appropriate for MIPS processors. + * An alternative that might be better on some machines is + * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) + */ +#if defined(IEEE_8087) +#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ + ((unsigned short *)a)[0] = (unsigned short)c, a++) +#else +#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ + ((unsigned short *)a)[1] = (unsigned short)c, a++) +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Nbits 53 +#define Bias 1023 +#define Emax 1023 +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 + +#ifndef Flt_Rounds +#ifdef FLT_ROUNDS +#define Flt_Rounds FLT_ROUNDS +#else +#define Flt_Rounds 1 +#endif +#endif /*Flt_Rounds*/ + +#define Rounding Flt_Rounds + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +/* struct BCinfo is used to pass information from _Py_dg_strtod to bigcomp */ + +typedef struct BCinfo BCinfo; +struct +BCinfo { + int dp0, dp1, dplen, dsign, e0, inexact; + int nd, nd0, rounding, scale, uflchk; +}; + +#define FFFFFFFF 0xffffffffUL + +#define Kmax 7 + +/* struct Bigint is used to represent arbitrary-precision integers. These + integers are stored in sign-magnitude format, with the magnitude stored as + an array of base 2**32 digits. Bigints are always normalized: if x is a + Bigint then x->wds >= 1, and either x->wds == 1 or x[wds-1] is nonzero. + + The Bigint fields are as follows: + + - next is a header used by Balloc and Bfree to keep track of lists + of freed Bigints; it's also used for the linked list of + powers of 5 of the form 5**2**i used by pow5mult. + - k indicates which pool this Bigint was allocated from + - maxwds is the maximum number of words space was allocated for + (usually maxwds == 2**k) + - sign is 1 for negative Bigints, 0 for positive. The sign is unused + (ignored on inputs, set to 0 on outputs) in almost all operations + involving Bigints: a notable exception is the diff function, which + ignores signs on inputs but sets the sign of the output correctly. + - wds is the actual number of significant words + - x contains the vector of words (digits) for this Bigint, from least + significant (x[0]) to most significant (x[wds-1]). +*/ + +struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; +}; + +typedef struct Bigint Bigint; + +/* Memory management: memory is allocated from, and returned to, Kmax+1 pools + of memory, where pool k (0 <= k <= Kmax) is for Bigints b with b->maxwds == + 1 << k. These pools are maintained as linked lists, with freelist[k] + pointing to the head of the list for pool k. + + On allocation, if there's no free slot in the appropriate pool, MALLOC is + called to get more memory. This memory is not returned to the system until + Python quits. There's also a private memory pool that's allocated from + in preference to using MALLOC. + + For Bigints with more than (1 << Kmax) digits (which implies at least 1233 + decimal digits), memory is directly allocated using MALLOC, and freed using + FREE. + + XXX: it would be easy to bypass this memory-management system and + translate each call to Balloc into a call to PyMem_Malloc, and each + Bfree to PyMem_Free. Investigate whether this has any significant + performance on impact. */ + +static Bigint *freelist[Kmax+1]; + +/* Allocate space for a Bigint with up to 1<next; + else { + x = 1 << k; + len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) + /sizeof(double); + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { + rv = (Bigint*)pmem_next; + pmem_next += len; + } + else { + rv = (Bigint*)MALLOC(len*sizeof(double)); + if (rv == NULL) + return NULL; + } + rv->k = k; + rv->maxwds = x; + } + rv->sign = rv->wds = 0; + return rv; +} + +/* Free a Bigint allocated with Balloc */ + +static void +Bfree(Bigint *v) +{ + if (v) { + if (v->k > Kmax) + FREE((void*)v); + else { + v->next = freelist[v->k]; + freelist[v->k] = v; + } + } +} + +#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ + y->wds*sizeof(Long) + 2*sizeof(int)) + +/* Multiply a Bigint b by m and add a. Either modifies b in place and returns + a pointer to the modified b, or Bfrees b and returns a pointer to a copy. + On failure, return NULL. In this case, b will have been already freed. */ + +static Bigint * +multadd(Bigint *b, int m, int a) /* multiply by m and add a */ +{ + int i, wds; +#ifdef ULLong + ULong *x; + ULLong carry, y; +#else + ULong carry, *x, y; + ULong xi, z; +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + carry = a; + do { +#ifdef ULLong + y = *x * (ULLong)m + carry; + carry = y >> 32; + *x++ = (ULong)(y & FFFFFFFF); +#else + xi = *x; + y = (xi & 0xffff) * m + carry; + z = (xi >> 16) * m + (y >> 16); + carry = z >> 16; + *x++ = (z << 16) + (y & 0xffff); +#endif + } + while(++i < wds); + if (carry) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + if (b1 == NULL){ + Bfree(b); + return NULL; + } + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = (ULong)carry; + b->wds = wds; + } + return b; +} + +/* convert a string s containing nd decimal digits (possibly containing a + decimal separator at position nd0, which is ignored) to a Bigint. This + function carries on where the parsing code in _Py_dg_strtod leaves off: on + entry, y9 contains the result of converting the first 9 digits. Returns + NULL on failure. */ + +static Bigint * +s2b(const char *s, int nd0, int nd, ULong y9, int dplen) +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; + b = Balloc(k); + if (b == NULL) + return NULL; + b->x[0] = y9; + b->wds = 1; + + i = 9; + if (9 < nd0) { + s += 9; + do { + b = multadd(b, 10, *s++ - '0'); + if (b == NULL) + return NULL; + } while(++i < nd0); + s += dplen; + } + else + s += dplen + 9; + for(; i < nd; i++) { + b = multadd(b, 10, *s++ - '0'); + if (b == NULL) + return NULL; + } + return b; +} + +/* count leading 0 bits in the 32-bit integer x. */ + +static int +hi0bits(ULong x) +{ + int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; +} + +/* count trailing 0 bits in the 32-bit integer y, and shift y right by that + number of bits. */ + +static int +lo0bits(ULong *y) +{ + int k; + ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x) + return 32; + } + *y = x; + return k; +} + +/* convert a small nonnegative integer to a Bigint */ + +static Bigint * +i2b(int i) +{ + Bigint *b; + + b = Balloc(1); + if (b == NULL) + return NULL; + b->x[0] = i; + b->wds = 1; + return b; +} + +/* multiply two Bigints. Returns a new Bigint, or NULL on failure. Ignores + the signs of a and b. */ + +static Bigint * +mult(Bigint *a, Bigint *b) +{ + Bigint *c; + int k, wa, wb, wc; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; + ULong y; +#ifdef ULLong + ULLong carry, z; +#else + ULong carry, z; + ULong z2; +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + if (c == NULL) + return NULL; + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef ULLong + for(; xb < xbe; xc0++) { + if ((y = *xb++)) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * (ULLong)y + *xc + carry; + carry = z >> 32; + *xc++ = (ULong)(z & FFFFFFFF); + } + while(x < xae); + *xc = (ULong)carry; + } + } +#else + for(; xb < xbe; xb++, xc0++) { + if (y = *xb & 0xffff) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if (y = *xb >> 16) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } +#endif + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; +} + +/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */ + +static Bigint *p5s; + +/* multiply the Bigint b by 5**k. Returns a pointer to the result, or NULL on + failure; if the returned pointer is distinct from b then the original + Bigint b will have been Bfree'd. Ignores the sign of b. */ + +static Bigint * +pow5mult(Bigint *b, int k) +{ + Bigint *b1, *p5, *p51; + int i; + static int p05[3] = { 5, 25, 125 }; + + if ((i = k & 3)) { + b = multadd(b, p05[i-1], 0); + if (b == NULL) + return NULL; + } + + if (!(k >>= 2)) + return b; + p5 = p5s; + if (!p5) { + /* first time */ + p5 = i2b(625); + if (p5 == NULL) { + Bfree(b); + return NULL; + } + p5s = p5; + p5->next = 0; + } + for(;;) { + if (k & 1) { + b1 = mult(b, p5); + Bfree(b); + b = b1; + if (b == NULL) + return NULL; + } + if (!(k >>= 1)) + break; + p51 = p5->next; + if (!p51) { + p51 = mult(p5,p5); + if (p51 == NULL) { + Bfree(b); + return NULL; + } + p51->next = 0; + p5->next = p51; + } + p5 = p51; + } + return b; +} + +/* shift a Bigint b left by k bits. Return a pointer to the shifted result, + or NULL on failure. If the returned pointer is distinct from b then the + original b will have been Bfree'd. Ignores the sign of b. */ + +static Bigint * +lshift(Bigint *b, int k) +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + + n = k >> 5; + k1 = b->k; + n1 = n + b->wds + 1; + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + if (b1 == NULL) { + Bfree(b); + return NULL; + } + x1 = b1->x; + for(i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; + if (k &= 0x1f) { + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } + while(x < xe); + if ((*x1 = z)) + ++n1; + } + else do + *x1++ = *x++; + while(x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; +} + +/* Do a three-way compare of a and b, returning -1 if a < b, 0 if a == b and + 1 if a > b. Ignores signs of a and b. */ + +static int +cmp(Bigint *a, Bigint *b) +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; +} + +/* Take the difference of Bigints a and b, returning a new Bigint. Returns + NULL on failure. The signs of a and b are ignored, but the sign of the + result is set appropriately. */ + +static Bigint * +diff(Bigint *a, Bigint *b) +{ + Bigint *c; + int i, wa, wb; + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef ULLong + ULLong borrow, y; +#else + ULong borrow, y; + ULong z; +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + if (c == NULL) + return NULL; + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + if (c == NULL) + return NULL; + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef ULLong + do { + y = (ULLong)*xa++ - *xb++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)(y & FFFFFFFF); + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)(y & FFFFFFFF); + } +#else + do { + y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } +#endif + while(!*--xc) + wa--; + c->wds = wa; + return c; +} + +/* Given a positive normal double x, return the difference between x and the next + double up. Doesn't give correct results for subnormals. */ + +static double +ulp(U *x) +{ + Long L; + U u; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; + word0(&u) = L; + word1(&u) = 0; + return dval(&u); +} + +/* Convert a Bigint to a double plus an exponent */ + +static double +b2d(Bigint *a, int *e) +{ + ULong *xa, *xa0, w, y, z; + int k; + U d; + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; + if (k < Ebits) { + word0(&d) = Exp_1 | y >> (Ebits - k); + w = xa > xa0 ? *--xa : 0; + word1(&d) = y << ((32-Ebits) + k) | w >> (Ebits - k); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + word0(&d) = Exp_1 | y << k | z >> (32 - k); + y = xa > xa0 ? *--xa : 0; + word1(&d) = z << k | y >> (32 - k); + } + else { + word0(&d) = Exp_1 | y; + word1(&d) = z; + } + ret_d: + return dval(&d); +} + +/* Convert a double to a Bigint plus an exponent. Return NULL on failure. + + Given a finite nonzero double d, return an odd Bigint b and exponent *e + such that fabs(d) = b * 2**e. On return, *bbits gives the number of + significant bits of e; that is, 2**(*bbits-1) <= b < 2**(*bbits). + + If d is zero, then b == 0, *e == -1010, *bbits = 0. + */ + + +static Bigint * +d2b(U *d, int *e, int *bits) +{ + Bigint *b; + int de, k; + ULong *x, y, z; + int i; + + b = Balloc(1); + if (b == NULL) + return NULL; + x = b->x; + + z = word0(d) & Frac_mask; + word0(d) &= 0x7fffffff; /* clear sign bit, which we ignore */ + if ((de = (int)(word0(d) >> Exp_shift))) + z |= Exp_msk1; + if ((y = word1(d))) { + if ((k = lo0bits(&y))) { + x[0] = y | z << (32 - k); + z >>= k; + } + else + x[0] = y; + i = + b->wds = (x[1] = z) ? 2 : 1; + } + else { + k = lo0bits(&z); + x[0] = z; + i = + b->wds = 1; + k += 32; + } + if (de) { + *e = de - Bias - (P-1) + k; + *bits = P - k; + } + else { + *e = de - Bias - (P-1) + 1 + k; + *bits = 32*i - hi0bits(x[i-1]); + } + return b; +} + +/* Compute the ratio of two Bigints, as a double. The result may have an + error of up to 2.5 ulps. */ + +static double +ratio(Bigint *a, Bigint *b) +{ + U da, db; + int k, ka, kb; + + dval(&da) = b2d(a, &ka); + dval(&db) = b2d(b, &kb); + k = ka - kb + 32*(a->wds - b->wds); + if (k > 0) + word0(&da) += k*Exp_msk1; + else { + k = -k; + word0(&db) += k*Exp_msk1; + } + return dval(&da) / dval(&db); +} + +static const double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +}; + +static const double +bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, + 9007199254740992.*9007199254740992.e-256 + /* = 2^106 * 1e-256 */ +}; +/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ +/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ +#define Scale_Bit 0x10 +#define n_bigtens 5 + +#define ULbits 32 +#define kshift 5 +#define kmask 31 + + +static int +dshift(Bigint *b, int p2) +{ + int rv = hi0bits(b->x[b->wds-1]) - 4; + if (p2 > 0) + rv -= p2; + return rv & kmask; +} + +/* special case of Bigint division. The quotient is always in the range 0 <= + quotient < 10, and on entry the divisor S is normalized so that its top 4 + bits (28--31) are zero and bit 27 is set. */ + +static int +quorem(Bigint *b, Bigint *S) +{ + int n; + ULong *bx, *bxe, q, *sx, *sxe; +#ifdef ULLong + ULLong borrow, carry, y, ys; +#else + ULong borrow, carry, y, ys; + ULong si, z, zs; +#endif + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef ULLong + ys = *sx++ * (ULLong)q + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)(y & FFFFFFFF); +#else + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#endif + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef ULLong + ys = *sx++ + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)(y & FFFFFFFF); +#else + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#endif + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; +} + + +/* return 0 on success, -1 on failure */ + +static int +bigcomp(U *rv, const char *s0, BCinfo *bc) +{ + Bigint *b, *d; + int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase; + + dsign = bc->dsign; + nd = bc->nd; + nd0 = bc->nd0; + p5 = nd + bc->e0 - 1; + speccase = 0; + if (rv->d == 0.) { /* special case: value near underflow-to-zero */ + /* threshold was rounded to zero */ + b = i2b(1); + if (b == NULL) + return -1; + p2 = Emin - P + 1; + bbits = 1; + word0(rv) = (P+2) << Exp_shift; + i = 0; + { + speccase = 1; + --p2; + dsign = 0; + goto have_i; + } + } + else + { + b = d2b(rv, &p2, &bbits); + if (b == NULL) + return -1; + } + p2 -= bc->scale; + /* floor(log2(rv)) == bbits - 1 + p2 */ + /* Check for denormal case. */ + i = P - bbits; + if (i > (j = P - Emin - 1 + p2)) { + i = j; + } + { + b = lshift(b, ++i); + if (b == NULL) + return -1; + b->x[0] |= 1; + } + have_i: + p2 -= p5 + i; + d = i2b(1); + if (d == NULL) { + Bfree(b); + return -1; + } + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + */ + if (p5 > 0) { + d = pow5mult(d, p5); + if (d == NULL) { + Bfree(b); + return -1; + } + } + else if (p5 < 0) { + b = pow5mult(b, -p5); + if (b == NULL) { + Bfree(d); + return -1; + } + } + if (p2 > 0) { + b2 = p2; + d2 = 0; + } + else { + b2 = 0; + d2 = -p2; + } + i = dshift(d, d2); + if ((b2 += i) > 0) { + b = lshift(b, b2); + if (b == NULL) { + Bfree(d); + return -1; + } + } + if ((d2 += i) > 0) { + d = lshift(d, d2); + if (d == NULL) { + Bfree(b); + return -1; + } + } + + /* Now b/d = exactly half-way between the two floating-point values */ + /* on either side of the input string. Compute first digit of b/d. */ + + if (!(dig = quorem(b,d))) { + b = multadd(b, 10, 0); /* very unlikely */ + if (b == NULL) { + Bfree(d); + return -1; + } + dig = quorem(b,d); + } + + /* Compare b/d with s0 */ + + assert(nd > 0); + dd = 9999; /* silence gcc compiler warning */ + for(i = 0; i < nd0; ) { + if ((dd = s0[i++] - '0' - dig)) + goto ret; + if (!b->x[0] && b->wds == 1) { + if (i < nd) + dd = 1; + goto ret; + } + b = multadd(b, 10, 0); + if (b == NULL) { + Bfree(d); + return -1; + } + dig = quorem(b,d); + } + for(j = bc->dp1; i++ < nd;) { + if ((dd = s0[j++] - '0' - dig)) + goto ret; + if (!b->x[0] && b->wds == 1) { + if (i < nd) + dd = 1; + goto ret; + } + b = multadd(b, 10, 0); + if (b == NULL) { + Bfree(d); + return -1; + } + dig = quorem(b,d); + } + if (b->x[0] || b->wds > 1) + dd = -1; + ret: + Bfree(b); + Bfree(d); + if (speccase) { + if (dd <= 0) + rv->d = 0.; + } + else if (dd < 0) { + if (!dsign) /* does not happen for round-near */ + retlow1: + dval(rv) -= ulp(rv); + } + else if (dd > 0) { + if (dsign) { + rethi1: + dval(rv) += ulp(rv); + } + } + else { + /* Exact half-way case: apply round-even rule. */ + if (word1(rv) & 1) { + if (dsign) + goto rethi1; + goto retlow1; + } + } + + return 0; +} + +double +_Py_dg_strtod(const char *s00, char **se) +{ + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1, error; + int esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + const char *s, *s0, *s1; + double aadj, aadj1; + Long L; + U aadj2, adj, rv, rv0; + ULong y, z; + BCinfo bc; + Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; + + sign = nz0 = nz = bc.dplen = bc.uflchk = 0; + dval(&rv) = 0.; + for(s = s00;;s++) switch(*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + goto ret0; + /* modify original dtoa.c so that it doesn't accept leading whitespace + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + */ + default: + goto break2; + } + break2: + if (*s == '0') { + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; + bc.dp0 = bc.dp1 = s - s0; + if (c == '.') { + c = *++s; + bc.dp1 = s - s0; + bc.dplen = bc.dp1 - bc.dp0; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + } + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + goto ret0; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) { + ret0: + s = s00; + sign = 0; + } + goto ret; + } + bc.e0 = e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + dval(&rv) = y; + if (k > 9) { + dval(&rv) = tens[k - 9] * dval(&rv) + z; + } + bd0 = 0; + if (nd <= DBL_DIG + && Flt_Rounds == 1 + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { + dval(&rv) *= tens[e]; + goto ret; + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ + e -= i; + dval(&rv) *= tens[i]; + dval(&rv) *= tens[e]; + goto ret; + } + } + else if (e >= -Ten_pmax) { + dval(&rv) /= tens[-e]; + goto ret; + } + } + e1 += nd - k; + + bc.scale = 0; + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ((i = e1 & 15)) + dval(&rv) *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: + errno = ERANGE; + /* Can't trust HUGE_VAL */ + word0(&rv) = Exp_mask; + word1(&rv) = 0; + goto ret; + } + e1 >>= 4; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= bigtens[j]; + /* The last multiplication could overflow. */ + word0(&rv) -= P*Exp_msk1; + dval(&rv) *= bigtens[j]; + if ((z = word0(&rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + word0(&rv) = Big0; + word1(&rv) = Big1; + } + else + word0(&rv) += P*Exp_msk1; + } + } + else if (e1 < 0) { + e1 = -e1; + if ((i = e1 & 15)) + dval(&rv) /= tens[i]; + if (e1 >>= 4) { + if (e1 >= 1 << n_bigtens) + goto undfl; + if (e1 & Scale_Bit) + bc.scale = 2*P; + for(j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(&rv) *= tinytens[j]; + if (bc.scale && (j = 2*P + 1 - ((word0(&rv) & Exp_mask) + >> Exp_shift)) > 0) { + /* scaled rv is denormal; clear j low bits */ + if (j >= 32) { + word1(&rv) = 0; + if (j >= 53) + word0(&rv) = (P+2)*Exp_msk1; + else + word0(&rv) &= 0xffffffff << (j-32); + } + else + word1(&rv) &= 0xffffffff << j; + } + if (!dval(&rv)) { + undfl: + dval(&rv) = 0.; + errno = ERANGE; + goto ret; + } + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bc.nd = nd; + bc.nd0 = nd0; /* Only needed if nd > strtod_diglim, but done here */ + /* to silence an erroneous warning about bc.nd0 */ + /* possibly not being initialized. */ + if (nd > strtod_diglim) { + /* ASSERT(strtod_diglim >= 18); 18 == one more than the */ + /* minimum number of decimal digits to distinguish double values */ + /* in IEEE arithmetic. */ + i = j = 18; + if (i > nd0) + j += bc.dplen; + for(;;) { + if (--j <= bc.dp1 && j >= bc.dp0) + j = bc.dp0 - 1; + if (s0[j] != '0') + break; + --i; + } + e += nd - i; + nd = i; + if (nd0 > nd) + nd0 = nd; + if (nd < 9) { /* must recompute y */ + y = 0; + for(i = 0; i < nd0; ++i) + y = 10*y + s0[i] - '0'; + for(j = bc.dp1; i < nd; ++i) + y = 10*y + s0[j++] - '0'; + } + } + bd0 = s2b(s0, nd0, nd, y, bc.dplen); + if (bd0 == NULL) + goto failed_malloc; + + for(;;) { + bd = Balloc(bd0->k); + if (bd == NULL) { + Bfree(bd0); + goto failed_malloc; + } + Bcopy(bd, bd0); + bb = d2b(&rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ + if (bb == NULL) { + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + bs = i2b(1); + if (bs == NULL) { + Bfree(bb); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; + j = bbe - bc.scale; + i = j + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; + bb2 += j; + bd2 += j; + bd2 += bc.scale; + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + if (bs == NULL) { + Bfree(bb); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + bb1 = mult(bs, bb); + Bfree(bb); + bb = bb1; + if (bb == NULL) { + Bfree(bs); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + } + if (bb2 > 0) { + bb = lshift(bb, bb2); + if (bb == NULL) { + Bfree(bs); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + } + if (bd5 > 0) { + bd = pow5mult(bd, bd5); + if (bd == NULL) { + Bfree(bb); + Bfree(bs); + Bfree(bd0); + goto failed_malloc; + } + } + if (bd2 > 0) { + bd = lshift(bd, bd2); + if (bd == NULL) { + Bfree(bb); + Bfree(bs); + Bfree(bd0); + goto failed_malloc; + } + } + if (bs2 > 0) { + bs = lshift(bs, bs2); + if (bs == NULL) { + Bfree(bb); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + } + delta = diff(bb, bd); + if (delta == NULL) { + Bfree(bb); + Bfree(bs); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + bc.dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); + if (bc.nd > nd && i <= 0) { + if (bc.dsign) + break; /* Must use bigcomp(). */ + { + bc.nd = nd; + i = -1; /* Discarded digits make delta smaller. */ + } + } + + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask + || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1 + ) { + break; + } + if (!delta->x[0] && delta->wds <= 1) { + /* exact result */ + break; + } + delta = lshift(delta,Log2P); + if (delta == NULL) { + Bfree(bb); + Bfree(bs); + Bfree(bd); + Bfree(bd0); + goto failed_malloc; + } + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (bc.dsign) { + if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 + && word1(&rv) == ( + (bc.scale && + (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) ? + (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : + 0xffffffff)) { + /*boundary case -- increment exponent*/ + word0(&rv) = (word0(&rv) & Exp_mask) + + Exp_msk1 + ; + word1(&rv) = 0; + bc.dsign = 0; + break; + } + } + else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) { + drop_down: + /* boundary case -- decrement exponent */ + if (bc.scale) { + L = word0(&rv) & Exp_mask; + if (L <= (2*P+1)*Exp_msk1) { + if (L > (P+2)*Exp_msk1) + /* round even ==> */ + /* accept rv */ + break; + /* rv = smallest denormal */ + if (bc.nd >nd) { + bc.uflchk = 1; + break; + } + goto undfl; + } + } + L = (word0(&rv) & Exp_mask) - Exp_msk1; + word0(&rv) = L | Bndry_mask1; + word1(&rv) = 0xffffffff; + break; + } + if (!(word1(&rv) & LSB)) + break; + if (bc.dsign) + dval(&rv) += ulp(&rv); + else { + dval(&rv) -= ulp(&rv); + if (!dval(&rv)) { + if (bc.nd >nd) { + bc.uflchk = 1; + break; + } + goto undfl; + } + } + bc.dsign = 1 - bc.dsign; + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (bc.dsign) + aadj = aadj1 = 1.; + else if (word1(&rv) || word0(&rv) & Bndry_mask) { + if (word1(&rv) == Tiny1 && !word0(&rv)) { + if (bc.nd >nd) { + bc.uflchk = 1; + break; + } + goto undfl; + } + aadj = 1.; + aadj1 = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + aadj1 = -aadj; + } + } + else { + aadj *= 0.5; + aadj1 = bc.dsign ? aadj : -aadj; + if (Flt_Rounds == 0) + aadj1 += 0.5; + } + y = word0(&rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + dval(&rv0) = dval(&rv); + word0(&rv) -= P*Exp_msk1; + adj.d = aadj1 * ulp(&rv); + dval(&rv) += adj.d; + if ((word0(&rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(&rv0) == Big0 && word1(&rv0) == Big1) + goto ovfl; + word0(&rv) = Big0; + word1(&rv) = Big1; + goto cont; + } + else + word0(&rv) += P*Exp_msk1; + } + else { + if (bc.scale && y <= 2*P*Exp_msk1) { + if (aadj <= 0x7fffffff) { + if ((z = (ULong)aadj) <= 0) + z = 1; + aadj = z; + aadj1 = bc.dsign ? aadj : -aadj; + } + dval(&aadj2) = aadj1; + word0(&aadj2) += (2*P+1)*Exp_msk1 - y; + aadj1 = dval(&aadj2); + } + adj.d = aadj1 * ulp(&rv); + dval(&rv) += adj.d; + } + z = word0(&rv) & Exp_mask; + if (bc.nd == nd) { + if (!bc.scale) + if (y == z) { + /* Can we stop now? */ + L = (Long)aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } + } + cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + if (bc.nd > nd) { + error = bigcomp(&rv, s0, &bc); + if (error) + goto failed_malloc; + } + + if (bc.scale) { + word0(&rv0) = Exp_1 - 2*P*Exp_msk1; + word1(&rv0) = 0; + dval(&rv) *= dval(&rv0); + /* try to avoid the bug of testing an 8087 register value */ + if (!(word0(&rv) & Exp_mask)) + errno = ERANGE; + } + ret: + if (se) + *se = (char *)s; + return sign ? -dval(&rv) : dval(&rv); + + failed_malloc: + if (se) + *se = (char *)s00; + errno = ENOMEM; + return -1.0; +} + +static char * +rv_alloc(int i) +{ + int j, k, *r; + + j = sizeof(ULong); + for(k = 0; + sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (unsigned)i; + j <<= 1) + k++; + r = (int*)Balloc(k); + if (r == NULL) + return NULL; + *r = k; + return (char *)(r+1); +} + +static char * +nrv_alloc(char *s, char **rve, int n) +{ + char *rv, *t; + + rv = rv_alloc(n); + if (rv == NULL) + return NULL; + t = rv; + while((*t = *s++)) t++; + if (rve) + *rve = t; + return rv; +} + +/* freedtoa(s) must be used to free values s returned by dtoa + * when MULTIPLE_THREADS is #defined. It should be used in all cases, + * but for consistency with earlier versions of dtoa, it is optional + * when MULTIPLE_THREADS is not defined. + */ + +void +_Py_dg_freedtoa(char *s) +{ + Bigint *b = (Bigint *)((int *)s - 1); + b->maxwds = 1 << (b->k = *(int*)b); + Bfree(b); +} + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + +/* Additional notes (METD): (1) returns NULL on failure. (2) to avoid memory + leakage, a successful call to _Py_dg_dtoa should always be matched by a + call to _Py_dg_freedtoa. */ + +char * +_Py_dg_dtoa(double dd, int mode, int ndigits, + int *decpt, int *sign, char **rve) +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4,5 ==> similar to 2 and 3, respectively, but (in + round-nearest mode) with the tests of mode 0 to + possibly return a shorter string that rounds to d. + With IEEE arithmetic and compilation with + -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same + as modes 2 and 3 when FLT_ROUNDS != 1. + 6-9 ==> Debugging modes similar to mode - 4: don't try + fast floating-point estimate (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick; + Long L; + int denorm; + ULong x; + Bigint *b, *b1, *delta, *mlo, *mhi, *S; + U d2, eps, u; + double ds; + char *s, *s0; + + /* set pointers to NULL, to silence gcc compiler warnings and make + cleanup easier on error */ + mlo = mhi = b = S = 0; + s0 = 0; + + u.d = dd; + if (word0(&u) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(&u) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + + /* quick return for Infinities, NaNs and zeros */ + if ((word0(&u) & Exp_mask) == Exp_mask) + { + /* Infinity or NaN */ + *decpt = 9999; + if (!word1(&u) && !(word0(&u) & 0xfffff)) + return nrv_alloc("Infinity", rve, 8); + return nrv_alloc("NaN", rve, 3); + } + if (!dval(&u)) { + *decpt = 1; + return nrv_alloc("0", rve, 1); + } + + /* compute k = floor(log10(d)). The computation may leave k + one too large, but should never leave k too small. */ + b = d2b(&u, &be, &bbits); + if (b == NULL) + goto failed_malloc; + if ((i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) { + dval(&d2) = dval(&u); + word0(&d2) &= Frac_mask1; + word0(&d2) |= Exp_11; + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(&u) << (64 - i) | word1(&u) >> (i - 32) + : word1(&u) << (32 - i); + dval(&d2) = x; + word0(&d2) -= 31*Exp_msk1; /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } + ds = (dval(&d2)-1.5)*0.289529654602168 + 0.1760912590558 + + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (dval(&u) < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + + try_quick = 1; + + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ + /* silence erroneous "gcc -Wall" warning. */ + switch(mode) { + case 0: + case 1: + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + s0 = rv_alloc(i); + if (s0 == NULL) + goto failed_malloc; + s = s0; + + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + dval(&d2) = dval(&u); + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + dval(&u) /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + dval(&u) /= ds; + } + else if ((j1 = -k)) { + dval(&u) *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + dval(&u) *= bigtens[i]; + } + } + if (k_check && dval(&u) < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + dval(&u) *= 10.; + ieps++; + } + dval(&eps) = ieps*dval(&u) + 7.; + word0(&eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + dval(&u) -= 5.; + if (dval(&u) > dval(&eps)) + goto one_digit; + if (dval(&u) < -dval(&eps)) + goto no_digits; + goto fast_failed; + } + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); + for(i = 0;;) { + L = (Long)dval(&u); + dval(&u) -= L; + *s++ = '0' + (int)L; + if (dval(&u) < dval(&eps)) + goto ret1; + if (1. - dval(&u) < dval(&eps)) + goto bump_up; + if (++i >= ilim) + break; + dval(&eps) *= 10.; + dval(&u) *= 10.; + } + } + else { + /* Generate ilim digits, then fix them up. */ + dval(&eps) *= tens[ilim-1]; + for(i = 1;; i++, dval(&u) *= 10.) { + L = (Long)(dval(&u)); + if (!(dval(&u) -= L)) + ilim = i; + *s++ = '0' + (int)L; + if (i == ilim) { + if (dval(&u) > 0.5 + dval(&eps)) + goto bump_up; + else if (dval(&u) < 0.5 - dval(&eps)) { + while(*--s == '0'); + s++; + goto ret1; + } + break; + } + } + } + fast_failed: + s = s0; + dval(&u) = dval(&d2); + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || dval(&u) <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++, dval(&u) *= 10.) { + L = (Long)(dval(&u) / ds); + dval(&u) -= L*ds; + *s++ = '0' + (int)L; + if (!dval(&u)) { + break; + } + if (i == ilim) { + dval(&u) += dval(&u); + if (dval(&u) > ds || (dval(&u) == ds && L & 1)) { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + } + goto ret1; + } + + m2 = b2; + m5 = b5; + if (leftright) { + i = + denorm ? be + (Bias + (P-1) - 1 + 1) : + 1 + P - bbits; + b2 += i; + s2 += i; + mhi = i2b(1); + if (mhi == NULL) + goto failed_malloc; + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + if (mhi == NULL) + goto failed_malloc; + b1 = mult(mhi, b); + Bfree(b); + b = b1; + if (b == NULL) + goto failed_malloc; + } + if ((j = b5 - m5)) { + b = pow5mult(b, j); + if (b == NULL) + goto failed_malloc; + } + } + else { + b = pow5mult(b, b5); + if (b == NULL) + goto failed_malloc; + } + } + S = i2b(1); + if (S == NULL) + goto failed_malloc; + if (s5 > 0) { + S = pow5mult(S, s5); + if (S == NULL) + goto failed_malloc; + } + + /* Check for special case that d is a normalized power of 2. */ + + spec_case = 0; + if ((mode < 2 || leftright) + ) { + if (!word1(&u) && !(word0(&u) & Bndry_mask) + && word0(&u) & (Exp_mask & ~Exp_msk1) + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)) + i = 32 - i; +#define iInc 28 + i = dshift(S, s2); + b2 += i; + m2 += i; + s2 += i; + if (b2 > 0) { + b = lshift(b, b2); + if (b == NULL) + goto failed_malloc; + } + if (s2 > 0) { + S = lshift(S, s2); + if (S == NULL) + goto failed_malloc; + } + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (b == NULL) + goto failed_malloc; + if (leftright) { + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + goto failed_malloc; + } + ilim = ilim1; + } + } + if (ilim <= 0 && (mode == 3 || mode == 5)) { + if (ilim < 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + else { + S = multadd(S, 5, 0); + if (S == NULL) + goto failed_malloc; + if (cmp(b, S) <= 0) + goto no_digits; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) { + mhi = lshift(mhi, m2); + if (mhi == NULL) + goto failed_malloc; + } + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + if (mhi == NULL) + goto failed_malloc; + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + if (mhi == NULL) + goto failed_malloc; + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + if (delta == NULL) + goto failed_malloc; + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); + if (j1 == 0 && mode != 1 && !(word1(&u) & 1) + ) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; + *s++ = dig; + goto ret; + } + if (j < 0 || (j == 0 && mode != 1 + && !(word1(&u) & 1) + )) { + if (!b->x[0] && b->wds <= 1) { + goto accept_dig; + } + if (j1 > 0) { + b = lshift(b, 1); + if (b == NULL) + goto failed_malloc; + j1 = cmp(b, S); + if ((j1 > 0 || (j1 == 0 && dig & 1)) + && dig++ == '9') + goto round_9_up; + } + accept_dig: + *s++ = dig; + goto ret; + } + if (j1 > 0) { + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + goto failed_malloc; + if (mlo == mhi) { + mlo = mhi = multadd(mhi, 10, 0); + if (mlo == NULL) + goto failed_malloc; + } + else { + mlo = multadd(mlo, 10, 0); + if (mlo == NULL) + goto failed_malloc; + mhi = multadd(mhi, 10, 0); + if (mhi == NULL) + goto failed_malloc; + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (!b->x[0] && b->wds <= 1) { + goto ret; + } + if (i >= ilim) + break; + b = multadd(b, 10, 0); + if (b == NULL) + goto failed_malloc; + } + + /* Round off last digit */ + + b = lshift(b, 1); + if (b == NULL) + goto failed_malloc; + j = cmp(b, S); + if (j > 0 || (j == 0 && dig & 1)) { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { + while(*--s == '0'); + s++; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; + failed_malloc: + if (S) + Bfree(S); + if (mlo && mlo != mhi) + Bfree(mlo); + if (mhi) + Bfree(mhi); + if (b) + Bfree(b); + if (s0) + _Py_dg_freedtoa(s0); + return NULL; +} +#ifdef __cplusplus +} +#endif + +#endif /* PY_NO_SHORT_FLOAT_REPR */ From python-checkins at python.org Sat Oct 24 14:15:17 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 12:15:17 -0000 Subject: [Python-checkins] r75652 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 14:15:17 2009 New Revision: 75652 Log: Blocked revisions 75651 via svnmerge ........ r75651 | mark.dickinson | 2009-10-24 13:13:30 +0100 (Sat, 24 Oct 2009) | 7 lines Issue #7117: Prepare for backport of py3k float repr. Add the Python/dtoa.c file containing the main algorithms; add corresponding include file and include in Python.h; include license information for Python/dtoa.c; add dtoa.c and dtoa.h to Makefile. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 14:17:24 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 12:17:24 -0000 Subject: [Python-checkins] r75653 - python/trunk/Python/dtoa.c Message-ID: Author: mark.dickinson Date: Sat Oct 24 14:17:24 2009 New Revision: 75653 Log: Temporary define to avoid build failure Modified: python/trunk/Python/dtoa.c Modified: python/trunk/Python/dtoa.c ============================================================================== --- python/trunk/Python/dtoa.c (original) +++ python/trunk/Python/dtoa.c Sat Oct 24 14:17:24 2009 @@ -116,6 +116,8 @@ #include "Python.h" +#define IEEE_8087 + /* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile the following code */ #ifndef PY_NO_SHORT_FLOAT_REPR From python-checkins at python.org Sat Oct 24 14:23:19 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 12:23:19 -0000 Subject: [Python-checkins] r75654 - in python/trunk: Lib/_pyio.py Lib/test/test_memoryio.py Misc/NEWS Modules/_io/bytesio.c Modules/_io/stringio.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 14:23:18 2009 New Revision: 75654 Log: Manual py3k backport: [svn r74158] Issue #6218: Make io.BytesIO and io.StringIO picklable. Modified: python/trunk/Lib/_pyio.py python/trunk/Lib/test/test_memoryio.py python/trunk/Misc/NEWS python/trunk/Modules/_io/bytesio.c python/trunk/Modules/_io/stringio.c Modified: python/trunk/Lib/_pyio.py ============================================================================== --- python/trunk/Lib/_pyio.py (original) +++ python/trunk/Lib/_pyio.py Sat Oct 24 14:23:18 2009 @@ -773,6 +773,11 @@ self._buffer = buf self._pos = 0 + def __getstate__(self): + if self.closed: + raise ValueError("__getstate__ on closed file") + return self.__dict__.copy() + def getvalue(self): """Return the bytes value (contents) of the buffer """ Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Sat Oct 24 14:23:18 2009 @@ -12,6 +12,7 @@ import io import _pyio as pyio import sys +import pickle class MemorySeekTestMixin: @@ -352,6 +353,42 @@ memio = self.ioclass() memio.foo = 1 + def test_pickling(self): + buf = self.buftype("1234567890") + memio = self.ioclass(buf) + memio.foo = 42 + memio.seek(2) + + class PickleTestMemIO(self.ioclass): + def __init__(me, initvalue, foo): + self.ioclass.__init__(me, initvalue) + me.foo = foo + # __getnewargs__ is undefined on purpose. This checks that PEP 307 + # is used to provide pickling support. + + # Pickle expects the class to be on the module level. Here we use a + # little hack to allow the PickleTestMemIO class to derive from + # self.ioclass without having to define all combinations explictly on + # the module-level. + import __main__ + PickleTestMemIO.__module__ = '__main__' + __main__.PickleTestMemIO = PickleTestMemIO + submemio = PickleTestMemIO(buf, 80) + submemio.seek(2) + + # We only support pickle protocol 2 and onward since we use extended + # __reduce__ API of PEP 307 to provide pickling support. + for proto in range(2, pickle.HIGHEST_PROTOCOL): + for obj in (memio, submemio): + obj2 = pickle.loads(pickle.dumps(obj, protocol=proto)) + self.assertEqual(obj.getvalue(), obj2.getvalue()) + self.assertEqual(obj.__class__, obj2.__class__) + self.assertEqual(obj.foo, obj2.foo) + self.assertEqual(obj.tell(), obj2.tell()) + obj.close() + self.assertRaises(ValueError, pickle.dumps, obj, proto) + del __main__.PickleTestMemIO + class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase): @@ -431,13 +468,26 @@ self.assertEqual(memio.getvalue(), buf) -class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase): - buftype = unicode - ioclass = pyio.StringIO - UnsupportedOperation = pyio.UnsupportedOperation - EOF = "" +class TextIOTestMixin: - # TextIO-specific behaviour. + def test_relative_seek(self): + memio = self.ioclass() + + self.assertRaises(IOError, memio.seek, -1, 1) + self.assertRaises(IOError, memio.seek, 3, 1) + self.assertRaises(IOError, memio.seek, -3, 1) + self.assertRaises(IOError, memio.seek, -1, 2) + self.assertRaises(IOError, memio.seek, 1, 1) + self.assertRaises(IOError, memio.seek, 1, 2) + + def test_textio_properties(self): + memio = self.ioclass() + + # These are just dummy values but we nevertheless check them for fear + # of unexpected breakage. + self.assertTrue(memio.encoding is None) + self.assertEqual(memio.errors, "strict") + self.assertEqual(memio.line_buffering, False) def test_newlines_property(self): memio = self.ioclass(newline=None) @@ -519,7 +569,6 @@ def test_newline_cr(self): # newline="\r" memio = self.ioclass("a\nb\r\nc\rd", newline="\r") - memio.seek(0) self.assertEqual(memio.read(), "a\rb\r\rc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"]) @@ -527,7 +576,6 @@ def test_newline_crlf(self): # newline="\r\n" memio = self.ioclass("a\nb\r\nc\rd", newline="\r\n") - memio.seek(0) self.assertEqual(memio.read(), "a\r\nb\r\r\nc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"]) @@ -538,6 +586,28 @@ self.assertEqual(memio.read(5), "a\nb\n") +class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, + TextIOTestMixin, unittest.TestCase): + buftype = unicode + ioclass = pyio.StringIO + UnsupportedOperation = pyio.UnsupportedOperation + EOF = "" + + +class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase): + """Test if pickle restores properly the internal state of StringIO. + """ + buftype = unicode + UnsupportedOperation = pyio.UnsupportedOperation + EOF = "" + + class ioclass(pyio.StringIO): + def __new__(cls, *args, **kwargs): + return pickle.loads(pickle.dumps(pyio.StringIO(*args, **kwargs))) + def __init__(self, *args, **kwargs): + pass + + class CBytesIOTest(PyBytesIOTest): ioclass = io.BytesIO UnsupportedOperation = io.UnsupportedOperation @@ -547,6 +617,33 @@ )(PyBytesIOTest.test_bytes_array) + def test_getstate(self): + memio = self.ioclass() + state = memio.__getstate__() + self.assertEqual(len(state), 3) + bytearray(state[0]) # Check if state[0] supports the buffer interface. + self.assert_(isinstance(state[1], int)) + self.assert_(isinstance(state[2], dict) or state[2] is None) + memio.close() + self.assertRaises(ValueError, memio.__getstate__) + + def test_setstate(self): + # This checks whether __setstate__ does proper input validation. + memio = self.ioclass() + memio.__setstate__((b"no error", 0, None)) + memio.__setstate__((bytearray(b"no error"), 0, None)) + memio.__setstate__((b"no error", 0, {'spam': 3})) + self.assertRaises(ValueError, memio.__setstate__, (b"", -1, None)) + self.assertRaises(TypeError, memio.__setstate__, ("unicode", 0, None)) + self.assertRaises(TypeError, memio.__setstate__, (b"", 0.0, None)) + self.assertRaises(TypeError, memio.__setstate__, (b"", 0, 0)) + self.assertRaises(TypeError, memio.__setstate__, (b"len-test", 0)) + self.assertRaises(TypeError, memio.__setstate__) + self.assertRaises(TypeError, memio.__setstate__, 0) + memio.close() + self.assertRaises(ValueError, memio.__setstate__, (b"closed", 0, None)) + + class CStringIOTest(PyStringIOTest): ioclass = io.StringIO UnsupportedOperation = io.UnsupportedOperation @@ -565,9 +662,50 @@ self.assertEqual(memio.tell(), len(buf) * 2) self.assertEqual(memio.getvalue(), buf + buf) + def test_getstate(self): + memio = self.ioclass() + state = memio.__getstate__() + self.assertEqual(len(state), 4) + self.assert_(isinstance(state[0], unicode)) + self.assert_(isinstance(state[1], str)) + self.assert_(isinstance(state[2], int)) + self.assert_(isinstance(state[3], dict) or state[3] is None) + memio.close() + self.assertRaises(ValueError, memio.__getstate__) + + def test_setstate(self): + # This checks whether __setstate__ does proper input validation. + memio = self.ioclass() + memio.__setstate__(("no error", "\n", 0, None)) + memio.__setstate__(("no error", "", 0, {'spam': 3})) + self.assertRaises(ValueError, memio.__setstate__, ("", "f", 0, None)) + self.assertRaises(ValueError, memio.__setstate__, ("", "", -1, None)) + self.assertRaises(TypeError, memio.__setstate__, (b"", "", 0, None)) + # trunk is more tolerant than py3k on the type of the newline param + #self.assertRaises(TypeError, memio.__setstate__, ("", b"", 0, None)) + self.assertRaises(TypeError, memio.__setstate__, ("", "", 0.0, None)) + self.assertRaises(TypeError, memio.__setstate__, ("", "", 0, 0)) + self.assertRaises(TypeError, memio.__setstate__, ("len-test", 0)) + self.assertRaises(TypeError, memio.__setstate__) + self.assertRaises(TypeError, memio.__setstate__, 0) + memio.close() + self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, None)) + + +class CStringIOPickleTest(PyStringIOPickleTest): + UnsupportedOperation = io.UnsupportedOperation + + class ioclass(io.StringIO): + def __new__(cls, *args, **kwargs): + return pickle.loads(pickle.dumps(io.StringIO(*args, **kwargs), + protocol=2)) + def __init__(self, *args, **kwargs): + pass + def test_main(): - tests = [PyBytesIOTest, PyStringIOTest, CBytesIOTest, CStringIOTest] + tests = [PyBytesIOTest, PyStringIOTest, CBytesIOTest, CStringIOTest, + PyStringIOPickleTest, CStringIOPickleTest] support.run_unittest(*tests) if __name__ == '__main__': Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 24 14:23:18 2009 @@ -418,6 +418,9 @@ Library ------- +- Issue #6218: io.StringIO and io.BytesIO instances are now picklable with + protocol 2. + - Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. - Issue #7099: Decimal.is_normal now returns True for numbers with exponent Modified: python/trunk/Modules/_io/bytesio.c ============================================================================== --- python/trunk/Modules/_io/bytesio.c (original) +++ python/trunk/Modules/_io/bytesio.c Sat Oct 24 14:23:18 2009 @@ -613,6 +613,120 @@ Py_RETURN_NONE; } +/* Pickling support. + + Note that only pickle protocol 2 and onward are supported since we use + extended __reduce__ API of PEP 307 to make BytesIO instances picklable. + + Providing support for protocol < 2 would require the __reduce_ex__ method + which is notably long-winded when defined properly. + + For BytesIO, the implementation would similar to one coded for + object.__reduce_ex__, but slightly less general. To be more specific, we + could call bytesio_getstate directly and avoid checking for the presence of + a fallback __reduce__ method. However, we would still need a __newobj__ + function to use the efficient instance representation of PEP 307. + */ + +static PyObject * +bytesio_getstate(bytesio *self) +{ + PyObject *initvalue = bytesio_getvalue(self); + PyObject *dict; + PyObject *state; + + if (initvalue == NULL) + return NULL; + if (self->dict == NULL) { + Py_INCREF(Py_None); + dict = Py_None; + } + else { + dict = PyDict_Copy(self->dict); + if (dict == NULL) + return NULL; + } + + state = Py_BuildValue("(OnN)", initvalue, self->pos, dict); + Py_DECREF(initvalue); + return state; +} + +static PyObject * +bytesio_setstate(bytesio *self, PyObject *state) +{ + PyObject *result; + PyObject *position_obj; + PyObject *dict; + Py_ssize_t pos; + + assert(state != NULL); + + /* We allow the state tuple to be longer than 3, because we may need + someday to extend the object's state without breaking + backward-compatibility. */ + if (!PyTuple_Check(state) || Py_SIZE(state) < 3) { + PyErr_Format(PyExc_TypeError, + "%.200s.__setstate__ argument should be 3-tuple, got %.200s", + Py_TYPE(self)->tp_name, Py_TYPE(state)->tp_name); + return NULL; + } + /* Reset the object to its default state. This is only needed to handle + the case of repeated calls to __setstate__. */ + self->string_size = 0; + self->pos = 0; + + /* Set the value of the internal buffer. If state[0] does not support the + buffer protocol, bytesio_write will raise the appropriate TypeError. */ + result = bytesio_write(self, PyTuple_GET_ITEM(state, 0)); + if (result == NULL) + return NULL; + Py_DECREF(result); + + /* Set carefully the position value. Alternatively, we could use the seek + method instead of modifying self->pos directly to better protect the + object internal state against errneous (or malicious) inputs. */ + position_obj = PyTuple_GET_ITEM(state, 1); + if (!PyIndex_Check(position_obj)) { + PyErr_Format(PyExc_TypeError, + "second item of state must be an integer, not %.200s", + Py_TYPE(position_obj)->tp_name); + return NULL; + } + pos = PyNumber_AsSsize_t(position_obj, PyExc_OverflowError); + if (pos == -1 && PyErr_Occurred()) + return NULL; + if (pos < 0) { + PyErr_SetString(PyExc_ValueError, + "position value cannot be negative"); + return NULL; + } + self->pos = pos; + + /* Set the dictionary of the instance variables. */ + dict = PyTuple_GET_ITEM(state, 2); + if (dict != Py_None) { + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, + "third item of state should be a dict, got a %.200s", + Py_TYPE(dict)->tp_name); + return NULL; + } + if (self->dict) { + /* Alternatively, we could replace the internal dictionary + completely. However, it seems more practical to just update it. */ + if (PyDict_Update(self->dict, dict) < 0) + return NULL; + } + else { + Py_INCREF(dict); + self->dict = dict; + } + } + + Py_RETURN_NONE; +} + static void bytesio_dealloc(bytesio *self) { @@ -637,9 +751,9 @@ if (self == NULL) return NULL; - self->string_size = 0; - self->pos = 0; - self->buf_size = 0; + /* tp_alloc initializes all the fields to zero. So we don't have to + initialize them here. */ + self->buf = (char *)PyMem_Malloc(0); if (self->buf == NULL) { Py_DECREF(self); @@ -712,6 +826,8 @@ {"getvalue", (PyCFunction)bytesio_getvalue, METH_VARARGS, getval_doc}, {"seek", (PyCFunction)bytesio_seek, METH_VARARGS, seek_doc}, {"truncate", (PyCFunction)bytesio_truncate, METH_VARARGS, truncate_doc}, + {"__getstate__", (PyCFunction)bytesio_getstate, METH_NOARGS, NULL}, + {"__setstate__", (PyCFunction)bytesio_setstate, METH_O, NULL}, {NULL, NULL} /* sentinel */ }; Modified: python/trunk/Modules/_io/stringio.c ============================================================================== --- python/trunk/Modules/_io/stringio.c (original) +++ python/trunk/Modules/_io/stringio.c Sat Oct 24 14:23:18 2009 @@ -539,9 +539,9 @@ if (self == NULL) return NULL; - self->string_size = 0; - self->pos = 0; - self->buf_size = 0; + /* tp_alloc initializes all the fields to zero. So we don't have to + initialize them here. */ + self->buf = (Py_UNICODE *)PyMem_Malloc(0); if (self->buf == NULL) { Py_DECREF(self); @@ -571,8 +571,8 @@ return -1; } if (value && value != Py_None && !PyUnicode_Check(value)) { - PyErr_Format(PyExc_ValueError, - "initial_value must be str or None, not %.200s", + PyErr_Format(PyExc_TypeError, + "initial_value must be unicode or None, not %.200s", Py_TYPE(value)->tp_name); return -1; } @@ -583,6 +583,9 @@ Py_CLEAR(self->writenl); Py_CLEAR(self->decoder); + assert((newline != NULL && newline_obj != Py_None) || + (newline == NULL && newline_obj == Py_None)); + if (newline) { self->readnl = PyString_FromString(newline); if (self->readnl == NULL) @@ -654,6 +657,135 @@ Py_RETURN_TRUE; } +/* Pickling support. + + The implementation of __getstate__ is similar to the one for BytesIO, + except that we also save the newline parameter. For __setstate__ and unlike + BytesIO, we call __init__ to restore the object's state. Doing so allows us + to avoid decoding the complex newline state while keeping the object + representation compact. + + See comment in bytesio.c regarding why only pickle protocols and onward are + supported. +*/ + +static PyObject * +stringio_getstate(stringio *self) +{ + PyObject *initvalue = stringio_getvalue(self); + PyObject *dict; + PyObject *state; + + if (initvalue == NULL) + return NULL; + if (self->dict == NULL) { + Py_INCREF(Py_None); + dict = Py_None; + } + else { + dict = PyDict_Copy(self->dict); + if (dict == NULL) + return NULL; + } + + state = Py_BuildValue("(OOnN)", initvalue, + self->readnl ? self->readnl : Py_None, + self->pos, dict); + Py_DECREF(initvalue); + return state; +} + +static PyObject * +stringio_setstate(stringio *self, PyObject *state) +{ + PyObject *initarg; + PyObject *position_obj; + PyObject *dict; + Py_ssize_t pos; + + assert(state != NULL); + CHECK_CLOSED(self); + + /* We allow the state tuple to be longer than 4, because we may need + someday to extend the object's state without breaking + backward-compatibility. */ + if (!PyTuple_Check(state) || Py_SIZE(state) < 4) { + PyErr_Format(PyExc_TypeError, + "%.200s.__setstate__ argument should be 4-tuple, got %.200s", + Py_TYPE(self)->tp_name, Py_TYPE(state)->tp_name); + return NULL; + } + + /* Initialize the object's state. */ + initarg = PyTuple_GetSlice(state, 0, 2); + if (initarg == NULL) + return NULL; + if (stringio_init(self, initarg, NULL) < 0) { + Py_DECREF(initarg); + return NULL; + } + Py_DECREF(initarg); + + /* Restore the buffer state. Even if __init__ did initialize the buffer, + we have to initialize it again since __init__ may translates the + newlines in the inital_value string. We clearly do not want that + because the string value in the state tuple has already been translated + once by __init__. So we do not take any chance and replace object's + buffer completely. */ + { + Py_UNICODE *buf = PyUnicode_AS_UNICODE(PyTuple_GET_ITEM(state, 0)); + Py_ssize_t bufsize = PyUnicode_GET_SIZE(PyTuple_GET_ITEM(state, 0)); + if (resize_buffer(self, bufsize) < 0) + return NULL; + memcpy(self->buf, buf, bufsize * sizeof(Py_UNICODE)); + self->string_size = bufsize; + } + + /* Set carefully the position value. Alternatively, we could use the seek + method instead of modifying self->pos directly to better protect the + object internal state against errneous (or malicious) inputs. */ + position_obj = PyTuple_GET_ITEM(state, 2); + if (!PyIndex_Check(position_obj)) { + PyErr_Format(PyExc_TypeError, + "third item of state must be an integer, got %.200s", + Py_TYPE(position_obj)->tp_name); + return NULL; + } + pos = PyNumber_AsSsize_t(position_obj, PyExc_OverflowError); + if (pos == -1 && PyErr_Occurred()) + return NULL; + if (pos < 0) { + PyErr_SetString(PyExc_ValueError, + "position value cannot be negative"); + return NULL; + } + self->pos = pos; + + /* Set the dictionary of the instance variables. */ + dict = PyTuple_GET_ITEM(state, 3); + if (dict != Py_None) { + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, + "fourth item of state should be a dict, got a %.200s", + Py_TYPE(dict)->tp_name); + return NULL; + } + if (self->dict) { + /* Alternatively, we could replace the internal dictionary + completely. However, it seems more practical to just update it. */ + if (PyDict_Update(self->dict, dict) < 0) + return NULL; + } + else { + Py_INCREF(dict); + self->dict = dict; + } + } + + Py_RETURN_NONE; +} + + static PyObject * stringio_closed(stringio *self, void *context) { @@ -688,10 +820,13 @@ {"truncate", (PyCFunction)stringio_truncate, METH_VARARGS, stringio_truncate_doc}, {"seek", (PyCFunction)stringio_seek, METH_VARARGS, stringio_seek_doc}, {"write", (PyCFunction)stringio_write, METH_O, stringio_write_doc}, - + {"seekable", (PyCFunction)stringio_seekable, METH_NOARGS}, {"readable", (PyCFunction)stringio_readable, METH_NOARGS}, {"writable", (PyCFunction)stringio_writable, METH_NOARGS}, + + {"__getstate__", (PyCFunction)stringio_getstate, METH_NOARGS}, + {"__setstate__", (PyCFunction)stringio_setstate, METH_O}, {NULL, NULL} /* sentinel */ }; From python-checkins at python.org Sat Oct 24 14:28:22 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 12:28:22 -0000 Subject: [Python-checkins] r75655 - in python/trunk: Lib/test/test_memoryio.py Modules/_io/bytesio.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 14:28:22 2009 New Revision: 75655 Log: Manual py3k backport: [svn r74316] Issue #5449: Fix io.BytesIO to not accept arbitrary keywords Modified: python/trunk/Lib/test/test_memoryio.py python/trunk/Modules/_io/bytesio.c Modified: python/trunk/Lib/test/test_memoryio.py ============================================================================== --- python/trunk/Lib/test/test_memoryio.py (original) +++ python/trunk/Lib/test/test_memoryio.py Sat Oct 24 14:28:22 2009 @@ -467,6 +467,11 @@ self.assertEqual(memio.write(a), 10) self.assertEqual(memio.getvalue(), buf) + def test_issue5449(self): + buf = self.buftype("1234567890") + self.ioclass(initial_bytes=buf) + self.assertRaises(TypeError, self.ioclass, buf, foo=None) + class TextIOTestMixin: Modified: python/trunk/Modules/_io/bytesio.c ============================================================================== --- python/trunk/Modules/_io/bytesio.c (original) +++ python/trunk/Modules/_io/bytesio.c Sat Oct 24 14:28:22 2009 @@ -766,9 +766,11 @@ static int bytesio_init(bytesio *self, PyObject *args, PyObject *kwds) { + char *kwlist[] = {"initial_bytes", NULL}; PyObject *initvalue = NULL; - if (!PyArg_ParseTuple(args, "|O:BytesIO", &initvalue)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:BytesIO", kwlist, + &initvalue)) return -1; /* In case, __init__ is called multiple times. */ From python-checkins at python.org Sat Oct 24 14:31:03 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 12:31:03 -0000 Subject: [Python-checkins] r75656 - python/branches/py3k Message-ID: Author: antoine.pitrou Date: Sat Oct 24 14:31:03 2009 New Revision: 75656 Log: Blocked revisions 75650,75654-75655 via svnmerge ........ r75650 | antoine.pitrou | 2009-10-24 13:59:41 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74155] Issue #6242: Fix deallocator of io.StringIO and io.BytesIO ........ r75654 | antoine.pitrou | 2009-10-24 14:23:18 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74158] Issue #6218: Make io.BytesIO and io.StringIO picklable. ........ r75655 | antoine.pitrou | 2009-10-24 14:28:22 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74316] Issue #5449: Fix io.BytesIO to not accept arbitrary keywords ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 14:41:27 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 12:41:27 -0000 Subject: [Python-checkins] r75657 - python/trunk/Modules/_io/stringio.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 14:41:27 2009 New Revision: 75657 Log: Fix compilation error in debug mode. Modified: python/trunk/Modules/_io/stringio.c Modified: python/trunk/Modules/_io/stringio.c ============================================================================== --- python/trunk/Modules/_io/stringio.c (original) +++ python/trunk/Modules/_io/stringio.c Sat Oct 24 14:41:27 2009 @@ -583,9 +583,6 @@ Py_CLEAR(self->writenl); Py_CLEAR(self->decoder); - assert((newline != NULL && newline_obj != Py_None) || - (newline == NULL && newline_obj == Py_None)); - if (newline) { self->readnl = PyString_FromString(newline); if (self->readnl == NULL) From solipsis at pitrou.net Sat Oct 24 14:52:01 2009 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 24 Oct 2009 12:52:01 +0000 (UTC) Subject: [Python-checkins] =?utf-8?q?r75643_-_in_sandbox/trunk/newgil=3A?= =?utf-8?q?=09Lib/unittest/runner=2EpyPython/ceval=5Fpthread=2Eh?= References: <20597.7557613098$1256338401@news.gmane.org> Message-ID: writes: > > Author: antoine.pitrou > Date: Sat Oct 24 00:51:28 2009 > New Revision: 75643 > > Log: > Addition of Windows support. > Beware: I witnessed very strange behaviour by test_multiprocessing which > tried to pickle the unittest runner, and had to patch unittest to avoid > the subsequent failures This was actually a unittest / test_multiprocessing bug: http://bugs.python.org/issue7197 From python-checkins at python.org Sat Oct 24 15:28:39 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 13:28:39 -0000 Subject: [Python-checkins] r75658 - in python/trunk: Include/pymacconfig.h Include/pymath.h Include/pyport.h PC/pyconfig.h Python/pymath.c configure configure.in pyconfig.h.in Message-ID: Author: mark.dickinson Date: Sat Oct 24 15:28:38 2009 New Revision: 75658 Log: Issue #7117 (backport py3k float repr) continued: - add double endianness detection to configure script - add configure-time check to see whether we can use inline assembly to get and set x87 control word in configure script - add functions to get and set x87 control word in Python/pymath.c - add pyport.h logic to determine whether it's safe to use the short float repr or not Modified: python/trunk/Include/pymacconfig.h python/trunk/Include/pymath.h python/trunk/Include/pyport.h python/trunk/PC/pyconfig.h python/trunk/Python/pymath.c python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Modified: python/trunk/Include/pymacconfig.h ============================================================================== --- python/trunk/Include/pymacconfig.h (original) +++ python/trunk/Include/pymacconfig.h Sat Oct 24 15:28:38 2009 @@ -17,6 +17,9 @@ # undef SIZEOF_VOID_P # undef SIZEOF__BOOL # undef WORDS_BIGENDIAN +# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 +# undef DOUBLE_IS_BIG_ENDIAN_IEEE754 +# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 # undef VA_LIST_IS_ARRAY # if defined(__LP64__) && defined(__x86_64__) @@ -65,6 +68,9 @@ #ifdef __BIG_ENDIAN__ #define WORDS_BIGENDIAN 1 +#define DOUBLE_IS_BIG_ENDIAN_IEEE754 +#else +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 #endif /* __BIG_ENDIAN */ /* Modified: python/trunk/Include/pymath.h ============================================================================== --- python/trunk/Include/pymath.h (original) +++ python/trunk/Include/pymath.h Sat Oct 24 15:28:38 2009 @@ -92,6 +92,11 @@ # endif #endif +#ifdef HAVE_GCC_ASM_FOR_X87 +PyAPI_FUNC(unsigned short) _Py_get_387controlword(void); +PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); +#endif + /* Py_IS_NAN(X) * Return 1 if float or double arg is a NaN, else 0. * Caution: Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Sat Oct 24 15:28:38 2009 @@ -488,6 +488,80 @@ errno = 0; \ } while(0) +/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are + * required to support the short float repr introduced in Python 3.1) require + * that the floating-point unit that's being used for arithmetic operations + * on C doubles is set to use 53-bit precision. It also requires that the + * FPU rounding mode is round-half-to-even, but that's less often an issue. + * + * If your FPU isn't already set to 53-bit precision/round-half-to-even, and + * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should + * + * #define HAVE_PY_SET_53BIT_PRECISION 1 + * + * and also give appropriate definitions for the following three macros: + * + * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and + * set FPU to 53-bit precision/round-half-to-even + * _PY_SET_53BIT_PRECISION_END : restore original FPU settings + * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to + * use the two macros above. + * + * The macros are designed to be used within a single C function: see + * Python/pystrtod.c for an example of their use. + */ + +/* get and set x87 control word for gcc/x86 */ +#ifdef HAVE_GCC_ASM_FOR_X87 +#define HAVE_PY_SET_53BIT_PRECISION 1 +/* _Py_get/set_387controlword functions are defined in Python/pymath.c */ +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned short old_387controlword, new_387controlword +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + old_387controlword = _Py_get_387controlword(); \ + new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(new_387controlword); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(old_387controlword) +#endif + +/* default definitions are empty */ +#ifndef HAVE_PY_SET_53BIT_PRECISION +#define _Py_SET_53BIT_PRECISION_HEADER +#define _Py_SET_53BIT_PRECISION_START +#define _Py_SET_53BIT_PRECISION_END +#endif + +/* If we can't guarantee 53-bit precision, don't use the code + in Python/dtoa.c, but fall back to standard code. This + means that repr of a float will be long (17 sig digits). + + Realistically, there are two things that could go wrong: + + (1) doubles aren't IEEE 754 doubles, or + (2) we're on x86 with the rounding precision set to 64-bits + (extended precision), and we don't know how to change + the rounding precision. + */ + +#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* double rounding is symptomatic of use of extended precision on x86. If + we're seeing double rounding, and we don't have any mechanism available for + changing the FPU rounding precision, then don't use Python/dtoa.c. */ +#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) +#define PY_NO_SHORT_FLOAT_REPR +#endif + + /* Py_DEPRECATED(version) * Declare a variable, type, or function deprecated. * Usage: Modified: python/trunk/PC/pyconfig.h ============================================================================== --- python/trunk/PC/pyconfig.h (original) +++ python/trunk/PC/pyconfig.h Sat Oct 24 15:28:38 2009 @@ -749,4 +749,8 @@ socket handles greater than FD_SETSIZE */ #define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 + #endif /* !Py_CONFIG_H */ Modified: python/trunk/Python/pymath.c ============================================================================== --- python/trunk/Python/pymath.c (original) +++ python/trunk/Python/pymath.c Sat Oct 24 15:28:38 2009 @@ -13,6 +13,24 @@ } #endif +#ifdef HAVE_GCC_ASM_FOR_X87 + +/* inline assembly for getting and setting the 387 FPU control word on + gcc/x86 */ + +unsigned short _Py_get_387controlword(void) { + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); + return cw; +} + +void _Py_set_387controlword(unsigned short cw) { + __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); +} + +#endif + + #ifndef HAVE_HYPOT double hypot(double x, double y) { Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Sat Oct 24 15:28:38 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74978 . +# From configure.in Revision: 75131 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.7. # @@ -23233,12 +23233,298 @@ fi -# ************************************ -# * Check for mathematical functions * -# ************************************ +# ************************************************** +# * Check for various properties of floating point * +# ************************************************** + +{ echo "$as_me:$LINENO: checking whether C doubles are little-endian IEEE 754 binary64" >&5 +echo $ECHO_N "checking whether C doubles are little-endian IEEE 754 binary64... $ECHO_C" >&6; } +if test "${ac_cv_little_endian_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else -LIBS_SAVE=$LIBS -LIBS="$LIBS $LIBM" +if test "$cross_compiling" = yes; then + ac_cv_little_endian_double=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) + return 0; + else + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_little_endian_double=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_little_endian_double=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +{ echo "$as_me:$LINENO: result: $ac_cv_little_endian_double" >&5 +echo "${ECHO_T}$ac_cv_little_endian_double" >&6; } +if test "$ac_cv_little_endian_double" = yes +then + +cat >>confdefs.h <<\_ACEOF +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether C doubles are big-endian IEEE 754 binary64" >&5 +echo $ECHO_N "checking whether C doubles are big-endian IEEE 754 binary64... $ECHO_C" >&6; } +if test "${ac_cv_big_endian_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +if test "$cross_compiling" = yes; then + ac_cv_big_endian_double=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) + return 0; + else + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_big_endian_double=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_big_endian_double=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +{ echo "$as_me:$LINENO: result: $ac_cv_big_endian_double" >&5 +echo "${ECHO_T}$ac_cv_big_endian_double" >&6; } +if test "$ac_cv_big_endian_double" = yes +then + +cat >>confdefs.h <<\_ACEOF +#define DOUBLE_IS_BIG_ENDIAN_IEEE754 1 +_ACEOF + +fi + +# Some ARM platforms use a mixed-endian representation for doubles. +# While Python doesn't currently have full support for these platforms +# (see e.g., issue 1762561), we can at least make sure that float <-> string +# conversions work. +{ echo "$as_me:$LINENO: checking whether C doubles are ARM mixed-endian IEEE 754 binary64" >&5 +echo $ECHO_N "checking whether C doubles are ARM mixed-endian IEEE 754 binary64... $ECHO_C" >&6; } +if test "${ac_cv_mixed_endian_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +if test "$cross_compiling" = yes; then + ac_cv_mixed_endian_double=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) + return 0; + else + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_mixed_endian_double=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_mixed_endian_double=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +{ echo "$as_me:$LINENO: result: $ac_cv_mixed_endian_double" >&5 +echo "${ECHO_T}$ac_cv_mixed_endian_double" >&6; } +if test "$ac_cv_mixed_endian_double" = yes +then + +cat >>confdefs.h <<\_ACEOF +#define DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1 +_ACEOF + +fi + +# The short float repr introduced in Python 3.1 requires the +# correctly-rounded string <-> double conversion functions from +# Python/dtoa.c, which in turn require that the FPU uses 53-bit +# rounding; this is a problem on x86, where the x87 FPU has a default +# rounding precision of 64 bits. For gcc/x86, we try to fix this by +# using inline assembler to get and set the x87 FPU control word. +if test "$GCC" = yes && test -n "`$CC -dM -E - &5 +echo $ECHO_N "checking whether we can use gcc inline assembler to get and set x87 control word... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); + __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + have_gcc_asm_for_x87=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + have_gcc_asm_for_x87=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { echo "$as_me:$LINENO: result: $have_gcc_asm_for_x87" >&5 +echo "${ECHO_T}$have_gcc_asm_for_x87" >&6; } + if test "$have_gcc_asm_for_x87" = yes + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GCC_ASM_FOR_X87 1 +_ACEOF + + fi +fi # Detect whether system arithmetic is subject to x87-style double # rounding issues. The result of this test has little meaning on non @@ -23327,6 +23613,13 @@ fi +# ************************************ +# * Check for mathematical functions * +# ************************************ + +LIBS_SAVE=$LIBS +LIBS="$LIBS $LIBM" + # Multiprocessing check for broken sem_getvalue { echo "$as_me:$LINENO: checking for broken sem_getvalue" >&5 echo $ECHO_N "checking for broken sem_getvalue... $ECHO_C" >&6; } Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Sat Oct 24 15:28:38 2009 @@ -3240,12 +3240,107 @@ fi], [AC_MSG_RESULT(default LIBC="$LIBC")]) -# ************************************ -# * Check for mathematical functions * -# ************************************ +# ************************************************** +# * Check for various properties of floating point * +# ************************************************** -LIBS_SAVE=$LIBS -LIBS="$LIBS $LIBM" +AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_little_endian_double, [ +AC_TRY_RUN([ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) + return 0; + else + return 1; +} +], +ac_cv_little_endian_double=yes, +ac_cv_little_endian_double=no, +ac_cv_little_endian_double=no)]) +AC_MSG_RESULT($ac_cv_little_endian_double) +if test "$ac_cv_little_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + with the least significant byte first]) +fi + +AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_big_endian_double, [ +AC_TRY_RUN([ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) + return 0; + else + return 1; +} +], +ac_cv_big_endian_double=yes, +ac_cv_big_endian_double=no, +ac_cv_big_endian_double=no)]) +AC_MSG_RESULT($ac_cv_big_endian_double) +if test "$ac_cv_big_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + with the most significant byte first]) +fi + +# Some ARM platforms use a mixed-endian representation for doubles. +# While Python doesn't currently have full support for these platforms +# (see e.g., issue 1762561), we can at least make sure that float <-> string +# conversions work. +AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_mixed_endian_double, [ +AC_TRY_RUN([ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) + return 0; + else + return 1; +} +], +ac_cv_mixed_endian_double=yes, +ac_cv_mixed_endian_double=no, +ac_cv_mixed_endian_double=no)]) +AC_MSG_RESULT($ac_cv_mixed_endian_double) +if test "$ac_cv_mixed_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + in ARM mixed-endian order (byte order 45670123)]) +fi + +# The short float repr introduced in Python 3.1 requires the +# correctly-rounded string <-> double conversion functions from +# Python/dtoa.c, which in turn require that the FPU uses 53-bit +# rounding; this is a problem on x86, where the x87 FPU has a default +# rounding precision of 64 bits. For gcc/x86, we try to fix this by +# using inline assembler to get and set the x87 FPU control word. +if test "$GCC" = yes && test -n "`$CC -dM -E - Author: tarek.ziade Date: Sat Oct 24 15:29:44 2009 New Revision: 75659 Log: #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd Modified: python/trunk/Lib/distutils/archive_util.py python/trunk/Lib/distutils/tests/test_archive_util.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/distutils/archive_util.py ============================================================================== --- python/trunk/Lib/distutils/archive_util.py (original) +++ python/trunk/Lib/distutils/archive_util.py Sat Oct 24 15:29:44 2009 @@ -233,9 +233,11 @@ kwargs['owner'] = owner kwargs['group'] = group - filename = func(base_name, base_dir, **kwargs) - if root_dir is not None: - log.debug("changing back to '%s'", save_cwd) - os.chdir(save_cwd) + try: + filename = func(base_name, base_dir, **kwargs) + finally: + if root_dir is not None: + log.debug("changing back to '%s'", save_cwd) + os.chdir(save_cwd) return filename Modified: python/trunk/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_archive_util.py (original) +++ python/trunk/Lib/distutils/tests/test_archive_util.py Sat Oct 24 15:29:44 2009 @@ -8,7 +8,8 @@ import warnings from distutils.archive_util import (check_archive_formats, make_tarball, - make_zipfile, make_archive) + make_zipfile, make_archive, + ARCHIVE_FORMATS) from distutils.spawn import find_executable, spawn from distutils.tests import support from test.test_support import check_warnings @@ -262,6 +263,20 @@ finally: archive.close() + def test_make_archive_cwd(self): + current_dir = os.getcwd() + def _breaks(*args, **kw): + raise RuntimeError() + ARCHIVE_FORMATS['xxx'] = (_breaks, [], 'xxx file') + try: + try: + make_archive('xxx', 'xxx', root_dir=self.mkdtemp()) + except: + pass + self.assertEquals(os.getcwd(), current_dir) + finally: + del ARCHIVE_FORMATS['xxx'] + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 24 15:29:44 2009 @@ -418,6 +418,9 @@ Library ------- +- Issue #7066: archive_util.make_archive now restores the cwd if an error is + raised. Initial patch by Ezio Melotti. + - Issue #6218: io.StringIO and io.BytesIO instances are now picklable with protocol 2. From python-checkins at python.org Sat Oct 24 15:31:41 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 13:31:41 -0000 Subject: [Python-checkins] r75660 - python/trunk/Python/dtoa.c Message-ID: Author: mark.dickinson Date: Sat Oct 24 15:31:41 2009 New Revision: 75660 Log: Remove temporary define from r75653 Modified: python/trunk/Python/dtoa.c Modified: python/trunk/Python/dtoa.c ============================================================================== --- python/trunk/Python/dtoa.c (original) +++ python/trunk/Python/dtoa.c Sat Oct 24 15:31:41 2009 @@ -116,8 +116,6 @@ #include "Python.h" -#define IEEE_8087 - /* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile the following code */ #ifndef PY_NO_SHORT_FLOAT_REPR From python-checkins at python.org Sat Oct 24 15:32:57 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 13:32:57 -0000 Subject: [Python-checkins] r75661 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 15:32:56 2009 New Revision: 75661 Log: Blocked revisions 75653,75658,75660 via svnmerge ........ r75653 | mark.dickinson | 2009-10-24 13:17:24 +0100 (Sat, 24 Oct 2009) | 1 line Temporary define to avoid build failure ........ r75658 | mark.dickinson | 2009-10-24 14:28:38 +0100 (Sat, 24 Oct 2009) | 8 lines Issue #7117 (backport py3k float repr) continued: - add double endianness detection to configure script - add configure-time check to see whether we can use inline assembly to get and set x87 control word in configure script - add functions to get and set x87 control word in Python/pymath.c - add pyport.h logic to determine whether it's safe to use the short float repr or not ........ r75660 | mark.dickinson | 2009-10-24 14:31:41 +0100 (Sat, 24 Oct 2009) | 1 line Remove temporary define from r75653 ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 15:38:27 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 24 Oct 2009 13:38:27 -0000 Subject: [Python-checkins] r75662 - in python/branches/py3k: Lib/distutils/archive_util.py Lib/distutils/tests/test_archive_util.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 24 15:38:27 2009 New Revision: 75662 Log: Merged revisions 75659 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75659 | tarek.ziade | 2009-10-24 15:29:44 +0200 (Sat, 24 Oct 2009) | 1 line #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/archive_util.py python/branches/py3k/Lib/distutils/tests/test_archive_util.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/distutils/archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/archive_util.py (original) +++ python/branches/py3k/Lib/distutils/archive_util.py Sat Oct 24 15:38:27 2009 @@ -232,10 +232,11 @@ kwargs['owner'] = owner kwargs['group'] = group - filename = func(base_name, base_dir, **kwargs) - - if root_dir is not None: - log.debug("changing back to '%s'", save_cwd) - os.chdir(save_cwd) + try: + filename = func(base_name, base_dir, **kwargs) + finally: + if root_dir is not None: + log.debug("changing back to '%s'", save_cwd) + os.chdir(save_cwd) return filename Modified: python/branches/py3k/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_archive_util.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_archive_util.py Sat Oct 24 15:38:27 2009 @@ -8,7 +8,8 @@ import warnings from distutils.archive_util import (check_archive_formats, make_tarball, - make_zipfile, make_archive) + make_zipfile, make_archive, + ARCHIVE_FORMATS) from distutils.spawn import find_executable, spawn from distutils.tests import support from test.support import check_warnings @@ -262,6 +263,20 @@ finally: archive.close() + def test_make_archive_cwd(self): + current_dir = os.getcwd() + def _breaks(*args, **kw): + raise RuntimeError() + ARCHIVE_FORMATS['xxx'] = (_breaks, [], 'xxx file') + try: + try: + make_archive('xxx', 'xxx', root_dir=self.mkdtemp()) + except: + pass + self.assertEquals(os.getcwd(), current_dir) + finally: + del ARCHIVE_FORMATS['xxx'] + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 24 15:38:27 2009 @@ -1143,6 +1143,9 @@ Library ------- +- Issue #7066: archive_util.make_archive now restores the cwd if an error is + raised. Initial patch by Ezio Melotti. + - Issue #6516: Added owner/group support when creating tar archives in Distutils. From python-checkins at python.org Sat Oct 24 15:42:11 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 24 Oct 2009 13:42:11 -0000 Subject: [Python-checkins] r75663 - in python/branches/release31-maint: Lib/distutils/archive_util.py Lib/distutils/tests/test_archive_util.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 24 15:42:10 2009 New Revision: 75663 Log: Merged revisions 75662 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75662 | tarek.ziade | 2009-10-24 15:38:27 +0200 (Sat, 24 Oct 2009) | 9 lines Merged revisions 75659 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75659 | tarek.ziade | 2009-10-24 15:29:44 +0200 (Sat, 24 Oct 2009) | 1 line #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/distutils/archive_util.py python/branches/release31-maint/Lib/distutils/tests/test_archive_util.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/distutils/archive_util.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/archive_util.py (original) +++ python/branches/release31-maint/Lib/distutils/archive_util.py Sat Oct 24 15:42:10 2009 @@ -171,10 +171,11 @@ func = format_info[0] for arg, val in format_info[1]: kwargs[arg] = val - filename = func(base_name, base_dir, **kwargs) - - if root_dir is not None: - log.debug("changing back to '%s'", save_cwd) - os.chdir(save_cwd) + try: + filename = func(base_name, base_dir, **kwargs) + finally: + if root_dir is not None: + log.debug("changing back to '%s'", save_cwd) + os.chdir(save_cwd) return filename Modified: python/branches/release31-maint/Lib/distutils/tests/test_archive_util.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_archive_util.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_archive_util.py Sat Oct 24 15:42:10 2009 @@ -8,7 +8,8 @@ import warnings from distutils.archive_util import (check_archive_formats, make_tarball, - make_zipfile, make_archive) + make_zipfile, make_archive, + ARCHIVE_FORMATS) from distutils.spawn import find_executable, spawn from distutils.tests import support from test.support import check_warnings @@ -192,6 +193,20 @@ base_name = os.path.join(tmpdir, 'archive') self.assertRaises(ValueError, make_archive, base_name, 'xxx') + def test_make_archive_cwd(self): + current_dir = os.getcwd() + def _breaks(*args, **kw): + raise RuntimeError() + ARCHIVE_FORMATS['xxx'] = (_breaks, [], 'xxx file') + try: + try: + make_archive('xxx', 'xxx', root_dir=self.mkdtemp()) + except: + pass + self.assertEquals(os.getcwd(), current_dir) + finally: + del ARCHIVE_FORMATS['xxx'] + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sat Oct 24 15:42:10 2009 @@ -1069,6 +1069,9 @@ Library ------- +- Issue #7066: archive_util.make_archive now restores the cwd if an error is + raised. Initial patch by Ezio Melotti. + - Issue #6545: Removed assert statements in distutils.Extension, so the behavior is similar when used with -O. From python-checkins at python.org Sat Oct 24 15:44:17 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 13:44:17 -0000 Subject: [Python-checkins] r75664 - in python/trunk: configure configure.in Message-ID: Author: mark.dickinson Date: Sat Oct 24 15:44:16 2009 New Revision: 75664 Log: Configure check for double rounding should take BASECFLAGS into account Modified: python/trunk/configure python/trunk/configure.in Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Sat Oct 24 15:44:16 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 75131 . +# From configure.in Revision: 75658 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.7. # @@ -23533,10 +23533,9 @@ # 0 otherwise. See http://bugs.python.org/issue2937 for more info. { echo "$as_me:$LINENO: checking for x87-style double rounding" >&5 echo $ECHO_N "checking for x87-style double rounding... $ECHO_C" >&6; } -if test "${ac_cv_x87_double_rounding+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - +# $BASECFLAGS may affect the result +ac_save_cc="$CC" +CC="$CC $BASECFLAGS" if test "$cross_compiling" = yes; then ac_cv_x87_double_rounding=no else @@ -23600,8 +23599,7 @@ fi -fi - +CC="$ac_save_cc" { echo "$as_me:$LINENO: result: $ac_cv_x87_double_rounding" >&5 echo "${ECHO_T}$ac_cv_x87_double_rounding" >&6; } if test "$ac_cv_x87_double_rounding" = yes Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Sat Oct 24 15:44:16 2009 @@ -3348,7 +3348,9 @@ # mode is round-to-nearest and double rounding issues are present, and # 0 otherwise. See http://bugs.python.org/issue2937 for more info. AC_MSG_CHECKING(for x87-style double rounding) -AC_CACHE_VAL(ac_cv_x87_double_rounding, [ +# $BASECFLAGS may affect the result +ac_save_cc="$CC" +CC="$CC $BASECFLAGS" AC_TRY_RUN([ #include #include @@ -3371,7 +3373,8 @@ ], ac_cv_x87_double_rounding=no, ac_cv_x87_double_rounding=yes, -ac_cv_x87_double_rounding=no)]) +ac_cv_x87_double_rounding=no) +CC="$ac_save_cc" AC_MSG_RESULT($ac_cv_x87_double_rounding) if test "$ac_cv_x87_double_rounding" = yes then From python-checkins at python.org Sat Oct 24 15:46:38 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 13:46:38 -0000 Subject: [Python-checkins] r75665 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 15:46:38 2009 New Revision: 75665 Log: Blocked revisions 75664 via svnmerge ........ r75664 | mark.dickinson | 2009-10-24 14:44:16 +0100 (Sat, 24 Oct 2009) | 1 line Configure check for double rounding should take BASECFLAGS into account ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 16:01:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 14:01:09 -0000 Subject: [Python-checkins] r75666 - in python/trunk: Doc/library/sys.rst Lib/test/test_sys.py Python/sysmodule.c Message-ID: Author: mark.dickinson Date: Sat Oct 24 16:01:08 2009 New Revision: 75666 Log: Issue #7117 (backport py3k float repr) continued: Add sys.float_repr_style attribute ('short' if short float repr is in used; 'legacy' otherwise). Modified: python/trunk/Doc/library/sys.rst python/trunk/Lib/test/test_sys.py python/trunk/Python/sysmodule.c Modified: python/trunk/Doc/library/sys.rst ============================================================================== --- python/trunk/Doc/library/sys.rst (original) +++ python/trunk/Doc/library/sys.rst Sat Oct 24 16:01:08 2009 @@ -332,6 +332,18 @@ .. versionadded:: 2.6 +.. data:: float_repr_style + + A string indicating how the :func:`repr` function behaves for + floats. If the string has value ``'short'`` then for a finite + float ``x``, ``repr(x)`` aims to produce a short string with the + property that ``float(repr(x)) == x``. This is the usual behaviour + in Python 2.7 and later. Otherwise, ``float_repr_style`` has value + ``'legacy'`` and ``repr(x)`` behaves in the same way as it did in + versions of Python prior to 2.7. + + .. versionadded:: 2.7 + .. function:: getcheckinterval() Modified: python/trunk/Lib/test/test_sys.py ============================================================================== --- python/trunk/Lib/test/test_sys.py (original) +++ python/trunk/Lib/test/test_sys.py Sat Oct 24 16:01:08 2009 @@ -369,6 +369,8 @@ self.assertEqual(vi[3], vi.releaselevel) self.assertEqual(vi[4], vi.serial) self.assertTrue(vi > (1,0,0)) + self.assertIsInstance(sys.float_repr_style, str) + self.assertTrue(sys.float_repr_style in ('short', 'legacy')) def test_43581(self): # Can't use sys.stdout, as this is a cStringIO object when Modified: python/trunk/Python/sysmodule.c ============================================================================== --- python/trunk/Python/sysmodule.c (original) +++ python/trunk/Python/sysmodule.c Sat Oct 24 16:01:08 2009 @@ -1056,6 +1056,7 @@ executable -- pathname of this Python interpreter\n\ prefix -- prefix used to find the Python library\n\ exec_prefix -- prefix used to find the machine-specific Python library\n\ +float_repr_style -- string indicating the style of repr() output for floats\n\ " ) #ifdef MS_WINDOWS @@ -1498,6 +1499,15 @@ FlagsType.tp_init = NULL; FlagsType.tp_new = NULL; + /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */ +#ifndef PY_NO_SHORT_FLOAT_REPR + SET_SYS_FROM_STRING("float_repr_style", + PyString_FromString("short")); +#else + SET_SYS_FROM_STRING("float_repr_style", + PyString_FromString("legacy")); +#endif + #undef SET_SYS_FROM_STRING if (PyErr_Occurred()) return NULL; From python-checkins at python.org Sat Oct 24 16:04:48 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 14:04:48 -0000 Subject: [Python-checkins] r75667 - python/branches/py3k/Lib/test/test_sys.py Message-ID: Author: mark.dickinson Date: Sat Oct 24 16:04:48 2009 New Revision: 75667 Log: Add tests for sys.float_repr_style Modified: python/branches/py3k/Lib/test/test_sys.py Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Sat Oct 24 16:04:48 2009 @@ -372,6 +372,8 @@ self.assertEqual(vi[3], vi.releaselevel) self.assertEqual(vi[4], vi.serial) self.assertTrue(vi > (1,0,0)) + self.assertIsInstance(sys.float_repr_style, str) + self.assertTrue(sys.float_repr_style in ('short', 'legacy')) def test_43581(self): # Can't use sys.stdout, as this is a StringIO object when From python-checkins at python.org Sat Oct 24 16:05:34 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 14:05:34 -0000 Subject: [Python-checkins] r75668 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 16:05:34 2009 New Revision: 75668 Log: Blocked revisions 75666 via svnmerge ........ r75666 | mark.dickinson | 2009-10-24 15:01:08 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117 (backport py3k float repr) continued: Add sys.float_repr_style attribute ('short' if short float repr is in used; 'legacy' otherwise). ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 17:10:37 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 24 Oct 2009 15:10:37 -0000 Subject: [Python-checkins] r75669 - in python/trunk: Lib/distutils/command/build_py.py Lib/distutils/command/install_lib.py Lib/distutils/errors.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_util.py Lib/distutils/util.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Sat Oct 24 17:10:37 2009 New Revision: 75669 Log: Issue #7071: byte-compilation in Distutils now looks at sys.dont_write_bytecode Modified: python/trunk/Lib/distutils/command/build_py.py python/trunk/Lib/distutils/command/install_lib.py python/trunk/Lib/distutils/errors.py python/trunk/Lib/distutils/tests/test_build_py.py python/trunk/Lib/distutils/tests/test_install_lib.py python/trunk/Lib/distutils/tests/test_util.py python/trunk/Lib/distutils/util.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/distutils/command/build_py.py ============================================================================== --- python/trunk/Lib/distutils/command/build_py.py (original) +++ python/trunk/Lib/distutils/command/build_py.py Sat Oct 24 17:10:37 2009 @@ -5,6 +5,7 @@ __revision__ = "$Id$" import os +import sys from glob import glob from distutils.core import Command @@ -372,6 +373,10 @@ self.build_module(module, module_file, package) def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compile not supported on this platform, skipping.') + return + from distutils.util import byte_compile prefix = self.build_lib if prefix[-1] != os.sep: Modified: python/trunk/Lib/distutils/command/install_lib.py ============================================================================== --- python/trunk/Lib/distutils/command/install_lib.py (original) +++ python/trunk/Lib/distutils/command/install_lib.py Sat Oct 24 17:10:37 2009 @@ -6,6 +6,8 @@ __revision__ = "$Id$" import os +import sys + from distutils.core import Command from distutils.errors import DistutilsOptionError @@ -118,6 +120,10 @@ return outfiles def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compile not supported on this platform, skipping.') + return + from distutils.util import byte_compile # Get the "--root" directory supplied to the "install" command, Modified: python/trunk/Lib/distutils/errors.py ============================================================================== --- python/trunk/Lib/distutils/errors.py (original) +++ python/trunk/Lib/distutils/errors.py Sat Oct 24 17:10:37 2009 @@ -74,6 +74,8 @@ class DistutilsTemplateError (DistutilsError): """Syntax error in a file list template.""" +class DistutilsByteCompileError(DistutilsError): + """Byte compile error.""" # Exception classes used by the CCompiler implementation classes class CCompilerError (Exception): Modified: python/trunk/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_build_py.py (original) +++ python/trunk/Lib/distutils/tests/test_build_py.py Sat Oct 24 17:10:37 2009 @@ -89,6 +89,22 @@ os.chdir(cwd) sys.stdout = sys.__stdout__ + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = build_py(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compile not supported ' in self.logs[0][1]) + def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/trunk/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install_lib.py (original) +++ python/trunk/Lib/distutils/tests/test_install_lib.py Sat Oct 24 17:10:37 2009 @@ -31,6 +31,8 @@ cmd.finalize_options() self.assertEquals(cmd.optimize, 2) + @unittest.skipUnless(not sys.dont_write_bytecode, + 'byte-compile not supported') def test_byte_compile(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) @@ -76,6 +78,21 @@ # get_input should return 2 elements self.assertEquals(len(cmd.get_inputs()), 2) + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = install_lib(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compile not supported ' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) Modified: python/trunk/Lib/distutils/tests/test_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_util.py (original) +++ python/trunk/Lib/distutils/tests/test_util.py Sat Oct 24 17:10:37 2009 @@ -1,7 +1,4 @@ """Tests for distutils.util.""" -# not covered yet: -# - byte_compile -# import os import sys import unittest @@ -9,11 +6,12 @@ from StringIO import StringIO import subprocess -from distutils.errors import DistutilsPlatformError +from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError from distutils.util import (get_platform, convert_path, change_root, check_environ, split_quoted, strtobool, rfc822_escape, get_compiler_versions, - _find_exe_version, _MAC_OS_X_LD_VERSION) + _find_exe_version, _MAC_OS_X_LD_VERSION, + byte_compile) from distutils import util from distutils.sysconfig import get_config_vars from distutils import sysconfig @@ -349,6 +347,16 @@ res = get_compiler_versions() self.assertEquals(res[2], None) + def test_dont_write_bytecode(self): + # makes sure byte_compile raise a DistutilsError + # if sys.dont_write_bytecode is True + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + self.assertRaises(DistutilsByteCompileError, byte_compile, []) + finally: + sys.dont_write_bytecode = False + def test_suite(): return unittest.makeSuite(UtilTestCase) Modified: python/trunk/Lib/distutils/util.py ============================================================================== --- python/trunk/Lib/distutils/util.py (original) +++ python/trunk/Lib/distutils/util.py Sat Oct 24 17:10:37 2009 @@ -13,6 +13,7 @@ from distutils.spawn import spawn, find_executable from distutils import log from distutils.version import LooseVersion +from distutils.errors import DistutilsByteCompileError def get_platform(): """Return a string that identifies the current platform. @@ -445,6 +446,10 @@ generated in indirect mode; unless you know what you're doing, leave it set to None. """ + # nothing is done if sys.dont_write_bytecode is True + if sys.dont_write_bytecode: + raise DistutilsByteCompileError('byte-compiling not supported.') + # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative # approach: choose direct mode *only* if the current interpreter is Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 24 17:10:37 2009 @@ -418,6 +418,9 @@ Library ------- +- Issue #7071: byte-compilation in Distutils is now done with respect to + sys.dont_write_bytecode. + - Issue #7066: archive_util.make_archive now restores the cwd if an error is raised. Initial patch by Ezio Melotti. From python-checkins at python.org Sat Oct 24 17:19:04 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 24 Oct 2009 15:19:04 -0000 Subject: [Python-checkins] r75670 - python/trunk/Lib/distutils/tests/test_util.py Message-ID: Author: tarek.ziade Date: Sat Oct 24 17:19:03 2009 New Revision: 75670 Log: fixed finally state in distutils.test_util Modified: python/trunk/Lib/distutils/tests/test_util.py Modified: python/trunk/Lib/distutils/tests/test_util.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_util.py (original) +++ python/trunk/Lib/distutils/tests/test_util.py Sat Oct 24 17:19:03 2009 @@ -355,7 +355,7 @@ try: self.assertRaises(DistutilsByteCompileError, byte_compile, []) finally: - sys.dont_write_bytecode = False + sys.dont_write_bytecode = old_dont_write_bytecode def test_suite(): return unittest.makeSuite(UtilTestCase) From python-checkins at python.org Sat Oct 24 17:51:31 2009 From: python-checkins at python.org (tarek.ziade) Date: Sat, 24 Oct 2009 15:51:31 -0000 Subject: [Python-checkins] r75671 - in python/trunk/Lib/distutils: command/build_py.py command/install_lib.py tests/test_build_py.py tests/test_install_lib.py util.py Message-ID: Author: tarek.ziade Date: Sat Oct 24 17:51:30 2009 New Revision: 75671 Log: fixed warning and error message Modified: python/trunk/Lib/distutils/command/build_py.py python/trunk/Lib/distutils/command/install_lib.py python/trunk/Lib/distutils/tests/test_build_py.py python/trunk/Lib/distutils/tests/test_install_lib.py python/trunk/Lib/distutils/util.py Modified: python/trunk/Lib/distutils/command/build_py.py ============================================================================== --- python/trunk/Lib/distutils/command/build_py.py (original) +++ python/trunk/Lib/distutils/command/build_py.py Sat Oct 24 17:51:30 2009 @@ -374,7 +374,7 @@ def byte_compile(self, files): if sys.dont_write_bytecode: - self.warn('byte-compile not supported on this platform, skipping.') + self.warn('byte-compiling is disabled, skipping.') return from distutils.util import byte_compile Modified: python/trunk/Lib/distutils/command/install_lib.py ============================================================================== --- python/trunk/Lib/distutils/command/install_lib.py (original) +++ python/trunk/Lib/distutils/command/install_lib.py Sat Oct 24 17:51:30 2009 @@ -121,7 +121,7 @@ def byte_compile(self, files): if sys.dont_write_bytecode: - self.warn('byte-compile not supported on this platform, skipping.') + self.warn('byte-compiling is disabled, skipping.') return from distutils.util import byte_compile Modified: python/trunk/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_build_py.py (original) +++ python/trunk/Lib/distutils/tests/test_build_py.py Sat Oct 24 17:51:30 2009 @@ -103,7 +103,7 @@ finally: sys.dont_write_bytecode = old_dont_write_bytecode - self.assertTrue('byte-compile not supported ' in self.logs[0][1]) + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/trunk/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_install_lib.py (original) +++ python/trunk/Lib/distutils/tests/test_install_lib.py Sat Oct 24 17:51:30 2009 @@ -92,7 +92,7 @@ finally: sys.dont_write_bytecode = old_dont_write_bytecode - self.assertTrue('byte-compile not supported ' in self.logs[0][1]) + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) Modified: python/trunk/Lib/distutils/util.py ============================================================================== --- python/trunk/Lib/distutils/util.py (original) +++ python/trunk/Lib/distutils/util.py Sat Oct 24 17:51:30 2009 @@ -448,7 +448,7 @@ """ # nothing is done if sys.dont_write_bytecode is True if sys.dont_write_bytecode: - raise DistutilsByteCompileError('byte-compiling not supported.') + raise DistutilsByteCompileError('byte-compiling is disabled.') # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative From python-checkins at python.org Sat Oct 24 17:54:35 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 15:54:35 -0000 Subject: [Python-checkins] r75672 - python/trunk/Include/pyport.h Message-ID: Author: mark.dickinson Date: Sat Oct 24 17:54:35 2009 New Revision: 75672 Log: Issue #7117: temporarily disable the short float repr while the pieces are being assembled. To re-enable, define the preprocessor symbol PY_SHORT_FLOAT_REPR Modified: python/trunk/Include/pyport.h Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Sat Oct 24 17:54:35 2009 @@ -561,6 +561,13 @@ #define PY_NO_SHORT_FLOAT_REPR #endif +/* temporarily disable the new float repr while the pieces are being + assembled, unless PY_SHORT_FLOAT_REPR is defined. These 7 lines + should be gone by 01/01/10. If they're still here, please complain + to Mark Dickinson (dickinsm at gmail.com). */ +#ifndef PY_SHORT_FLOAT_REPR +#define PY_NO_SHORT_FLOAT_REPR +#endif /* Py_DEPRECATED(version) * Declare a variable, type, or function deprecated. From python-checkins at python.org Sat Oct 24 17:56:07 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 24 Oct 2009 15:56:07 -0000 Subject: [Python-checkins] r75673 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 24 17:56:07 2009 New Revision: 75673 Log: Blocked revisions 75672 via svnmerge ........ r75672 | mark.dickinson | 2009-10-24 16:54:35 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117: temporarily disable the short float repr while the pieces are being assembled. To re-enable, define the preprocessor symbol PY_SHORT_FLOAT_REPR ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 21:01:49 2009 From: python-checkins at python.org (steven.bethard) Date: Sat, 24 Oct 2009 19:01:49 -0000 Subject: [Python-checkins] r75674 - peps/trunk/pep-0389.txt Message-ID: Author: steven.bethard Date: Sat Oct 24 21:01:49 2009 New Revision: 75674 Log: Updates to argparse PEP based on python-dev feedback. Modified: peps/trunk/pep-0389.txt Modified: peps/trunk/pep-0389.txt ============================================================================== --- peps/trunk/pep-0389.txt (original) +++ peps/trunk/pep-0389.txt Sat Oct 24 21:01:49 2009 @@ -8,7 +8,7 @@ Content-Type: text/x-rst Created: 25-Sep-2009 Python-Version: 2.7 and 3.2 -Post-History: 27-Sep-2009 +Post-History: 27-Sep-2009, 24-Oct-2009 Abstract @@ -117,9 +117,9 @@ which provides an ``ensure_value`` method [12]_, while the argparse module allows attributes to be assigned to any object, e.g.:: - foo_object = ... - parser.parse_args(namespace=foo_object) - foo_object.some_attribute_parsed_from_command_line + foo_object = ... + parser.parse_args(namespace=foo_object) + foo_object.some_attribute_parsed_from_command_line Modifying optparse to allow any object to be passed in would be difficult because simply passing the ``foo_object`` around instead @@ -133,37 +133,130 @@ incompatibilities seems unlikely. -Deprecation of getopt and optparse -================================== -There is still some debate over the best way (if at all) to encourage -users to move from getopt and optparse to their replacement, -argparse. The current recommendation of this PEP is the following -conservative deprecation strategy: - -* Python 3.2, Python 2.7 and any later Python 2.X releases -- - PendingDeprecation warnings, which by default are not displayed, - and documentation notes directing users of getopt and optparse to - argparse. - -* Python 3.3 -- Same as above - -* Python 3.4 -- Deprecation warnings for getopt and optparse, which - by default *are* displayed. - -Though this is slower than the usual deprecation process, it seems -prudent to avoid producing any casually visible Deprecation warnings -until Python 3.X has had some additional time to attract developers. +Deprecation of optparse +======================= +Because all of optparse's features are available in argparse, the +optparse module will be deprecated. The following very conservative +deprecation strategy will be followed: +* Python 2.7+ and 3.2+ -- The following note will be added to the + optparse documentation: + + The optparse module is deprecated, and has been replaced by the + argparse module. + +* Python 2.7+ -- If the Python 3 compatibility flag, ``-3``, is + provided at the command line, then importing optparse will issue a + DeprecationWarning. Otherwise no warnings will be issued. + +* Python 3.2 (estimated Jun 2010) -- Importing optparse will issue + a PendingDeprecationWarning, which is not displayed by default. + +* Python 3.3 (estimated Jan 2012) -- Importing optparse will issue + a PendingDeprecationWarning, which is not displayed by default. + +* Python 3.4 (estimated Jun 2013) -- Importing optparse will issue + a DeprecationWarning, which *is* displayed by default. + +* Python 3.5 (estimated Jan 2015) -- The optparse module will be + removed. + +Though this is slower than the usual deprecation process, with two +releases of PendingDeprecationWarnings instead of the usual one, it +seems prudent to avoid producing any casually visible Deprecation +warnings until Python 3.X has had some additional time to attract +developers. + + +Updates to getopt documentation +=============================== +The getopt module will not be deprecated. However, its documentation +will be updated to point to argparse in a couple of places. At the +top of the module, the following note will be added: + + The getopt module is a parser for command line options whose API + is designed to be familiar to users of the C getopt function. + Users who are unfamiliar with the C getopt function or who would + like to write less code and get better help and error messages + should consider using the argparse module instead. + +Additionally, after the final getopt example, the following note will +be added: + + Note that an equivalent command line interface could be produced + with less code by using the argparse module:: + + import argparse + + if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('-o', '--output') + parser.add_argument('-v', dest='verbose', action='store_true') + args = parser.parse_args() + # ... do something with args.output ... + # ... do something with args.verbose .. -Open Issues -=========== + +Deferred: string formatting +=========================== The argparse module supports Python from 2.3 up through 3.2 and as a result relies on traditional ``%(foo)s`` style string formatting. It has been suggested that it might be better to use the new style -``{foo}`` string formatting [13]_. This seems like a good idea, but -would break backwards compatibility for existing argparse-based -scripts unless we can come up with a way to reasonably support both -syntaxes. +``{foo}`` string formatting [13]_. There was some discussion about +how best to do this for modules in the standard library [14]_ and +several people are developing functions for automatically converting +%-formatting to {}-formatting [15]_ [16]_. When one of these is added +to the standard library, argparse will use them to support both +formatting styles. + + +Rejected: getopt compatibility methods +====================================== +Previously, when this PEP was suggesting the deprecation of getopt +as well as optparse, there was some talk of adding a method like:: + + ArgumentParser.add_getopt_arguments(options[, long_options]) + +However, this method will not be added for a number of reasons: + +* The getopt module is not being deprecated, so there is less need. +* This method would not actually ease the transition for any getopt + users who were already maintaining usage messages, because the API + above gives no way of adding help messages to the arguments. +* Some users of getopt consider it very important that only a single + function call is necessary. The API above does not satisfy this + requirement because both ``ArgumentParser()`` and ``parse_args()`` + must also be called. + + +Out of Scope: Various Feature Requests +====================================== +Several feature requests for argparse were made in the discussion of +this PEP: + +* Support argument defaults from environment variables +* Support argument defaults from configuration files +* Support "foo --help subcommand" in addition to the currently + supported "foo subcommand --help" + +These are all reasonable feature requests for the argparse module, +but are out of the scope of this PEP, and have been redirected to +the argparse issue tracker. + + +Discussion: sys.err and sys.exit +================================ +There were some concerns that argparse by default always writes to +``sys.err`` and always calls ``sys.exit`` when invalid arguments are +provided. This is the desired behavior for the vast majority of +argparse use cases which revolve around simple command line +interfaces. However, in some cases, it may be desirable to keep +argparse from exiting, or to have it write its messages to something +other than ``sys.err``. These use cases can be supported by +subclassing ``ArgumentParser`` and overriding the ``exit`` or +``_print_message`` methods. The latter is an undocumented +implementation detail, but could be officially exposed if this turns +out to be a common need. References @@ -207,6 +300,15 @@ .. [13] use {}-formatting instead of %-formatting (http://bugs.python.org/msg89279) +.. [14] transitioning from % to {} formatting + (http://mail.python.org/pipermail/python-dev/2009-September/092326.html) + +.. [15] Vinay Sajip's %-to-{} converter + (http://gist.github.com/200936) + +.. [16] Benjamin Peterson's %-to-{} converter + (http://bazaar.launchpad.net/~gutworth/+junk/mod2format/files) + Copyright ========= From python-checkins at python.org Sat Oct 24 21:50:44 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 24 Oct 2009 19:50:44 -0000 Subject: [Python-checkins] r75675 - in python/trunk: Objects/floatobject.c PC/os2emx/python27.def Message-ID: Author: eric.smith Date: Sat Oct 24 21:50:44 2009 New Revision: 75675 Log: Removed unused function PyFloat_AsStringEx. It is unused in floatobject.c, and it's not declared in any .h file. Modified: python/trunk/Objects/floatobject.c python/trunk/PC/os2emx/python27.def Modified: python/trunk/Objects/floatobject.c ============================================================================== --- python/trunk/Objects/floatobject.c (original) +++ python/trunk/Objects/floatobject.c Sat Oct 24 21:50:44 2009 @@ -299,17 +299,6 @@ /* Methods */ -/* XXX PyFloat_AsStringEx should not be a public API function (for one - XXX thing, its signature passes a buffer without a length; for another, - XXX it isn't useful outside this file). -*/ -void -PyFloat_AsStringEx(char *buf, PyFloatObject *v, int precision) -{ - _PyOS_double_to_string(buf, 100, v->ob_fval, 'g', precision, - Py_DTSF_ADD_DOT_0, NULL); -} - /* Macro and helper that convert PyObject obj to a C double and store the value in dbl; this replaces the functionality of the coercion slot function. If conversion to double raises an exception, obj is Modified: python/trunk/PC/os2emx/python27.def ============================================================================== --- python/trunk/PC/os2emx/python27.def (original) +++ python/trunk/PC/os2emx/python27.def Sat Oct 24 21:50:44 2009 @@ -306,7 +306,6 @@ "PyFloat_AsReprString" "PyFloat_AsString" "_PyFloat_Init" - "PyFloat_AsStringEx" "PyFloat_Type" ; From python27_s.lib(frameobject) From python-checkins at python.org Sat Oct 24 21:52:23 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 24 Oct 2009 19:52:23 -0000 Subject: [Python-checkins] r75676 - python/branches/py3k Message-ID: Author: eric.smith Date: Sat Oct 24 21:52:23 2009 New Revision: 75676 Log: Blocked revisions 75675 via svnmerge ........ r75675 | eric.smith | 2009-10-24 15:50:44 -0400 (Sat, 24 Oct 2009) | 1 line Removed unused function PyFloat_AsStringEx. It is unused in floatobject.c, and it's not declared in any .h file. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 24 21:53:00 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 24 Oct 2009 19:53:00 -0000 Subject: [Python-checkins] r75677 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Sat Oct 24 21:53:00 2009 New Revision: 75677 Log: Blocked revisions 75675 via svnmerge ........ r75675 | eric.smith | 2009-10-24 15:50:44 -0400 (Sat, 24 Oct 2009) | 1 line Removed unused function PyFloat_AsStringEx. It is unused in floatobject.c, and it's not declared in any .h file. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 24 22:11:21 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:11:21 -0000 Subject: [Python-checkins] r75678 - in python/branches/py3k: Doc/library/sys.rst Lib/distutils/command/build_ext.py Lib/plat-atheos Lib/test/regrtest.py Lib/test/test_fcntl.py Lib/test/test_file.py Lib/test/test_fileio.py Python/dynload_atheos.c Python/thread.c Python/thread_atheos.h Tools/scripts/h2py.py configure configure.in setup.py Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:11:21 2009 New Revision: 75678 Log: Remove AtheOS support, as per PEP 11 (which claims that all code was removed in Python 3.0). Removed: python/branches/py3k/Lib/plat-atheos/ python/branches/py3k/Python/dynload_atheos.c python/branches/py3k/Python/thread_atheos.h Modified: python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Lib/distutils/command/build_ext.py python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/test_fcntl.py python/branches/py3k/Lib/test/test_file.py python/branches/py3k/Lib/test/test_fileio.py python/branches/py3k/Python/thread.c python/branches/py3k/Tools/scripts/h2py.py python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/setup.py Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sat Oct 24 22:11:21 2009 @@ -576,7 +576,6 @@ Mac OS X ``'darwin'`` OS/2 ``'os2'`` OS/2 EMX ``'os2emx'`` - AtheOS ``'atheos'`` ================ =========================== Modified: python/branches/py3k/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/build_ext.py (original) +++ python/branches/py3k/Lib/distutils/command/build_ext.py Sat Oct 24 22:11:21 2009 @@ -262,9 +262,9 @@ if os.name == 'os2': self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config')) - # for extensions under Cygwin and AtheOS Python's library directory must be + # for extensions under Cygwin Python's library directory must be # appended to library_dirs - if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': + if sys.platform[:6] == 'cygwin': if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", @@ -776,22 +776,6 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib] - elif sys.platform[:6] == "atheos": - from distutils import sysconfig - - template = "python%d.%d" - pythonlib = (template % - (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) - # Get SHLIBS from Makefile - extra = [] - for lib in sysconfig.get_config_var('SHLIBS').split(): - if lib.startswith('-l'): - extra.append(lib[2:]) - else: - extra.append(lib) - # don't extend ext.libraries, it may be shared with other - # extensions, it is a reference to the original list - return ext.libraries + [pythonlib, "m"] + extra elif sys.platform == 'darwin': # Don't use the default code below return ext.libraries Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Sat Oct 24 22:11:21 2009 @@ -1188,19 +1188,6 @@ test_zipfile test_zlib """, - 'atheos': - """ - test_curses - test_dbm_gnu - test_epoll - test_largefile - test_locale - test_kqueue - test_mhlib - test_mmap - test_poll - test_resource - """, 'cygwin': """ test_curses Modified: python/branches/py3k/Lib/test/test_fcntl.py ============================================================================== --- python/branches/py3k/Lib/test/test_fcntl.py (original) +++ python/branches/py3k/Lib/test/test_fcntl.py Sat Oct 24 22:11:21 2009 @@ -16,15 +16,12 @@ # TODO - Write tests for flock() and lockf(). def get_lockdata(): - if sys.platform.startswith('atheos'): - start_len = "qq" + try: + os.O_LARGEFILE + except AttributeError: + start_len = "ll" else: - try: - os.O_LARGEFILE - except AttributeError: - start_len = "ll" - else: - start_len = "qq" + start_len = "qq" if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3', 'Darwin1.2', 'darwin', Modified: python/branches/py3k/Lib/test/test_file.py ============================================================================== --- python/branches/py3k/Lib/test/test_file.py (original) +++ python/branches/py3k/Lib/test/test_file.py Sat Oct 24 22:11:21 2009 @@ -106,8 +106,7 @@ ('writelines', ([],)), ('__iter__', ()), ] - if not sys.platform.startswith('atheos'): - methods.append(('truncate', ())) + methods.append(('truncate', ())) # __exit__ should close the file self.f.__exit__(None, None, None) Modified: python/branches/py3k/Lib/test/test_fileio.py ============================================================================== --- python/branches/py3k/Lib/test/test_fileio.py (original) +++ python/branches/py3k/Lib/test/test_fileio.py Sat Oct 24 22:11:21 2009 @@ -96,8 +96,6 @@ methods = ['fileno', 'isatty', 'read', 'readinto', 'seek', 'tell', 'truncate', 'write', 'seekable', 'readable', 'writable'] - if sys.platform.startswith('atheos'): - methods.remove('truncate') self.f.close() self.assertTrue(self.f.closed) Deleted: python/branches/py3k/Python/dynload_atheos.c ============================================================================== --- python/branches/py3k/Python/dynload_atheos.c Sat Oct 24 22:11:21 2009 +++ (empty file) @@ -1,47 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include -#include - -#include "Python.h" -#include "importdl.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - void *p; - int lib; - char funcname[258]; - - if (Py_VerboseFlag) - printf("load_library %s\n", pathname); - - lib = load_library(pathname, 0); - if (lib < 0) { - char buf[512]; - if (Py_VerboseFlag) - perror(pathname); - PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s", - pathname, strerror(errno)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname); - if (Py_VerboseFlag) - printf("get_symbol_address %s\n", funcname); - if (get_symbol_address(lib, funcname, -1, &p) < 0) { - p = NULL; - if (Py_VerboseFlag) - perror(funcname); - } - - return (dl_funcptr) p; -} Modified: python/branches/py3k/Python/thread.c ============================================================================== --- python/branches/py3k/Python/thread.c (original) +++ python/branches/py3k/Python/thread.c Sat Oct 24 22:11:21 2009 @@ -137,10 +137,6 @@ #include "thread_plan9.h" #endif -#ifdef ATHEOS_THREADS -#include "thread_atheos.h" -#endif - /* #ifdef FOOBAR_THREADS #include "thread_foobar.h" Deleted: python/branches/py3k/Python/thread_atheos.h ============================================================================== --- python/branches/py3k/Python/thread_atheos.h Sat Oct 24 22:11:21 2009 +++ (empty file) @@ -1,300 +0,0 @@ -/* Threading for AtheOS. - Based on thread_beos.h. */ - -#include -#include -#include -#include -#include - -/* Missing decl from threads.h */ -extern int exit_thread(int); - - -/* Undefine FASTLOCK to play with simple semaphores. */ -#define FASTLOCK - - -#ifdef FASTLOCK - -/* Use an atomic counter and a semaphore for maximum speed. */ -typedef struct fastmutex { - sem_id sem; - atomic_t count; -} fastmutex_t; - - -static int fastmutex_create(const char *name, fastmutex_t * mutex); -static int fastmutex_destroy(fastmutex_t * mutex); -static int fastmutex_lock(fastmutex_t * mutex); -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout); -static int fastmutex_unlock(fastmutex_t * mutex); - - -static int fastmutex_create(const char *name, fastmutex_t * mutex) -{ - mutex->count = 0; - mutex->sem = create_semaphore(name, 0, 0); - return (mutex->sem < 0) ? -1 : 0; -} - - -static int fastmutex_destroy(fastmutex_t * mutex) -{ - if (fastmutex_timedlock(mutex, 0) == 0 || errno == EWOULDBLOCK) { - return delete_semaphore(mutex->sem); - } - return 0; -} - - -static int fastmutex_lock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore(mutex->sem); - return 0; -} - - -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore_x(mutex->sem, 1, 0, timeout); - return 0; -} - - -static int fastmutex_unlock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, -1); - if (prev > 1) - return unlock_semaphore(mutex->sem); - return 0; -} - - -#endif /* FASTLOCK */ - - -/* - * Initialization. - * - */ -static void PyThread__init_thread(void) -{ - /* Do nothing. */ - return; -} - - -/* - * Thread support. - * - */ - -static atomic_t thread_count = 0; - -long PyThread_start_new_thread(void (*func) (void *), void *arg) -{ - status_t success = -1; - thread_id tid; - char name[OS_NAME_LENGTH]; - atomic_t this_thread; - - dprintf(("PyThread_start_new_thread called\n")); - - this_thread = atomic_add(&thread_count, 1); - PyOS_snprintf(name, sizeof(name), "python thread (%d)", this_thread); - - tid = spawn_thread(name, func, NORMAL_PRIORITY, 0, arg); - if (tid < 0) { - dprintf(("PyThread_start_new_thread spawn_thread failed: %s\n", strerror(errno))); - } else { - success = resume_thread(tid); - if (success < 0) { - dprintf(("PyThread_start_new_thread resume_thread failed: %s\n", strerror(errno))); - } - } - - return (success < 0 ? -1 : tid); -} - - -long PyThread_get_thread_ident(void) -{ - return get_thread_id(NULL); -} - - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - - /* Thread-safe way to read a variable without a mutex: */ - if (atomic_add(&thread_count, 0) == 0) { - /* No threads around, so exit main(). */ - if (no_cleanup) - _exit(0); - else - exit(0); - } else { - /* We're a thread */ - exit_thread(0); - } -} - - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - - /* No need to do anything, the threads get torn down if main()exits. */ - if (no_cleanup) - _exit(status); - else - exit(status); -} - - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - - -/* - * Lock support. - * - */ - -static atomic_t lock_count = 0; - -PyThread_type_lock PyThread_allocate_lock(void) -{ -#ifdef FASTLOCK - fastmutex_t *lock; -#else - sem_id sema; -#endif - char name[OS_NAME_LENGTH]; - atomic_t this_lock; - - dprintf(("PyThread_allocate_lock called\n")); - -#ifdef FASTLOCK - lock = (fastmutex_t *) malloc(sizeof(fastmutex_t)); - if (lock == NULL) { - dprintf(("PyThread_allocate_lock failed: out of memory\n")); - return (PyThread_type_lock) NULL; - } -#endif - this_lock = atomic_add(&lock_count, 1); - PyOS_snprintf(name, sizeof(name), "python lock (%d)", this_lock); - -#ifdef FASTLOCK - if (fastmutex_create(name, lock) < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - free(lock); - lock = NULL; - } - dprintf(("PyThread_allocate_lock()-> %p\n", lock)); - return (PyThread_type_lock) lock; -#else - sema = create_semaphore(name, 1, 0); - if (sema < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - sema = 0; - } - dprintf(("PyThread_allocate_lock()-> %p\n", sema)); - return (PyThread_type_lock) sema; -#endif -} - - -void PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_destroy((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } - free(lock); -#else - if (delete_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} - - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int retval; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, - waitflag)); - -#ifdef FASTLOCK - if (waitflag) - retval = fastmutex_lock((fastmutex_t *) lock); - else - retval = fastmutex_timedlock((fastmutex_t *) lock, 0); -#else - if (waitflag) - retval = lock_semaphore((sem_id) lock); - else - retval = lock_semaphore_x((sem_id) lock, 1, 0, 0); -#endif - if (retval < 0) { - dprintf(("PyThread_acquire_lock(%p, %d) failed: %s\n", - lock, waitflag, strerror(errno))); - } - dprintf(("PyThread_acquire_lock(%p, %d)-> %d\n", lock, waitflag, - retval)); - return retval < 0 ? 0 : 1; -} - - -void PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_unlock((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#else - if (unlock_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} Modified: python/branches/py3k/Tools/scripts/h2py.py ============================================================================== --- python/branches/py3k/Tools/scripts/h2py.py (original) +++ python/branches/py3k/Tools/scripts/h2py.py Sat Oct 24 22:11:21 2009 @@ -49,13 +49,7 @@ try: searchdirs=os.environ['INCLUDE'].split(';') except KeyError: - try: - if sys.platform.startswith("atheos"): - searchdirs=os.environ['C_INCLUDE_PATH'].split(':') - else: - raise KeyError - except KeyError: - searchdirs=['/usr/include'] + searchdirs=['/usr/include'] def main(): global filedict Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sat Oct 24 22:11:21 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74745 . +# From configure.in Revision: 74979 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -2066,7 +2066,6 @@ case $MACHDEP in cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; - atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; esac @@ -3802,7 +3801,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f -r conftest* +rm -f conftest* @@ -3972,7 +3971,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN* | atheos*) + CYGWIN*) enable_shared="yes";; *) enable_shared="no";; @@ -4108,11 +4107,6 @@ BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ;; - atheos*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; Darwin*) LDLIBRARY='libpython$(VERSION).dylib' BLDLIBRARY='-L. -lpython$(VERSION)' @@ -4451,7 +4445,6 @@ if test -z "$LN" ; then case $ac_sys_system in CYGWIN*) LN="ln -s";; - atheos*) LN="ln -s";; *) LN=ln;; esac fi @@ -5355,7 +5348,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -5376,7 +5369,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -6474,7 +6467,7 @@ fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -7004,7 +6997,7 @@ else ac_cv_type_uid_t=no fi -rm -f -r conftest* +rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -14696,7 +14689,6 @@ fi;; SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; - atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac fi @@ -14737,7 +14729,6 @@ *gcc*) CCSHARED="-shared";; *) CCSHARED="";; esac;; - atheos*) CCSHARED="-fPIC";; esac fi { echo "$as_me:$LINENO: result: $CCSHARED" >&5 @@ -15548,7 +15539,7 @@ else unistd_defines_pthreads=no fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -16022,149 +16013,6 @@ THREADOBJ="Python/thread.o" else - if test "${ac_cv_header_atheos_threads_h+set}" = set; then - { echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 -echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6; } -if test "${ac_cv_header_atheos_threads_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 -echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking atheos/threads.h usability" >&5 -echo $ECHO_N "checking atheos/threads.h usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking atheos/threads.h presence" >&5 -echo $ECHO_N "checking atheos/threads.h presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: atheos/threads.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: atheos/threads.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: atheos/threads.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: atheos/threads.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------- ## -## Report this to http://bugs.python.org/ ## -## -------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 -echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6; } -if test "${ac_cv_header_atheos_threads_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_header_atheos_threads_h=$ac_header_preproc -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 -echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6; } - -fi -if test $ac_cv_header_atheos_threads_h = yes; then - cat >>confdefs.h <<\_ACEOF -#define WITH_THREAD 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define ATHEOS_THREADS 1 -_ACEOF - - THREADOBJ="Python/thread.o" -else - { echo "$as_me:$LINENO: checking for pthread_create in -lpthreads" >&5 echo $ECHO_N "checking for pthread_create in -lpthreads... $ECHO_C" >&6; } if test "${ac_cv_lib_pthreads_pthread_create+set}" = set; then @@ -16461,9 +16309,6 @@ fi - -fi - fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ @@ -17016,7 +16861,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f -r conftest* +rm -f conftest* ;; kame) @@ -17039,7 +16884,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-glibc) @@ -17060,7 +16905,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-inet6) @@ -17098,7 +16943,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; v6d) @@ -17121,7 +16966,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f -r conftest* +rm -f conftest* ;; zeta) @@ -17143,7 +16988,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; esac @@ -17439,7 +17284,6 @@ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/[0156]\..*) DYNLOADFILE="dynload_next.o";; - atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading @@ -25235,7 +25079,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi @@ -25505,7 +25349,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sat Oct 24 22:11:21 2009 @@ -248,7 +248,6 @@ case $MACHDEP in cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; - atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; esac @@ -630,7 +629,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN* | atheos*) + CYGWIN*) enable_shared="yes";; *) enable_shared="no";; @@ -716,11 +715,6 @@ BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ;; - atheos*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; Darwin*) LDLIBRARY='libpython$(VERSION).dylib' BLDLIBRARY='-L. -lpython$(VERSION)' @@ -774,7 +768,6 @@ if test -z "$LN" ; then case $ac_sys_system in CYGWIN*) LN="ln -s";; - atheos*) LN="ln -s";; *) LN=ln;; esac fi @@ -1701,7 +1694,6 @@ fi;; SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; - atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac fi @@ -1740,7 +1732,6 @@ *gcc*) CCSHARED="-shared";; *) CCSHARED="";; esac;; - atheos*) CCSHARED="-fPIC";; esac fi AC_MSG_RESULT($CCSHARED) @@ -2056,10 +2047,6 @@ AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) posix_threads=yes THREADOBJ="Python/thread.o"],[ - AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(ATHEOS_THREADS, 1, - [Define this if you have AtheOS threads.]) - THREADOBJ="Python/thread.o"],[ AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) posix_threads=yes LIBS="$LIBS -lpthreads" @@ -2077,7 +2064,7 @@ LIBS="$LIBS -lcma" THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) - ])])])])])])])])]) + ])])])])])])])]) AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) LIBS="$LIBS -lmpc" @@ -2409,7 +2396,6 @@ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; - atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading Modified: python/branches/py3k/setup.py ============================================================================== --- python/branches/py3k/setup.py (original) +++ python/branches/py3k/setup.py Sat Oct 24 22:11:21 2009 @@ -288,7 +288,7 @@ def get_platform(self): # Get value of sys.platform - for platform in ['cygwin', 'darwin', 'atheos', 'osf1']: + for platform in ['cygwin', 'darwin', 'osf1']: if sys.platform.startswith(platform): return platform return sys.platform @@ -355,13 +355,6 @@ platform = self.get_platform() srcdir = sysconfig.get_config_var('srcdir') - # Check for AtheOS which has libraries in non-standard locations - if platform == 'atheos': - lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] - lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) - inc_dirs += ['/system/include', '/atheos/autolnk/include'] - inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) - # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] @@ -465,7 +458,7 @@ exts.append( Extension('parser', ['parsermodule.c']) ) # Memory-mapped files (also works on Win32). - if platform not in ['atheos', 'mac']: + if platform not in ['mac']: exts.append( Extension('mmap', ['mmapmodule.c']) ) else: missing.append('mmap') @@ -975,13 +968,10 @@ # Steen Lumholt's termios module exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface - if platform not in ['atheos']: - exts.append( Extension('resource', ['resource.c']) ) - else: - missing.append('resource') + exts.append( Extension('resource', ['resource.c']) ) # Sun yellow pages. Some systems have the functions in libc. - if platform not in ['cygwin', 'atheos', 'qnx6']: + if platform not in ['cygwin', 'qnx6']: if (self.compiler_obj.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] else: From python-checkins at python.org Sat Oct 24 22:22:34 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:22:34 -0000 Subject: [Python-checkins] r75679 - peps/trunk/pep-0011.txt Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:22:33 2009 New Revision: 75679 Log: Mach C Threads now unsupported Modified: peps/trunk/pep-0011.txt Modified: peps/trunk/pep-0011.txt ============================================================================== --- peps/trunk/pep-0011.txt (original) +++ peps/trunk/pep-0011.txt Sat Oct 24 22:22:33 2009 @@ -144,6 +144,10 @@ Build broken in: Python 2.7 (edit configure to reenable) Code removed in: Python 3.0 + Name: Systems using Mach C Threads + Unsupported in: Python 3.2 + Code removed in: Python 3.3 + Platform Maintainers Cygwin Jason Tishler (jason at tishler.net) From python-checkins at python.org Sat Oct 24 22:24:16 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:24:16 -0000 Subject: [Python-checkins] r75680 - python/branches/py3k/Python/thread.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:24:16 2009 New Revision: 75680 Log: Disable support for Mach C Threads. Modified: python/branches/py3k/Python/thread.c Modified: python/branches/py3k/Python/thread.c ============================================================================== --- python/branches/py3k/Python/thread.c (original) +++ python/branches/py3k/Python/thread.c Sat Oct 24 22:24:16 2009 @@ -122,6 +122,7 @@ #endif #ifdef C_THREADS +#error Mach C Threads are now unsupported, and code will be removed in 3.3. #include "thread_cthread.h" #endif From python-checkins at python.org Sat Oct 24 22:30:13 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:30:13 -0000 Subject: [Python-checkins] r75681 - peps/trunk/pep-0011.txt Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:30:13 2009 New Revision: 75681 Log: SunOS LWP (lightweight processes) now unsupported Modified: peps/trunk/pep-0011.txt Modified: peps/trunk/pep-0011.txt ============================================================================== --- peps/trunk/pep-0011.txt (original) +++ peps/trunk/pep-0011.txt Sat Oct 24 22:30:13 2009 @@ -148,6 +148,10 @@ Unsupported in: Python 3.2 Code removed in: Python 3.3 + Name: SunOS lightweight processes (LWP) + Unsupported in: Python 3.2 + Code removed in: Python 3.3 + Platform Maintainers Cygwin Jason Tishler (jason at tishler.net) From python-checkins at python.org Sat Oct 24 22:30:34 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:30:34 -0000 Subject: [Python-checkins] r75682 - python/branches/py3k/Python/thread.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:30:34 2009 New Revision: 75682 Log: Disable support for SunOS LWP Modified: python/branches/py3k/Python/thread.c Modified: python/branches/py3k/Python/thread.c ============================================================================== --- python/branches/py3k/Python/thread.c (original) +++ python/branches/py3k/Python/thread.c Sat Oct 24 22:30:34 2009 @@ -109,6 +109,7 @@ #endif #ifdef SUN_LWP +#error SunOS lightweight processes are now unsupported, and code will be removed in 3.3. #include "thread_lwp.h" #endif From python-checkins at python.org Sat Oct 24 22:35:25 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:35:25 -0000 Subject: [Python-checkins] r75683 - peps/trunk/pep-0011.txt Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:35:25 2009 New Revision: 75683 Log: GNU pth threads now unsupported Modified: peps/trunk/pep-0011.txt Modified: peps/trunk/pep-0011.txt ============================================================================== --- peps/trunk/pep-0011.txt (original) +++ peps/trunk/pep-0011.txt Sat Oct 24 22:35:25 2009 @@ -152,6 +152,10 @@ Unsupported in: Python 3.2 Code removed in: Python 3.3 + Name: Systems using --with-pth (GNU pth threads) + Unsupported in: Python 3.2 + Code removed in: Python 3.3 + Platform Maintainers Cygwin Jason Tishler (jason at tishler.net) From python-checkins at python.org Sat Oct 24 22:35:53 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:35:53 -0000 Subject: [Python-checkins] r75684 - in python/branches/py3k: Python/thread.c configure configure.in Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:35:52 2009 New Revision: 75684 Log: Disable GNU pth support Modified: python/branches/py3k/Python/thread.c python/branches/py3k/configure python/branches/py3k/configure.in Modified: python/branches/py3k/Python/thread.c ============================================================================== --- python/branches/py3k/Python/thread.c (original) +++ python/branches/py3k/Python/thread.c Sat Oct 24 22:35:52 2009 @@ -114,6 +114,7 @@ #endif #ifdef HAVE_PTH +#error GNU pth threads are now unsupported, and code will be removed in 3.3. #include "thread_pth.h" #undef _POSIX_THREADS #endif Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Sat Oct 24 22:35:52 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74979 . +# From configure.in Revision: 75678 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -1352,7 +1352,6 @@ disable/enable thread support --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads - --with-pth use GNU pth threading libraries --with(out)-doc-strings disable/enable documentation strings --with(out)-tsc enable/disable timestamp counter profile --with(out)-pymalloc disable/enable specialized mallocs @@ -15843,28 +15842,6 @@ THREADOBJ="Python/thread.o" else - { echo "$as_me:$LINENO: checking for --with-pth" >&5 -echo $ECHO_N "checking for --with-pth... $ECHO_C" >&6; } - -# Check whether --with-pth was given. -if test "${with_pth+set}" = set; then - withval=$with_pth; { echo "$as_me:$LINENO: result: $withval" >&5 -echo "${ECHO_T}$withval" >&6; } - cat >>confdefs.h <<\_ACEOF -#define WITH_THREAD 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTH 1 -_ACEOF - - LIBS="-lpth $LIBS" - THREADOBJ="Python/thread.o" -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - # Just looking for pthread_create in libpthread is not enough: # on HP/UX, pthread.h renames pthread_create to a different symbol name. # So we really have to include pthread.h, and then link. @@ -16315,8 +16292,6 @@ conftest$ac_exeext conftest.$ac_ext fi -fi - fi Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Sat Oct 24 22:35:52 2009 @@ -2018,17 +2018,6 @@ AC_DEFINE(MACH_C_THREADS, 1, [Define if you are using Mach cthreads under mach /]) THREADOBJ="Python/thread.o"],[ - AC_MSG_CHECKING(for --with-pth) - AC_ARG_WITH([pth], - AC_HELP_STRING(--with-pth, use GNU pth threading libraries), - [AC_MSG_RESULT($withval) - AC_DEFINE([WITH_THREAD]) - AC_DEFINE([HAVE_PTH], 1, - [Define if you have GNU PTH threads.]) - LIBS="-lpth $LIBS" - THREADOBJ="Python/thread.o"], - [AC_MSG_RESULT(no) - # Just looking for pthread_create in libpthread is not enough: # on HP/UX, pthread.h renames pthread_create to a different symbol name. # So we really have to include pthread.h, and then link. @@ -2064,7 +2053,7 @@ LIBS="$LIBS -lcma" THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) - ])])])])])])])]) + ])])])])])])]) AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) LIBS="$LIBS -lmpc" From python-checkins at python.org Sat Oct 24 22:43:29 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:43:29 -0000 Subject: [Python-checkins] r75685 - peps/trunk/pep-0011.txt Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:43:29 2009 New Revision: 75685 Log: SGI Irix threads now unsupported Modified: peps/trunk/pep-0011.txt Modified: peps/trunk/pep-0011.txt ============================================================================== --- peps/trunk/pep-0011.txt (original) +++ peps/trunk/pep-0011.txt Sat Oct 24 22:43:29 2009 @@ -156,6 +156,10 @@ Unsupported in: Python 3.2 Code removed in: Python 3.3 + Name: Systems using Irix threads + Unsupported in: Python 3.2 + Code removed in: Python 3.3 + Platform Maintainers Cygwin Jason Tishler (jason at tishler.net) From python-checkins at python.org Sat Oct 24 22:43:49 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:43:49 -0000 Subject: [Python-checkins] r75686 - python/branches/py3k/Python/thread.c Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:43:49 2009 New Revision: 75686 Log: Disable support for Irix threads Modified: python/branches/py3k/Python/thread.c Modified: python/branches/py3k/Python/thread.c ============================================================================== --- python/branches/py3k/Python/thread.c (original) +++ python/branches/py3k/Python/thread.c Sat Oct 24 22:43:49 2009 @@ -23,12 +23,6 @@ #include -#ifdef __sgi -#ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */ -#undef _POSIX_THREADS -#endif -#endif - #include "pythread.h" #ifndef _POSIX_THREADS @@ -101,6 +95,7 @@ static size_t _pythread_stacksize = 0; #ifdef SGI_THREADS +#error SGI Irix threads are now unsupported, and code will be removed in 3.3. #include "thread_sgi.h" #endif From python-checkins at python.org Sat Oct 24 22:47:05 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 20:47:05 -0000 Subject: [Python-checkins] r75687 - python/branches/py3k/Misc/NEWS Message-ID: Author: antoine.pitrou Date: Sat Oct 24 22:47:05 2009 New Revision: 75687 Log: Add NEWS entry for the various unsupported platforms. Modified: python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 24 22:47:05 2009 @@ -12,6 +12,13 @@ Core and Builtins ----------------- +- Support for AtheOS has been completely removed from the code base. It was + disabled since Python 3.0. + +- Support for several legacy threading libraries has been disabled. These + libraries are: Mach C threads, SunOS LWP, GNU pth, Irix threads. Support code + will be entirely removed in 3.3. + - Peephole constant folding had missed UNARY_POSITIVE. - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which From nnorwitz at gmail.com Sun Oct 25 00:40:01 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 24 Oct 2009 18:40:01 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091024224001.GA13771@python.psfb.org> More important issues: ---------------------- test_zipimport_support leaked [25, 0, 0] references, sum=25 Less important issues: ---------------------- test_cmd_line leaked [25, -25, 25] references, sum=25 test_distutils leaked [25, -25, 0] references, sum=0 test_smtplib leaked [4, 0, -88] references, sum=-84 test_ssl leaked [-339, 339, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Sun Oct 25 00:41:49 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 22:41:49 -0000 Subject: [Python-checkins] r75688 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sun Oct 25 00:41:49 2009 New Revision: 75688 Log: Output system properties at the beginning Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sun Oct 25 00:41:49 2009 @@ -17,6 +17,7 @@ import subprocess import socket from optparse import OptionParser, SUPPRESS_HELP +import platform # Compatibility try: @@ -425,6 +426,20 @@ options.throughput = options.latency = True if options.interval: sys.setcheckinterval(options.interval) + + print("== %s %s (%s) ==" % ( + platform.python_implementation(), + platform.python_version(), + platform.python_build()[0], + )) + # Processor identification often has repeated spaces + cpu = ' '.join(platform.processor().split()) + print("== %s %s on '%s' ==" % ( + platform.machine(), + platform.system(), + cpu, + )) + print() if options.throughput: print("--- Throughput ---") From python-checkins at python.org Sun Oct 25 00:45:14 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 22:45:14 -0000 Subject: [Python-checkins] r75689 - in sandbox/trunk/ccbench: atom-linux-newgil.txt atom-linux-py3k.txt Message-ID: Author: antoine.pitrou Date: Sun Oct 25 00:45:13 2009 New Revision: 75689 Log: Add sample results (obtained on a netbook) Added: sandbox/trunk/ccbench/atom-linux-newgil.txt (contents, props changed) sandbox/trunk/ccbench/atom-linux-py3k.txt (contents, props changed) Added: sandbox/trunk/ccbench/atom-linux-newgil.txt ============================================================================== --- (empty file) +++ sandbox/trunk/ccbench/atom-linux-newgil.txt Sun Oct 25 00:45:13 2009 @@ -0,0 +1,51 @@ +== CPython 3.2a0.0 (unknown:75687) == +== i686 Linux on 'Intel(R) Atom(TM) CPU Z530 @ 1.60GHz' == + +--- Throughput --- + +Pi calculation (Python) + +threads=1: 236 iterations/s. +threads=2: 222 ( 93 %) +threads=3: 223 ( 94 %) +threads=4: 218 ( 92 %) + +regular expression (C) + +threads=1: 96 iterations/s. +threads=2: 88 ( 91 %) +threads=3: 80 ( 83 %) +threads=4: 72 ( 75 %) + +bz2 compression (C) + +threads=1: 156 iterations/s. +threads=2: 214 ( 136 %) +threads=3: 200 ( 128 %) +threads=4: 203 ( 129 %) + +--- Latency --- + +Background CPU task: Pi calculation (Python) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 1 ms. (std dev: 3 ms.) +CPU threads=2: 1 ms. (std dev: 3 ms.) +CPU threads=3: 1 ms. (std dev: 2 ms.) +CPU threads=4: 1 ms. (std dev: 3 ms.) + +Background CPU task: regular expression (C) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 5 ms. (std dev: 2 ms.) +CPU threads=2: 6 ms. (std dev: 4 ms.) +CPU threads=3: 6 ms. (std dev: 3 ms.) +CPU threads=4: 5 ms. (std dev: 2 ms.) + +Background CPU task: bz2 compression (C) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 0 ms. (std dev: 0 ms.) +CPU threads=2: 0 ms. (std dev: 2 ms.) +CPU threads=3: 0 ms. (std dev: 1 ms.) +CPU threads=4: 0 ms. (std dev: 0 ms.) Added: sandbox/trunk/ccbench/atom-linux-py3k.txt ============================================================================== --- (empty file) +++ sandbox/trunk/ccbench/atom-linux-py3k.txt Sun Oct 25 00:45:13 2009 @@ -0,0 +1,51 @@ +== CPython 3.2a0.0 (py3k:75687) == +== i686 Linux on 'Intel(R) Atom(TM) CPU Z530 @ 1.60GHz' == + +--- Throughput --- + +Pi calculation (Python) + +threads=1: 238 iterations/s. +threads=2: 173 ( 72 %) +threads=3: 162 ( 68 %) +threads=4: 157 ( 66 %) + +regular expression (C) + +threads=1: 98 iterations/s. +threads=2: 98 ( 100 %) +threads=3: 98 ( 99 %) +threads=4: 87 ( 88 %) + +bz2 compression (C) + +threads=1: 156 iterations/s. +threads=2: 217 ( 138 %) +threads=3: 205 ( 131 %) +threads=4: 197 ( 126 %) + +--- Latency --- + +Background CPU task: Pi calculation (Python) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 0 ms. (std dev: 1 ms.) +CPU threads=2: 15 ms. (std dev: 29 ms.) +CPU threads=3: 38 ms. (std dev: 43 ms.) +CPU threads=4: 14 ms. (std dev: 34 ms.) + +Background CPU task: regular expression (C) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 987 ms. (std dev: 578 ms.) +CPU threads=2: 990 ms. (std dev: 578 ms.) +CPU threads=3: 1401 ms. (std dev: 578 ms.) +CPU threads=4: 1080 ms. (std dev: 578 ms.) + +Background CPU task: bz2 compression (C) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 0 ms. (std dev: 0 ms.) +CPU threads=2: 1 ms. (std dev: 3 ms.) +CPU threads=3: 0 ms. (std dev: 0 ms.) +CPU threads=4: 0 ms. (std dev: 2 ms.) From python-checkins at python.org Sun Oct 25 01:41:41 2009 From: python-checkins at python.org (steven.bethard) Date: Sat, 24 Oct 2009 23:41:41 -0000 Subject: [Python-checkins] r75690 - peps/trunk/pep-0389.txt Message-ID: Author: steven.bethard Date: Sun Oct 25 01:41:41 2009 New Revision: 75690 Log: Fix sys.stderr typo. Modified: peps/trunk/pep-0389.txt Modified: peps/trunk/pep-0389.txt ============================================================================== --- peps/trunk/pep-0389.txt (original) +++ peps/trunk/pep-0389.txt Sun Oct 25 01:41:41 2009 @@ -244,15 +244,15 @@ the argparse issue tracker. -Discussion: sys.err and sys.exit -================================ +Discussion: sys.stderr and sys.exit +=================================== There were some concerns that argparse by default always writes to -``sys.err`` and always calls ``sys.exit`` when invalid arguments are -provided. This is the desired behavior for the vast majority of +``sys.stderr`` and always calls ``sys.exit`` when invalid arguments +are provided. This is the desired behavior for the vast majority of argparse use cases which revolve around simple command line interfaces. However, in some cases, it may be desirable to keep argparse from exiting, or to have it write its messages to something -other than ``sys.err``. These use cases can be supported by +other than ``sys.stderr``. These use cases can be supported by subclassing ``ArgumentParser`` and overriding the ``exit`` or ``_print_message`` methods. The latter is an undocumented implementation detail, but could be officially exposed if this turns From python-checkins at python.org Sun Oct 25 01:52:14 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sat, 24 Oct 2009 23:52:14 -0000 Subject: [Python-checkins] r75691 - in sandbox/trunk/ccbench: athlonx2-linux-newgil.txt athlonx2-linux-py3k.txt Message-ID: Author: antoine.pitrou Date: Sun Oct 25 01:52:14 2009 New Revision: 75691 Log: Add Athlon X2 benchmark results Added: sandbox/trunk/ccbench/athlonx2-linux-newgil.txt (contents, props changed) sandbox/trunk/ccbench/athlonx2-linux-py3k.txt (contents, props changed) Added: sandbox/trunk/ccbench/athlonx2-linux-newgil.txt ============================================================================== --- (empty file) +++ sandbox/trunk/ccbench/athlonx2-linux-newgil.txt Sun Oct 25 01:52:14 2009 @@ -0,0 +1,51 @@ +== CPython 3.2a0.0 (unknown:75668) == +== x86_64 Linux on 'AMD Athlon(tm) 64 X2 Dual Core Processor 3600+' == + +--- Throughput --- + +Pi calculation (Python) + +threads=1: 752 iterations/s. +threads=2: 716 ( 95 %) +threads=3: 718 ( 95 %) +threads=4: 702 ( 93 %) + +regular expression (C) + +threads=1: 173 iterations/s. +threads=2: 159 ( 91 %) +threads=3: 158 ( 91 %) +threads=4: 158 ( 91 %) + +bz2 compression (C) + +threads=1: 326 iterations/s. +threads=2: 628 ( 192 %) +threads=3: 624 ( 191 %) +threads=4: 639 ( 195 %) + +--- Latency --- + +Background CPU task: Pi calculation (Python) + +CPU threads=0: 0 ms. (std dev: 0 ms.) +CPU threads=1: 0 ms. (std dev: 1 ms.) +CPU threads=2: 1 ms. (std dev: 3 ms.) +CPU threads=3: 0 ms. (std dev: 1 ms.) +CPU threads=4: 0 ms. (std dev: 2 ms.) + +Background CPU task: regular expression (C) + +CPU threads=0: 0 ms. (std dev: 2 ms.) +CPU threads=1: 3 ms. (std dev: 2 ms.) +CPU threads=2: 3 ms. (std dev: 2 ms.) +CPU threads=3: 5 ms. (std dev: 4 ms.) +CPU threads=4: 4 ms. (std dev: 3 ms.) + +Background CPU task: bz2 compression (C) + +CPU threads=0: 0 ms. (std dev: 2 ms.) +CPU threads=1: 0 ms. (std dev: 2 ms.) +CPU threads=2: 0 ms. (std dev: 1 ms.) +CPU threads=3: 0 ms. (std dev: 2 ms.) +CPU threads=4: 0 ms. (std dev: 1 ms.) Added: sandbox/trunk/ccbench/athlonx2-linux-py3k.txt ============================================================================== --- (empty file) +++ sandbox/trunk/ccbench/athlonx2-linux-py3k.txt Sun Oct 25 01:52:14 2009 @@ -0,0 +1,51 @@ +== CPython 3.2a0.0 (py3k:75680:75684M) == +== x86_64 Linux on 'AMD Athlon(tm) 64 X2 Dual Core Processor 3600+' == + +--- Throughput --- + +Pi calculation (Python) + +threads=1: 761 iterations/s. +threads=2: 603 ( 79 %) +threads=3: 606 ( 79 %) +threads=4: 587 ( 77 %) + +regular expression (C) + +threads=1: 166 iterations/s. +threads=2: 162 ( 97 %) +threads=3: 156 ( 93 %) +threads=4: 163 ( 98 %) + +bz2 compression (C) + +threads=1: 340 iterations/s. +threads=2: 623 ( 183 %) +threads=3: 636 ( 186 %) +threads=4: 634 ( 186 %) + +--- Latency --- + +Background CPU task: Pi calculation (Python) + +CPU threads=0: 0 ms. (std dev: 2 ms.) +CPU threads=1: 9 ms. (std dev: 7 ms.) +CPU threads=2: 4 ms. (std dev: 7 ms.) +CPU threads=3: 2 ms. (std dev: 3 ms.) +CPU threads=4: 1 ms. (std dev: 3 ms.) + +Background CPU task: regular expression (C) + +CPU threads=0: 0 ms. (std dev: 1 ms.) +CPU threads=1: 1031 ms. (std dev: 578 ms.) +CPU threads=2: 1045 ms. (std dev: 575 ms.) +CPU threads=3: 1076 ms. (std dev: 578 ms.) +CPU threads=4: 661 ms. (std dev: 397 ms.) + +Background CPU task: bz2 compression (C) + +CPU threads=0: 0 ms. (std dev: 2 ms.) +CPU threads=1: 0 ms. (std dev: 0 ms.) +CPU threads=2: 0 ms. (std dev: 2 ms.) +CPU threads=3: 0 ms. (std dev: 1 ms.) +CPU threads=4: 0 ms. (std dev: 0 ms.) From python-checkins at python.org Sun Oct 25 14:09:20 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 25 Oct 2009 13:09:20 -0000 Subject: [Python-checkins] r75692 - in sandbox/trunk/newgil: Doc/library/sys.rst Lib/distutils/archive_util.py Lib/distutils/command/build_ext.py Lib/distutils/tests/test_archive_util.py Lib/plat-atheos Lib/test/regrtest.py Lib/test/test_fcntl.py Lib/test/test_file.py Lib/test/test_fileio.py Lib/test/test_sys.py Misc/NEWS Python/dynload_atheos.c Python/thread.c Python/thread_atheos.h Tools/scripts/h2py.py configure configure.in setup.py Message-ID: Author: antoine.pitrou Date: Sun Oct 25 14:09:19 2009 New Revision: 75692 Log: Merged revisions 75649,75652,75656,75661-75662,75665,75667-75668,75673,75676,75678,75680,75682,75684,75686-75687 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75649 | mark.dickinson | 2009-10-24 13:49:04 +0200 (sam., 24 oct. 2009) | 9 lines Recorded merge of revisions 75648 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75648 | mark.dickinson | 2009-10-24 12:47:17 +0100 (Sat, 24 Oct 2009) | 1 line Acknowledge Ned Deily (extensive bug hunting and testing on OS X) ........ ................ r75652 | mark.dickinson | 2009-10-24 14:15:17 +0200 (sam., 24 oct. 2009) | 12 lines Blocked revisions 75651 via svnmerge ........ r75651 | mark.dickinson | 2009-10-24 13:13:30 +0100 (Sat, 24 Oct 2009) | 7 lines Issue #7117: Prepare for backport of py3k float repr. Add the Python/dtoa.c file containing the main algorithms; add corresponding include file and include in Python.h; include license information for Python/dtoa.c; add dtoa.c and dtoa.h to Makefile. ........ ................ r75656 | antoine.pitrou | 2009-10-24 14:31:03 +0200 (sam., 24 oct. 2009) | 16 lines Blocked revisions 75650,75654-75655 via svnmerge ........ r75650 | antoine.pitrou | 2009-10-24 13:59:41 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74155] Issue #6242: Fix deallocator of io.StringIO and io.BytesIO ........ r75654 | antoine.pitrou | 2009-10-24 14:23:18 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74158] Issue #6218: Make io.BytesIO and io.StringIO picklable. ........ r75655 | antoine.pitrou | 2009-10-24 14:28:22 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74316] Issue #5449: Fix io.BytesIO to not accept arbitrary keywords ........ ................ r75661 | mark.dickinson | 2009-10-24 15:32:56 +0200 (sam., 24 oct. 2009) | 22 lines Blocked revisions 75653,75658,75660 via svnmerge ........ r75653 | mark.dickinson | 2009-10-24 13:17:24 +0100 (Sat, 24 Oct 2009) | 1 line Temporary define to avoid build failure ........ r75658 | mark.dickinson | 2009-10-24 14:28:38 +0100 (Sat, 24 Oct 2009) | 8 lines Issue #7117 (backport py3k float repr) continued: - add double endianness detection to configure script - add configure-time check to see whether we can use inline assembly to get and set x87 control word in configure script - add functions to get and set x87 control word in Python/pymath.c - add pyport.h logic to determine whether it's safe to use the short float repr or not ........ r75660 | mark.dickinson | 2009-10-24 14:31:41 +0100 (Sat, 24 Oct 2009) | 1 line Remove temporary define from r75653 ........ ................ r75662 | tarek.ziade | 2009-10-24 15:38:27 +0200 (sam., 24 oct. 2009) | 9 lines Merged revisions 75659 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75659 | tarek.ziade | 2009-10-24 15:29:44 +0200 (Sat, 24 Oct 2009) | 1 line #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd ........ ................ r75665 | mark.dickinson | 2009-10-24 15:46:38 +0200 (sam., 24 oct. 2009) | 8 lines Blocked revisions 75664 via svnmerge ........ r75664 | mark.dickinson | 2009-10-24 14:44:16 +0100 (Sat, 24 Oct 2009) | 1 line Configure check for double rounding should take BASECFLAGS into account ........ ................ r75667 | mark.dickinson | 2009-10-24 16:04:48 +0200 (sam., 24 oct. 2009) | 1 line Add tests for sys.float_repr_style ................ r75668 | mark.dickinson | 2009-10-24 16:05:34 +0200 (sam., 24 oct. 2009) | 10 lines Blocked revisions 75666 via svnmerge ........ r75666 | mark.dickinson | 2009-10-24 15:01:08 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117 (backport py3k float repr) continued: Add sys.float_repr_style attribute ('short' if short float repr is in used; 'legacy' otherwise). ........ ................ r75673 | mark.dickinson | 2009-10-24 17:56:07 +0200 (sam., 24 oct. 2009) | 10 lines Blocked revisions 75672 via svnmerge ........ r75672 | mark.dickinson | 2009-10-24 16:54:35 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117: temporarily disable the short float repr while the pieces are being assembled. To re-enable, define the preprocessor symbol PY_SHORT_FLOAT_REPR ........ ................ r75676 | eric.smith | 2009-10-24 21:52:23 +0200 (sam., 24 oct. 2009) | 8 lines Blocked revisions 75675 via svnmerge ........ r75675 | eric.smith | 2009-10-24 15:50:44 -0400 (Sat, 24 Oct 2009) | 1 line Removed unused function PyFloat_AsStringEx. It is unused in floatobject.c, and it's not declared in any .h file. ........ ................ r75678 | antoine.pitrou | 2009-10-24 22:11:21 +0200 (sam., 24 oct. 2009) | 3 lines Remove AtheOS support, as per PEP 11 (which claims that all code was removed in Python 3.0). ................ r75680 | antoine.pitrou | 2009-10-24 22:24:16 +0200 (sam., 24 oct. 2009) | 3 lines Disable support for Mach C Threads. ................ r75682 | antoine.pitrou | 2009-10-24 22:30:34 +0200 (sam., 24 oct. 2009) | 3 lines Disable support for SunOS LWP ................ r75684 | antoine.pitrou | 2009-10-24 22:35:52 +0200 (sam., 24 oct. 2009) | 3 lines Disable GNU pth support ................ r75686 | antoine.pitrou | 2009-10-24 22:43:49 +0200 (sam., 24 oct. 2009) | 3 lines Disable support for Irix threads ................ r75687 | antoine.pitrou | 2009-10-24 22:47:05 +0200 (sam., 24 oct. 2009) | 3 lines Add NEWS entry for the various unsupported platforms. ................ Removed: sandbox/trunk/newgil/Lib/plat-atheos/ sandbox/trunk/newgil/Python/dynload_atheos.c sandbox/trunk/newgil/Python/thread_atheos.h Modified: sandbox/trunk/newgil/ (props changed) sandbox/trunk/newgil/Doc/library/sys.rst sandbox/trunk/newgil/Lib/distutils/archive_util.py sandbox/trunk/newgil/Lib/distutils/command/build_ext.py sandbox/trunk/newgil/Lib/distutils/tests/test_archive_util.py sandbox/trunk/newgil/Lib/test/regrtest.py sandbox/trunk/newgil/Lib/test/test_fcntl.py sandbox/trunk/newgil/Lib/test/test_file.py sandbox/trunk/newgil/Lib/test/test_fileio.py sandbox/trunk/newgil/Lib/test/test_sys.py sandbox/trunk/newgil/Misc/NEWS sandbox/trunk/newgil/Python/thread.c sandbox/trunk/newgil/Tools/scripts/h2py.py sandbox/trunk/newgil/configure sandbox/trunk/newgil/configure.in sandbox/trunk/newgil/setup.py Modified: sandbox/trunk/newgil/Doc/library/sys.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/sys.rst (original) +++ sandbox/trunk/newgil/Doc/library/sys.rst Sun Oct 25 14:09:19 2009 @@ -576,7 +576,6 @@ Mac OS X ``'darwin'`` OS/2 ``'os2'`` OS/2 EMX ``'os2emx'`` - AtheOS ``'atheos'`` ================ =========================== Modified: sandbox/trunk/newgil/Lib/distutils/archive_util.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/archive_util.py (original) +++ sandbox/trunk/newgil/Lib/distutils/archive_util.py Sun Oct 25 14:09:19 2009 @@ -232,10 +232,11 @@ kwargs['owner'] = owner kwargs['group'] = group - filename = func(base_name, base_dir, **kwargs) - - if root_dir is not None: - log.debug("changing back to '%s'", save_cwd) - os.chdir(save_cwd) + try: + filename = func(base_name, base_dir, **kwargs) + finally: + if root_dir is not None: + log.debug("changing back to '%s'", save_cwd) + os.chdir(save_cwd) return filename Modified: sandbox/trunk/newgil/Lib/distutils/command/build_ext.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/command/build_ext.py (original) +++ sandbox/trunk/newgil/Lib/distutils/command/build_ext.py Sun Oct 25 14:09:19 2009 @@ -262,9 +262,9 @@ if os.name == 'os2': self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config')) - # for extensions under Cygwin and AtheOS Python's library directory must be + # for extensions under Cygwin Python's library directory must be # appended to library_dirs - if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': + if sys.platform[:6] == 'cygwin': if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", @@ -776,22 +776,6 @@ # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib] - elif sys.platform[:6] == "atheos": - from distutils import sysconfig - - template = "python%d.%d" - pythonlib = (template % - (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) - # Get SHLIBS from Makefile - extra = [] - for lib in sysconfig.get_config_var('SHLIBS').split(): - if lib.startswith('-l'): - extra.append(lib[2:]) - else: - extra.append(lib) - # don't extend ext.libraries, it may be shared with other - # extensions, it is a reference to the original list - return ext.libraries + [pythonlib, "m"] + extra elif sys.platform == 'darwin': # Don't use the default code below return ext.libraries Modified: sandbox/trunk/newgil/Lib/distutils/tests/test_archive_util.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/tests/test_archive_util.py (original) +++ sandbox/trunk/newgil/Lib/distutils/tests/test_archive_util.py Sun Oct 25 14:09:19 2009 @@ -8,7 +8,8 @@ import warnings from distutils.archive_util import (check_archive_formats, make_tarball, - make_zipfile, make_archive) + make_zipfile, make_archive, + ARCHIVE_FORMATS) from distutils.spawn import find_executable, spawn from distutils.tests import support from test.support import check_warnings @@ -262,6 +263,20 @@ finally: archive.close() + def test_make_archive_cwd(self): + current_dir = os.getcwd() + def _breaks(*args, **kw): + raise RuntimeError() + ARCHIVE_FORMATS['xxx'] = (_breaks, [], 'xxx file') + try: + try: + make_archive('xxx', 'xxx', root_dir=self.mkdtemp()) + except: + pass + self.assertEquals(os.getcwd(), current_dir) + finally: + del ARCHIVE_FORMATS['xxx'] + def test_suite(): return unittest.makeSuite(ArchiveUtilTestCase) Modified: sandbox/trunk/newgil/Lib/test/regrtest.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/regrtest.py (original) +++ sandbox/trunk/newgil/Lib/test/regrtest.py Sun Oct 25 14:09:19 2009 @@ -1188,19 +1188,6 @@ test_zipfile test_zlib """, - 'atheos': - """ - test_curses - test_dbm_gnu - test_epoll - test_largefile - test_locale - test_kqueue - test_mhlib - test_mmap - test_poll - test_resource - """, 'cygwin': """ test_curses Modified: sandbox/trunk/newgil/Lib/test/test_fcntl.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_fcntl.py (original) +++ sandbox/trunk/newgil/Lib/test/test_fcntl.py Sun Oct 25 14:09:19 2009 @@ -16,15 +16,12 @@ # TODO - Write tests for flock() and lockf(). def get_lockdata(): - if sys.platform.startswith('atheos'): - start_len = "qq" + try: + os.O_LARGEFILE + except AttributeError: + start_len = "ll" else: - try: - os.O_LARGEFILE - except AttributeError: - start_len = "ll" - else: - start_len = "qq" + start_len = "qq" if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3', 'Darwin1.2', 'darwin', Modified: sandbox/trunk/newgil/Lib/test/test_file.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_file.py (original) +++ sandbox/trunk/newgil/Lib/test/test_file.py Sun Oct 25 14:09:19 2009 @@ -106,8 +106,7 @@ ('writelines', ([],)), ('__iter__', ()), ] - if not sys.platform.startswith('atheos'): - methods.append(('truncate', ())) + methods.append(('truncate', ())) # __exit__ should close the file self.f.__exit__(None, None, None) Modified: sandbox/trunk/newgil/Lib/test/test_fileio.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_fileio.py (original) +++ sandbox/trunk/newgil/Lib/test/test_fileio.py Sun Oct 25 14:09:19 2009 @@ -96,8 +96,6 @@ methods = ['fileno', 'isatty', 'read', 'readinto', 'seek', 'tell', 'truncate', 'write', 'seekable', 'readable', 'writable'] - if sys.platform.startswith('atheos'): - methods.remove('truncate') self.f.close() self.assertTrue(self.f.closed) Modified: sandbox/trunk/newgil/Lib/test/test_sys.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_sys.py (original) +++ sandbox/trunk/newgil/Lib/test/test_sys.py Sun Oct 25 14:09:19 2009 @@ -372,6 +372,8 @@ self.assertEqual(vi[3], vi.releaselevel) self.assertEqual(vi[4], vi.serial) self.assertTrue(vi > (1,0,0)) + self.assertIsInstance(sys.float_repr_style, str) + self.assertTrue(sys.float_repr_style in ('short', 'legacy')) def test_43581(self): # Can't use sys.stdout, as this is a StringIO object when Modified: sandbox/trunk/newgil/Misc/NEWS ============================================================================== --- sandbox/trunk/newgil/Misc/NEWS (original) +++ sandbox/trunk/newgil/Misc/NEWS Sun Oct 25 14:09:19 2009 @@ -12,6 +12,13 @@ Core and Builtins ----------------- +- Support for AtheOS has been completely removed from the code base. It was + disabled since Python 3.0. + +- Support for several legacy threading libraries has been disabled. These + libraries are: Mach C threads, SunOS LWP, GNU pth, Irix threads. Support code + will be entirely removed in 3.3. + - Peephole constant folding had missed UNARY_POSITIVE. - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which @@ -1143,6 +1150,9 @@ Library ------- +- Issue #7066: archive_util.make_archive now restores the cwd if an error is + raised. Initial patch by Ezio Melotti. + - Issue #6516: Added owner/group support when creating tar archives in Distutils. Deleted: sandbox/trunk/newgil/Python/dynload_atheos.c ============================================================================== --- sandbox/trunk/newgil/Python/dynload_atheos.c Sun Oct 25 14:09:19 2009 +++ (empty file) @@ -1,47 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include -#include - -#include "Python.h" -#include "importdl.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - void *p; - int lib; - char funcname[258]; - - if (Py_VerboseFlag) - printf("load_library %s\n", pathname); - - lib = load_library(pathname, 0); - if (lib < 0) { - char buf[512]; - if (Py_VerboseFlag) - perror(pathname); - PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s", - pathname, strerror(errno)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname); - if (Py_VerboseFlag) - printf("get_symbol_address %s\n", funcname); - if (get_symbol_address(lib, funcname, -1, &p) < 0) { - p = NULL; - if (Py_VerboseFlag) - perror(funcname); - } - - return (dl_funcptr) p; -} Modified: sandbox/trunk/newgil/Python/thread.c ============================================================================== --- sandbox/trunk/newgil/Python/thread.c (original) +++ sandbox/trunk/newgil/Python/thread.c Sun Oct 25 14:09:19 2009 @@ -23,12 +23,6 @@ #include -#ifdef __sgi -#ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */ -#undef _POSIX_THREADS -#endif -#endif - #include "pythread.h" #ifndef _POSIX_THREADS @@ -101,6 +95,7 @@ static size_t _pythread_stacksize = 0; #ifdef SGI_THREADS +#error SGI Irix threads are now unsupported, and code will be removed in 3.3. #include "thread_sgi.h" #endif @@ -109,10 +104,12 @@ #endif #ifdef SUN_LWP +#error SunOS lightweight processes are now unsupported, and code will be removed in 3.3. #include "thread_lwp.h" #endif #ifdef HAVE_PTH +#error GNU pth threads are now unsupported, and code will be removed in 3.3. #include "thread_pth.h" #undef _POSIX_THREADS #endif @@ -122,6 +119,7 @@ #endif #ifdef C_THREADS +#error Mach C Threads are now unsupported, and code will be removed in 3.3. #include "thread_cthread.h" #endif @@ -137,10 +135,6 @@ #include "thread_plan9.h" #endif -#ifdef ATHEOS_THREADS -#include "thread_atheos.h" -#endif - /* #ifdef FOOBAR_THREADS #include "thread_foobar.h" Deleted: sandbox/trunk/newgil/Python/thread_atheos.h ============================================================================== --- sandbox/trunk/newgil/Python/thread_atheos.h Sun Oct 25 14:09:19 2009 +++ (empty file) @@ -1,300 +0,0 @@ -/* Threading for AtheOS. - Based on thread_beos.h. */ - -#include -#include -#include -#include -#include - -/* Missing decl from threads.h */ -extern int exit_thread(int); - - -/* Undefine FASTLOCK to play with simple semaphores. */ -#define FASTLOCK - - -#ifdef FASTLOCK - -/* Use an atomic counter and a semaphore for maximum speed. */ -typedef struct fastmutex { - sem_id sem; - atomic_t count; -} fastmutex_t; - - -static int fastmutex_create(const char *name, fastmutex_t * mutex); -static int fastmutex_destroy(fastmutex_t * mutex); -static int fastmutex_lock(fastmutex_t * mutex); -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout); -static int fastmutex_unlock(fastmutex_t * mutex); - - -static int fastmutex_create(const char *name, fastmutex_t * mutex) -{ - mutex->count = 0; - mutex->sem = create_semaphore(name, 0, 0); - return (mutex->sem < 0) ? -1 : 0; -} - - -static int fastmutex_destroy(fastmutex_t * mutex) -{ - if (fastmutex_timedlock(mutex, 0) == 0 || errno == EWOULDBLOCK) { - return delete_semaphore(mutex->sem); - } - return 0; -} - - -static int fastmutex_lock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore(mutex->sem); - return 0; -} - - -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore_x(mutex->sem, 1, 0, timeout); - return 0; -} - - -static int fastmutex_unlock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, -1); - if (prev > 1) - return unlock_semaphore(mutex->sem); - return 0; -} - - -#endif /* FASTLOCK */ - - -/* - * Initialization. - * - */ -static void PyThread__init_thread(void) -{ - /* Do nothing. */ - return; -} - - -/* - * Thread support. - * - */ - -static atomic_t thread_count = 0; - -long PyThread_start_new_thread(void (*func) (void *), void *arg) -{ - status_t success = -1; - thread_id tid; - char name[OS_NAME_LENGTH]; - atomic_t this_thread; - - dprintf(("PyThread_start_new_thread called\n")); - - this_thread = atomic_add(&thread_count, 1); - PyOS_snprintf(name, sizeof(name), "python thread (%d)", this_thread); - - tid = spawn_thread(name, func, NORMAL_PRIORITY, 0, arg); - if (tid < 0) { - dprintf(("PyThread_start_new_thread spawn_thread failed: %s\n", strerror(errno))); - } else { - success = resume_thread(tid); - if (success < 0) { - dprintf(("PyThread_start_new_thread resume_thread failed: %s\n", strerror(errno))); - } - } - - return (success < 0 ? -1 : tid); -} - - -long PyThread_get_thread_ident(void) -{ - return get_thread_id(NULL); -} - - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - - /* Thread-safe way to read a variable without a mutex: */ - if (atomic_add(&thread_count, 0) == 0) { - /* No threads around, so exit main(). */ - if (no_cleanup) - _exit(0); - else - exit(0); - } else { - /* We're a thread */ - exit_thread(0); - } -} - - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - - /* No need to do anything, the threads get torn down if main()exits. */ - if (no_cleanup) - _exit(status); - else - exit(status); -} - - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - - -/* - * Lock support. - * - */ - -static atomic_t lock_count = 0; - -PyThread_type_lock PyThread_allocate_lock(void) -{ -#ifdef FASTLOCK - fastmutex_t *lock; -#else - sem_id sema; -#endif - char name[OS_NAME_LENGTH]; - atomic_t this_lock; - - dprintf(("PyThread_allocate_lock called\n")); - -#ifdef FASTLOCK - lock = (fastmutex_t *) malloc(sizeof(fastmutex_t)); - if (lock == NULL) { - dprintf(("PyThread_allocate_lock failed: out of memory\n")); - return (PyThread_type_lock) NULL; - } -#endif - this_lock = atomic_add(&lock_count, 1); - PyOS_snprintf(name, sizeof(name), "python lock (%d)", this_lock); - -#ifdef FASTLOCK - if (fastmutex_create(name, lock) < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - free(lock); - lock = NULL; - } - dprintf(("PyThread_allocate_lock()-> %p\n", lock)); - return (PyThread_type_lock) lock; -#else - sema = create_semaphore(name, 1, 0); - if (sema < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - sema = 0; - } - dprintf(("PyThread_allocate_lock()-> %p\n", sema)); - return (PyThread_type_lock) sema; -#endif -} - - -void PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_destroy((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } - free(lock); -#else - if (delete_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} - - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int retval; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, - waitflag)); - -#ifdef FASTLOCK - if (waitflag) - retval = fastmutex_lock((fastmutex_t *) lock); - else - retval = fastmutex_timedlock((fastmutex_t *) lock, 0); -#else - if (waitflag) - retval = lock_semaphore((sem_id) lock); - else - retval = lock_semaphore_x((sem_id) lock, 1, 0, 0); -#endif - if (retval < 0) { - dprintf(("PyThread_acquire_lock(%p, %d) failed: %s\n", - lock, waitflag, strerror(errno))); - } - dprintf(("PyThread_acquire_lock(%p, %d)-> %d\n", lock, waitflag, - retval)); - return retval < 0 ? 0 : 1; -} - - -void PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_unlock((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#else - if (unlock_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} Modified: sandbox/trunk/newgil/Tools/scripts/h2py.py ============================================================================== --- sandbox/trunk/newgil/Tools/scripts/h2py.py (original) +++ sandbox/trunk/newgil/Tools/scripts/h2py.py Sun Oct 25 14:09:19 2009 @@ -49,13 +49,7 @@ try: searchdirs=os.environ['INCLUDE'].split(';') except KeyError: - try: - if sys.platform.startswith("atheos"): - searchdirs=os.environ['C_INCLUDE_PATH'].split(':') - else: - raise KeyError - except KeyError: - searchdirs=['/usr/include'] + searchdirs=['/usr/include'] def main(): global filedict Modified: sandbox/trunk/newgil/configure ============================================================================== --- sandbox/trunk/newgil/configure (original) +++ sandbox/trunk/newgil/configure Sun Oct 25 14:09:19 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74745 . +# From configure.in Revision: 75678 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -1352,7 +1352,6 @@ disable/enable thread support --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads - --with-pth use GNU pth threading libraries --with(out)-doc-strings disable/enable documentation strings --with(out)-tsc enable/disable timestamp counter profile --with(out)-pymalloc disable/enable specialized mallocs @@ -2066,7 +2065,6 @@ case $MACHDEP in cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; - atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; esac @@ -3802,7 +3800,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f -r conftest* +rm -f conftest* @@ -3972,7 +3970,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN* | atheos*) + CYGWIN*) enable_shared="yes";; *) enable_shared="no";; @@ -4108,11 +4106,6 @@ BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ;; - atheos*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; Darwin*) LDLIBRARY='libpython$(VERSION).dylib' BLDLIBRARY='-L. -lpython$(VERSION)' @@ -4451,7 +4444,6 @@ if test -z "$LN" ; then case $ac_sys_system in CYGWIN*) LN="ln -s";; - atheos*) LN="ln -s";; *) LN=ln;; esac fi @@ -5355,7 +5347,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -5376,7 +5368,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -6474,7 +6466,7 @@ fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -7004,7 +6996,7 @@ else ac_cv_type_uid_t=no fi -rm -f -r conftest* +rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -14696,7 +14688,6 @@ fi;; SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; - atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac fi @@ -14737,7 +14728,6 @@ *gcc*) CCSHARED="-shared";; *) CCSHARED="";; esac;; - atheos*) CCSHARED="-fPIC";; esac fi { echo "$as_me:$LINENO: result: $CCSHARED" >&5 @@ -15548,7 +15538,7 @@ else unistd_defines_pthreads=no fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -15852,28 +15842,6 @@ THREADOBJ="Python/thread.o" else - { echo "$as_me:$LINENO: checking for --with-pth" >&5 -echo $ECHO_N "checking for --with-pth... $ECHO_C" >&6; } - -# Check whether --with-pth was given. -if test "${with_pth+set}" = set; then - withval=$with_pth; { echo "$as_me:$LINENO: result: $withval" >&5 -echo "${ECHO_T}$withval" >&6; } - cat >>confdefs.h <<\_ACEOF -#define WITH_THREAD 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTH 1 -_ACEOF - - LIBS="-lpth $LIBS" - THREADOBJ="Python/thread.o" -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - # Just looking for pthread_create in libpthread is not enough: # on HP/UX, pthread.h renames pthread_create to a different symbol name. # So we really have to include pthread.h, and then link. @@ -16022,149 +15990,6 @@ THREADOBJ="Python/thread.o" else - if test "${ac_cv_header_atheos_threads_h+set}" = set; then - { echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 -echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6; } -if test "${ac_cv_header_atheos_threads_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 -echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking atheos/threads.h usability" >&5 -echo $ECHO_N "checking atheos/threads.h usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking atheos/threads.h presence" >&5 -echo $ECHO_N "checking atheos/threads.h presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: atheos/threads.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: atheos/threads.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: atheos/threads.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: atheos/threads.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------- ## -## Report this to http://bugs.python.org/ ## -## -------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 -echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6; } -if test "${ac_cv_header_atheos_threads_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_header_atheos_threads_h=$ac_header_preproc -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 -echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6; } - -fi -if test $ac_cv_header_atheos_threads_h = yes; then - cat >>confdefs.h <<\_ACEOF -#define WITH_THREAD 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define ATHEOS_THREADS 1 -_ACEOF - - THREADOBJ="Python/thread.o" -else - { echo "$as_me:$LINENO: checking for pthread_create in -lpthreads" >&5 echo $ECHO_N "checking for pthread_create in -lpthreads... $ECHO_C" >&6; } if test "${ac_cv_lib_pthreads_pthread_create+set}" = set; then @@ -16461,17 +16286,12 @@ fi - -fi - fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -fi - fi @@ -17016,7 +16836,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f -r conftest* +rm -f conftest* ;; kame) @@ -17039,7 +16859,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-glibc) @@ -17060,7 +16880,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-inet6) @@ -17098,7 +16918,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; v6d) @@ -17121,7 +16941,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f -r conftest* +rm -f conftest* ;; zeta) @@ -17143,7 +16963,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; esac @@ -17439,7 +17259,6 @@ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/[0156]\..*) DYNLOADFILE="dynload_next.o";; - atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading @@ -25235,7 +25054,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi @@ -25505,7 +25324,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi Modified: sandbox/trunk/newgil/configure.in ============================================================================== --- sandbox/trunk/newgil/configure.in (original) +++ sandbox/trunk/newgil/configure.in Sun Oct 25 14:09:19 2009 @@ -248,7 +248,6 @@ case $MACHDEP in cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; - atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; esac @@ -630,7 +629,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN* | atheos*) + CYGWIN*) enable_shared="yes";; *) enable_shared="no";; @@ -716,11 +715,6 @@ BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ;; - atheos*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; Darwin*) LDLIBRARY='libpython$(VERSION).dylib' BLDLIBRARY='-L. -lpython$(VERSION)' @@ -774,7 +768,6 @@ if test -z "$LN" ; then case $ac_sys_system in CYGWIN*) LN="ln -s";; - atheos*) LN="ln -s";; *) LN=ln;; esac fi @@ -1701,7 +1694,6 @@ fi;; SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; - atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac fi @@ -1740,7 +1732,6 @@ *gcc*) CCSHARED="-shared";; *) CCSHARED="";; esac;; - atheos*) CCSHARED="-fPIC";; esac fi AC_MSG_RESULT($CCSHARED) @@ -2027,17 +2018,6 @@ AC_DEFINE(MACH_C_THREADS, 1, [Define if you are using Mach cthreads under mach /]) THREADOBJ="Python/thread.o"],[ - AC_MSG_CHECKING(for --with-pth) - AC_ARG_WITH([pth], - AC_HELP_STRING(--with-pth, use GNU pth threading libraries), - [AC_MSG_RESULT($withval) - AC_DEFINE([WITH_THREAD]) - AC_DEFINE([HAVE_PTH], 1, - [Define if you have GNU PTH threads.]) - LIBS="-lpth $LIBS" - THREADOBJ="Python/thread.o"], - [AC_MSG_RESULT(no) - # Just looking for pthread_create in libpthread is not enough: # on HP/UX, pthread.h renames pthread_create to a different symbol name. # So we really have to include pthread.h, and then link. @@ -2056,10 +2036,6 @@ AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) posix_threads=yes THREADOBJ="Python/thread.o"],[ - AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(ATHEOS_THREADS, 1, - [Define this if you have AtheOS threads.]) - THREADOBJ="Python/thread.o"],[ AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) posix_threads=yes LIBS="$LIBS -lpthreads" @@ -2077,7 +2053,7 @@ LIBS="$LIBS -lcma" THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) - ])])])])])])])])]) + ])])])])])])]) AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) LIBS="$LIBS -lmpc" @@ -2409,7 +2385,6 @@ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; - atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading Modified: sandbox/trunk/newgil/setup.py ============================================================================== --- sandbox/trunk/newgil/setup.py (original) +++ sandbox/trunk/newgil/setup.py Sun Oct 25 14:09:19 2009 @@ -288,7 +288,7 @@ def get_platform(self): # Get value of sys.platform - for platform in ['cygwin', 'darwin', 'atheos', 'osf1']: + for platform in ['cygwin', 'darwin', 'osf1']: if sys.platform.startswith(platform): return platform return sys.platform @@ -355,13 +355,6 @@ platform = self.get_platform() srcdir = sysconfig.get_config_var('srcdir') - # Check for AtheOS which has libraries in non-standard locations - if platform == 'atheos': - lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] - lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) - inc_dirs += ['/system/include', '/atheos/autolnk/include'] - inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) - # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] @@ -465,7 +458,7 @@ exts.append( Extension('parser', ['parsermodule.c']) ) # Memory-mapped files (also works on Win32). - if platform not in ['atheos', 'mac']: + if platform not in ['mac']: exts.append( Extension('mmap', ['mmapmodule.c']) ) else: missing.append('mmap') @@ -975,13 +968,10 @@ # Steen Lumholt's termios module exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface - if platform not in ['atheos']: - exts.append( Extension('resource', ['resource.c']) ) - else: - missing.append('resource') + exts.append( Extension('resource', ['resource.c']) ) # Sun yellow pages. Some systems have the functions in libc. - if platform not in ['cygwin', 'atheos', 'qnx6']: + if platform not in ['cygwin', 'qnx6']: if (self.compiler_obj.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] else: From python-checkins at python.org Sun Oct 25 19:12:23 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 25 Oct 2009 18:12:23 -0000 Subject: [Python-checkins] r75693 - in sandbox/trunk/newgil: Include/ceval.h Lib/test/test_sys.py Python/ceval_gil.h Python/sysmodule.c Message-ID: Author: antoine.pitrou Date: Sun Oct 25 19:12:23 2009 New Revision: 75693 Log: Add a sys.setswitchinterval()/getswitchinterval() to set the desired interval between thread switches (in seconds). Modified: sandbox/trunk/newgil/Include/ceval.h sandbox/trunk/newgil/Lib/test/test_sys.py sandbox/trunk/newgil/Python/ceval_gil.h sandbox/trunk/newgil/Python/sysmodule.c Modified: sandbox/trunk/newgil/Include/ceval.h ============================================================================== --- sandbox/trunk/newgil/Include/ceval.h (original) +++ sandbox/trunk/newgil/Include/ceval.h Sun Oct 25 19:12:23 2009 @@ -171,6 +171,9 @@ PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); PyAPI_FUNC(void) PyEval_ReInitThreads(void); +PyAPI_FUNC(void) _PyEval_SetSwitchInterval(double seconds); +PyAPI_FUNC(double) _PyEval_GetSwitchInterval(void); + #define Py_BEGIN_ALLOW_THREADS { \ PyThreadState *_save; \ _save = PyEval_SaveThread(); Modified: sandbox/trunk/newgil/Lib/test/test_sys.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_sys.py (original) +++ sandbox/trunk/newgil/Lib/test/test_sys.py Sun Oct 25 19:12:23 2009 @@ -148,6 +148,21 @@ sys.setcheckinterval(n) self.assertEquals(sys.getcheckinterval(), n) + def test_switchinterval(self): + self.assertRaises(TypeError, sys.setswitchinterval) + self.assertRaises(TypeError, sys.setswitchinterval, "a") + self.assertRaises(ValueError, sys.setswitchinterval, -1.0) + self.assertRaises(ValueError, sys.setswitchinterval, 0.0) + orig = sys.getswitchinterval() + # sanity check + self.assertTrue(orig < 0.5, orig) + try: + for n in 0.00001, 0.05, 3.0, orig: + sys.setswitchinterval(n) + self.assertAlmostEquals(sys.getswitchinterval(), n) + finally: + sys.setswitchinterval(orig) + def test_recursionlimit(self): self.assertRaises(TypeError, sys.getrecursionlimit, 42) oldlimit = sys.getrecursionlimit() Modified: sandbox/trunk/newgil/Python/ceval_gil.h ============================================================================== --- sandbox/trunk/newgil/Python/ceval_gil.h (original) +++ sandbox/trunk/newgil/Python/ceval_gil.h Sun Oct 25 19:12:23 2009 @@ -8,10 +8,12 @@ /* First some general settings */ -/* milliseconds */ -#define INTERVAL 5 +/* milliseconds (the public API uses seconds, though) */ +#define DEFAULT_INTERVAL 5 +static double gil_interval = DEFAULT_INTERVAL; +#define INTERVAL (gil_interval >= 1.0 ? gil_interval : 1.0) -/* Enable if you want to force the switching of threads at least every INTERVAL */ +/* Enable if you want to force the switching of threads at least every `gil_interval` */ #undef FORCE_SWITCHING #define FORCE_SWITCHING @@ -39,7 +41,7 @@ #define ADD_MILLISECONDS(tv, interval) \ do { \ - tv.tv_usec += interval * 1000; \ + tv.tv_usec += (long) interval * 1000; \ tv.tv_sec += tv.tv_usec / 1000000; \ tv.tv_usec %= 1000000; \ } while (0) @@ -80,7 +82,7 @@ struct timeval deadline; \ \ GETTIMEOFDAY(&deadline); \ - ADD_MILLISECONDS(deadline, INTERVAL); \ + ADD_MILLISECONDS(deadline, milliseconds); \ ts.tv_sec = deadline.tv_sec; \ ts.tv_nsec = deadline.tv_usec * 1000; \ \ @@ -356,3 +358,15 @@ { _take_gil(tstate, 1); } + +void _PyEval_SetSwitchInterval(double seconds) +{ + if (seconds <= 0) + Py_FatalError("switch interval must be strictly positive"); + gil_interval = seconds * 1000.0; +} + +double _PyEval_GetSwitchInterval() +{ + return gil_interval / 1000.0; +} Modified: sandbox/trunk/newgil/Python/sysmodule.c ============================================================================== --- sandbox/trunk/newgil/Python/sysmodule.c (original) +++ sandbox/trunk/newgil/Python/sysmodule.c Sun Oct 25 19:12:23 2009 @@ -441,9 +441,6 @@ return temp; } -/* TODO: deprecate */ -static int _check_interval = 100; - PyDoc_STRVAR(getprofile_doc, "getprofile()\n\ \n\ @@ -451,6 +448,9 @@ See the profiler chapter in the library manual." ); +/* TODO: deprecate */ +static int _check_interval = 100; + static PyObject * sys_setcheckinterval(PyObject *self, PyObject *args) { @@ -477,6 +477,47 @@ "getcheckinterval() -> current check interval; see setcheckinterval()." ); +#ifdef WITH_THREAD +static PyObject * +sys_setswitchinterval(PyObject *self, PyObject *args) +{ + double d; + if (!PyArg_ParseTuple(args, "d:setswitchinterval", &d)) + return NULL; + if (d <= 0.0) { + PyErr_SetString(PyExc_ValueError, + "switch interval must be strictly positive"); + return NULL; + } + _PyEval_SetSwitchInterval(d); + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR(setswitchinterval_doc, +"setswitchinterval(n)\n\ +\n\ +Set the ideal thread switching delay inside the Python interpreter\n\ +The actual frequency of switching threads can be lower if the\n\ +interpreter executes long sequences of uninterruptible code\n\ +(this is implementation-specific and workload-dependent).\n\ +\n\ +The parameter must represent the desired switching delay in seconds\n\ +A typical value is 0.005 (5 milliseconds)." +); + +static PyObject * +sys_getswitchinterval(PyObject *self, PyObject *args) +{ + return PyFloat_FromDouble(_PyEval_GetSwitchInterval()); +} + +PyDoc_STRVAR(getswitchinterval_doc, +"getswitchinterval() -> current thread switch interval; see setswitchinterval()." +); + +#endif /* WITH_THREAD */ + #ifdef WITH_TSC static PyObject * sys_settscdump(PyObject *self, PyObject *args) @@ -898,6 +939,12 @@ setcheckinterval_doc}, {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, getcheckinterval_doc}, +#ifdef WITH_THREAD + {"setswitchinterval", sys_setswitchinterval, METH_VARARGS, + setswitchinterval_doc}, + {"getswitchinterval", sys_getswitchinterval, METH_NOARGS, + getswitchinterval_doc}, +#endif #ifdef HAVE_DLOPEN {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, setdlopenflags_doc}, From python-checkins at python.org Sun Oct 25 19:12:43 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 25 Oct 2009 18:12:43 -0000 Subject: [Python-checkins] r75694 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sun Oct 25 19:12:43 2009 New Revision: 75694 Log: Add an option to set the switching interval (for newgil) Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sun Oct 25 19:12:43 2009 @@ -402,8 +402,11 @@ action="store_true", dest="latency", default=False, help="run latency tests") parser.add_option("-i", "--interval", - action="store", type="int", dest="interval", default=None, + action="store", type="int", dest="check_interval", default=None, help="sys.setcheckinterval() value") + parser.add_option("-I", "--switch-interval", + action="store", type="float", dest="switch_interval", default=None, + help="sys.setswitchinterval() value") parser.add_option("-n", "--num-threads", action="store", type="int", dest="nthreads", default=4, help="max number of threads in tests") @@ -424,8 +427,10 @@ if not options.throughput and not options.latency: options.throughput = options.latency = True - if options.interval: - sys.setcheckinterval(options.interval) + if options.check_interval: + sys.setcheckinterval(options.check_interval) + if options.switch_interval: + sys.setswitchinterval(options.switch_interval) print("== %s %s (%s) ==" % ( platform.python_implementation(), From python-checkins at python.org Sun Oct 25 19:14:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 25 Oct 2009 18:14:15 -0000 Subject: [Python-checkins] r75695 - sandbox/trunk/ccbench/ccbench.py Message-ID: Author: antoine.pitrou Date: Sun Oct 25 19:14:14 2009 New Revision: 75695 Log: Make all threads daemonic Modified: sandbox/trunk/ccbench/ccbench.py Modified: sandbox/trunk/ccbench/ccbench.py ============================================================================== --- sandbox/trunk/ccbench/ccbench.py (original) +++ sandbox/trunk/ccbench/ccbench.py Sun Oct 25 19:14:14 2009 @@ -226,6 +226,7 @@ for i in range(nthreads): threads.append(threading.Thread(target=run)) for t in threads: + t.setDaemon(True) t.start() # We don't want measurements to include thread startup overhead, # so we arrange for timing to start after all threads are ready. @@ -329,6 +330,7 @@ for i in range(nthreads): threads.append(threading.Thread(target=run)) for t in threads: + t.setDaemon(True) t.start() # Wait for threads to be ready with ready_cond: From python-checkins at python.org Sun Oct 25 21:25:43 2009 From: python-checkins at python.org (georg.brandl) Date: Sun, 25 Oct 2009 20:25:43 -0000 Subject: [Python-checkins] r75696 - python/trunk/Demo/comparisons/sortingtest.py Message-ID: Author: georg.brandl Date: Sun Oct 25 21:25:43 2009 New Revision: 75696 Log: Fix a demo. Modified: python/trunk/Demo/comparisons/sortingtest.py Modified: python/trunk/Demo/comparisons/sortingtest.py ============================================================================== --- python/trunk/Demo/comparisons/sortingtest.py (original) +++ python/trunk/Demo/comparisons/sortingtest.py Sun Oct 25 21:25:43 2009 @@ -24,7 +24,6 @@ # - Handles blank input lines correctly import re -import string import sys def main(): @@ -32,18 +31,13 @@ def makekey(item, prog=prog): match = prog.match(item) if match: - var, num = match.group(1, 2) - return string.atoi(num), var + var, num = match.groups() + return int(num), var else: # Bad input -- pretend it's a var with value 0 return 0, item - while 1: - line = sys.stdin.readline() - if not line: - break - items = line.split() - items = map(makekey, items) - items.sort() + for line in sys.stdin: + items = sorted(makekey(item) for item in line.split()) for num, var in items: print "%s=%s" % (var, num), print From python-checkins at python.org Sun Oct 25 21:39:06 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 25 Oct 2009 20:39:06 -0000 Subject: [Python-checkins] r75697 - in python/trunk: Misc/NEWS Objects/longobject.c Message-ID: Author: mark.dickinson Date: Sun Oct 25 21:39:06 2009 New Revision: 75697 Log: Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. Modified: python/trunk/Misc/NEWS python/trunk/Objects/longobject.c Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Oct 25 21:39:06 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #1087418: Boost performance of bitwise operations for longs. + - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. Modified: python/trunk/Objects/longobject.c ============================================================================== --- python/trunk/Objects/longobject.c (original) +++ python/trunk/Objects/longobject.c Sun Oct 25 21:39:06 2009 @@ -3411,6 +3411,22 @@ return (PyObject *) z; } +/* Compute two's complement of digit vector a[0:m], writing result to + z[0:m]. The digit vector a need not be normalized, but should not + be entirely zero. a and z may point to the same digit vector. */ + +static void +v_complement(digit *z, digit *a, Py_ssize_t m) +{ + Py_ssize_t i; + digit carry = 1; + for (i = 0; i < m; ++i) { + carry += a[i] ^ PyLong_MASK; + z[i] = carry & PyLong_MASK; + carry >>= PyLong_SHIFT; + } + assert(carry == 0); +} /* Bitwise and/xor/or operations */ @@ -3419,104 +3435,122 @@ int op, /* '&', '|', '^' */ PyLongObject *b) { - digit maska, maskb; /* 0 or PyLong_MASK */ - int negz; + int nega, negb, negz; Py_ssize_t size_a, size_b, size_z, i; PyLongObject *z; - digit diga, digb; - PyObject *v; - if (Py_SIZE(a) < 0) { - a = (PyLongObject *) long_invert(a); - if (a == NULL) + /* Bitwise operations for negative numbers operate as though + on a two's complement representation. So convert arguments + from sign-magnitude to two's complement, and convert the + result back to sign-magnitude at the end. */ + + /* If a is negative, replace it by its two's complement. */ + size_a = ABS(Py_SIZE(a)); + nega = Py_SIZE(a) < 0; + if (nega) { + z = _PyLong_New(size_a); + if (z == NULL) return NULL; - maska = PyLong_MASK; + v_complement(z->ob_digit, a->ob_digit, size_a); + a = z; } - else { + else + /* Keep reference count consistent. */ Py_INCREF(a); - maska = 0; - } - if (Py_SIZE(b) < 0) { - b = (PyLongObject *) long_invert(b); - if (b == NULL) { + + /* Same for b. */ + size_b = ABS(Py_SIZE(b)); + negb = Py_SIZE(b) < 0; + if (negb) { + z = _PyLong_New(size_b); + if (z == NULL) { Py_DECREF(a); return NULL; } - maskb = PyLong_MASK; + v_complement(z->ob_digit, b->ob_digit, size_b); + b = z; } - else { + else Py_INCREF(b); - maskb = 0; + + /* Swap a and b if necessary to ensure size_a >= size_b. */ + if (size_a < size_b) { + z = a; a = b; b = z; + size_z = size_a; size_a = size_b; size_b = size_z; + negz = nega; nega = negb; negb = negz; } - negz = 0; + /* JRH: The original logic here was to allocate the result value (z) + as the longer of the two operands. However, there are some cases + where the result is guaranteed to be shorter than that: AND of two + positives, OR of two negatives: use the shorter number. AND with + mixed signs: use the positive number. OR with mixed signs: use the + negative number. + */ switch (op) { case '^': - if (maska != maskb) { - maska ^= PyLong_MASK; - negz = -1; - } + negz = nega ^ negb; + size_z = size_a; break; case '&': - if (maska && maskb) { - op = '|'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega & negb; + size_z = negb ? size_a : size_b; break; case '|': - if (maska || maskb) { - op = '&'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega | negb; + size_z = negb ? size_b : size_a; break; + default: + PyErr_BadArgument(); + return NULL; } - /* JRH: The original logic here was to allocate the result value (z) - as the longer of the two operands. However, there are some cases - where the result is guaranteed to be shorter than that: AND of two - positives, OR of two negatives: use the shorter number. AND with - mixed signs: use the positive number. OR with mixed signs: use the - negative number. After the transformations above, op will be '&' - iff one of these cases applies, and mask will be non-0 for operands - whose length should be ignored. - */ - - size_a = Py_SIZE(a); - size_b = Py_SIZE(b); - size_z = op == '&' - ? (maska - ? size_b - : (maskb ? size_a : MIN(size_a, size_b))) - : MAX(size_a, size_b); - z = _PyLong_New(size_z); + /* We allow an extra digit if z is negative, to make sure that + the final two's complement of z doesn't overflow. */ + z = _PyLong_New(size_z + negz); if (z == NULL) { Py_DECREF(a); Py_DECREF(b); return NULL; } - for (i = 0; i < size_z; ++i) { - diga = (i < size_a ? a->ob_digit[i] : 0) ^ maska; - digb = (i < size_b ? b->ob_digit[i] : 0) ^ maskb; - switch (op) { - case '&': z->ob_digit[i] = diga & digb; break; - case '|': z->ob_digit[i] = diga | digb; break; - case '^': z->ob_digit[i] = diga ^ digb; break; - } + /* Compute digits for overlap of a and b. */ + switch(op) { + case '&': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] & b->ob_digit[i]; + break; + case '|': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] | b->ob_digit[i]; + break; + case '^': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ b->ob_digit[i]; + break; + default: + PyErr_BadArgument(); + return NULL; + } + + /* Copy any remaining digits of a, inverting if necessary. */ + if (op == '^' && negb) + for (; i < size_z; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ PyLong_MASK; + else if (i < size_z) + memcpy(&z->ob_digit[i], &a->ob_digit[i], + (size_z-i)*sizeof(digit)); + + /* Complement result if negative. */ + if (negz) { + Py_SIZE(z) = -(Py_SIZE(z)); + z->ob_digit[size_z] = PyLong_MASK; + v_complement(z->ob_digit, z->ob_digit, size_z+1); } Py_DECREF(a); Py_DECREF(b); - z = long_normalize(z); - if (negz == 0) - return (PyObject *) z; - v = long_invert(z); - Py_DECREF(z); - return v; + return (PyObject *)long_normalize(z); } static PyObject * From python-checkins at python.org Sun Oct 25 21:43:35 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 25 Oct 2009 20:43:35 -0000 Subject: [Python-checkins] r75698 - in python/branches/py3k: Misc/NEWS Objects/longobject.c Message-ID: Author: mark.dickinson Date: Sun Oct 25 21:43:34 2009 New Revision: 75698 Log: Merged revisions 75697 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75697 | mark.dickinson | 2009-10-25 20:39:06 +0000 (Sun, 25 Oct 2009) | 3 lines Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/longobject.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Oct 25 21:43:34 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #1087418: Boost performance of bitwise operations for longs. + - Support for AtheOS has been completely removed from the code base. It was disabled since Python 3.0. Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Sun Oct 25 21:43:34 2009 @@ -3638,6 +3638,22 @@ return (PyObject *) maybe_small_long(z); } +/* Compute two's complement of digit vector a[0:m], writing result to + z[0:m]. The digit vector a need not be normalized, but should not + be entirely zero. a and z may point to the same digit vector. */ + +static void +v_complement(digit *z, digit *a, Py_ssize_t m) +{ + Py_ssize_t i; + digit carry = 1; + for (i = 0; i < m; ++i) { + carry += a[i] ^ PyLong_MASK; + z[i] = carry & PyLong_MASK; + carry >>= PyLong_SHIFT; + } + assert(carry == 0); +} /* Bitwise and/xor/or operations */ @@ -3646,104 +3662,122 @@ int op, /* '&', '|', '^' */ PyLongObject *b) { - digit maska, maskb; /* 0 or PyLong_MASK */ - int negz; + int nega, negb, negz; Py_ssize_t size_a, size_b, size_z, i; PyLongObject *z; - digit diga, digb; - PyObject *v; - if (Py_SIZE(a) < 0) { - a = (PyLongObject *) long_invert(a); - if (a == NULL) + /* Bitwise operations for negative numbers operate as though + on a two's complement representation. So convert arguments + from sign-magnitude to two's complement, and convert the + result back to sign-magnitude at the end. */ + + /* If a is negative, replace it by its two's complement. */ + size_a = ABS(Py_SIZE(a)); + nega = Py_SIZE(a) < 0; + if (nega) { + z = _PyLong_New(size_a); + if (z == NULL) return NULL; - maska = PyLong_MASK; + v_complement(z->ob_digit, a->ob_digit, size_a); + a = z; } - else { + else + /* Keep reference count consistent. */ Py_INCREF(a); - maska = 0; - } - if (Py_SIZE(b) < 0) { - b = (PyLongObject *) long_invert(b); - if (b == NULL) { + + /* Same for b. */ + size_b = ABS(Py_SIZE(b)); + negb = Py_SIZE(b) < 0; + if (negb) { + z = _PyLong_New(size_b); + if (z == NULL) { Py_DECREF(a); return NULL; } - maskb = PyLong_MASK; + v_complement(z->ob_digit, b->ob_digit, size_b); + b = z; } - else { + else Py_INCREF(b); - maskb = 0; + + /* Swap a and b if necessary to ensure size_a >= size_b. */ + if (size_a < size_b) { + z = a; a = b; b = z; + size_z = size_a; size_a = size_b; size_b = size_z; + negz = nega; nega = negb; negb = negz; } - negz = 0; + /* JRH: The original logic here was to allocate the result value (z) + as the longer of the two operands. However, there are some cases + where the result is guaranteed to be shorter than that: AND of two + positives, OR of two negatives: use the shorter number. AND with + mixed signs: use the positive number. OR with mixed signs: use the + negative number. + */ switch (op) { case '^': - if (maska != maskb) { - maska ^= PyLong_MASK; - negz = -1; - } + negz = nega ^ negb; + size_z = size_a; break; case '&': - if (maska && maskb) { - op = '|'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega & negb; + size_z = negb ? size_a : size_b; break; case '|': - if (maska || maskb) { - op = '&'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega | negb; + size_z = negb ? size_b : size_a; break; + default: + PyErr_BadArgument(); + return NULL; } - /* JRH: The original logic here was to allocate the result value (z) - as the longer of the two operands. However, there are some cases - where the result is guaranteed to be shorter than that: AND of two - positives, OR of two negatives: use the shorter number. AND with - mixed signs: use the positive number. OR with mixed signs: use the - negative number. After the transformations above, op will be '&' - iff one of these cases applies, and mask will be non-0 for operands - whose length should be ignored. - */ - - size_a = Py_SIZE(a); - size_b = Py_SIZE(b); - size_z = op == '&' - ? (maska - ? size_b - : (maskb ? size_a : MIN(size_a, size_b))) - : MAX(size_a, size_b); - z = _PyLong_New(size_z); + /* We allow an extra digit if z is negative, to make sure that + the final two's complement of z doesn't overflow. */ + z = _PyLong_New(size_z + negz); if (z == NULL) { Py_DECREF(a); Py_DECREF(b); return NULL; } - for (i = 0; i < size_z; ++i) { - diga = (i < size_a ? a->ob_digit[i] : 0) ^ maska; - digb = (i < size_b ? b->ob_digit[i] : 0) ^ maskb; - switch (op) { - case '&': z->ob_digit[i] = diga & digb; break; - case '|': z->ob_digit[i] = diga | digb; break; - case '^': z->ob_digit[i] = diga ^ digb; break; - } + /* Compute digits for overlap of a and b. */ + switch(op) { + case '&': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] & b->ob_digit[i]; + break; + case '|': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] | b->ob_digit[i]; + break; + case '^': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ b->ob_digit[i]; + break; + default: + PyErr_BadArgument(); + return NULL; + } + + /* Copy any remaining digits of a, inverting if necessary. */ + if (op == '^' && negb) + for (; i < size_z; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ PyLong_MASK; + else if (i < size_z) + memcpy(&z->ob_digit[i], &a->ob_digit[i], + (size_z-i)*sizeof(digit)); + + /* Complement result if negative. */ + if (negz) { + Py_SIZE(z) = -(Py_SIZE(z)); + z->ob_digit[size_z] = PyLong_MASK; + v_complement(z->ob_digit, z->ob_digit, size_z+1); } Py_DECREF(a); Py_DECREF(b); - z = long_normalize(z); - if (negz == 0) - return (PyObject *) maybe_small_long(z); - v = long_invert(z); - Py_DECREF(z); - return v; + return (PyObject *)maybe_small_long(long_normalize(z)); } static PyObject * From python-checkins at python.org Sun Oct 25 21:50:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 25 Oct 2009 20:50:18 -0000 Subject: [Python-checkins] r75699 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sun Oct 25 21:50:18 2009 New Revision: 75699 Log: Blocked revisions 75697 via svnmerge ........ r75697 | mark.dickinson | 2009-10-25 20:39:06 +0000 (Sun, 25 Oct 2009) | 3 lines Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sun Oct 25 21:51:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Sun, 25 Oct 2009 20:51:18 -0000 Subject: [Python-checkins] r75700 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Sun Oct 25 21:51:18 2009 New Revision: 75700 Log: Blocked revisions 75698 via svnmerge ................ r75698 | mark.dickinson | 2009-10-25 20:43:34 +0000 (Sun, 25 Oct 2009) | 10 lines Merged revisions 75697 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75697 | mark.dickinson | 2009-10-25 20:39:06 +0000 (Sun, 25 Oct 2009) | 3 lines Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sun Oct 25 23:48:51 2009 From: python-checkins at python.org (r.david.murray) Date: Sun, 25 Oct 2009 22:48:51 -0000 Subject: [Python-checkins] r75701 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Sun Oct 25 23:48:51 2009 New Revision: 75701 Log: Unblocked revisions 75519 via svnmerge ................ r75519 | r.david.murray | 2009-10-19 12:04:44 -0400 (Mon, 19 Oct 2009) | 12 lines Note that on py3k we are actually looking at sys.stdout, not sys.__stdout__. Merged revisions 75518 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75518 | r.david.murray | 2009-10-19 12:01:28 -0400 (Mon, 19 Oct 2009) | 3 lines Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sun Oct 25 23:54:02 2009 From: python-checkins at python.org (r.david.murray) Date: Sun, 25 Oct 2009 22:54:02 -0000 Subject: [Python-checkins] r75702 - in python/branches/release31-maint: Lib/test/test_curses.py Message-ID: Author: r.david.murray Date: Sun Oct 25 23:54:02 2009 New Revision: 75702 Log: Merged revisions 75519 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k regrtest -j support wasn't backported to 3.1, but in 3.1 regrtest itself captures stdout, so doing this skip is needed. ................ r75519 | r.david.murray | 2009-10-19 12:04:44 -0400 (Mon, 19 Oct 2009) | 12 lines Note that on py3k we are actually looking at sys.stdout, not sys.__stdout__. Merged revisions 75518 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75518 | r.david.murray | 2009-10-19 12:01:28 -0400 (Mon, 19 Oct 2009) | 3 lines Only run test_curses when sys.__stdout__ is a tty. This eliminates the last false positive when running regrtest with -j. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_curses.py Modified: python/branches/release31-maint/Lib/test/test_curses.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_curses.py (original) +++ python/branches/release31-maint/Lib/test/test_curses.py Sun Oct 25 23:54:02 2009 @@ -275,6 +275,8 @@ curses.resetty() def test_main(): + if not sys.stdout.isatty(): + raise unittest.SkipTest("sys.stdout is not a tty") # testing setupterm() inside initscr/endwin # causes terminal breakage curses.setupterm(fd=sys.stdout.fileno()) From python-checkins at python.org Mon Oct 26 00:00:54 2009 From: python-checkins at python.org (antoine.pitrou) Date: Sun, 25 Oct 2009 23:00:54 -0000 Subject: [Python-checkins] r75703 - python/branches/py3k/pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Mon Oct 26 00:00:53 2009 New Revision: 75703 Log: This mention is obsolete. Modified: python/branches/py3k/pyconfig.h.in Modified: python/branches/py3k/pyconfig.h.in ============================================================================== --- python/branches/py3k/pyconfig.h.in (original) +++ python/branches/py3k/pyconfig.h.in Mon Oct 26 00:00:53 2009 @@ -12,9 +12,6 @@ support for AIX C++ shared extension modules. */ #undef AIX_GENUINE_CPLUSPLUS -/* Define this if you have AtheOS threads. */ -#undef ATHEOS_THREADS - /* Define if you have the Mach cthreads package */ #undef C_THREADS From python-checkins at python.org Mon Oct 26 00:08:47 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 25 Oct 2009 23:08:47 -0000 Subject: [Python-checkins] r75704 - in python/branches/py3k: Lib/distutils/command/build_py.py Lib/distutils/command/install_lib.py Lib/distutils/errors.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_util.py Lib/distutils/util.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Mon Oct 26 00:08:47 2009 New Revision: 75704 Log: Merged revisions 75669-75671 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75669 | tarek.ziade | 2009-10-24 17:10:37 +0200 (Sat, 24 Oct 2009) | 1 line Issue #7071: byte-compilation in Distutils now looks at sys.dont_write_bytecode ........ r75670 | tarek.ziade | 2009-10-24 17:19:03 +0200 (Sat, 24 Oct 2009) | 1 line fixed finally state in distutils.test_util ........ r75671 | tarek.ziade | 2009-10-24 17:51:30 +0200 (Sat, 24 Oct 2009) | 1 line fixed warning and error message ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/command/build_py.py python/branches/py3k/Lib/distutils/command/install_lib.py python/branches/py3k/Lib/distutils/errors.py python/branches/py3k/Lib/distutils/tests/test_build_py.py python/branches/py3k/Lib/distutils/tests/test_install_lib.py python/branches/py3k/Lib/distutils/tests/test_util.py python/branches/py3k/Lib/distutils/util.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/distutils/command/build_py.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/build_py.py (original) +++ python/branches/py3k/Lib/distutils/command/build_py.py Mon Oct 26 00:08:47 2009 @@ -5,6 +5,7 @@ __revision__ = "$Id$" import os +import sys from glob import glob from distutils.core import Command @@ -369,6 +370,10 @@ self.build_module(module, module_file, package) def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile prefix = self.build_lib if prefix[-1] != os.sep: Modified: python/branches/py3k/Lib/distutils/command/install_lib.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/install_lib.py (original) +++ python/branches/py3k/Lib/distutils/command/install_lib.py Mon Oct 26 00:08:47 2009 @@ -6,6 +6,8 @@ __revision__ = "$Id$" import os +import sys + from distutils.core import Command from distutils.errors import DistutilsOptionError @@ -115,6 +117,10 @@ return outfiles def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile # Get the "--root" directory supplied to the "install" command, Modified: python/branches/py3k/Lib/distutils/errors.py ============================================================================== --- python/branches/py3k/Lib/distutils/errors.py (original) +++ python/branches/py3k/Lib/distutils/errors.py Mon Oct 26 00:08:47 2009 @@ -74,6 +74,8 @@ class DistutilsTemplateError (DistutilsError): """Syntax error in a file list template.""" +class DistutilsByteCompileError(DistutilsError): + """Byte compile error.""" # Exception classes used by the CCompiler implementation classes class CCompilerError (Exception): Modified: python/branches/py3k/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_build_py.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_build_py.py Mon Oct 26 00:08:47 2009 @@ -89,6 +89,22 @@ os.chdir(cwd) sys.stdout = sys.__stdout__ + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = build_py(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/branches/py3k/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_install_lib.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_install_lib.py Mon Oct 26 00:08:47 2009 @@ -31,6 +31,8 @@ cmd.finalize_options() self.assertEquals(cmd.optimize, 2) + @unittest.skipUnless(not sys.dont_write_bytecode, + 'byte-compile not supported') def test_byte_compile(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) @@ -76,6 +78,21 @@ # get_input should return 2 elements self.assertEquals(len(cmd.get_inputs()), 2) + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = install_lib(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) Modified: python/branches/py3k/Lib/distutils/tests/test_util.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_util.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_util.py Mon Oct 26 00:08:47 2009 @@ -1,7 +1,4 @@ """Tests for distutils.util.""" -# not covered yet: -# - byte_compile -# import os import sys import unittest @@ -9,11 +6,12 @@ from io import BytesIO import subprocess -from distutils.errors import DistutilsPlatformError +from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError from distutils.util import (get_platform, convert_path, change_root, check_environ, split_quoted, strtobool, rfc822_escape, get_compiler_versions, - _find_exe_version, _MAC_OS_X_LD_VERSION) + _find_exe_version, _MAC_OS_X_LD_VERSION, + byte_compile) from distutils import util from distutils.sysconfig import get_config_vars from distutils import sysconfig @@ -349,6 +347,16 @@ res = get_compiler_versions() self.assertEquals(res[2], None) + def test_dont_write_bytecode(self): + # makes sure byte_compile raise a DistutilsError + # if sys.dont_write_bytecode is True + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + self.assertRaises(DistutilsByteCompileError, byte_compile, []) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + def test_suite(): return unittest.makeSuite(UtilTestCase) Modified: python/branches/py3k/Lib/distutils/util.py ============================================================================== --- python/branches/py3k/Lib/distutils/util.py (original) +++ python/branches/py3k/Lib/distutils/util.py Mon Oct 26 00:08:47 2009 @@ -13,6 +13,7 @@ from distutils.spawn import spawn, find_executable from distutils import log from distutils.version import LooseVersion +from distutils.errors import DistutilsByteCompileError def get_platform(): """Return a string that identifies the current platform. @@ -444,6 +445,10 @@ generated in indirect mode; unless you know what you're doing, leave it set to None. """ + # nothing is done if sys.dont_write_bytecode is True + if sys.dont_write_bytecode: + raise DistutilsByteCompileError('byte-compiling is disabled.') + # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative # approach: choose direct mode *only* if the current interpreter is Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 26 00:08:47 2009 @@ -1152,6 +1152,9 @@ Library ------- +- Issue #7071: byte-compilation in Distutils is now done with respect to + sys.dont_write_bytecode. + - Issue #7066: archive_util.make_archive now restores the cwd if an error is raised. Initial patch by Ezio Melotti. From python-checkins at python.org Mon Oct 26 00:16:52 2009 From: python-checkins at python.org (tarek.ziade) Date: Sun, 25 Oct 2009 23:16:52 -0000 Subject: [Python-checkins] r75705 - in python/branches/release31-maint: Lib/distutils/command/build_py.py Lib/distutils/command/install_lib.py Lib/distutils/errors.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_util.py Lib/distutils/util.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Mon Oct 26 00:16:51 2009 New Revision: 75705 Log: Merged revisions 75704 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75704 | tarek.ziade | 2009-10-26 00:08:47 +0100 (Mon, 26 Oct 2009) | 17 lines Merged revisions 75669-75671 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75669 | tarek.ziade | 2009-10-24 17:10:37 +0200 (Sat, 24 Oct 2009) | 1 line Issue #7071: byte-compilation in Distutils now looks at sys.dont_write_bytecode ........ r75670 | tarek.ziade | 2009-10-24 17:19:03 +0200 (Sat, 24 Oct 2009) | 1 line fixed finally state in distutils.test_util ........ r75671 | tarek.ziade | 2009-10-24 17:51:30 +0200 (Sat, 24 Oct 2009) | 1 line fixed warning and error message ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/distutils/command/build_py.py python/branches/release31-maint/Lib/distutils/command/install_lib.py python/branches/release31-maint/Lib/distutils/errors.py python/branches/release31-maint/Lib/distutils/tests/test_build_py.py python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py python/branches/release31-maint/Lib/distutils/tests/test_util.py python/branches/release31-maint/Lib/distutils/util.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/distutils/command/build_py.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/command/build_py.py (original) +++ python/branches/release31-maint/Lib/distutils/command/build_py.py Mon Oct 26 00:16:51 2009 @@ -5,6 +5,7 @@ __revision__ = "$Id$" import sys, os +import sys from glob import glob from distutils.core import Command @@ -369,6 +370,10 @@ self.build_module(module, module_file, package) def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile prefix = self.build_lib if prefix[-1] != os.sep: Modified: python/branches/release31-maint/Lib/distutils/command/install_lib.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/command/install_lib.py (original) +++ python/branches/release31-maint/Lib/distutils/command/install_lib.py Mon Oct 26 00:16:51 2009 @@ -6,6 +6,8 @@ __revision__ = "$Id$" import os +import sys + from distutils.core import Command from distutils.errors import DistutilsOptionError @@ -115,6 +117,10 @@ return outfiles def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile # Get the "--root" directory supplied to the "install" command, Modified: python/branches/release31-maint/Lib/distutils/errors.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/errors.py (original) +++ python/branches/release31-maint/Lib/distutils/errors.py Mon Oct 26 00:16:51 2009 @@ -74,6 +74,8 @@ class DistutilsTemplateError (DistutilsError): """Syntax error in a file list template.""" +class DistutilsByteCompileError(DistutilsError): + """Byte compile error.""" # Exception classes used by the CCompiler implementation classes class CCompilerError (Exception): Modified: python/branches/release31-maint/Lib/distutils/tests/test_build_py.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_build_py.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_build_py.py Mon Oct 26 00:16:51 2009 @@ -89,6 +89,22 @@ os.chdir(cwd) sys.stdout = sys.__stdout__ + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = build_py(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_install_lib.py Mon Oct 26 00:16:51 2009 @@ -31,6 +31,8 @@ cmd.finalize_options() self.assertEquals(cmd.optimize, 2) + @unittest.skipUnless(not sys.dont_write_bytecode, + 'byte-compile not supported') def test_byte_compile(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) @@ -76,6 +78,21 @@ # get_input should return 2 elements self.assertEquals(len(cmd.get_inputs()), 2) + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = install_lib(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) Modified: python/branches/release31-maint/Lib/distutils/tests/test_util.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/tests/test_util.py (original) +++ python/branches/release31-maint/Lib/distutils/tests/test_util.py Mon Oct 26 00:16:51 2009 @@ -1,16 +1,13 @@ """Tests for distutils.util.""" -# not covered yet: -# - byte_compile -# import os import sys import unittest from copy import copy -from distutils.errors import DistutilsPlatformError +from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError from distutils.util import (get_platform, convert_path, change_root, check_environ, split_quoted, strtobool, - rfc822_escape) + rfc822_escape, byte_compile) from distutils import util # used to patch _environ_checked from distutils.sysconfig import get_config_vars from distutils import sysconfig @@ -258,6 +255,16 @@ 'header%(8s)s') % {'8s': '\n'+8*' '} self.assertEquals(res, wanted) + def test_dont_write_bytecode(self): + # makes sure byte_compile raise a DistutilsError + # if sys.dont_write_bytecode is True + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + self.assertRaises(DistutilsByteCompileError, byte_compile, []) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + def test_suite(): return unittest.makeSuite(UtilTestCase) Modified: python/branches/release31-maint/Lib/distutils/util.py ============================================================================== --- python/branches/release31-maint/Lib/distutils/util.py (original) +++ python/branches/release31-maint/Lib/distutils/util.py Mon Oct 26 00:16:51 2009 @@ -11,6 +11,7 @@ from distutils.dep_util import newer from distutils.spawn import spawn from distutils import log +from distutils.errors import DistutilsByteCompileError def get_platform (): """Return a string that identifies the current platform. This is used @@ -443,6 +444,9 @@ generated in indirect mode; unless you know what you're doing, leave it set to None. """ + # nothing is done if sys.dont_write_bytecode is True + if sys.dont_write_bytecode: + raise DistutilsByteCompileError('byte-compiling is disabled.') # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Mon Oct 26 00:16:51 2009 @@ -34,6 +34,9 @@ Library ------- +- Issue #7071: byte-compilation in Distutils is now done with respect to + sys.dont_write_bytecode. + - Issue #7099: Decimal.is_normal now returns True for numbers with exponent larger than emax. From python-checkins at python.org Mon Oct 26 02:48:08 2009 From: python-checkins at python.org (barry.warsaw) Date: Mon, 26 Oct 2009 01:48:08 -0000 Subject: [Python-checkins] r75706 - in python/branches/release26-maint: Include/patchlevel.h Lib/distutils/__init__.py Lib/idlelib/idlever.py Lib/pydoc_topics.py Misc/NEWS Misc/RPM/python-2.6.spec README Message-ID: Author: barry.warsaw Date: Mon Oct 26 02:48:07 2009 New Revision: 75706 Log: bumping to 2.6.4 Modified: python/branches/release26-maint/Include/patchlevel.h python/branches/release26-maint/Lib/distutils/__init__.py python/branches/release26-maint/Lib/idlelib/idlever.py python/branches/release26-maint/Lib/pydoc_topics.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Misc/RPM/python-2.6.spec python/branches/release26-maint/README Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Mon Oct 26 02:48:07 2009 @@ -23,11 +23,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 6 #define PY_MICRO_VERSION 4 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 2 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.6.4rc2+" +#define PY_VERSION "2.6.4" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ Modified: python/branches/release26-maint/Lib/distutils/__init__.py ============================================================================== --- python/branches/release26-maint/Lib/distutils/__init__.py (original) +++ python/branches/release26-maint/Lib/distutils/__init__.py Mon Oct 26 02:48:07 2009 @@ -22,5 +22,5 @@ # #--start constants-- -__version__ = "2.6.4rc2" +__version__ = "2.6.4" #--end constants-- Modified: python/branches/release26-maint/Lib/idlelib/idlever.py ============================================================================== --- python/branches/release26-maint/Lib/idlelib/idlever.py (original) +++ python/branches/release26-maint/Lib/idlelib/idlever.py Mon Oct 26 02:48:07 2009 @@ -1 +1 @@ -IDLE_VERSION = "2.6.4rc2" +IDLE_VERSION = "2.6.4" Modified: python/branches/release26-maint/Lib/pydoc_topics.py ============================================================================== --- python/branches/release26-maint/Lib/pydoc_topics.py (original) +++ python/branches/release26-maint/Lib/pydoc_topics.py Mon Oct 26 02:48:07 2009 @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Sun Oct 18 12:30:40 2009 +# Autogenerated by Sphinx on Sun Oct 25 21:45:56 2009 topics = {'assert': u'\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError, expression2\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list is recursively defined as\nfollows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets. (This rule is relaxed as of\n Python 1.5; in earlier versions, the object had to be a tuple.\n Since strings are sequences, an assignment like ``a, b = "xy"`` is\n now legal as long as the string has the right length.)\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` statement in the\n current code block: the name is bound to the object in the current\n local namespace.\n\n * Otherwise: the name is bound to the object in the current global\n namespace.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield a plain integer. If it is negative, the\n sequence\'s length is added to it. The resulting value must be a\n nonnegative integer less than the sequence\'s length, and the\n sequence is asked to assign the assigned object to its item with\n that index. If the index is out of range, ``IndexError`` is raised\n (assignment to a subscripted sequence cannot add new items to a\n list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to (small) integers. If either\n bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n(In the current implementation, the syntax for targets is taken to be\nthe same as for expressions, and invalid syntax is rejected during the\ncode generation phase, causing less detailed error messages.)\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print x\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the initial value is\nretrieved with a ``getattr()`` and the result is assigned with a\n``setattr()``. Notice that the two methods do not necessarily refer\nto the same variable. When ``getattr()`` refers to a class variable,\n``setattr()`` still writes to an instance variable. For example:\n\n class A:\n x = 3 # class variable\n a = A()\n a.x += 1 # writes a.x as 4 leaving A.x as 3\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n', Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Mon Oct 26 02:48:07 2009 @@ -7,7 +7,7 @@ What's New in Python 2.6.4 final? ================================= -*Release date: XX-Oct-2009* +*Release date: 25-Oct-2009* Core and Builtins ----------------- Modified: python/branches/release26-maint/Misc/RPM/python-2.6.spec ============================================================================== --- python/branches/release26-maint/Misc/RPM/python-2.6.spec (original) +++ python/branches/release26-maint/Misc/RPM/python-2.6.spec Mon Oct 26 02:48:07 2009 @@ -34,7 +34,7 @@ %define name python #--start constants-- -%define version 2.6.4rc2 +%define version 2.6.4 %define libver 2.6 #--end constants-- %define release 1pydotorg Modified: python/branches/release26-maint/README ============================================================================== --- python/branches/release26-maint/README (original) +++ python/branches/release26-maint/README Mon Oct 26 02:48:07 2009 @@ -1,5 +1,5 @@ -This is Python version 2.6.4rc2 -=============================== +This is Python version 2.6.4 +============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Python Software Foundation. From python-checkins at python.org Mon Oct 26 02:48:31 2009 From: python-checkins at python.org (barry.warsaw) Date: Mon, 26 Oct 2009 01:48:31 -0000 Subject: [Python-checkins] r75707 - python/tags/r264 Message-ID: Author: barry.warsaw Date: Mon Oct 26 02:48:31 2009 New Revision: 75707 Log: Tagging 2.6.4 final Added: python/tags/r264/ - copied from r75706, /python/branches/release26-maint/ From python-checkins at python.org Mon Oct 26 04:27:33 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 26 Oct 2009 03:27:33 -0000 Subject: [Python-checkins] r75708 - python/branches/release31-maint/Lib/test/test_threading.py Message-ID: Author: r.david.murray Date: Mon Oct 26 04:27:32 2009 New Revision: 75708 Log: Convert py2 print statement to print function in test skip. Modified: python/branches/release31-maint/Lib/test/test_threading.py Modified: python/branches/release31-maint/Lib/test/test_threading.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_threading.py (original) +++ python/branches/release31-maint/Lib/test/test_threading.py Mon Oct 26 04:27:32 2009 @@ -438,8 +438,8 @@ # Skip platforms with known problems forking from a worker thread. # See http://bugs.python.org/issue3863. if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'): - print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread' - ' due to known OS bugs on'), sys.platform + print('Skipping test_3_join_in_forked_from_thread' + ' due to known OS bugs on', sys.platform, file=sys.stderr) return script = """if 1: main_thread = threading.current_thread() From python-checkins at python.org Mon Oct 26 08:58:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 07:58:05 -0000 Subject: [Python-checkins] r75709 - python/branches/py3k/Modules/arraymodule.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 08:58:04 2009 New Revision: 75709 Log: Silence gcc warning about possibly uninitialized variable 'converted_items' Modified: python/branches/py3k/Modules/arraymodule.c Modified: python/branches/py3k/Modules/arraymodule.c ============================================================================== --- python/branches/py3k/Modules/arraymodule.c (original) +++ python/branches/py3k/Modules/arraymodule.c Mon Oct 26 08:58:04 2009 @@ -1850,6 +1850,8 @@ /* Impossible, but needed to shut up GCC about the unhandled * enumeration value. */ + default: + PyErr_BadArgument(); return NULL; } From python-checkins at python.org Mon Oct 26 09:24:15 2009 From: python-checkins at python.org (r.david.murray) Date: Mon, 26 Oct 2009 08:24:15 -0000 Subject: [Python-checkins] r75710 - python/branches/py3k/Lib/test/test_xmlrpc.py Message-ID: Author: r.david.murray Date: Mon Oct 26 09:24:14 2009 New Revision: 75710 Log: Make the XMLRCP CGIHandlerTestCase pass like it did before the change of the test to use StringIO instead of a temp file. There may or may not be an underlying problem here, so this patch makes the test function as originally designed until a determination can be made as to whether or not there is an underlying bug here. See issue 7165 for discussion. Modified: python/branches/py3k/Lib/test/test_xmlrpc.py Modified: python/branches/py3k/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_xmlrpc.py Mon Oct 26 09:24:14 2009 @@ -10,6 +10,8 @@ import socket import os import re +import io +import contextlib from test import support alist = [{'astring': 'foo at bar.baz.spam', @@ -713,6 +715,21 @@ else: self.fail('ProtocolError not raised') + + at contextlib.contextmanager +def captured_stdout(encoding='utf-8'): + """A variation on support.captured_stdout() which gives a text stream + having a `buffer` attribute. + """ + import io + orig_stdout = sys.stdout + sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding) + try: + yield sys.stdout + finally: + sys.stdout = orig_stdout + + class CGIHandlerTestCase(unittest.TestCase): def setUp(self): self.cgi = xmlrpc.server.CGIXMLRPCRequestHandler() @@ -725,7 +742,7 @@ env['REQUEST_METHOD'] = 'GET' # if the method is GET and no request_text is given, it runs handle_get # get sysout output - with support.captured_stdout() as data_out: + with captured_stdout(encoding=self.cgi.encoding) as data_out: self.cgi.handle_request() # parse Status header @@ -754,7 +771,7 @@ """ with support.EnvironmentVarGuard() as env, \ - support.captured_stdout() as data_out, \ + captured_stdout(encoding=self.cgi.encoding) as data_out, \ support.captured_stdin() as data_in: data_in.write(data) data_in.seek(0) From nnorwitz at gmail.com Mon Oct 26 11:46:53 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 26 Oct 2009 05:46:53 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091026104653.GA5230@python.psfb.org> More important issues: ---------------------- test_ssl leaked [420, 0, 0] references, sum=420 Less important issues: ---------------------- test_asynchat leaked [-132, 0, 0] references, sum=-132 test_smtplib leaked [-161, -88, 0] references, sum=-249 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [282, -282, 0] references, sum=0 From python-checkins at python.org Mon Oct 26 12:59:30 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 11:59:30 -0000 Subject: [Python-checkins] r75711 - python/trunk/Lib/test/test_readline.py Message-ID: Author: mark.dickinson Date: Mon Oct 26 12:59:30 2009 New Revision: 75711 Log: Skip readline tests if readline module is not available. Modified: python/trunk/Lib/test/test_readline.py Modified: python/trunk/Lib/test/test_readline.py ============================================================================== --- python/trunk/Lib/test/test_readline.py (original) +++ python/trunk/Lib/test/test_readline.py Mon Oct 26 12:59:30 2009 @@ -6,9 +6,10 @@ why the tests cover only a small subset of the interface. """ import unittest -from test.test_support import run_unittest +from test.test_support import run_unittest, import_module -import readline +# Skip tests if there is no readline module +readline = import_module('readline') class TestHistoryManipulation (unittest.TestCase): def testHistoryUpdates(self): From python-checkins at python.org Mon Oct 26 13:01:07 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 12:01:07 -0000 Subject: [Python-checkins] r75712 - in python/branches/py3k: Lib/test/test_readline.py Message-ID: Author: mark.dickinson Date: Mon Oct 26 13:01:06 2009 New Revision: 75712 Log: Merged revisions 75711 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75711 | mark.dickinson | 2009-10-26 11:59:30 +0000 (Mon, 26 Oct 2009) | 1 line Skip readline tests if readline module is not available. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_readline.py Modified: python/branches/py3k/Lib/test/test_readline.py ============================================================================== --- python/branches/py3k/Lib/test/test_readline.py (original) +++ python/branches/py3k/Lib/test/test_readline.py Mon Oct 26 13:01:06 2009 @@ -6,9 +6,10 @@ why the tests cover only a small subset of the interface. """ import unittest -from test.support import run_unittest +from test.support import run_unittest, import_module -import readline +# Skip tests if there is no readline module +readline = import_module('readline') class TestHistoryManipulation (unittest.TestCase): def testHistoryUpdates(self): From python-checkins at python.org Mon Oct 26 13:02:08 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 12:02:08 -0000 Subject: [Python-checkins] r75713 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Mon Oct 26 13:02:07 2009 New Revision: 75713 Log: Blocked revisions 75712 via svnmerge ................ r75712 | mark.dickinson | 2009-10-26 12:01:06 +0000 (Mon, 26 Oct 2009) | 9 lines Merged revisions 75711 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75711 | mark.dickinson | 2009-10-26 11:59:30 +0000 (Mon, 26 Oct 2009) | 1 line Skip readline tests if readline module is not available. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Mon Oct 26 15:18:44 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 14:18:44 -0000 Subject: [Python-checkins] r75714 - python/trunk/Python/bltinmodule.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 15:18:44 2009 New Revision: 75714 Log: Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum Modified: python/trunk/Python/bltinmodule.c Modified: python/trunk/Python/bltinmodule.c ============================================================================== --- python/trunk/Python/bltinmodule.c (original) +++ python/trunk/Python/bltinmodule.c Mon Oct 26 15:18:44 2009 @@ -2350,6 +2350,15 @@ } break; } + /* It's tempting to use PyNumber_InPlaceAdd instead of + PyNumber_Add here, to avoid quadratic running time + when doing 'sum(list_of_lists, [])'. However, this + would produce a change in behaviour: a snippet like + + empty = [] + sum([[x] for x in range(10)], empty) + + would change the value of empty. */ temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); From python-checkins at python.org Mon Oct 26 15:19:43 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 14:19:43 -0000 Subject: [Python-checkins] r75715 - in python/branches/py3k: Python/bltinmodule.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 15:19:42 2009 New Revision: 75715 Log: Merged revisions 75714 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75714 | mark.dickinson | 2009-10-26 14:18:44 +0000 (Mon, 26 Oct 2009) | 1 line Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Python/bltinmodule.c Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Mon Oct 26 15:19:42 2009 @@ -1958,6 +1958,15 @@ } break; } + /* It's tempting to use PyNumber_InPlaceAdd instead of + PyNumber_Add here, to avoid quadratic running time + when doing 'sum(list_of_lists, [])'. However, this + would produce a change in behaviour: a snippet like + + empty = [] + sum([[x] for x in range(10)], empty) + + would change the value of empty. */ temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); From python-checkins at python.org Mon Oct 26 15:36:29 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 14:36:29 -0000 Subject: [Python-checkins] r75716 - python/branches/py3k/Python/pystrtod.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 15:36:29 2009 New Revision: 75716 Log: Move some comments to more appropriate places Modified: python/branches/py3k/Python/pystrtod.c Modified: python/branches/py3k/Python/pystrtod.c ============================================================================== --- python/branches/py3k/Python/pystrtod.c (original) +++ python/branches/py3k/Python/pystrtod.c Mon Oct 26 15:36:29 2009 @@ -3,11 +3,8 @@ #include #include -/* _Py_parse_inf_or_nan: Attempt to parse a string of the form "nan", "inf" or - "infinity", with an optional leading sign of "+" or "-". On success, - return the NaN or Infinity as a double and set *endptr to point just beyond - the successfully parsed portion of the string. On failure, return -1.0 and - set *endptr to point to the start of the string. */ +/* Case-insensitive string match used for nan and inf detection; t should be + lower-case. Returns 1 for a successful match, 0 otherwise. */ static int case_insensitive_match(const char *s, const char *t) @@ -19,6 +16,12 @@ return *t ? 0 : 1; } +/* _Py_parse_inf_or_nan: Attempt to parse a string of the form "nan", "inf" or + "infinity", with an optional leading sign of "+" or "-". On success, + return the NaN or Infinity as a double and set *endptr to point just beyond + the successfully parsed portion of the string. On failure, return -1.0 and + set *endptr to point to the start of the string. */ + double _Py_parse_inf_or_nan(const char *p, char **endptr) { From python-checkins at python.org Mon Oct 26 15:48:55 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 26 Oct 2009 14:48:55 -0000 Subject: [Python-checkins] r75717 - python/trunk/Objects/floatobject.c Message-ID: Author: eric.smith Date: Mon Oct 26 15:48:55 2009 New Revision: 75717 Log: Start to remove _PyOS_double_to_string, as mentioned in issue 7117. Modified: python/trunk/Objects/floatobject.c Modified: python/trunk/Objects/floatobject.c ============================================================================== --- python/trunk/Objects/floatobject.c (original) +++ python/trunk/Objects/floatobject.c Mon Oct 26 15:48:55 2009 @@ -335,58 +335,72 @@ return 0; } -/* XXX PyFloat_AsString and PyFloat_AsReprString should be deprecated: +/* XXX PyFloat_AsString and PyFloat_AsReprString are deprecated: XXX they pass a char buffer without passing a length. */ void PyFloat_AsString(char *buf, PyFloatObject *v) { - _PyOS_double_to_string(buf, 100, v->ob_fval, 'g', PyFloat_STR_PRECISION, - Py_DTSF_ADD_DOT_0, NULL); + char *tmp = PyOS_double_to_string(v->ob_fval, 'g', + PyFloat_STR_PRECISION, + Py_DTSF_ADD_DOT_0, NULL); + strcpy(buf, tmp); + PyMem_Free(tmp); } void PyFloat_AsReprString(char *buf, PyFloatObject *v) { - _PyOS_double_to_string(buf, 100, v->ob_fval, 'r', 0, - Py_DTSF_ADD_DOT_0, NULL); + char * tmp = PyOS_double_to_string(v->ob_fval, 'r', 0, + Py_DTSF_ADD_DOT_0, NULL); + strcpy(buf, tmp); + PyMem_Free(tmp); } /* ARGSUSED */ static int float_print(PyFloatObject *v, FILE *fp, int flags) { - char buf[100]; - if (flags & Py_PRINT_RAW) - _PyOS_double_to_string(buf, sizeof(buf), v->ob_fval, - 'g', PyFloat_STR_PRECISION, - Py_DTSF_ADD_DOT_0, NULL); - else - _PyOS_double_to_string(buf, sizeof(buf), v->ob_fval, - 'r', 0, Py_DTSF_ADD_DOT_0, NULL); + char *buf; + if (flags & Py_PRINT_RAW) + buf = PyOS_double_to_string(v->ob_fval, + 'g', PyFloat_STR_PRECISION, + Py_DTSF_ADD_DOT_0, NULL); + else + buf = PyOS_double_to_string(v->ob_fval, + 'r', 0, Py_DTSF_ADD_DOT_0, NULL); Py_BEGIN_ALLOW_THREADS fputs(buf, fp); Py_END_ALLOW_THREADS + PyMem_Free(buf); return 0; } static PyObject * +float_str_or_repr(PyFloatObject *v, int precision, char format_code) +{ + PyObject *result; + char *buf = PyOS_double_to_string(PyFloat_AS_DOUBLE(v), + format_code, precision, + Py_DTSF_ADD_DOT_0, + NULL); + if (!buf) + return PyErr_NoMemory(); + result = PyString_FromString(buf); + PyMem_Free(buf); + return result; +} + +static PyObject * float_repr(PyFloatObject *v) { - char buf[100]; - _PyOS_double_to_string(buf, sizeof(buf), v->ob_fval, 'r', 0, - Py_DTSF_ADD_DOT_0, NULL); - return PyString_FromString(buf); + return float_str_or_repr(v, 0, 'r'); } static PyObject * float_str(PyFloatObject *v) { - char buf[100]; - _PyOS_double_to_string(buf, sizeof(buf), v->ob_fval, 'g', - PyFloat_STR_PRECISION, - Py_DTSF_ADD_DOT_0, NULL); - return PyString_FromString(buf); + return float_str_or_repr(v, PyFloat_STR_PRECISION, 'g'); } /* Comparison is pretty much a nightmare. When comparing float to float, From python-checkins at python.org Mon Oct 26 16:06:40 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 26 Oct 2009 15:06:40 -0000 Subject: [Python-checkins] r75718 - python/trunk/Modules/cPickle.c Message-ID: Author: eric.smith Date: Mon Oct 26 16:06:39 2009 New Revision: 75718 Log: Continue removing _PyOS_double_to_string, as mentioned in issue 7117. Modified: python/trunk/Modules/cPickle.c Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Mon Oct 26 16:06:39 2009 @@ -1170,15 +1170,29 @@ return -1; } else { - char c_str[250]; - c_str[0] = FLOAT; - _PyOS_double_to_string(c_str + 1, sizeof(c_str) - 2, x, 'g', - 17, 0, NULL); - /* Extend the formatted string with a newline character */ - strcat(c_str, "\n"); + int result = -1; + char *buf = NULL; + char op = FLOAT; - if (self->write_func(self, c_str, strlen(c_str)) < 0) - return -1; + if (self->write_func(self, &op, 1) < 0) + goto done; + + buf = PyOS_double_to_string(x, 'g', 17, 0, NULL); + if (!buf) { + PyErr_NoMemory(); + goto done; + } + + if (self->write_func(self, buf, strlen(buf)) < 0) + goto done; + + if (self->write_func(self, "\n", 1) < 0) + goto done; + + result = 0; +done: + PyMem_Free(buf); + return result; } return 0; From python-checkins at python.org Mon Oct 26 16:10:57 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 26 Oct 2009 15:10:57 -0000 Subject: [Python-checkins] r75719 - python/branches/py3k Message-ID: Author: eric.smith Date: Mon Oct 26 16:10:57 2009 New Revision: 75719 Log: Blocked revisions 75717-75718 via svnmerge ........ r75717 | eric.smith | 2009-10-26 10:48:55 -0400 (Mon, 26 Oct 2009) | 1 line Start to remove _PyOS_double_to_string, as mentioned in issue 7117. ........ r75718 | eric.smith | 2009-10-26 11:06:39 -0400 (Mon, 26 Oct 2009) | 1 line Continue removing _PyOS_double_to_string, as mentioned in issue 7117. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 26 16:39:50 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 15:39:50 -0000 Subject: [Python-checkins] r75720 - python/trunk/Python/pystrtod.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 16:39:50 2009 New Revision: 75720 Log: Issue #7117 (backport py3k float repr) continued: Backport pystrtod.c from py3k. Modified: python/trunk/Python/pystrtod.c Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Mon Oct 26 16:39:50 2009 @@ -3,6 +3,60 @@ #include #include +/* Case-insensitive string match used for nan and inf detection; t should be + lower-case. Returns 1 for a successful match, 0 otherwise. */ + +static int +case_insensitive_match(const char *s, const char *t) +{ + while(*t && Py_TOLOWER(*s) == *t) { + s++; + t++; + } + return *t ? 0 : 1; +} + +/* _Py_parse_inf_or_nan: Attempt to parse a string of the form "nan", "inf" or + "infinity", with an optional leading sign of "+" or "-". On success, + return the NaN or Infinity as a double and set *endptr to point just beyond + the successfully parsed portion of the string. On failure, return -1.0 and + set *endptr to point to the start of the string. */ + +double +_Py_parse_inf_or_nan(const char *p, char **endptr) +{ + double retval; + const char *s; + int negate = 0; + + s = p; + if (*s == '-') { + negate = 1; + s++; + } + else if (*s == '+') { + s++; + } + if (case_insensitive_match(s, "inf")) { + s += 3; + if (case_insensitive_match(s, "inity")) + s += 5; + retval = negate ? -Py_HUGE_VAL : Py_HUGE_VAL; + } +#ifdef Py_NAN + else if (case_insensitive_match(s, "nan")) { + s += 3; + retval = negate ? -Py_NAN : Py_NAN; + } +#endif + else { + s = p; + retval = -1.0; + } + *endptr = (char *)s; + return retval; +} + /** * PyOS_ascii_strtod: * @nptr: the string to convert to a numeric value. @@ -32,6 +86,33 @@ * Return value: the #gdouble value. **/ +#ifndef PY_NO_SHORT_FLOAT_REPR + +double +_PyOS_ascii_strtod(const char *nptr, char **endptr) +{ + double result; + _Py_SET_53BIT_PRECISION_HEADER; + + assert(nptr != NULL); + /* Set errno to zero, so that we can distinguish zero results + and underflows */ + errno = 0; + + _Py_SET_53BIT_PRECISION_START; + result = _Py_dg_strtod(nptr, endptr); + _Py_SET_53BIT_PRECISION_END; + + if (*endptr == nptr) + /* string might represent and inf or nan */ + result = _Py_parse_inf_or_nan(nptr, endptr); + + return result; + +} + +#else + /* Use system strtod; since strtod is locale aware, we may have to first fix the decimal separator. @@ -40,21 +121,8 @@ correctly rounded results. */ -/* Case-insensitive string match used for nan and inf detection; t should be - lower-case. Returns 1 for a successful match, 0 otherwise. */ - -static int -case_insensitive_match(const char *s, const char *t) -{ - while(*t && Py_TOLOWER(*s) == *t) { - s++; - t++; - } - return *t ? 0 : 1; -} - double -PyOS_ascii_strtod(const char *nptr, char **endptr) +_PyOS_ascii_strtod(const char *nptr, char **endptr) { char *fail_pos; double val = -1.0; @@ -78,19 +146,19 @@ decimal_point_pos = NULL; + /* Parse infinities and nans */ + val = _Py_parse_inf_or_nan(nptr, endptr); + if (*endptr != nptr) + return val; + /* Set errno to zero, so that we can distinguish zero results and underflows */ errno = 0; - /* We process any leading whitespace and the optional sign manually, - then pass the remainder to the system strtod. This ensures that - the result of an underflow has the correct sign. (bug #1725) */ - + /* We process the optional sign manually, then pass the remainder to + the system strtod. This ensures that the result of an underflow + has the correct sign. (bug #1725) */ p = nptr; - /* Skip leading space */ - while (Py_ISSPACE(*p)) - p++; - /* Process leading sign, if present */ if (*p == '-') { negate = 1; @@ -100,31 +168,6 @@ p++; } - /* Parse infinities and nans */ - if (*p == 'i' || *p == 'I') { - if (case_insensitive_match(p+1, "nf")) { - val = Py_HUGE_VAL; - if (case_insensitive_match(p+3, "inity")) - fail_pos = (char *)p+8; - else - fail_pos = (char *)p+3; - goto got_val; - } - else - goto invalid_string; - } -#ifdef Py_NAN - if (*p == 'n' || *p == 'N') { - if (case_insensitive_match(p+1, "an")) { - val = Py_NAN; - fail_pos = (char *)p+3; - goto got_val; - } - else - goto invalid_string; - } -#endif - /* Some platform strtods accept hex floats; Python shouldn't (at the moment), so we check explicitly for strings starting with '0x'. */ if (*p == '0' && (*(p+1) == 'x' || *(p+1) == 'X')) @@ -175,8 +218,7 @@ copy = (char *)PyMem_MALLOC(end - digits_pos + 1 + decimal_point_len); if (copy == NULL) { - if (endptr) - *endptr = (char *)nptr; + *endptr = (char *)nptr; errno = ENOMEM; return val; } @@ -214,28 +256,108 @@ if (fail_pos == digits_pos) goto invalid_string; - got_val: if (negate && fail_pos != nptr) val = -val; - - if (endptr) - *endptr = fail_pos; + *endptr = fail_pos; return val; invalid_string: - if (endptr) - *endptr = (char*)nptr; + *endptr = (char*)nptr; errno = EINVAL; return -1.0; } +#endif + +double +PyOS_ascii_strtod(const char *nptr, char **endptr) +{ + char *fail_pos; + const char *p; + double x; + + /* _PyOS_ascii_strtod already does everything that we want, + except that it doesn't parse leading whitespace */ + p = nptr; + while (Py_ISSPACE(*p)) + p++; + x = _PyOS_ascii_strtod(p, &fail_pos); + if (fail_pos == p) + fail_pos = (char *)nptr; + if (endptr) + *endptr = (char *)fail_pos; + return x; +} + double PyOS_ascii_atof(const char *nptr) { return PyOS_ascii_strtod(nptr, NULL); } +/* PyOS_string_to_double is the recommended replacement for the + PyOS_ascii_strtod and PyOS_ascii_atof functions. It converts a + null-terminated byte string s (interpreted as a string of ASCII characters) + to a float. The string should not have leading or trailing whitespace (in + contrast, PyOS_ascii_strtod allows leading whitespace but not trailing + whitespace). The conversion is independent of the current locale. + + If endptr is NULL, try to convert the whole string. Raise ValueError and + return -1.0 if the string is not a valid representation of a floating-point + number. + + If endptr is non-NULL, try to convert as much of the string as possible. + If no initial segment of the string is the valid representation of a + floating-point number then *endptr is set to point to the beginning of the + string, -1.0 is returned and again ValueError is raised. + + On overflow (e.g., when trying to convert '1e500' on an IEEE 754 machine), + if overflow_exception is NULL then +-Py_HUGE_VAL is returned, and no Python + exception is raised. Otherwise, overflow_exception should point to a + a Python exception, this exception will be raised, -1.0 will be returned, + and *endptr will point just past the end of the converted value. + + If any other failure occurs (for example lack of memory), -1.0 is returned + and the appropriate Python exception will have been set. +*/ + +double +PyOS_string_to_double(const char *s, + char **endptr, + PyObject *overflow_exception) +{ + double x, result=-1.0; + char *fail_pos; + + errno = 0; + PyFPE_START_PROTECT("PyOS_string_to_double", return -1.0) + x = PyOS_ascii_strtod(s, &fail_pos); + PyFPE_END_PROTECT(x) + + if (errno == ENOMEM) { + PyErr_NoMemory(); + fail_pos = (char *)s; + } + else if (!endptr && (fail_pos == s || *fail_pos != '\0')) + PyErr_Format(PyExc_ValueError, + "could not convert string to float: " + "%.200s", s); + else if (fail_pos == s) + PyErr_Format(PyExc_ValueError, + "could not convert string to float: " + "%.200s", s); + else if (errno == ERANGE && fabs(x) >= 1.0 && overflow_exception) + PyErr_Format(overflow_exception, + "value too large to convert to float: " + "%.200s", s); + else + result = x; + + if (endptr != NULL) + *endptr = fail_pos; + return result; +} /* Given a string that may have a decimal point in the current locale, change it back to a dot. Since the string cannot get @@ -415,7 +537,7 @@ ensure_decimal_point(char* buffer, size_t buf_size, int precision) { int digit_count, insert_count = 0, convert_to_exp = 0; - char* chars_to_insert, *digits_start; + char *chars_to_insert, *digits_start; /* search for the first non-digit character */ char *p = buffer; @@ -505,7 +627,7 @@ #define FLOAT_FORMATBUFLEN 120 /** - * _PyOS_ascii_formatd: + * PyOS_ascii_formatd: * @buffer: A buffer to place the resulting string in * @buf_size: The length of the buffer. * @format: The printf()-style format to use for the @@ -523,12 +645,12 @@ * Return value: The pointer to the buffer with the converted string. * On failure returns NULL but does not set any Python exception. **/ -/* DEPRECATED, will be deleted in 2.8 and 3.2 */ -PyAPI_FUNC(char *) -PyOS_ascii_formatd(char *buffer, +char * +_PyOS_ascii_formatd(char *buffer, size_t buf_size, const char *format, - double d) + double d, + int precision) { char format_char; size_t format_len = strlen(format); @@ -537,11 +659,6 @@ also with at least one character past the decimal. */ char tmp_format[FLOAT_FORMATBUFLEN]; - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "PyOS_ascii_formatd is deprecated, " - "use PyOS_double_to_string instead", 1) < 0) - return NULL; - /* The last character in the format string must be the format char */ format_char = format[format_len - 1]; @@ -603,24 +720,24 @@ extra character would produce more significant digits that we really want. */ if (format_char == 'Z') - buffer = ensure_decimal_point(buffer, buf_size, -1); + buffer = ensure_decimal_point(buffer, buf_size, precision); return buffer; } -/* Precisions used by repr() and str(), respectively. - - The repr() precision (17 significant decimal digits) is the minimal number - that is guaranteed to have enough precision so that if the number is read - back in the exact same binary value is recreated. This is true for IEEE - floating point by design, and also happens to work for all other modern - hardware. - - The str() precision (12 significant decimal digits) is chosen so that in - most cases, the rounding noise created by various operations is suppressed, - while giving plenty of precision for practical use. +char * +PyOS_ascii_formatd(char *buffer, + size_t buf_size, + const char *format, + double d) +{ + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyOS_ascii_formatd is deprecated, " + "use PyOS_double_to_string instead", 1) < 0) + return NULL; -*/ + return _PyOS_ascii_formatd(buffer, buf_size, format, d, -1); +} PyAPI_FUNC(void) _PyOS_double_to_string(char *buf, size_t buf_len, double val, @@ -738,31 +855,520 @@ } +#ifdef PY_NO_SHORT_FLOAT_REPR + +/* The fallback code to use if _Py_dg_dtoa is not available. */ + PyAPI_FUNC(char *) PyOS_double_to_string(double val, char format_code, int precision, int flags, - int *ptype) + int *type) { - char buf[128]; - Py_ssize_t len; - char *result; - - _PyOS_double_to_string(buf, sizeof(buf), val, format_code, precision, - flags, ptype); - len = strlen(buf); - if (len == 0) { + char format[32]; + Py_ssize_t bufsize; + char *buf; + int t, exp; + int upper = 0; + + /* Validate format_code, and map upper and lower case */ + switch (format_code) { + case 'e': /* exponent */ + case 'f': /* fixed */ + case 'g': /* general */ + break; + case 'E': + upper = 1; + format_code = 'e'; + break; + case 'F': + upper = 1; + format_code = 'f'; + break; + case 'G': + upper = 1; + format_code = 'g'; + break; + case 'r': /* repr format */ + /* Supplied precision is unused, must be 0. */ + if (precision != 0) { + PyErr_BadInternalCall(); + return NULL; + } + /* The repr() precision (17 significant decimal digits) is the + minimal number that is guaranteed to have enough precision + so that if the number is read back in the exact same binary + value is recreated. This is true for IEEE floating point + by design, and also happens to work for all other modern + hardware. */ + precision = 17; + format_code = 'g'; + break; + default: PyErr_BadInternalCall(); return NULL; } - /* Add 1 for the trailing 0 byte. */ - result = PyMem_Malloc(len + 1); - if (result == NULL) { + /* Here's a quick-and-dirty calculation to figure out how big a buffer + we need. In general, for a finite float we need: + + 1 byte for each digit of the decimal significand, and + + 1 for a possible sign + 1 for a possible decimal point + 2 for a possible [eE][+-] + 1 for each digit of the exponent; if we allow 19 digits + total then we're safe up to exponents of 2**63. + 1 for the trailing nul byte + + This gives a total of 24 + the number of digits in the significand, + and the number of digits in the significand is: + + for 'g' format: at most precision, except possibly + when precision == 0, when it's 1. + for 'e' format: precision+1 + for 'f' format: precision digits after the point, at least 1 + before. To figure out how many digits appear before the point + we have to examine the size of the number. If fabs(val) < 1.0 + then there will be only one digit before the point. If + fabs(val) >= 1.0, then there are at most + + 1+floor(log10(ceiling(fabs(val)))) + + digits before the point (where the 'ceiling' allows for the + possibility that the rounding rounds the integer part of val + up). A safe upper bound for the above quantity is + 1+floor(exp/3), where exp is the unique integer such that 0.5 + <= fabs(val)/2**exp < 1.0. This exp can be obtained from + frexp. + + So we allow room for precision+1 digits for all formats, plus an + extra floor(exp/3) digits for 'f' format. + + */ + + if (Py_IS_NAN(val) || Py_IS_INFINITY(val)) + /* 3 for 'inf'/'nan', 1 for sign, 1 for '\0' */ + bufsize = 5; + else { + bufsize = 25 + precision; + if (format_code == 'f' && fabs(val) >= 1.0) { + frexp(val, &exp); + bufsize += exp/3; + } + } + + buf = PyMem_Malloc(bufsize); + if (buf == NULL) { PyErr_NoMemory(); return NULL; } - strcpy(result, buf); - return result; + /* Handle nan and inf. */ + if (Py_IS_NAN(val)) { + strcpy(buf, "nan"); + t = Py_DTST_NAN; + } else if (Py_IS_INFINITY(val)) { + if (copysign(1., val) == 1.) + strcpy(buf, "inf"); + else + strcpy(buf, "-inf"); + t = Py_DTST_INFINITE; + } else { + t = Py_DTST_FINITE; + if (flags & Py_DTSF_ADD_DOT_0) + format_code = 'Z'; + + PyOS_snprintf(format, sizeof(format), "%%%s.%i%c", + (flags & Py_DTSF_ALT ? "#" : ""), precision, + format_code); + _PyOS_ascii_formatd(buf, bufsize, format, val, precision); + } + + /* Add sign when requested. It's convenient (esp. when formatting + complex numbers) to include a sign even for inf and nan. */ + if (flags & Py_DTSF_SIGN && buf[0] != '-') { + size_t len = strlen(buf); + /* the bufsize calculations above should ensure that we've got + space to add a sign */ + assert((size_t)bufsize >= len+2); + memmove(buf+1, buf, len+1); + buf[0] = '+'; + } + if (upper) { + /* Convert to upper case. */ + char *p1; + for (p1 = buf; *p1; p1++) + *p1 = Py_TOUPPER(*p1); + } + + if (type) + *type = t; + return buf; +} + +#else + +/* _Py_dg_dtoa is available. */ + +/* I'm using a lookup table here so that I don't have to invent a non-locale + specific way to convert to uppercase */ +#define OFS_INF 0 +#define OFS_NAN 1 +#define OFS_E 2 + +/* The lengths of these are known to the code below, so don't change them */ +static char *lc_float_strings[] = { + "inf", + "nan", + "e", +}; +static char *uc_float_strings[] = { + "INF", + "NAN", + "E", +}; + + +/* Convert a double d to a string, and return a PyMem_Malloc'd block of + memory contain the resulting string. + + Arguments: + d is the double to be converted + format_code is one of 'e', 'f', 'g', 'r'. 'e', 'f' and 'g' + correspond to '%e', '%f' and '%g'; 'r' corresponds to repr. + mode is one of '0', '2' or '3', and is completely determined by + format_code: 'e' and 'g' use mode 2; 'f' mode 3, 'r' mode 0. + precision is the desired precision + always_add_sign is nonzero if a '+' sign should be included for positive + numbers + add_dot_0_if_integer is nonzero if integers in non-exponential form + should have ".0" added. Only applies to format codes 'r' and 'g'. + use_alt_formatting is nonzero if alternative formatting should be + used. Only applies to format codes 'e', 'f' and 'g'. For code 'g', + at most one of use_alt_formatting and add_dot_0_if_integer should + be nonzero. + type, if non-NULL, will be set to one of these constants to identify + the type of the 'd' argument: + Py_DTST_FINITE + Py_DTST_INFINITE + Py_DTST_NAN + + Returns a PyMem_Malloc'd block of memory containing the resulting string, + or NULL on error. If NULL is returned, the Python error has been set. + */ + +static char * +format_float_short(double d, char format_code, + int mode, Py_ssize_t precision, + int always_add_sign, int add_dot_0_if_integer, + int use_alt_formatting, char **float_strings, int *type) +{ + char *buf = NULL; + char *p = NULL; + Py_ssize_t bufsize = 0; + char *digits, *digits_end; + int decpt_as_int, sign, exp_len, exp = 0, use_exp = 0; + Py_ssize_t decpt, digits_len, vdigits_start, vdigits_end; + _Py_SET_53BIT_PRECISION_HEADER; + + /* _Py_dg_dtoa returns a digit string (no decimal point or exponent). + Must be matched by a call to _Py_dg_freedtoa. */ + _Py_SET_53BIT_PRECISION_START; + digits = _Py_dg_dtoa(d, mode, precision, &decpt_as_int, &sign, + &digits_end); + _Py_SET_53BIT_PRECISION_END; + + decpt = (Py_ssize_t)decpt_as_int; + if (digits == NULL) { + /* The only failure mode is no memory. */ + PyErr_NoMemory(); + goto exit; + } + assert(digits_end != NULL && digits_end >= digits); + digits_len = digits_end - digits; + + if (digits_len && !Py_ISDIGIT(digits[0])) { + /* Infinities and nans here; adapt Gay's output, + so convert Infinity to inf and NaN to nan, and + ignore sign of nan. Then return. */ + + /* ignore the actual sign of a nan */ + if (digits[0] == 'n' || digits[0] == 'N') + sign = 0; + + /* We only need 5 bytes to hold the result "+inf\0" . */ + bufsize = 5; /* Used later in an assert. */ + buf = (char *)PyMem_Malloc(bufsize); + if (buf == NULL) { + PyErr_NoMemory(); + goto exit; + } + p = buf; + + if (sign == 1) { + *p++ = '-'; + } + else if (always_add_sign) { + *p++ = '+'; + } + if (digits[0] == 'i' || digits[0] == 'I') { + strncpy(p, float_strings[OFS_INF], 3); + p += 3; + + if (type) + *type = Py_DTST_INFINITE; + } + else if (digits[0] == 'n' || digits[0] == 'N') { + strncpy(p, float_strings[OFS_NAN], 3); + p += 3; + + if (type) + *type = Py_DTST_NAN; + } + else { + /* shouldn't get here: Gay's code should always return + something starting with a digit, an 'I', or 'N' */ + strncpy(p, "ERR", 3); + p += 3; + assert(0); + } + goto exit; + } + + /* The result must be finite (not inf or nan). */ + if (type) + *type = Py_DTST_FINITE; + + + /* We got digits back, format them. We may need to pad 'digits' + either on the left or right (or both) with extra zeros, so in + general the resulting string has the form + + [][] + + where either of the pieces could be empty, and there's a + decimal point that could appear either in or in the + leading or trailing . + + Imagine an infinite 'virtual' string vdigits, consisting of the + string 'digits' (starting at index 0) padded on both the left and + right with infinite strings of zeros. We want to output a slice + + vdigits[vdigits_start : vdigits_end] + + of this virtual string. Thus if vdigits_start < 0 then we'll end + up producing some leading zeros; if vdigits_end > digits_len there + will be trailing zeros in the output. The next section of code + determines whether to use an exponent or not, figures out the + position 'decpt' of the decimal point, and computes 'vdigits_start' + and 'vdigits_end'. */ + vdigits_end = digits_len; + switch (format_code) { + case 'e': + use_exp = 1; + vdigits_end = precision; + break; + case 'f': + vdigits_end = decpt + precision; + break; + case 'g': + if (decpt <= -4 || decpt > + (add_dot_0_if_integer ? precision-1 : precision)) + use_exp = 1; + if (use_alt_formatting) + vdigits_end = precision; + break; + case 'r': + /* convert to exponential format at 1e16. We used to convert + at 1e17, but that gives odd-looking results for some values + when a 16-digit 'shortest' repr is padded with bogus zeros. + For example, repr(2e16+8) would give 20000000000000010.0; + the true value is 20000000000000008.0. */ + if (decpt <= -4 || decpt > 16) + use_exp = 1; + break; + default: + PyErr_BadInternalCall(); + goto exit; + } + + /* if using an exponent, reset decimal point position to 1 and adjust + exponent accordingly.*/ + if (use_exp) { + exp = decpt - 1; + decpt = 1; + } + /* ensure vdigits_start < decpt <= vdigits_end, or vdigits_start < + decpt < vdigits_end if add_dot_0_if_integer and no exponent */ + vdigits_start = decpt <= 0 ? decpt-1 : 0; + if (!use_exp && add_dot_0_if_integer) + vdigits_end = vdigits_end > decpt ? vdigits_end : decpt + 1; + else + vdigits_end = vdigits_end > decpt ? vdigits_end : decpt; + + /* double check inequalities */ + assert(vdigits_start <= 0 && + 0 <= digits_len && + digits_len <= vdigits_end); + /* decimal point should be in (vdigits_start, vdigits_end] */ + assert(vdigits_start < decpt && decpt <= vdigits_end); + + /* Compute an upper bound how much memory we need. This might be a few + chars too long, but no big deal. */ + bufsize = + /* sign, decimal point and trailing 0 byte */ + 3 + + + /* total digit count (including zero padding on both sides) */ + (vdigits_end - vdigits_start) + + + /* exponent "e+100", max 3 numerical digits */ + (use_exp ? 5 : 0); + + /* Now allocate the memory and initialize p to point to the start of + it. */ + buf = (char *)PyMem_Malloc(bufsize); + if (buf == NULL) { + PyErr_NoMemory(); + goto exit; + } + p = buf; + + /* Add a negative sign if negative, and a plus sign if non-negative + and always_add_sign is true. */ + if (sign == 1) + *p++ = '-'; + else if (always_add_sign) + *p++ = '+'; + + /* note that exactly one of the three 'if' conditions is true, + so we include exactly one decimal point */ + /* Zero padding on left of digit string */ + if (decpt <= 0) { + memset(p, '0', decpt-vdigits_start); + p += decpt - vdigits_start; + *p++ = '.'; + memset(p, '0', 0-decpt); + p += 0-decpt; + } + else { + memset(p, '0', 0-vdigits_start); + p += 0 - vdigits_start; + } + + /* Digits, with included decimal point */ + if (0 < decpt && decpt <= digits_len) { + strncpy(p, digits, decpt-0); + p += decpt-0; + *p++ = '.'; + strncpy(p, digits+decpt, digits_len-decpt); + p += digits_len-decpt; + } + else { + strncpy(p, digits, digits_len); + p += digits_len; + } + + /* And zeros on the right */ + if (digits_len < decpt) { + memset(p, '0', decpt-digits_len); + p += decpt-digits_len; + *p++ = '.'; + memset(p, '0', vdigits_end-decpt); + p += vdigits_end-decpt; + } + else { + memset(p, '0', vdigits_end-digits_len); + p += vdigits_end-digits_len; + } + + /* Delete a trailing decimal pt unless using alternative formatting. */ + if (p[-1] == '.' && !use_alt_formatting) + p--; + + /* Now that we've done zero padding, add an exponent if needed. */ + if (use_exp) { + *p++ = float_strings[OFS_E][0]; + exp_len = sprintf(p, "%+.02d", exp); + p += exp_len; + } + exit: + if (buf) { + *p = '\0'; + /* It's too late if this fails, as we've already stepped on + memory that isn't ours. But it's an okay debugging test. */ + assert(p-buf < bufsize); + } + if (digits) + _Py_dg_freedtoa(digits); + + return buf; +} + + +PyAPI_FUNC(char *) PyOS_double_to_string(double val, + char format_code, + int precision, + int flags, + int *type) +{ + char **float_strings = lc_float_strings; + int mode; + + /* Validate format_code, and map upper and lower case. Compute the + mode and make any adjustments as needed. */ + switch (format_code) { + /* exponent */ + case 'E': + float_strings = uc_float_strings; + format_code = 'e'; + /* Fall through. */ + case 'e': + mode = 2; + precision++; + break; + + /* fixed */ + case 'F': + float_strings = uc_float_strings; + format_code = 'f'; + /* Fall through. */ + case 'f': + mode = 3; + break; + + /* general */ + case 'G': + float_strings = uc_float_strings; + format_code = 'g'; + /* Fall through. */ + case 'g': + mode = 2; + /* precision 0 makes no sense for 'g' format; interpret as 1 */ + if (precision == 0) + precision = 1; + break; + + /* repr format */ + case 'r': + mode = 0; + /* Supplied precision is unused, must be 0. */ + if (precision != 0) { + PyErr_BadInternalCall(); + return NULL; + } + break; + + default: + PyErr_BadInternalCall(); + return NULL; + } + + return format_float_short(val, format_code, mode, precision, + flags & Py_DTSF_SIGN, + flags & Py_DTSF_ADD_DOT_0, + flags & Py_DTSF_ALT, + float_strings, type); } +#endif /* ifdef PY_NO_SHORT_FLOAT_REPR */ From python-checkins at python.org Mon Oct 26 16:40:42 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 15:40:42 -0000 Subject: [Python-checkins] r75721 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Mon Oct 26 16:40:42 2009 New Revision: 75721 Log: Blocked revisions 75720 via svnmerge ........ r75720 | mark.dickinson | 2009-10-26 15:39:50 +0000 (Mon, 26 Oct 2009) | 3 lines Issue #7117 (backport py3k float repr) continued: Backport pystrtod.c from py3k. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 26 18:46:18 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 26 Oct 2009 17:46:18 -0000 Subject: [Python-checkins] r75722 - in python/trunk: Include/pystrtod.h Misc/NEWS Objects/stringobject.c Objects/unicodeobject.c Python/pystrtod.c Message-ID: Author: eric.smith Date: Mon Oct 26 18:46:17 2009 New Revision: 75722 Log: Finished removing _PyOS_double_to_string, as mentioned in issue 7117. Modified: python/trunk/Include/pystrtod.h python/trunk/Misc/NEWS python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c python/trunk/Python/pystrtod.c Modified: python/trunk/Include/pystrtod.h ============================================================================== --- python/trunk/Include/pystrtod.h (original) +++ python/trunk/Include/pystrtod.h Mon Oct 26 18:46:17 2009 @@ -13,13 +13,6 @@ PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d); -/* Use PyOS_double_to_string instead. It's the same, except it allocates - the appropriately sized buffer and returns it. This function will go - away in Python 2.8 and 3.2. */ -PyAPI_FUNC(void) _PyOS_double_to_string(char *buf, size_t buf_len, double val, - char format_code, int precision, - int flags, int* type); - /* The caller is responsible for calling PyMem_Free to free the buffer that's is returned. */ PyAPI_FUNC(char *) PyOS_double_to_string(double val, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 26 18:46:17 2009 @@ -12,6 +12,10 @@ Core and Builtins ----------------- +- Removed _PyOS_double_to_string. Use PyOS_double_to_string + instead. This is in preparation for (but not strictly related to) + issue #7117, short float repr. + - Issue #1087418: Boost performance of bitwise operations for longs. - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Mon Oct 26 18:46:17 2009 @@ -4336,7 +4336,10 @@ formatfloat(char *buf, size_t buflen, int flags, int prec, int type, PyObject *v) { + char *tmp; double x; + Py_ssize_t len; + x = PyFloat_AsDouble(v); if (x == -1.0 && PyErr_Occurred()) { PyErr_Format(PyExc_TypeError, "float argument required, " @@ -4381,9 +4384,20 @@ "formatted float is too long (precision too large?)"); return -1; } - _PyOS_double_to_string(buf, buflen, x, type, prec, - (flags&F_ALT)?Py_DTSF_ALT:0, NULL); - return (int)strlen(buf); + tmp = PyOS_double_to_string(x, type, prec, + (flags&F_ALT)?Py_DTSF_ALT:0, NULL); + if (!tmp) + return -1; + len = strlen(tmp); + if (len >= buflen) { + PyErr_SetString(PyExc_OverflowError, + "formatted float is too long (precision too large?)"); + PyMem_Free(tmp); + return -1; + } + strcpy(buf, tmp); + PyMem_Free(tmp); + return (int)len; } /* _PyString_FormatLong emulates the format codes d, u, o, x and X, and Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon Oct 26 18:46:17 2009 @@ -8289,18 +8289,6 @@ } static int -doubletounicode(Py_UNICODE *buffer, size_t len, int format_code, - int precision, int flags, double x) -{ - Py_ssize_t result; - - _PyOS_double_to_string((char *)buffer, len, x, format_code, precision, - flags, NULL); - result = strtounicode(buffer, (char *)buffer); - return Py_SAFE_DOWNCAST(result, Py_ssize_t, int); -} - -static int longtounicode(Py_UNICODE *buffer, size_t len, const char *format, long x) { Py_ssize_t result; @@ -8323,6 +8311,8 @@ PyObject *v) { double x; + Py_ssize_t result; + char *tmp; x = PyFloat_AsDouble(v); if (x == -1.0 && PyErr_Occurred()) @@ -8365,8 +8355,15 @@ "formatted float is too long (precision too large?)"); return -1; } - return doubletounicode(buf, buflen, type, prec, - (flags&F_ALT)?Py_DTSF_ALT:0, x); + + tmp = PyOS_double_to_string(x, type, prec, + (flags&F_ALT)?Py_DTSF_ALT:0, NULL); + if (!tmp) + return -1; + + result = strtounicode(buf, tmp); + PyMem_Free(tmp); + return Py_SAFE_DOWNCAST(result, Py_ssize_t, int); } static PyObject* Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Mon Oct 26 18:46:17 2009 @@ -392,25 +392,6 @@ } -Py_LOCAL_INLINE(void) -ensure_sign(char* buffer, size_t buf_size) -{ - size_t len; - - if (buffer[0] == '-') - /* Already have a sign. */ - return; - - /* Include the trailing 0 byte. */ - len = strlen(buffer)+1; - if (len >= buf_size+1) - /* No room for the sign, don't do anything. */ - return; - - memmove(buffer+1, buffer, len); - buffer[0] = '+'; -} - /* From the C99 standard, section 7.19.6: The exponent always contains at least two digits, and only as many more digits as necessary to represent the exponent. @@ -739,122 +720,6 @@ return _PyOS_ascii_formatd(buffer, buf_size, format, d, -1); } -PyAPI_FUNC(void) -_PyOS_double_to_string(char *buf, size_t buf_len, double val, - char format_code, int precision, - int flags, int *ptype) -{ - char format[32]; - int t; - int upper = 0; - - if (buf_len < 1) { - assert(0); - /* There's no way to signal this error. Just return. */ - return; - } - buf[0] = 0; - - /* Validate format_code, and map upper and lower case */ - switch (format_code) { - case 'e': /* exponent */ - case 'f': /* fixed */ - case 'g': /* general */ - break; - case 'E': - upper = 1; - format_code = 'e'; - break; - case 'F': - upper = 1; - format_code = 'f'; - break; - case 'G': - upper = 1; - format_code = 'g'; - break; - case 'r': /* repr format */ - /* Supplied precision is unused, must be 0. */ - if (precision != 0) - return; - /* The repr() precision (17 significant decimal digits) is the - minimal number that is guaranteed to have enough precision - so that if the number is read back in the exact same binary - value is recreated. This is true for IEEE floating point - by design, and also happens to work for all other modern - hardware. */ - precision = 17; - format_code = 'g'; - break; - default: - assert(0); - return; - } - - /* Check for buf too small to fit "-inf". Other buffer too small - conditions are dealt with when converting or formatting finite - numbers. */ - if (buf_len < 5) { - assert(0); - return; - } - - /* Handle nan and inf. */ - if (Py_IS_NAN(val)) { - strcpy(buf, "nan"); - t = Py_DTST_NAN; - } else if (Py_IS_INFINITY(val)) { - if (copysign(1., val) == 1.) - strcpy(buf, "inf"); - else - strcpy(buf, "-inf"); - t = Py_DTST_INFINITE; - } else { - t = Py_DTST_FINITE; - - /* Build the format string. */ - PyOS_snprintf(format, sizeof(format), "%%%s.%i%c", - (flags & Py_DTSF_ALT ? "#" : ""), precision, - format_code); - - /* Have PyOS_snprintf do the hard work. */ - PyOS_snprintf(buf, buf_len, format, val); - - /* Do various fixups on the return string */ - - /* Get the current locale, and find the decimal point string. - Convert that string back to a dot. */ - change_decimal_from_locale_to_dot(buf); - - /* If an exponent exists, ensure that the exponent is at least - MIN_EXPONENT_DIGITS digits, providing the buffer is large - enough for the extra zeros. Also, if there are more than - MIN_EXPONENT_DIGITS, remove as many zeros as possible until - we get back to MIN_EXPONENT_DIGITS */ - ensure_minimum_exponent_length(buf, buf_len); - - /* Possibly make sure we have at least one character after the - decimal point (and make sure we have a decimal point). */ - if (flags & Py_DTSF_ADD_DOT_0) - buf = ensure_decimal_point(buf, buf_len, precision); - } - - /* Add the sign if asked and the result isn't negative. */ - if (flags & Py_DTSF_SIGN && buf[0] != '-') - ensure_sign(buf, buf_len); - - if (upper) { - /* Convert to upper case. */ - char *p; - for (p = buf; *p; p++) - *p = Py_TOUPPER(*p); - } - - if (ptype) - *ptype = t; -} - - #ifdef PY_NO_SHORT_FLOAT_REPR /* The fallback code to use if _Py_dg_dtoa is not available. */ From python-checkins at python.org Mon Oct 26 18:48:13 2009 From: python-checkins at python.org (eric.smith) Date: Mon, 26 Oct 2009 17:48:13 -0000 Subject: [Python-checkins] r75723 - python/branches/py3k Message-ID: Author: eric.smith Date: Mon Oct 26 18:48:13 2009 New Revision: 75723 Log: Blocked revisions 75722 via svnmerge ........ r75722 | eric.smith | 2009-10-26 13:46:17 -0400 (Mon, 26 Oct 2009) | 1 line Finished removing _PyOS_double_to_string, as mentioned in issue 7117. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 26 19:15:09 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 26 Oct 2009 18:15:09 -0000 Subject: [Python-checkins] r75724 - in sandbox/trunk/newgil: Lib/distutils/command/build_py.py Lib/distutils/command/install_lib.py Lib/distutils/errors.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_util.py Lib/distutils/util.py Lib/test/test_readline.py Lib/test/test_xmlrpc.py Misc/NEWS Modules/arraymodule.c Objects/longobject.c Python/bltinmodule.c Python/pystrtod.c pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Mon Oct 26 19:15:09 2009 New Revision: 75724 Log: Merged revisions 75698,75703-75704,75709-75710,75712,75715-75716,75719,75721,75723 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75698 | mark.dickinson | 2009-10-25 21:43:34 +0100 (dim., 25 oct. 2009) | 10 lines Merged revisions 75697 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75697 | mark.dickinson | 2009-10-25 20:39:06 +0000 (Sun, 25 Oct 2009) | 3 lines Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. ........ ................ r75703 | antoine.pitrou | 2009-10-26 00:00:53 +0100 (lun., 26 oct. 2009) | 3 lines This mention is obsolete. ................ r75704 | tarek.ziade | 2009-10-26 00:08:47 +0100 (lun., 26 oct. 2009) | 17 lines Merged revisions 75669-75671 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75669 | tarek.ziade | 2009-10-24 17:10:37 +0200 (Sat, 24 Oct 2009) | 1 line Issue #7071: byte-compilation in Distutils now looks at sys.dont_write_bytecode ........ r75670 | tarek.ziade | 2009-10-24 17:19:03 +0200 (Sat, 24 Oct 2009) | 1 line fixed finally state in distutils.test_util ........ r75671 | tarek.ziade | 2009-10-24 17:51:30 +0200 (Sat, 24 Oct 2009) | 1 line fixed warning and error message ........ ................ r75709 | mark.dickinson | 2009-10-26 08:58:04 +0100 (lun., 26 oct. 2009) | 1 line Silence gcc warning about possibly uninitialized variable 'converted_items' ................ r75710 | r.david.murray | 2009-10-26 09:24:14 +0100 (lun., 26 oct. 2009) | 6 lines Make the XMLRCP CGIHandlerTestCase pass like it did before the change of the test to use StringIO instead of a temp file. There may or may not be an underlying problem here, so this patch makes the test function as originally designed until a determination can be made as to whether or not there is an underlying bug here. See issue 7165 for discussion. ................ r75712 | mark.dickinson | 2009-10-26 13:01:06 +0100 (lun., 26 oct. 2009) | 9 lines Merged revisions 75711 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75711 | mark.dickinson | 2009-10-26 11:59:30 +0000 (Mon, 26 Oct 2009) | 1 line Skip readline tests if readline module is not available. ........ ................ r75715 | mark.dickinson | 2009-10-26 15:19:42 +0100 (lun., 26 oct. 2009) | 9 lines Merged revisions 75714 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75714 | mark.dickinson | 2009-10-26 14:18:44 +0000 (Mon, 26 Oct 2009) | 1 line Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum ........ ................ r75716 | mark.dickinson | 2009-10-26 15:36:29 +0100 (lun., 26 oct. 2009) | 1 line Move some comments to more appropriate places ................ r75719 | eric.smith | 2009-10-26 16:10:57 +0100 (lun., 26 oct. 2009) | 12 lines Blocked revisions 75717-75718 via svnmerge ........ r75717 | eric.smith | 2009-10-26 10:48:55 -0400 (Mon, 26 Oct 2009) | 1 line Start to remove _PyOS_double_to_string, as mentioned in issue 7117. ........ r75718 | eric.smith | 2009-10-26 11:06:39 -0400 (Mon, 26 Oct 2009) | 1 line Continue removing _PyOS_double_to_string, as mentioned in issue 7117. ........ ................ r75721 | mark.dickinson | 2009-10-26 16:40:42 +0100 (lun., 26 oct. 2009) | 9 lines Blocked revisions 75720 via svnmerge ........ r75720 | mark.dickinson | 2009-10-26 15:39:50 +0000 (Mon, 26 Oct 2009) | 3 lines Issue #7117 (backport py3k float repr) continued: Backport pystrtod.c from py3k. ........ ................ r75723 | eric.smith | 2009-10-26 18:48:13 +0100 (lun., 26 oct. 2009) | 8 lines Blocked revisions 75722 via svnmerge ........ r75722 | eric.smith | 2009-10-26 13:46:17 -0400 (Mon, 26 Oct 2009) | 1 line Finished removing _PyOS_double_to_string, as mentioned in issue 7117. ........ ................ Modified: sandbox/trunk/newgil/ (props changed) sandbox/trunk/newgil/Lib/distutils/command/build_py.py sandbox/trunk/newgil/Lib/distutils/command/install_lib.py sandbox/trunk/newgil/Lib/distutils/errors.py sandbox/trunk/newgil/Lib/distutils/tests/test_build_py.py sandbox/trunk/newgil/Lib/distutils/tests/test_install_lib.py sandbox/trunk/newgil/Lib/distutils/tests/test_util.py sandbox/trunk/newgil/Lib/distutils/util.py sandbox/trunk/newgil/Lib/test/test_readline.py sandbox/trunk/newgil/Lib/test/test_xmlrpc.py sandbox/trunk/newgil/Misc/NEWS sandbox/trunk/newgil/Modules/arraymodule.c sandbox/trunk/newgil/Objects/longobject.c sandbox/trunk/newgil/Python/bltinmodule.c sandbox/trunk/newgil/Python/pystrtod.c sandbox/trunk/newgil/pyconfig.h.in Modified: sandbox/trunk/newgil/Lib/distutils/command/build_py.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/command/build_py.py (original) +++ sandbox/trunk/newgil/Lib/distutils/command/build_py.py Mon Oct 26 19:15:09 2009 @@ -5,6 +5,7 @@ __revision__ = "$Id$" import os +import sys from glob import glob from distutils.core import Command @@ -369,6 +370,10 @@ self.build_module(module, module_file, package) def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile prefix = self.build_lib if prefix[-1] != os.sep: Modified: sandbox/trunk/newgil/Lib/distutils/command/install_lib.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/command/install_lib.py (original) +++ sandbox/trunk/newgil/Lib/distutils/command/install_lib.py Mon Oct 26 19:15:09 2009 @@ -6,6 +6,8 @@ __revision__ = "$Id$" import os +import sys + from distutils.core import Command from distutils.errors import DistutilsOptionError @@ -115,6 +117,10 @@ return outfiles def byte_compile(self, files): + if sys.dont_write_bytecode: + self.warn('byte-compiling is disabled, skipping.') + return + from distutils.util import byte_compile # Get the "--root" directory supplied to the "install" command, Modified: sandbox/trunk/newgil/Lib/distutils/errors.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/errors.py (original) +++ sandbox/trunk/newgil/Lib/distutils/errors.py Mon Oct 26 19:15:09 2009 @@ -74,6 +74,8 @@ class DistutilsTemplateError (DistutilsError): """Syntax error in a file list template.""" +class DistutilsByteCompileError(DistutilsError): + """Byte compile error.""" # Exception classes used by the CCompiler implementation classes class CCompilerError (Exception): Modified: sandbox/trunk/newgil/Lib/distutils/tests/test_build_py.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/tests/test_build_py.py (original) +++ sandbox/trunk/newgil/Lib/distutils/tests/test_build_py.py Mon Oct 26 19:15:09 2009 @@ -89,6 +89,22 @@ os.chdir(cwd) sys.stdout = sys.__stdout__ + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = build_py(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + def test_suite(): return unittest.makeSuite(BuildPyTestCase) Modified: sandbox/trunk/newgil/Lib/distutils/tests/test_install_lib.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/tests/test_install_lib.py (original) +++ sandbox/trunk/newgil/Lib/distutils/tests/test_install_lib.py Mon Oct 26 19:15:09 2009 @@ -31,6 +31,8 @@ cmd.finalize_options() self.assertEquals(cmd.optimize, 2) + @unittest.skipUnless(not sys.dont_write_bytecode, + 'byte-compile not supported') def test_byte_compile(self): pkg_dir, dist = self.create_dist() cmd = install_lib(dist) @@ -76,6 +78,21 @@ # get_input should return 2 elements self.assertEquals(len(cmd.get_inputs()), 2) + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + pkg_dir, dist = self.create_dist() + cmd = install_lib(dist) + cmd.compile = 1 + cmd.optimize = 1 + + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + cmd.byte_compile([]) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + + self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) Modified: sandbox/trunk/newgil/Lib/distutils/tests/test_util.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/tests/test_util.py (original) +++ sandbox/trunk/newgil/Lib/distutils/tests/test_util.py Mon Oct 26 19:15:09 2009 @@ -1,7 +1,4 @@ """Tests for distutils.util.""" -# not covered yet: -# - byte_compile -# import os import sys import unittest @@ -9,11 +6,12 @@ from io import BytesIO import subprocess -from distutils.errors import DistutilsPlatformError +from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError from distutils.util import (get_platform, convert_path, change_root, check_environ, split_quoted, strtobool, rfc822_escape, get_compiler_versions, - _find_exe_version, _MAC_OS_X_LD_VERSION) + _find_exe_version, _MAC_OS_X_LD_VERSION, + byte_compile) from distutils import util from distutils.sysconfig import get_config_vars from distutils import sysconfig @@ -349,6 +347,16 @@ res = get_compiler_versions() self.assertEquals(res[2], None) + def test_dont_write_bytecode(self): + # makes sure byte_compile raise a DistutilsError + # if sys.dont_write_bytecode is True + old_dont_write_bytecode = sys.dont_write_bytecode + sys.dont_write_bytecode = True + try: + self.assertRaises(DistutilsByteCompileError, byte_compile, []) + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + def test_suite(): return unittest.makeSuite(UtilTestCase) Modified: sandbox/trunk/newgil/Lib/distutils/util.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/util.py (original) +++ sandbox/trunk/newgil/Lib/distutils/util.py Mon Oct 26 19:15:09 2009 @@ -13,6 +13,7 @@ from distutils.spawn import spawn, find_executable from distutils import log from distutils.version import LooseVersion +from distutils.errors import DistutilsByteCompileError def get_platform(): """Return a string that identifies the current platform. @@ -444,6 +445,10 @@ generated in indirect mode; unless you know what you're doing, leave it set to None. """ + # nothing is done if sys.dont_write_bytecode is True + if sys.dont_write_bytecode: + raise DistutilsByteCompileError('byte-compiling is disabled.') + # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative # approach: choose direct mode *only* if the current interpreter is Modified: sandbox/trunk/newgil/Lib/test/test_readline.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_readline.py (original) +++ sandbox/trunk/newgil/Lib/test/test_readline.py Mon Oct 26 19:15:09 2009 @@ -6,9 +6,10 @@ why the tests cover only a small subset of the interface. """ import unittest -from test.support import run_unittest +from test.support import run_unittest, import_module -import readline +# Skip tests if there is no readline module +readline = import_module('readline') class TestHistoryManipulation (unittest.TestCase): def testHistoryUpdates(self): Modified: sandbox/trunk/newgil/Lib/test/test_xmlrpc.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_xmlrpc.py (original) +++ sandbox/trunk/newgil/Lib/test/test_xmlrpc.py Mon Oct 26 19:15:09 2009 @@ -10,6 +10,8 @@ import socket import os import re +import io +import contextlib from test import support alist = [{'astring': 'foo at bar.baz.spam', @@ -713,6 +715,21 @@ else: self.fail('ProtocolError not raised') + + at contextlib.contextmanager +def captured_stdout(encoding='utf-8'): + """A variation on support.captured_stdout() which gives a text stream + having a `buffer` attribute. + """ + import io + orig_stdout = sys.stdout + sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding) + try: + yield sys.stdout + finally: + sys.stdout = orig_stdout + + class CGIHandlerTestCase(unittest.TestCase): def setUp(self): self.cgi = xmlrpc.server.CGIXMLRPCRequestHandler() @@ -725,7 +742,7 @@ env['REQUEST_METHOD'] = 'GET' # if the method is GET and no request_text is given, it runs handle_get # get sysout output - with support.captured_stdout() as data_out: + with captured_stdout(encoding=self.cgi.encoding) as data_out: self.cgi.handle_request() # parse Status header @@ -754,7 +771,7 @@ """ with support.EnvironmentVarGuard() as env, \ - support.captured_stdout() as data_out, \ + captured_stdout(encoding=self.cgi.encoding) as data_out, \ support.captured_stdin() as data_in: data_in.write(data) data_in.seek(0) Modified: sandbox/trunk/newgil/Misc/NEWS ============================================================================== --- sandbox/trunk/newgil/Misc/NEWS (original) +++ sandbox/trunk/newgil/Misc/NEWS Mon Oct 26 19:15:09 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #1087418: Boost performance of bitwise operations for longs. + - Support for AtheOS has been completely removed from the code base. It was disabled since Python 3.0. @@ -1150,6 +1152,9 @@ Library ------- +- Issue #7071: byte-compilation in Distutils is now done with respect to + sys.dont_write_bytecode. + - Issue #7066: archive_util.make_archive now restores the cwd if an error is raised. Initial patch by Ezio Melotti. Modified: sandbox/trunk/newgil/Modules/arraymodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/arraymodule.c (original) +++ sandbox/trunk/newgil/Modules/arraymodule.c Mon Oct 26 19:15:09 2009 @@ -1850,6 +1850,8 @@ /* Impossible, but needed to shut up GCC about the unhandled * enumeration value. */ + default: + PyErr_BadArgument(); return NULL; } Modified: sandbox/trunk/newgil/Objects/longobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/longobject.c (original) +++ sandbox/trunk/newgil/Objects/longobject.c Mon Oct 26 19:15:09 2009 @@ -3635,6 +3635,22 @@ return (PyObject *) maybe_small_long(z); } +/* Compute two's complement of digit vector a[0:m], writing result to + z[0:m]. The digit vector a need not be normalized, but should not + be entirely zero. a and z may point to the same digit vector. */ + +static void +v_complement(digit *z, digit *a, Py_ssize_t m) +{ + Py_ssize_t i; + digit carry = 1; + for (i = 0; i < m; ++i) { + carry += a[i] ^ PyLong_MASK; + z[i] = carry & PyLong_MASK; + carry >>= PyLong_SHIFT; + } + assert(carry == 0); +} /* Bitwise and/xor/or operations */ @@ -3643,104 +3659,122 @@ int op, /* '&', '|', '^' */ PyLongObject *b) { - digit maska, maskb; /* 0 or PyLong_MASK */ - int negz; + int nega, negb, negz; Py_ssize_t size_a, size_b, size_z, i; PyLongObject *z; - digit diga, digb; - PyObject *v; - if (Py_SIZE(a) < 0) { - a = (PyLongObject *) long_invert(a); - if (a == NULL) + /* Bitwise operations for negative numbers operate as though + on a two's complement representation. So convert arguments + from sign-magnitude to two's complement, and convert the + result back to sign-magnitude at the end. */ + + /* If a is negative, replace it by its two's complement. */ + size_a = ABS(Py_SIZE(a)); + nega = Py_SIZE(a) < 0; + if (nega) { + z = _PyLong_New(size_a); + if (z == NULL) return NULL; - maska = PyLong_MASK; + v_complement(z->ob_digit, a->ob_digit, size_a); + a = z; } - else { + else + /* Keep reference count consistent. */ Py_INCREF(a); - maska = 0; - } - if (Py_SIZE(b) < 0) { - b = (PyLongObject *) long_invert(b); - if (b == NULL) { + + /* Same for b. */ + size_b = ABS(Py_SIZE(b)); + negb = Py_SIZE(b) < 0; + if (negb) { + z = _PyLong_New(size_b); + if (z == NULL) { Py_DECREF(a); return NULL; } - maskb = PyLong_MASK; + v_complement(z->ob_digit, b->ob_digit, size_b); + b = z; } - else { + else Py_INCREF(b); - maskb = 0; + + /* Swap a and b if necessary to ensure size_a >= size_b. */ + if (size_a < size_b) { + z = a; a = b; b = z; + size_z = size_a; size_a = size_b; size_b = size_z; + negz = nega; nega = negb; negb = negz; } - negz = 0; + /* JRH: The original logic here was to allocate the result value (z) + as the longer of the two operands. However, there are some cases + where the result is guaranteed to be shorter than that: AND of two + positives, OR of two negatives: use the shorter number. AND with + mixed signs: use the positive number. OR with mixed signs: use the + negative number. + */ switch (op) { case '^': - if (maska != maskb) { - maska ^= PyLong_MASK; - negz = -1; - } + negz = nega ^ negb; + size_z = size_a; break; case '&': - if (maska && maskb) { - op = '|'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega & negb; + size_z = negb ? size_a : size_b; break; case '|': - if (maska || maskb) { - op = '&'; - maska ^= PyLong_MASK; - maskb ^= PyLong_MASK; - negz = -1; - } + negz = nega | negb; + size_z = negb ? size_b : size_a; break; + default: + PyErr_BadArgument(); + return NULL; } - /* JRH: The original logic here was to allocate the result value (z) - as the longer of the two operands. However, there are some cases - where the result is guaranteed to be shorter than that: AND of two - positives, OR of two negatives: use the shorter number. AND with - mixed signs: use the positive number. OR with mixed signs: use the - negative number. After the transformations above, op will be '&' - iff one of these cases applies, and mask will be non-0 for operands - whose length should be ignored. - */ - - size_a = Py_SIZE(a); - size_b = Py_SIZE(b); - size_z = op == '&' - ? (maska - ? size_b - : (maskb ? size_a : MIN(size_a, size_b))) - : MAX(size_a, size_b); - z = _PyLong_New(size_z); + /* We allow an extra digit if z is negative, to make sure that + the final two's complement of z doesn't overflow. */ + z = _PyLong_New(size_z + negz); if (z == NULL) { Py_DECREF(a); Py_DECREF(b); return NULL; } - for (i = 0; i < size_z; ++i) { - diga = (i < size_a ? a->ob_digit[i] : 0) ^ maska; - digb = (i < size_b ? b->ob_digit[i] : 0) ^ maskb; - switch (op) { - case '&': z->ob_digit[i] = diga & digb; break; - case '|': z->ob_digit[i] = diga | digb; break; - case '^': z->ob_digit[i] = diga ^ digb; break; - } + /* Compute digits for overlap of a and b. */ + switch(op) { + case '&': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] & b->ob_digit[i]; + break; + case '|': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] | b->ob_digit[i]; + break; + case '^': + for (i = 0; i < size_b; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ b->ob_digit[i]; + break; + default: + PyErr_BadArgument(); + return NULL; + } + + /* Copy any remaining digits of a, inverting if necessary. */ + if (op == '^' && negb) + for (; i < size_z; ++i) + z->ob_digit[i] = a->ob_digit[i] ^ PyLong_MASK; + else if (i < size_z) + memcpy(&z->ob_digit[i], &a->ob_digit[i], + (size_z-i)*sizeof(digit)); + + /* Complement result if negative. */ + if (negz) { + Py_SIZE(z) = -(Py_SIZE(z)); + z->ob_digit[size_z] = PyLong_MASK; + v_complement(z->ob_digit, z->ob_digit, size_z+1); } Py_DECREF(a); Py_DECREF(b); - z = long_normalize(z); - if (negz == 0) - return (PyObject *) maybe_small_long(z); - v = long_invert(z); - Py_DECREF(z); - return v; + return (PyObject *)maybe_small_long(long_normalize(z)); } static PyObject * Modified: sandbox/trunk/newgil/Python/bltinmodule.c ============================================================================== --- sandbox/trunk/newgil/Python/bltinmodule.c (original) +++ sandbox/trunk/newgil/Python/bltinmodule.c Mon Oct 26 19:15:09 2009 @@ -1958,6 +1958,15 @@ } break; } + /* It's tempting to use PyNumber_InPlaceAdd instead of + PyNumber_Add here, to avoid quadratic running time + when doing 'sum(list_of_lists, [])'. However, this + would produce a change in behaviour: a snippet like + + empty = [] + sum([[x] for x in range(10)], empty) + + would change the value of empty. */ temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); Modified: sandbox/trunk/newgil/Python/pystrtod.c ============================================================================== --- sandbox/trunk/newgil/Python/pystrtod.c (original) +++ sandbox/trunk/newgil/Python/pystrtod.c Mon Oct 26 19:15:09 2009 @@ -3,11 +3,8 @@ #include #include -/* _Py_parse_inf_or_nan: Attempt to parse a string of the form "nan", "inf" or - "infinity", with an optional leading sign of "+" or "-". On success, - return the NaN or Infinity as a double and set *endptr to point just beyond - the successfully parsed portion of the string. On failure, return -1.0 and - set *endptr to point to the start of the string. */ +/* Case-insensitive string match used for nan and inf detection; t should be + lower-case. Returns 1 for a successful match, 0 otherwise. */ static int case_insensitive_match(const char *s, const char *t) @@ -19,6 +16,12 @@ return *t ? 0 : 1; } +/* _Py_parse_inf_or_nan: Attempt to parse a string of the form "nan", "inf" or + "infinity", with an optional leading sign of "+" or "-". On success, + return the NaN or Infinity as a double and set *endptr to point just beyond + the successfully parsed portion of the string. On failure, return -1.0 and + set *endptr to point to the start of the string. */ + double _Py_parse_inf_or_nan(const char *p, char **endptr) { Modified: sandbox/trunk/newgil/pyconfig.h.in ============================================================================== --- sandbox/trunk/newgil/pyconfig.h.in (original) +++ sandbox/trunk/newgil/pyconfig.h.in Mon Oct 26 19:15:09 2009 @@ -12,9 +12,6 @@ support for AIX C++ shared extension modules. */ #undef AIX_GENUINE_CPLUSPLUS -/* Define this if you have AtheOS threads. */ -#undef ATHEOS_THREADS - /* Define if you have the Mach cthreads package */ #undef C_THREADS From python-checkins at python.org Mon Oct 26 20:16:47 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 26 Oct 2009 19:16:47 -0000 Subject: [Python-checkins] r75725 - in python/trunk: Modules/readline.c configure configure.in pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Mon Oct 26 20:16:46 2009 New Revision: 75725 Log: Some platforms have rl_completion_append_character but not rl_completion_suppress_append. Reported by Mark D. Modified: python/trunk/Modules/readline.c python/trunk/configure python/trunk/configure.in python/trunk/pyconfig.h.in Modified: python/trunk/Modules/readline.c ============================================================================== --- python/trunk/Modules/readline.c (original) +++ python/trunk/Modules/readline.c Mon Oct 26 20:16:46 2009 @@ -803,6 +803,8 @@ { #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER rl_completion_append_character ='\0'; +#endif +#ifdef HAVE_RL_COMPLETION_SUPPRESS_APPEND rl_completion_suppress_append = 0; #endif Py_XDECREF(begidx); Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Mon Oct 26 20:16:46 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 75658 . +# From configure.in Revision: 75664 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.7. # @@ -3865,7 +3865,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f -r conftest* +rm -f conftest* @@ -5422,7 +5422,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -5443,7 +5443,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -6541,7 +6541,7 @@ fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -7071,7 +7071,7 @@ else ac_cv_type_uid_t=no fi -rm -f -r conftest* +rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -15731,7 +15731,7 @@ else unistd_defines_pthreads=no fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -17345,7 +17345,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f -r conftest* +rm -f conftest* ;; kame) @@ -17368,7 +17368,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-glibc) @@ -17389,7 +17389,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-inet6) @@ -17427,7 +17427,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; v6d) @@ -17450,7 +17450,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f -r conftest* +rm -f conftest* ;; zeta) @@ -17472,7 +17472,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; esac @@ -25580,7 +25580,26 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 +_ACEOF + +fi +rm -f conftest* fi @@ -25850,7 +25869,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Mon Oct 26 20:16:46 2009 @@ -3674,6 +3674,10 @@ [readline/readline.h], AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) fi # check for readline 4.0 Modified: python/trunk/pyconfig.h.in ============================================================================== --- python/trunk/pyconfig.h.in (original) +++ python/trunk/pyconfig.h.in Mon Oct 26 20:16:46 2009 @@ -529,6 +529,9 @@ /* Define if you have readline 4.2 */ #undef HAVE_RL_COMPLETION_MATCHES +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK From python-checkins at python.org Mon Oct 26 20:22:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 26 Oct 2009 19:22:15 -0000 Subject: [Python-checkins] r75726 - in python/branches/py3k: Modules/readline.c configure configure.in pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Mon Oct 26 20:22:14 2009 New Revision: 75726 Log: Merged revisions 75725 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75725 | antoine.pitrou | 2009-10-26 20:16:46 +0100 (lun., 26 oct. 2009) | 4 lines Some platforms have rl_completion_append_character but not rl_completion_suppress_append. Reported by Mark D. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/readline.c python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/pyconfig.h.in Modified: python/branches/py3k/Modules/readline.c ============================================================================== --- python/branches/py3k/Modules/readline.c (original) +++ python/branches/py3k/Modules/readline.c Mon Oct 26 20:22:14 2009 @@ -802,6 +802,8 @@ { #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER rl_completion_append_character ='\0'; +#endif +#ifdef HAVE_RL_COMPLETION_SUPPRESS_APPEND rl_completion_suppress_append = 0; #endif Py_XDECREF(begidx); Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Mon Oct 26 20:22:14 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 75678 . +# From configure.in Revision: 75684 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -25056,6 +25056,25 @@ fi rm -f conftest* + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 +_ACEOF + +fi +rm -f conftest* + fi # check for readline 4.0 Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Mon Oct 26 20:22:14 2009 @@ -3528,6 +3528,10 @@ [readline/readline.h], AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) fi # check for readline 4.0 Modified: python/branches/py3k/pyconfig.h.in ============================================================================== --- python/branches/py3k/pyconfig.h.in (original) +++ python/branches/py3k/pyconfig.h.in Mon Oct 26 20:22:14 2009 @@ -533,6 +533,9 @@ /* Define if you have readline 4.2 */ #undef HAVE_RL_COMPLETION_MATCHES +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK From python-checkins at python.org Mon Oct 26 20:32:51 2009 From: python-checkins at python.org (antoine.pitrou) Date: Mon, 26 Oct 2009 19:32:51 -0000 Subject: [Python-checkins] r75727 - in python/branches/release31-maint: Modules/readline.c configure configure.in pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Mon Oct 26 20:32:51 2009 New Revision: 75727 Log: Merged revisions 75726 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75726 | antoine.pitrou | 2009-10-26 20:22:14 +0100 (lun., 26 oct. 2009) | 10 lines Merged revisions 75725 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75725 | antoine.pitrou | 2009-10-26 20:16:46 +0100 (lun., 26 oct. 2009) | 4 lines Some platforms have rl_completion_append_character but not rl_completion_suppress_append. Reported by Mark D. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/readline.c python/branches/release31-maint/configure python/branches/release31-maint/configure.in python/branches/release31-maint/pyconfig.h.in Modified: python/branches/release31-maint/Modules/readline.c ============================================================================== --- python/branches/release31-maint/Modules/readline.c (original) +++ python/branches/release31-maint/Modules/readline.c Mon Oct 26 20:32:51 2009 @@ -760,6 +760,8 @@ { #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER rl_completion_append_character ='\0'; +#endif +#ifdef HAVE_RL_COMPLETION_SUPPRESS_APPEND rl_completion_suppress_append = 0; #endif Py_XDECREF(begidx); Modified: python/branches/release31-maint/configure ============================================================================== --- python/branches/release31-maint/configure (original) +++ python/branches/release31-maint/configure Mon Oct 26 20:32:51 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74747 . +# From configure.in Revision: 74980 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.1. # @@ -3802,7 +3802,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f -r conftest* +rm -f conftest* @@ -5350,7 +5350,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -5371,7 +5371,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -6469,7 +6469,7 @@ fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -6999,7 +6999,7 @@ else ac_cv_type_uid_t=no fi -rm -f -r conftest* +rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -14409,7 +14409,7 @@ else unistd_defines_pthreads=no fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -15877,7 +15877,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f -r conftest* +rm -f conftest* ;; kame) @@ -15900,7 +15900,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-glibc) @@ -15921,7 +15921,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-inet6) @@ -15959,7 +15959,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; v6d) @@ -15982,7 +15982,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f -r conftest* +rm -f conftest* ;; zeta) @@ -16004,7 +16004,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; esac @@ -23989,7 +23989,26 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 +_ACEOF + +fi +rm -f conftest* fi @@ -24259,7 +24278,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi Modified: python/branches/release31-maint/configure.in ============================================================================== --- python/branches/release31-maint/configure.in (original) +++ python/branches/release31-maint/configure.in Mon Oct 26 20:32:51 2009 @@ -3568,6 +3568,10 @@ [readline/readline.h], AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) fi # check for readline 4.0 Modified: python/branches/release31-maint/pyconfig.h.in ============================================================================== --- python/branches/release31-maint/pyconfig.h.in (original) +++ python/branches/release31-maint/pyconfig.h.in Mon Oct 26 20:32:51 2009 @@ -524,6 +524,9 @@ /* Define if you have readline 4.2 */ #undef HAVE_RL_COMPLETION_MATCHES +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK From python-checkins at python.org Mon Oct 26 20:59:24 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 19:59:24 -0000 Subject: [Python-checkins] r75728 - in python/trunk/Modules/_io: _iomodule.h bufferedio.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 20:59:23 2009 New Revision: 75728 Log: Use correct conversion specifier and length modifier when printing an integer of type off_t. Also, don't assume that long long is available. Modified: python/trunk/Modules/_io/_iomodule.h python/trunk/Modules/_io/bufferedio.c Modified: python/trunk/Modules/_io/_iomodule.h ============================================================================== --- python/trunk/Modules/_io/_iomodule.h (original) +++ python/trunk/Modules/_io/_iomodule.h Mon Oct 26 20:59:23 2009 @@ -83,26 +83,30 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN +# define PY_PRIdOFF "ld" +#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +# define PY_PRIdOFF "zd" #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/trunk/Modules/_io/bufferedio.c ============================================================================== --- python/trunk/Modules/_io/bufferedio.c (original) +++ python/trunk/Modules/_io/bufferedio.c Mon Oct 26 20:59:23 2009 @@ -580,7 +580,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; @@ -612,7 +613,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; From python-checkins at python.org Mon Oct 26 21:02:55 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 20:02:55 -0000 Subject: [Python-checkins] r75729 - in python/branches/py3k: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 21:02:55 2009 New Revision: 75729 Log: Merged revisions 75728 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75728 | mark.dickinson | 2009-10-26 19:59:23 +0000 (Mon, 26 Oct 2009) | 3 lines Use correct conversion specifier and length modifier when printing an integer of type off_t. Also, don't assume that long long is available. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/_iomodule.h python/branches/py3k/Modules/_io/bufferedio.c Modified: python/branches/py3k/Modules/_io/_iomodule.h ============================================================================== --- python/branches/py3k/Modules/_io/_iomodule.h (original) +++ python/branches/py3k/Modules/_io/_iomodule.h Mon Oct 26 21:02:55 2009 @@ -78,26 +78,30 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN +# define PY_PRIdOFF "ld" +#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +# define PY_PRIdOFF "zd" #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/py3k/Modules/_io/bufferedio.c ============================================================================== --- python/branches/py3k/Modules/_io/bufferedio.c (original) +++ python/branches/py3k/Modules/_io/bufferedio.c Mon Oct 26 21:02:55 2009 @@ -580,7 +580,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; @@ -612,7 +613,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; From python-checkins at python.org Mon Oct 26 22:09:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 21:09:09 -0000 Subject: [Python-checkins] r75730 - python/trunk/Include/pystrtod.h Message-ID: Author: mark.dickinson Date: Mon Oct 26 22:09:09 2009 New Revision: 75730 Log: Issue #7117: Backport missing pystrtod.h declarations from py3k. Modified: python/trunk/Include/pystrtod.h Modified: python/trunk/Include/pystrtod.h ============================================================================== --- python/trunk/Include/pystrtod.h (original) +++ python/trunk/Include/pystrtod.h Mon Oct 26 22:09:09 2009 @@ -12,6 +12,9 @@ /* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */ PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d); +PyAPI_FUNC(double) PyOS_string_to_double(const char *str, + char **endptr, + PyObject *overflow_exception); /* The caller is responsible for calling PyMem_Free to free the buffer that's is returned. */ @@ -21,6 +24,8 @@ int flags, int *type); +PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); + /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ #define Py_DTSF_SIGN 0x01 /* always add the sign */ From python-checkins at python.org Mon Oct 26 22:11:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 21:11:21 -0000 Subject: [Python-checkins] r75731 - in python/trunk: Lib/test/test_float.py Objects/floatobject.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 22:11:20 2009 New Revision: 75731 Log: Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in floatobject.c. Also, remove limitation on length of unicode inputs to float(). Modified: python/trunk/Lib/test/test_float.py python/trunk/Objects/floatobject.c Modified: python/trunk/Lib/test/test_float.py ============================================================================== --- python/trunk/Lib/test/test_float.py (original) +++ python/trunk/Lib/test/test_float.py Mon Oct 26 22:11:20 2009 @@ -31,8 +31,6 @@ if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) - # Implementation limitation in PyFloat_FromString() - self.assertRaises(ValueError, float, unicode("1"*10000)) @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): Modified: python/trunk/Objects/floatobject.c ============================================================================== --- python/trunk/Objects/floatobject.c (original) +++ python/trunk/Objects/floatobject.c Mon Oct 26 22:11:20 2009 @@ -181,9 +181,10 @@ double x; char buffer[256]; /* for errors */ #ifdef Py_USING_UNICODE - char s_buffer[256]; /* for objects convertible to a char buffer */ + char *s_buffer = NULL; #endif Py_ssize_t len; + PyObject *result = NULL; if (pend) *pend = NULL; @@ -193,23 +194,21 @@ } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "Unicode float() literal too long to convert"); - return NULL; - } + s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v)+1); + if (s_buffer == NULL) + return PyErr_NoMemory(); if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, NULL)) - return NULL; + goto error; s = s_buffer; len = strlen(s); } #endif else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, - "float() argument must be a string or a number"); + "float() argument must be a string or a number"); return NULL; } last = s + len; @@ -219,36 +218,26 @@ /* We don't care about overflow or underflow. If the platform * supports them, infinities and signed zeroes (on underflow) are * fine. */ - errno = 0; - PyFPE_START_PROTECT("strtod", return NULL) - x = PyOS_ascii_strtod(s, (char **)&end); - PyFPE_END_PROTECT(x) - if (end == s) { - if (errno == ENOMEM) - PyErr_NoMemory(); - else { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for float(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - } - return NULL; - } - /* Since end != s, the platform made *some* kind of sense out - of the input. Trust it. */ + x = PyOS_string_to_double(s, (char **)&end, NULL); + if (x == -1.0 && PyErr_Occurred()) + goto error; while (Py_ISSPACE(*end)) end++; - if (end != last) { - if (*end == '\0') - PyErr_SetString(PyExc_ValueError, - "null byte in argument for float()"); - else { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for float(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - } - return NULL; + if (end == last) + result = PyFloat_FromDouble(x); + else { + PyOS_snprintf(buffer, sizeof(buffer), + "invalid literal for float(): %.200s", s); + PyErr_SetString(PyExc_ValueError, buffer); + result = NULL; } - return PyFloat_FromDouble(x); + + error: +#ifdef Py_USING_UNICODE + if (s_buffer) + PyMem_FREE(s_buffer); +#endif + return result; } static void From python-checkins at python.org Mon Oct 26 22:12:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 21:12:51 -0000 Subject: [Python-checkins] r75732 - python/branches/py3k/Objects/floatobject.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 22:12:50 2009 New Revision: 75732 Log: Fix extra-long line; also makes py3k match trunk here. Modified: python/branches/py3k/Objects/floatobject.c Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Mon Oct 26 22:12:50 2009 @@ -183,7 +183,7 @@ } else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, - "float() argument must be a string or a number"); + "float() argument must be a string or a number"); return NULL; } last = s + len; From python-checkins at python.org Mon Oct 26 22:13:15 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 21:13:15 -0000 Subject: [Python-checkins] r75733 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Mon Oct 26 22:13:15 2009 New Revision: 75733 Log: Blocked revisions 75730-75731 via svnmerge ........ r75730 | mark.dickinson | 2009-10-26 21:09:09 +0000 (Mon, 26 Oct 2009) | 2 lines Issue #7117: Backport missing pystrtod.h declarations from py3k. ........ r75731 | mark.dickinson | 2009-10-26 21:11:20 +0000 (Mon, 26 Oct 2009) | 4 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in floatobject.c. Also, remove limitation on length of unicode inputs to float(). ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 26 22:25:54 2009 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 26 Oct 2009 21:25:54 -0000 Subject: [Python-checkins] r75734 - in sandbox/trunk/2to3/lib2to3: fixes/fix_map.py tests/test_fixers.py Message-ID: Author: benjamin.peterson Date: Mon Oct 26 22:25:53 2009 New Revision: 75734 Log: warn on map(None, ...) with more than 2 arguments #7203 Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_map.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Mon Oct 26 22:25:53 2009 @@ -50,7 +50,7 @@ | power< 'map' - args=trailer< '(' [any] ')' > + args=trailer< '(' [arglist=any] ')' > > """ @@ -73,6 +73,14 @@ if "map_none" in results: new = results["arg"].clone() else: + if "arglist" in results: + args = results["arglist"] + if args.type == syms.arglist and \ + args.children[0].type == token.NAME and \ + args.children[0].value == "None": + self.warning(node, "cannot convert map(None, ...) " + "with multiple arguments") + return if in_special_context(node): return None new = node.clone() Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py (original) +++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Mon Oct 26 22:25:53 2009 @@ -2834,6 +2834,11 @@ a = """x = list(map(f, 'abc')) # foo""" self.check(b, a) + def test_None_with_multiple_arguments(self): + s = """x = map(None, a, b, c)""" + self.warns_unchanged(s, "cannot convert map(None, ...) with " + "multiple arguments") + def test_map_basic(self): b = """x = map(f, 'abc')""" a = """x = list(map(f, 'abc'))""" @@ -2847,10 +2852,6 @@ a = """x = list('abc')""" self.check(b, a) - b = """x = map(None, 'abc', 'def')""" - a = """x = list(map(None, 'abc', 'def'))""" - self.check(b, a) - b = """x = map(lambda x: x+1, range(4))""" a = """x = [x+1 for x in range(4)]""" self.check(b, a) From python-checkins at python.org Mon Oct 26 22:28:25 2009 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 26 Oct 2009 21:28:25 -0000 Subject: [Python-checkins] r75735 - sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Message-ID: Author: benjamin.peterson Date: Mon Oct 26 22:28:25 2009 New Revision: 75735 Log: remove unused result Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_map.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Mon Oct 26 22:28:25 2009 @@ -49,8 +49,7 @@ > | power< - 'map' - args=trailer< '(' [arglist=any] ')' > + 'map' trailer< '(' [arglist=any] ')' > > """ From python-checkins at python.org Mon Oct 26 22:29:03 2009 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 26 Oct 2009 21:29:03 -0000 Subject: [Python-checkins] r75736 - sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Message-ID: Author: benjamin.peterson Date: Mon Oct 26 22:29:02 2009 New Revision: 75736 Log: using get() here is a bit pointless Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_map.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Mon Oct 26 22:29:02 2009 @@ -65,9 +65,9 @@ new.prefix = u"" new = Call(Name(u"list"), [new]) elif "map_lambda" in results: - new = ListComp(results.get("xp").clone(), - results.get("fp").clone(), - results.get("it").clone()) + new = ListComp(results["xp"].clone(), + results["fp"].clone(), + results["it"].clone()) else: if "map_none" in results: new = results["arg"].clone() From ncoghlan at gmail.com Mon Oct 26 22:39:56 2009 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 27 Oct 2009 07:39:56 +1000 Subject: [Python-checkins] r75714 - python/trunk/Python/bltinmodule.c In-Reply-To: <4ae5aff2.0767f10a.06bd.ffffca23SMTPIN_ADDED@mx.google.com> References: <4ae5aff2.0767f10a.06bd.ffffca23SMTPIN_ADDED@mx.google.com> Message-ID: <4AE6172C.7030202@gmail.com> mark.dickinson wrote: > Modified: python/trunk/Python/bltinmodule.c > ============================================================================== > --- python/trunk/Python/bltinmodule.c (original) > +++ python/trunk/Python/bltinmodule.c Mon Oct 26 15:18:44 2009 > @@ -2350,6 +2350,15 @@ > } > break; > } > + /* It's tempting to use PyNumber_InPlaceAdd instead of > + PyNumber_Add here, to avoid quadratic running time > + when doing 'sum(list_of_lists, [])'. However, this > + would produce a change in behaviour: a snippet like > + > + empty = [] > + sum([[x] for x in range(10)], empty) > + > + would change the value of empty. */ > temp = PyNumber_Add(result, item); > Py_DECREF(result); > Py_DECREF(item); Could you get the best of both worlds by switching to in-place add only after the first pass through the addition loop? Then [0]+empty would create a new list that is private to the sum() call, with further results accumulated in that new object to avoid the quadratic behavour. There may be other corner cases that would make even that a bad idea, but it would at least avoid the issue mentioned in the new comment. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- From python-checkins at python.org Mon Oct 26 22:51:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 21:51:18 -0000 Subject: [Python-checkins] r75737 - in python/branches/py3k: Lib/test/test_complex.py Misc/NEWS Objects/complexobject.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 22:51:18 2009 New Revision: 75737 Log: Remove length limitation on string arguments to complex() Modified: python/branches/py3k/Lib/test/test_complex.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/complexobject.c Modified: python/branches/py3k/Lib/test/test_complex.py ============================================================================== --- python/branches/py3k/Lib/test/test_complex.py (original) +++ python/branches/py3k/Lib/test/test_complex.py Mon Oct 26 22:51:18 2009 @@ -284,7 +284,6 @@ self.assertRaises(ValueError, complex, "1+2j)") self.assertRaises(ValueError, complex, "1+(2j)") self.assertRaises(ValueError, complex, "(1+2j)123") - self.assertRaises(ValueError, complex, "1"*500) self.assertRaises(ValueError, complex, "x") self.assertRaises(ValueError, complex, "1j+2") self.assertRaises(ValueError, complex, "1e1ej") @@ -295,6 +294,9 @@ self.assertRaises(ValueError, complex, "1.11.1j") self.assertRaises(ValueError, complex, "1e1.1j") + # check that complex accepts long unicode strings + self.assertEqual(type(complex("1"*500)), complex) + class EvilExc(Exception): pass Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Oct 26 22:51:18 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Remove length limitation when constructing a complex number from a string. + - Issue #1087418: Boost performance of bitwise operations for longs. - Support for AtheOS has been completely removed from the code base. It was Modified: python/branches/py3k/Objects/complexobject.c ============================================================================== --- python/branches/py3k/Objects/complexobject.c (original) +++ python/branches/py3k/Objects/complexobject.c Mon Oct 26 22:51:18 2009 @@ -740,20 +740,20 @@ char *end; double x=0.0, y=0.0, z; int got_bracket=0; - char s_buffer[256]; + char *s_buffer = NULL; Py_ssize_t len; if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "complex() literal too large to convert"); - return NULL; - } + s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v) + 1); + if (s_buffer == NULL) + return PyErr_NoMemory(); if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, - NULL)) + NULL)) { + PyMem_FREE(s_buffer); return NULL; + } s = s_buffer; len = strlen(s); } @@ -870,9 +870,13 @@ if (s-start != len) goto parse_error; + if (s_buffer) + PyMem_FREE(s_buffer); return complex_subtype_from_doubles(type, x, y); parse_error: + if (s_buffer) + PyMem_FREE(s_buffer); PyErr_SetString(PyExc_ValueError, "complex() arg is a malformed string"); return NULL; From python-checkins at python.org Mon Oct 26 23:05:06 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 22:05:06 -0000 Subject: [Python-checkins] r75738 - python/branches/py3k/Objects/complexobject.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 23:05:06 2009 New Revision: 75738 Log: Make sure memory is freed on error in complex_subtype_from_string. Modified: python/branches/py3k/Objects/complexobject.c Modified: python/branches/py3k/Objects/complexobject.c ============================================================================== --- python/branches/py3k/Objects/complexobject.c (original) +++ python/branches/py3k/Objects/complexobject.c Mon Oct 26 23:05:06 2009 @@ -750,10 +750,8 @@ if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, - NULL)) { - PyMem_FREE(s_buffer); - return NULL; - } + NULL)) + goto error; s = s_buffer; len = strlen(s); } @@ -802,7 +800,7 @@ if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) { /* all 4 forms starting with land here */ @@ -815,7 +813,7 @@ if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) /* j */ @@ -875,10 +873,11 @@ return complex_subtype_from_doubles(type, x, y); parse_error: - if (s_buffer) - PyMem_FREE(s_buffer); PyErr_SetString(PyExc_ValueError, "complex() arg is a malformed string"); + error: + if (s_buffer) + PyMem_FREE(s_buffer); return NULL; } From dickinsm at gmail.com Mon Oct 26 23:23:39 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 26 Oct 2009 22:23:39 +0000 Subject: [Python-checkins] r75714 - python/trunk/Python/bltinmodule.c In-Reply-To: <4AE6172C.7030202@gmail.com> References: <4ae5aff2.0767f10a.06bd.ffffca23SMTPIN_ADDED@mx.google.com> <4AE6172C.7030202@gmail.com> Message-ID: <5c6f2a5d0910261523k246c04bcqd3eac4c5981b867f@mail.gmail.com> On Mon, Oct 26, 2009 at 9:39 PM, Nick Coghlan wrote: > mark.dickinson wrote: >> Modified: python/trunk/Python/bltinmodule.c >> ============================================================================== >> --- python/trunk/Python/bltinmodule.c (original) >> +++ python/trunk/Python/bltinmodule.c Mon Oct 26 15:18:44 2009 >> @@ -2350,6 +2350,15 @@ >> ? ? ? ? ? ? ? ? ? ? ? } >> ? ? ? ? ? ? ? ? ? ? ? break; >> ? ? ? ? ? ? ? } >> + ? ? ? ? ? ? /* It's tempting to use PyNumber_InPlaceAdd instead of >> + ? ? ? ? ? ? ? ?PyNumber_Add here, to avoid quadratic running time >> + ? ? ? ? ? ? ? ?when doing 'sum(list_of_lists, [])'. ?However, this >> + ? ? ? ? ? ? ? ?would produce a change in behaviour: a snippet like >> + >> + ? ? ? ? ? ? ? ? ?empty = [] >> + ? ? ? ? ? ? ? ? ?sum([[x] for x in range(10)], empty) >> + >> + ? ? ? ? ? ? ? ?would change the value of empty. */ >> ? ? ? ? ? ? ? temp = PyNumber_Add(result, item); >> ? ? ? ? ? ? ? Py_DECREF(result); >> ? ? ? ? ? ? ? Py_DECREF(item); > > Could you get the best of both worlds by switching to in-place add only > after the first pass through the addition loop? Quite possibly yes; I think that's a discussion for the issue tracker somewhere, though. I added this comment because (1) it took me a long time to figure out why making this change wasn't a good idea, and (2) I later discovered I wasn't alone: this exact change *was* made back in October 2003 [1], and then had to be reverted. So it seemed a good idea to make sure no-one else had the same 'bright idea'. Various alternatives were considered back then too, but I don't think anyone found a solution that was universally acceptable. Mark [1] http://mail.python.org/pipermail/python-dev/2003-October/039511.html From python-checkins at python.org Mon Oct 26 23:28:15 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 22:28:15 -0000 Subject: [Python-checkins] r75739 - in python/trunk: Lib/test/test_complex.py Misc/NEWS Objects/complexobject.c Message-ID: Author: mark.dickinson Date: Mon Oct 26 23:28:14 2009 New Revision: 75739 Log: Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in complexobject.c. Also remove length restriction on unicode inputs to the complex constructor. Modified: python/trunk/Lib/test/test_complex.py python/trunk/Misc/NEWS python/trunk/Objects/complexobject.c Modified: python/trunk/Lib/test/test_complex.py ============================================================================== --- python/trunk/Lib/test/test_complex.py (original) +++ python/trunk/Lib/test/test_complex.py Mon Oct 26 23:28:14 2009 @@ -306,7 +306,6 @@ self.assertRaises(ValueError, complex, "1+(2j)") self.assertRaises(ValueError, complex, "(1+2j)123") if test_support.have_unicode: - self.assertRaises(ValueError, complex, unicode("1"*500)) self.assertRaises(ValueError, complex, unicode("x")) self.assertRaises(ValueError, complex, "1j+2") self.assertRaises(ValueError, complex, "1e1ej") @@ -317,6 +316,10 @@ self.assertRaises(ValueError, complex, "1.11.1j") self.assertRaises(ValueError, complex, "1e1.1j") + if test_support.have_unicode: + # check that complex accepts long unicode strings + self.assertEqual(type(complex(unicode("1"*500))), complex) + class EvilExc(Exception): pass Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Oct 26 23:28:14 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Remove length limitation when constructing a complex number from a + unicode string. + - Removed _PyOS_double_to_string. Use PyOS_double_to_string instead. This is in preparation for (but not strictly related to) issue #7117, short float repr. Modified: python/trunk/Objects/complexobject.c ============================================================================== --- python/trunk/Objects/complexobject.c (original) +++ python/trunk/Objects/complexobject.c Mon Oct 26 23:28:14 2009 @@ -921,7 +921,7 @@ double x=0.0, y=0.0, z; int got_bracket=0; #ifdef Py_USING_UNICODE - char s_buffer[256]; + char *s_buffer = NULL; #endif Py_ssize_t len; @@ -931,16 +931,14 @@ } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "complex() literal too large to convert"); - return NULL; - } + s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v)+1); + if (s_buffer == NULL) + return PyErr_NoMemory(); if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, NULL)) - return NULL; + goto error; s = s_buffer; len = strlen(s); } @@ -985,21 +983,26 @@ */ /* first look for forms starting with */ - errno = 0; - z = PyOS_ascii_strtod(s, &end); - if (end == s && errno == ENOMEM) - return PyErr_NoMemory(); - + z = PyOS_string_to_double(s, &end, NULL); + if (z == -1.0 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_ValueError)) + PyErr_Clear(); + else + goto error; + } if (end != s) { /* all 4 forms starting with land here */ s = end; if (*s == '+' || *s == '-') { /* j | j */ x = z; - errno = 0; - y = PyOS_ascii_strtod(s, &end); - if (end == s && errno == ENOMEM) - return PyErr_NoMemory(); + y = PyOS_string_to_double(s, &end, NULL); + if (y == -1.0 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_ValueError)) + PyErr_Clear(); + else + goto error; + } if (end != s) /* j */ s = end; @@ -1053,11 +1056,21 @@ if (s-start != len) goto parse_error; + +#ifdef Py_USING_UNICODE + if (s_buffer) + PyMem_FREE(s_buffer); +#endif return complex_subtype_from_doubles(type, x, y); parse_error: PyErr_SetString(PyExc_ValueError, "complex() arg is a malformed string"); + error: +#ifdef Py_USING_UNICODE + if (s_buffer) + PyMem_FREE(s_buffer); +#endif return NULL; } From python-checkins at python.org Mon Oct 26 23:29:03 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 22:29:03 -0000 Subject: [Python-checkins] r75740 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Mon Oct 26 23:29:02 2009 New Revision: 75740 Log: Blocked revisions 75739 via svnmerge ........ r75739 | mark.dickinson | 2009-10-26 22:28:14 +0000 (Mon, 26 Oct 2009) | 5 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in complexobject.c. Also remove length restriction on unicode inputs to the complex constructor. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Mon Oct 26 23:48:33 2009 From: python-checkins at python.org (mark.dickinson) Date: Mon, 26 Oct 2009 22:48:33 -0000 Subject: [Python-checkins] r75741 - python/branches/py3k/Lib/test/test_telnetlib.py Message-ID: Author: mark.dickinson Date: Mon Oct 26 23:48:32 2009 New Revision: 75741 Log: Issue #7207: Fix race condition in telnetlib test; should stop test failures on OS X 10.6. Modified: python/branches/py3k/Lib/test/test_telnetlib.py Modified: python/branches/py3k/Lib/test/test_telnetlib.py ============================================================================== --- python/branches/py3k/Lib/test/test_telnetlib.py (original) +++ python/branches/py3k/Lib/test/test_telnetlib.py Mon Oct 26 23:48:32 2009 @@ -12,12 +12,14 @@ HOST = support.HOST EOF_sigil = object() -def server(evt, serv, dataq=None): - """ Open a tcp server in three steps +def server(evt, serv, dataq=None, test_done=None): + """ Open a tcp server in four steps 1) set evt to true to let the parent know we are ready 2) [optional] if is not False, write the list of data from dataq.get() to the socket. - 3) set evt to true to let the parent know we're done + 3) [optional] if test_done is not None, it's an event; wait + for parent to set test_done before closing connection + 4) set evt to true to let the parent know we're done """ serv.listen(5) evt.set() @@ -39,6 +41,8 @@ except socket.timeout: pass finally: + if test_done is not None: + test_done.wait() serv.close() evt.set() @@ -324,8 +328,24 @@ class WriteTests(TestCase): '''The only thing that write does is replace each tl.IAC for tl.IAC+tl.IAC''' - setUp = _read_setUp - tearDown = _read_tearDown + def setUp(self): + self.evt = threading.Event() + self.test_done = threading.Event() + self.dataq = queue.Queue() + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.settimeout(3) + self.port = support.bind_port(self.sock) + self.thread = threading.Thread(target=server, args=( + self.evt, self.sock, self.dataq, self.test_done)) + self.thread.start() + self.evt.wait() + self.evt.clear() + time.sleep(.1) + + def tearDown(self): + self.test_done.set() + self.evt.wait() + self.thread.join() def _test_write(self, data): self.telnet.sock._raw_sent = b'' From python-checkins at python.org Mon Oct 26 23:51:17 2009 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 26 Oct 2009 22:51:17 -0000 Subject: [Python-checkins] r75742 - python/trunk/Lib/test/test_strptime.py Message-ID: Author: benjamin.peterson Date: Mon Oct 26 23:51:16 2009 New Revision: 75742 Log: use 'is' instead of id() Modified: python/trunk/Lib/test/test_strptime.py Modified: python/trunk/Lib/test/test_strptime.py ============================================================================== --- python/trunk/Lib/test/test_strptime.py (original) +++ python/trunk/Lib/test/test_strptime.py Mon Oct 26 23:51:16 2009 @@ -493,9 +493,9 @@ _strptime._strptime_time("10", "%d") _strptime._strptime_time("2005", "%Y") _strptime._TimeRE_cache.locale_time.lang = "Ni" - original_time_re = id(_strptime._TimeRE_cache) + original_time_re = _strptime._TimeRE_cache _strptime._strptime_time("10", "%d") - self.assertNotEqual(original_time_re, id(_strptime._TimeRE_cache)) + self.assertIsNot(original_time_re, _strptime._TimeRE_cache) self.assertEqual(len(_strptime._regex_cache), 1) def test_regex_cleanup(self): @@ -514,11 +514,10 @@ def test_new_localetime(self): # A new LocaleTime instance should be created when a new TimeRE object # is created. - locale_time_id = id(_strptime._TimeRE_cache.locale_time) + locale_time_id = _strptime._TimeRE_cache.locale_time _strptime._TimeRE_cache.locale_time.lang = "Ni" _strptime._strptime_time("10", "%d") - self.assertNotEqual(locale_time_id, - id(_strptime._TimeRE_cache.locale_time)) + self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) def test_TimeRE_recreation(self): # The TimeRE instance should be recreated upon changing the locale. @@ -530,15 +529,15 @@ try: _strptime._strptime_time('10', '%d') # Get id of current cache object. - first_time_re_id = id(_strptime._TimeRE_cache) + first_time_re = _strptime._TimeRE_cache try: # Change the locale and force a recreation of the cache. locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8')) _strptime._strptime_time('10', '%d') # Get the new cache object's id. - second_time_re_id = id(_strptime._TimeRE_cache) + second_time_re = _strptime._TimeRE_cache # They should not be equal. - self.assertNotEqual(first_time_re_id, second_time_re_id) + self.assertIsNot(first_time_re, second_time_re) # Possible test locale is not supported while initial locale is. # If this is the case just suppress the exception and fall-through # to the reseting to the original locale. From g.brandl at gmx.net Tue Oct 27 10:28:04 2009 From: g.brandl at gmx.net (Georg Brandl) Date: Tue, 27 Oct 2009 10:28:04 +0100 Subject: [Python-checkins] r75734 - in sandbox/trunk/2to3/lib2to3: fixes/fix_map.py tests/test_fixers.py In-Reply-To: <28987.6888193705$1256592372@news.gmane.org> References: <28987.6888193705$1256592372@news.gmane.org> Message-ID: benjamin.peterson schrieb: > Author: benjamin.peterson > Date: Mon Oct 26 22:25:53 2009 > New Revision: 75734 > > Log: > warn on map(None, ...) with more than 2 arguments #7203 > > > Modified: > sandbox/trunk/2to3/lib2to3/fixes/fix_map.py > sandbox/trunk/2to3/lib2to3/tests/test_fixers.py > > Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py > ============================================================================== > --- sandbox/trunk/2to3/lib2to3/fixes/fix_map.py (original) > +++ sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Mon Oct 26 22:25:53 2009 > @@ -50,7 +50,7 @@ > | > power< > 'map' > - args=trailer< '(' [any] ')' > > + args=trailer< '(' [arglist=any] ')' > > > > """ > > @@ -73,6 +73,14 @@ > if "map_none" in results: > new = results["arg"].clone() > else: > + if "arglist" in results: > + args = results["arglist"] > + if args.type == syms.arglist and \ > + args.children[0].type == token.NAME and \ > + args.children[0].value == "None": > + self.warning(node, "cannot convert map(None, ...) " > + "with multiple arguments") Maybe a short explanation *why* would be a good idea... Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. From nnorwitz at gmail.com Tue Oct 27 11:46:22 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 27 Oct 2009 05:46:22 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091027104622.GA20974@python.psfb.org> More important issues: ---------------------- test_distutils leaked [0, 0, 25] references, sum=25 Less important issues: ---------------------- test_file2k leaked [-78, 0, 84] references, sum=6 test_smtplib leaked [-181, 0, 5] references, sum=-176 test_threading leaked [48, 48, 48] references, sum=144 test_urllib2_localnet leaked [0, 284, -284] references, sum=0 From python-checkins at python.org Tue Oct 27 12:32:11 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 11:32:11 -0000 Subject: [Python-checkins] r75743 - python/trunk/Modules/cPickle.c Message-ID: Author: eric.smith Date: Tue Oct 27 12:32:11 2009 New Revision: 75743 Log: Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in cPickle as part of short float repr. Modified: python/trunk/Modules/cPickle.c Modified: python/trunk/Modules/cPickle.c ============================================================================== --- python/trunk/Modules/cPickle.c (original) +++ python/trunk/Modules/cPickle.c Tue Oct 27 12:32:11 2009 @@ -3552,11 +3552,11 @@ if (len < 2) return bad_readline(); if (!( s=pystrndup(s,len))) return -1; - errno = 0; - d = PyOS_ascii_strtod(s, &endptr); + d = PyOS_string_to_double(s, &endptr, PyExc_OverflowError); - if ((errno == ERANGE && !(fabs(d) <= 1.0)) || - (endptr[0] != '\n') || (endptr[1] != '\0')) { + if (d == -1.0 && PyErr_Occurred()) { + goto finally; + } else if ((endptr[0] != '\n') || (endptr[1] != '\0')) { PyErr_SetString(PyExc_ValueError, "could not convert string to float"); goto finally; From python-checkins at python.org Tue Oct 27 12:36:44 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 11:36:44 -0000 Subject: [Python-checkins] r75744 - python/branches/py3k Message-ID: Author: eric.smith Date: Tue Oct 27 12:36:44 2009 New Revision: 75744 Log: Blocked revisions 75743 via svnmerge ........ r75743 | eric.smith | 2009-10-27 07:32:11 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in cPickle as part of short float repr. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Oct 27 13:12:44 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 12:12:44 -0000 Subject: [Python-checkins] r75745 - python/trunk/Modules/stropmodule.c Message-ID: Author: eric.smith Date: Tue Oct 27 13:12:44 2009 New Revision: 75745 Log: Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr. Modified: python/trunk/Modules/stropmodule.c Modified: python/trunk/Modules/stropmodule.c ============================================================================== --- python/trunk/Modules/stropmodule.c (original) +++ python/trunk/Modules/stropmodule.c Tue Oct 27 13:12:44 2009 @@ -879,10 +879,12 @@ PyErr_SetString(PyExc_ValueError, "empty string for atof()"); return NULL; } - errno = 0; + PyFPE_START_PROTECT("strop_atof", return 0) - x = PyOS_ascii_strtod(s, &end); + x = PyOS_string_to_double(s, &end, PyExc_OverflowError); PyFPE_END_PROTECT(x) + if (x == -1 && PyErr_Occurred()) + return NULL; while (*end && isspace(Py_CHARMASK(*end))) end++; if (*end != '\0') { @@ -891,12 +893,6 @@ PyErr_SetString(PyExc_ValueError, buffer); return NULL; } - else if (errno != 0) { - PyOS_snprintf(buffer, sizeof(buffer), - "atof() literal too large: %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } return PyFloat_FromDouble(x); } From python-checkins at python.org Tue Oct 27 13:13:06 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 12:13:06 -0000 Subject: [Python-checkins] r75746 - python/branches/py3k Message-ID: Author: eric.smith Date: Tue Oct 27 13:13:06 2009 New Revision: 75746 Log: Blocked revisions 75745 via svnmerge ........ r75745 | eric.smith | 2009-10-27 08:12:44 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Oct 27 13:30:12 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 12:30:12 -0000 Subject: [Python-checkins] r75747 - in python/branches/release26-maint: Modules/readline.c configure configure.in pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Tue Oct 27 13:30:12 2009 New Revision: 75747 Log: Merged revisions 75531,75725 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75531 | antoine.pitrou | 2009-10-19 20:17:18 +0200 (lun., 19 oct. 2009) | 4 lines Issue #5833: Fix extra space character in readline completion with the GNU readline library version 6.0. ........ r75725 | antoine.pitrou | 2009-10-26 20:16:46 +0100 (lun., 26 oct. 2009) | 4 lines Some platforms have rl_completion_append_character but not rl_completion_suppress_append. Reported by Mark D. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Modules/readline.c python/branches/release26-maint/configure python/branches/release26-maint/configure.in python/branches/release26-maint/pyconfig.h.in Modified: python/branches/release26-maint/Modules/readline.c ============================================================================== --- python/branches/release26-maint/Modules/readline.c (original) +++ python/branches/release26-maint/Modules/readline.c Tue Oct 27 13:30:12 2009 @@ -759,6 +759,12 @@ static char ** flex_complete(char *text, int start, int end) { +#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER + rl_completion_append_character ='\0'; +#endif +#ifdef HAVE_RL_COMPLETION_SUPPRESS_APPEND + rl_completion_suppress_append = 0; +#endif Py_XDECREF(begidx); Py_XDECREF(endidx); begidx = PyInt_FromLong((long) start); @@ -801,9 +807,6 @@ rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character ='\0'; -#endif begidx = PyInt_FromLong(0L); endidx = PyInt_FromLong(0L); Modified: python/branches/release26-maint/configure ============================================================================== --- python/branches/release26-maint/configure (original) +++ python/branches/release26-maint/configure Tue Oct 27 13:30:12 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 74982 . +# From configure.in Revision: 75132 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.6. # @@ -3855,7 +3855,7 @@ { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi -rm -f -r conftest* +rm -f conftest* @@ -5394,7 +5394,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -5415,7 +5415,7 @@ else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -6513,7 +6513,7 @@ fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $was_it_defined" >&5 echo "${ECHO_T}$was_it_defined" >&6; } @@ -7043,7 +7043,7 @@ else ac_cv_type_uid_t=no fi -rm -f -r conftest* +rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 @@ -14163,7 +14163,7 @@ else unistd_defines_pthreads=no fi -rm -f -r conftest* +rm -f conftest* { echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5 echo "${ECHO_T}$unistd_defines_pthreads" >&6; } @@ -15777,7 +15777,7 @@ $EGREP "yes" >/dev/null 2>&1; then ipv6type=$i fi -rm -f -r conftest* +rm -f conftest* ;; kame) @@ -15800,7 +15800,7 @@ ipv6libdir=/usr/local/v6/lib ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-glibc) @@ -15821,7 +15821,7 @@ ipv6type=$i; ipv6trylibc=yes fi -rm -f -r conftest* +rm -f conftest* ;; linux-inet6) @@ -15859,7 +15859,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; v6d) @@ -15882,7 +15882,7 @@ ipv6libdir=/usr/local/v6/lib; BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS" fi -rm -f -r conftest* +rm -f conftest* ;; zeta) @@ -15904,7 +15904,7 @@ ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi -rm -f -r conftest* +rm -f conftest* ;; esac @@ -23497,7 +23497,26 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 +_ACEOF + +fi +rm -f conftest* fi @@ -23767,7 +23786,7 @@ _ACEOF fi -rm -f -r conftest* +rm -f conftest* fi Modified: python/branches/release26-maint/configure.in ============================================================================== --- python/branches/release26-maint/configure.in (original) +++ python/branches/release26-maint/configure.in Tue Oct 27 13:30:12 2009 @@ -3499,6 +3499,10 @@ [readline/readline.h], AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) fi # check for readline 4.0 Modified: python/branches/release26-maint/pyconfig.h.in ============================================================================== --- python/branches/release26-maint/pyconfig.h.in (original) +++ python/branches/release26-maint/pyconfig.h.in Tue Oct 27 13:30:12 2009 @@ -498,6 +498,9 @@ /* Define if you have readline 4.2 */ #undef HAVE_RL_COMPLETION_MATCHES +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK From python-checkins at python.org Tue Oct 27 13:32:19 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 12:32:19 -0000 Subject: [Python-checkins] r75748 - in python/branches/release26-maint: Lib/test/test_thread.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 13:32:18 2009 New Revision: 75748 Log: Merged revisions 75633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75633 | antoine.pitrou | 2009-10-23 20:32:15 +0200 (ven., 23 oct. 2009) | 3 lines Issue #7194: test_thread could try to release an unacquired mutex (and fail). ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_thread.py Modified: python/branches/release26-maint/Lib/test/test_thread.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_thread.py (original) +++ python/branches/release26-maint/Lib/test/test_thread.py Tue Oct 27 13:32:18 2009 @@ -26,6 +26,7 @@ self.done_mutex.acquire() self.running_mutex = thread.allocate_lock() self.random_mutex = thread.allocate_lock() + self.created = 0 self.running = 0 self.next_ident = 0 @@ -37,6 +38,7 @@ self.next_ident += 1 verbose_print("creating task %s" % self.next_ident) thread.start_new_thread(self.task, (self.next_ident,)) + self.created += 1 self.running += 1 def task(self, ident): @@ -47,7 +49,7 @@ verbose_print("task %s done" % ident) with self.running_mutex: self.running -= 1 - if self.running == 0: + if self.created == NUMTASKS and self.running == 0: self.done_mutex.release() def test_starting_threads(self): @@ -89,6 +91,7 @@ for tss in (262144, 0x100000): verbose_print("trying stack_size = (%d)" % tss) self.next_ident = 0 + self.created = 0 for i in range(NUMTASKS): self.newtask() From python-checkins at python.org Tue Oct 27 13:48:52 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 12:48:52 -0000 Subject: [Python-checkins] r75749 - in python/branches/release26-maint: Lib/test/test_threading.py Misc/ACKS Misc/NEWS Modules/main.c Python/pythonrun.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 13:48:52 2009 New Revision: 75749 Log: Merged revisions 75570,75574,75624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75570 | antoine.pitrou | 2009-10-20 23:29:37 +0200 (mar., 20 oct. 2009) | 6 lines Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. ........ r75574 | antoine.pitrou | 2009-10-20 23:59:25 +0200 (mar., 20 oct. 2009) | 4 lines Test wouldn't work in debug mode. We probably need a function in test_support to handle this. ........ r75624 | antoine.pitrou | 2009-10-23 14:01:13 +0200 (ven., 23 oct. 2009) | 3 lines Fix Windows buildbot failure ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_threading.py python/branches/release26-maint/Misc/ACKS python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Modules/main.c python/branches/release26-maint/Python/pythonrun.c Modified: python/branches/release26-maint/Lib/test/test_threading.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_threading.py (original) +++ python/branches/release26-maint/Lib/test/test_threading.py Tue Oct 27 13:48:52 2009 @@ -284,6 +284,30 @@ self.failIf(rc == 2, "interpreted was blocked") self.failUnless(rc == 0, "Unexpected error") + def test_join_nondaemon_on_shutdown(self): + # Issue 1722344 + # Raising SystemExit skipped threading._shutdown + import subprocess + p = subprocess.Popen([sys.executable, "-c", """if 1: + import threading + from time import sleep + + def child(): + sleep(1) + # As a non-daemon thread we SHOULD wake up and nothing + # should be torn down yet + print "Woke up, sleep function is:", sleep + + threading.Thread(target=child).start() + raise SystemExit + """], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + self.assertEqual(stdout.strip(), + "Woke up, sleep function is: ") + stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip() + self.assertEqual(stderr, "") def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in Modified: python/branches/release26-maint/Misc/ACKS ============================================================================== --- python/branches/release26-maint/Misc/ACKS (original) +++ python/branches/release26-maint/Misc/ACKS Tue Oct 27 13:48:52 2009 @@ -517,6 +517,7 @@ Tim O'Malley Pascal Oberndoerfer Jeffrey Ollie +Adam Olsen Grant Olson Piet van Oostrum Jason Orendorff Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 13:48:52 2009 @@ -4,6 +4,22 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.6.5 +========================== + +*Release date: XX-XXX-20XX* + +Core and Builtins +----------------- + +- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which + fixes the problem of some exceptions being thrown at shutdown when the + interpreter is killed. Patch by Adam Olsen. + +Library +------- + + What's New in Python 2.6.4 final? ================================= Modified: python/branches/release26-maint/Modules/main.c ============================================================================== --- python/branches/release26-maint/Modules/main.c (original) +++ python/branches/release26-maint/Modules/main.c Tue Oct 27 13:48:52 2009 @@ -222,33 +222,6 @@ } -/* Wait until threading._shutdown completes, provided - the threading module was imported in the first place. - The shutdown routine will wait until all non-daemon - "threading" threads have completed. */ -#include "abstract.h" -static void -WaitForThreadShutdown(void) -{ -#ifdef WITH_THREAD - PyObject *result; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, - "threading"); - if (threading == NULL) { - /* threading not imported */ - PyErr_Clear(); - return; - } - result = PyObject_CallMethod(threading, "_shutdown", ""); - if (result == NULL) - PyErr_WriteUnraisable(threading); - else - Py_DECREF(result); - Py_DECREF(threading); -#endif -} - /* Main program */ int @@ -620,8 +593,6 @@ sts = PyRun_AnyFileFlags(stdin, "", &cf) != 0; } - WaitForThreadShutdown(); - Py_Finalize(); #ifdef RISCOS if (Py_RISCOSWimpFlag) Modified: python/branches/release26-maint/Python/pythonrun.c ============================================================================== --- python/branches/release26-maint/Python/pythonrun.c (original) +++ python/branches/release26-maint/Python/pythonrun.c Tue Oct 27 13:48:52 2009 @@ -17,6 +17,7 @@ #include "ast.h" #include "eval.h" #include "marshal.h" +#include "abstract.h" #ifdef HAVE_SIGNAL_H #include @@ -61,6 +62,7 @@ PyCompilerFlags *); static void err_input(perrdetail *); static void initsigs(void); +static void wait_for_thread_shutdown(void); static void call_sys_exitfunc(void); static void call_ll_exitfuncs(void); extern void _PyUnicode_Init(void); @@ -387,6 +389,8 @@ if (!initialized) return; + wait_for_thread_shutdown(); + /* The interpreter is still entirely intact at this point, and the * exit funcs may be relying on that. In particular, if some thread * or exit func is still waiting to do an import, the import machinery @@ -1663,6 +1667,32 @@ #include "pythread.h" #endif +/* Wait until threading._shutdown completes, provided + the threading module was imported in the first place. + The shutdown routine will wait until all non-daemon + "threading" threads have completed. */ +static void +wait_for_thread_shutdown(void) +{ +#ifdef WITH_THREAD + PyObject *result; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, + "threading"); + if (threading == NULL) { + /* threading not imported */ + PyErr_Clear(); + return; + } + result = PyObject_CallMethod(threading, "_shutdown", ""); + if (result == NULL) + PyErr_WriteUnraisable(threading); + else + Py_DECREF(result); + Py_DECREF(threading); +#endif +} + #define NEXITFUNCS 32 static void (*exitfuncs[NEXITFUNCS])(void); static int nexitfuncs = 0; From python-checkins at python.org Tue Oct 27 13:56:06 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 12:56:06 -0000 Subject: [Python-checkins] r75750 - in python/branches/release26-maint: Misc/ACKS Misc/NEWS Objects/listobject.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 13:56:06 2009 New Revision: 75750 Log: Merged revisions 75367 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75367 | antoine.pitrou | 2009-10-11 23:03:26 +0200 (dim., 11 oct. 2009) | 4 lines Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Misc/ACKS python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Objects/listobject.c Modified: python/branches/release26-maint/Misc/ACKS ============================================================================== --- python/branches/release26-maint/Misc/ACKS (original) +++ python/branches/release26-maint/Misc/ACKS Tue Oct 27 13:56:06 2009 @@ -167,6 +167,7 @@ Erik Demaine Roger Dev Raghuram Devarakonda +Scott Dial Toby Dickenson Mark Dickinson Daniel Diniz Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 13:56:06 2009 @@ -16,6 +16,9 @@ fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. +- Issue #7084: Fix a (very unlikely) crash when printing a list from one + thread, and mutating it from another one. Patch by Scott Dial. + Library ------- Modified: python/branches/release26-maint/Objects/listobject.c ============================================================================== --- python/branches/release26-maint/Objects/listobject.c (original) +++ python/branches/release26-maint/Objects/listobject.c Tue Oct 27 13:56:06 2009 @@ -319,6 +319,7 @@ { int rc; Py_ssize_t i; + PyObject *item; rc = Py_ReprEnter((PyObject*)op); if (rc != 0) { @@ -333,15 +334,19 @@ fprintf(fp, "["); Py_END_ALLOW_THREADS for (i = 0; i < Py_SIZE(op); i++) { + item = op->ob_item[i]; + Py_INCREF(item); if (i > 0) { Py_BEGIN_ALLOW_THREADS fprintf(fp, ", "); Py_END_ALLOW_THREADS } - if (PyObject_Print(op->ob_item[i], fp, 0) != 0) { + if (PyObject_Print(item, fp, 0) != 0) { + Py_DECREF(item); Py_ReprLeave((PyObject *)op); return -1; } + Py_DECREF(item); } Py_BEGIN_ALLOW_THREADS fprintf(fp, "]"); From python-checkins at python.org Tue Oct 27 14:04:15 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 13:04:15 -0000 Subject: [Python-checkins] r75751 - in python/branches/release26-maint: Lib/test/test___all__.py Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Oct 27 14:04:15 2009 New Revision: 75751 Log: Backporting since it would have helped us find a regression. Merged revisions 75312 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75312 | antoine.pitrou | 2009-10-10 22:52:11 +0200 (sam., 10 oct. 2009) | 4 lines Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test___all__.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/test/test___all__.py ============================================================================== --- python/branches/release26-maint/Lib/test/test___all__.py (original) +++ python/branches/release26-maint/Lib/test/test___all__.py Tue Oct 27 14:04:15 2009 @@ -1,9 +1,18 @@ +from __future__ import print_function + import unittest -from test.test_support import run_unittest +from test import test_support as support +import os import sys import warnings +class NoAll(RuntimeError): + pass + +class FailedImport(RuntimeError): + pass + class AllTest(unittest.TestCase): @@ -14,171 +23,97 @@ DeprecationWarning) try: exec "import %s" % modname in names - except ImportError: + except: # Silent fail here seems the best route since some modules - # may not be available in all environments. - return - self.failUnless(hasattr(sys.modules[modname], "__all__"), - "%s has no __all__ attribute" % modname) + # may not be available or not initialize properly in all + # environments. + raise FailedImport(modname) + if not hasattr(sys.modules[modname], "__all__"): + raise NoAll(modname) names = {} - exec "from %s import *" % modname in names + try: + exec "from %s import *" % modname in names + except Exception as e: + # Include the module name in the exception string + self.fail("__all__ failure in {0}: {1}: {2}".format( + modname, e.__class__.__name__, e)) if "__builtins__" in names: del names["__builtins__"] keys = set(names) all = set(sys.modules[modname].__all__) self.assertEqual(keys, all) + def walk_modules(self, basedir, modpath): + for fn in sorted(os.listdir(basedir)): + path = os.path.join(basedir, fn) + if os.path.isdir(path): + pkg_init = os.path.join(path, '__init__.py') + if os.path.exists(pkg_init): + yield pkg_init, modpath + fn + for p, m in self.walk_modules(path, modpath + fn + "."): + yield p, m + continue + if not fn.endswith('.py') or fn == '__init__.py': + continue + yield path, modpath + fn[:-3] + def test_all(self): + # Blacklisted modules and packages + blacklist = set([ + # Will raise a SyntaxError when compiling the exec statement + '__future__', + ]) + if not sys.platform.startswith('java'): # In case _socket fails to build, make this test fail more gracefully # than an AttributeError somewhere deep in CGIHTTPServer. import _socket - self.check_all("BaseHTTPServer") - self.check_all("Bastion") - self.check_all("CGIHTTPServer") - self.check_all("ConfigParser") - self.check_all("Cookie") - self.check_all("MimeWriter") - self.check_all("Queue") - self.check_all("SimpleHTTPServer") - self.check_all("SocketServer") - self.check_all("StringIO") - self.check_all("UserString") - self.check_all("aifc") - self.check_all("atexit") - self.check_all("audiodev") - self.check_all("base64") - self.check_all("bdb") - self.check_all("binhex") - self.check_all("calendar") - self.check_all("cgi") - self.check_all("cmd") - self.check_all("code") - self.check_all("codecs") - self.check_all("codeop") - self.check_all("colorsys") - self.check_all("commands") - self.check_all("compileall") - self.check_all("copy") - self.check_all("copy_reg") - self.check_all("csv") - self.check_all("dbhash") - self.check_all("decimal") - self.check_all("difflib") - self.check_all("dircache") - self.check_all("dis") - self.check_all("doctest") - self.check_all("dummy_thread") - self.check_all("dummy_threading") - self.check_all("filecmp") - self.check_all("fileinput") - self.check_all("fnmatch") - self.check_all("fpformat") - self.check_all("ftplib") - self.check_all("getopt") - self.check_all("getpass") - self.check_all("gettext") - self.check_all("glob") - self.check_all("gzip") - self.check_all("heapq") - self.check_all("htmllib") - self.check_all("httplib") - self.check_all("ihooks") - self.check_all("imaplib") - self.check_all("imghdr") - self.check_all("imputil") - self.check_all("keyword") - self.check_all("linecache") - self.check_all("locale") - self.check_all("logging") - self.check_all("macpath") - self.check_all("macurl2path") - self.check_all("mailbox") - self.check_all("mailcap") - self.check_all("mhlib") - self.check_all("mimetools") - self.check_all("mimetypes") - self.check_all("mimify") - self.check_all("multifile") - self.check_all("netrc") - self.check_all("nntplib") - self.check_all("ntpath") - self.check_all("opcode") - self.check_all("optparse") - self.check_all("os") - self.check_all("os2emxpath") - self.check_all("pdb") - self.check_all("pickle") - self.check_all("pickletools") - self.check_all("pipes") - self.check_all("popen2") - self.check_all("poplib") - self.check_all("posixpath") - self.check_all("pprint") - self.check_all("profile") - self.check_all("pstats") - self.check_all("pty") - self.check_all("py_compile") - self.check_all("pyclbr") - self.check_all("quopri") - self.check_all("random") - self.check_all("re") - self.check_all("repr") - self.check_all("rexec") - self.check_all("rfc822") - self.check_all("rlcompleter") - self.check_all("robotparser") - self.check_all("sched") - self.check_all("sets") - self.check_all("sgmllib") - self.check_all("shelve") - self.check_all("shlex") - self.check_all("shutil") - self.check_all("smtpd") - self.check_all("smtplib") - self.check_all("sndhdr") - self.check_all("socket") - self.check_all("_strptime") - self.check_all("symtable") - self.check_all("tabnanny") - self.check_all("tarfile") - self.check_all("telnetlib") - self.check_all("tempfile") - self.check_all("test.test_support") - self.check_all("textwrap") - self.check_all("threading") - self.check_all("timeit") - self.check_all("toaiff") - self.check_all("tokenize") - self.check_all("traceback") - self.check_all("tty") - self.check_all("unittest") - self.check_all("urllib") - self.check_all("urlparse") - self.check_all("uu") - self.check_all("warnings") - self.check_all("wave") - self.check_all("weakref") - self.check_all("webbrowser") - self.check_all("xdrlib") - self.check_all("zipfile") - # rlcompleter needs special consideration; it import readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( try: - self.check_all("rlcompleter") - finally: + import rlcompleter + import locale + except ImportError: + pass + else: + locale.setlocale(locale.LC_CTYPE, 'C') + + ignored = [] + failed_imports = [] + lib_dir = os.path.dirname(os.path.dirname(__file__)) + for path, modname in self.walk_modules(lib_dir, ""): + m = modname + blacklisted = False + while m: + if m in blacklist: + blacklisted = True + break + m = m.rpartition('.')[0] + if blacklisted: + continue + if support.verbose: + print(modname) try: - import locale - except ImportError: - pass - else: - locale.setlocale(locale.LC_CTYPE, 'C') + # This heuristic speeds up the process by removing, de facto, + # most test modules (and avoiding the auto-executing ones). + with open(path, "rb") as f: + if "__all__" not in f.read(): + raise NoAll(modname) + self.check_all(modname) + except NoAll: + ignored.append(modname) + except FailedImport: + failed_imports.append(modname) + + if support.verbose: + print('Following modules have no __all__ and have been ignored:', + ignored) + print('Following modules failed to be imported:', failed_imports) def test_main(): - run_unittest(AllTest) + support.run_unittest(AllTest) if __name__ == "__main__": test_main() Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 14:04:15 2009 @@ -22,6 +22,12 @@ Library ------- +Tests +----- + +- Issue #7055: test___all__ now greedily detects all modules which have an + __all__ attribute, rather than using a hardcoded and incomplete list. + What's New in Python 2.6.4 final? ================================= From python-checkins at python.org Tue Oct 27 14:08:37 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 13:08:37 -0000 Subject: [Python-checkins] r75752 - in python/branches/release31-maint: Lib/dbm/__init__.py Lib/test/test___all__.py Misc/NEWS Message-ID: Author: antoine.pitrou Date: Tue Oct 27 14:08:37 2009 New Revision: 75752 Log: Backporting since it would have helped us find a regression. Merged revisions 75314 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75314 | antoine.pitrou | 2009-10-10 23:08:31 +0200 (sam., 10 oct. 2009) | 10 lines Merged revisions 75312 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75312 | antoine.pitrou | 2009-10-10 22:52:11 +0200 (sam., 10 oct. 2009) | 4 lines Issue #7055: test___all__ now greedily detects all modules which have an __all__ attribute, rather than using a hardcoded and incomplete list. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/dbm/__init__.py python/branches/release31-maint/Lib/test/test___all__.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/dbm/__init__.py ============================================================================== --- python/branches/release31-maint/Lib/dbm/__init__.py (original) +++ python/branches/release31-maint/Lib/dbm/__init__.py Tue Oct 27 14:08:37 2009 @@ -36,7 +36,7 @@ only if it doesn't exist; and 'n' always creates a new database. """ -__all__ = ['open', 'whichdb', 'error', 'errors'] +__all__ = ['open', 'whichdb', 'error', 'error'] import io import os Modified: python/branches/release31-maint/Lib/test/test___all__.py ============================================================================== --- python/branches/release31-maint/Lib/test/test___all__.py (original) +++ python/branches/release31-maint/Lib/test/test___all__.py Tue Oct 27 14:08:37 2009 @@ -1,9 +1,17 @@ import unittest -from test.support import run_unittest +from test import support +import os import sys import warnings +class NoAll(RuntimeError): + pass + +class FailedImport(RuntimeError): + pass + + class AllTest(unittest.TestCase): def check_all(self, modname): @@ -13,153 +21,97 @@ DeprecationWarning) try: exec("import %s" % modname, names) - except ImportError: + except: # Silent fail here seems the best route since some modules - # may not be available in all environments. - return - self.assertTrue(hasattr(sys.modules[modname], "__all__"), - "%s has no __all__ attribute" % modname) + # may not be available or not initialize properly in all + # environments. + raise FailedImport(modname) + if not hasattr(sys.modules[modname], "__all__"): + raise NoAll(modname) names = {} - exec("from %s import *" % modname, names) + try: + exec("from %s import *" % modname, names) + except Exception as e: + # Include the module name in the exception string + self.fail("__all__ failure in {}: {}: {}".format( + modname, e.__class__.__name__, e)) if "__builtins__" in names: del names["__builtins__"] keys = set(names) all = set(sys.modules[modname].__all__) self.assertEqual(keys, all) + def walk_modules(self, basedir, modpath): + for fn in sorted(os.listdir(basedir)): + path = os.path.join(basedir, fn) + if os.path.isdir(path): + pkg_init = os.path.join(path, '__init__.py') + if os.path.exists(pkg_init): + yield pkg_init, modpath + fn + for p, m in self.walk_modules(path, modpath + fn + "."): + yield p, m + continue + if not fn.endswith('.py') or fn == '__init__.py': + continue + yield path, modpath + fn[:-3] + def test_all(self): + # Blacklisted modules and packages + blacklist = set([ + # Will raise a SyntaxError when compiling the exec statement + '__future__', + ]) + if not sys.platform.startswith('java'): # In case _socket fails to build, make this test fail more gracefully # than an AttributeError somewhere deep in CGIHTTPServer. import _socket - self.check_all("http.server") - self.check_all("configparser") - self.check_all("http.cookies") - self.check_all("queue") - self.check_all("socketserver") - self.check_all("aifc") - self.check_all("base64") - self.check_all("bdb") - self.check_all("binhex") - self.check_all("calendar") - self.check_all("collections") - self.check_all("cgi") - self.check_all("cmd") - self.check_all("code") - self.check_all("codecs") - self.check_all("codeop") - self.check_all("colorsys") - self.check_all("compileall") - self.check_all("copy") - self.check_all("copyreg") - self.check_all("csv") - self.check_all("dbm.bsd") - self.check_all("decimal") - self.check_all("difflib") - self.check_all("dircache") - self.check_all("dis") - self.check_all("doctest") - self.check_all("_dummy_thread") - self.check_all("dummy_threading") - self.check_all("filecmp") - self.check_all("fileinput") - self.check_all("fnmatch") - self.check_all("fpformat") - self.check_all("ftplib") - self.check_all("getopt") - self.check_all("getpass") - self.check_all("gettext") - self.check_all("glob") - self.check_all("gzip") - self.check_all("heapq") - self.check_all("http.client") - self.check_all("ihooks") - self.check_all("io") - self.check_all("_pyio") - self.check_all("imaplib") - self.check_all("imghdr") - self.check_all("keyword") - self.check_all("linecache") - self.check_all("locale") - self.check_all("logging") - self.check_all("macpath") - self.check_all("macurl2path") - self.check_all("mailbox") - self.check_all("mailcap") - self.check_all("mhlib") - self.check_all("mimetypes") - self.check_all("multifile") - self.check_all("netrc") - self.check_all("nntplib") - self.check_all("ntpath") - self.check_all("opcode") - self.check_all("optparse") - self.check_all("os") - self.check_all("os2emxpath") - self.check_all("pdb") - self.check_all("pickle") - self.check_all("pickletools") - self.check_all("pipes") - self.check_all("poplib") - self.check_all("posixpath") - self.check_all("pprint") - self.check_all("profile") - self.check_all("pstats") - self.check_all("pty") - self.check_all("py_compile") - self.check_all("pyclbr") - self.check_all("quopri") - self.check_all("random") - self.check_all("re") - self.check_all("reprlib") - self.check_all("rlcompleter") - self.check_all("urllib.robotparser") - self.check_all("sched") - self.check_all("shelve") - self.check_all("shlex") - self.check_all("shutil") - self.check_all("smtpd") - self.check_all("smtplib") - self.check_all("sndhdr") - self.check_all("socket") - self.check_all("_strptime") - self.check_all("symtable") - self.check_all("tabnanny") - self.check_all("tarfile") - self.check_all("telnetlib") - self.check_all("tempfile") - self.check_all("test.support") - self.check_all("textwrap") - self.check_all("threading") - self.check_all("timeit") - self.check_all("tokenize") - self.check_all("traceback") - self.check_all("tty") - self.check_all("unittest") - self.check_all("uu") - self.check_all("warnings") - self.check_all("wave") - self.check_all("weakref") - self.check_all("webbrowser") - self.check_all("xdrlib") - self.check_all("zipfile") - # rlcompleter needs special consideration; it import readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( try: - self.check_all("rlcompleter") - finally: + import rlcompleter + import locale + except ImportError: + pass + else: + locale.setlocale(locale.LC_CTYPE, 'C') + + ignored = [] + failed_imports = [] + lib_dir = os.path.dirname(os.path.dirname(__file__)) + for path, modname in self.walk_modules(lib_dir, ""): + m = modname + blacklisted = False + while m: + if m in blacklist: + blacklisted = True + break + m = m.rpartition('.')[0] + if blacklisted: + continue + if support.verbose: + print(modname) try: - import locale - except ImportError: - pass - else: - locale.setlocale(locale.LC_CTYPE, 'C') + # This heuristic speeds up the process by removing, de facto, + # most test modules (and avoiding the auto-executing ones). + with open(path, "rb") as f: + if b"__all__" not in f.read(): + raise NoAll(modname) + self.check_all(modname) + except NoAll: + ignored.append(modname) + except FailedImport: + failed_imports.append(modname) + + if support.verbose: + print('Following modules have no __all__ and have been ignored:', + ignored) + print('Following modules failed to be imported:', failed_imports) def test_main(): - run_unittest(AllTest) + support.run_unittest(AllTest) if __name__ == "__main__": test_main() Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Tue Oct 27 14:08:37 2009 @@ -108,6 +108,9 @@ Tests ----- +- Issue #7055: test___all__ now greedily detects all modules which have an + __all__ attribute, rather than using a hardcoded and incomplete list. + - Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. From python-checkins at python.org Tue Oct 27 14:12:17 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:12:17 -0000 Subject: [Python-checkins] r75753 - in python/branches/release26-maint: Doc/library/collections.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:12:17 2009 New Revision: 75753 Log: Merged revisions 68605 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68605 | raymond.hettinger | 2009-01-14 02:39:51 +0100 (Mi, 14 Jan 2009) | 1 line Fix-up indentation of sample code blocks for namedtuple mthod definitions. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/collections.rst Modified: python/branches/release26-maint/Doc/library/collections.rst ============================================================================== --- python/branches/release26-maint/Doc/library/collections.rst (original) +++ python/branches/release26-maint/Doc/library/collections.rst Tue Oct 27 14:12:17 2009 @@ -590,7 +590,7 @@ Class method that makes a new instance from an existing sequence or iterable. -.. doctest:: + .. doctest:: >>> t = [11, 22] >>> Point._make(t) @@ -606,9 +606,7 @@ .. method:: somenamedtuple._replace(kwargs) Return a new instance of the named tuple replacing specified fields with new - values: - -:: + values:: >>> p = Point(x=11, y=22) >>> p._replace(x=33) @@ -622,7 +620,7 @@ Tuple of strings listing the field names. Useful for introspection and for creating new named tuple types from existing named tuples. -.. doctest:: + .. doctest:: >>> p._fields # view the field names ('x', 'y') From python-checkins at python.org Tue Oct 27 14:14:29 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:14:29 -0000 Subject: [Python-checkins] r75754 - in python/branches/release26-maint: Doc/library/logging.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:14:28 2009 New Revision: 75754 Log: Merged revisions 68623-68624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68623 | vinay.sajip | 2009-01-15 23:48:13 +0100 (Do, 15 Jan 2009) | 1 line Made minor changes/corrections in markup. Added a couple of section headings. ........ r68624 | vinay.sajip | 2009-01-16 00:04:47 +0100 (Fr, 16 Jan 2009) | 1 line Minor changes/corrections in markup. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/logging.rst 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 Tue Oct 27 14:14:28 2009 @@ -518,6 +518,9 @@ the message to its destination. Most user-defined subclasses of :class:`Handler` will need to override this :meth:`emit`. +Useful Handlers +--------------- + In addition to the base :class:`Handler` class, many useful subclasses are provided: @@ -526,40 +529,44 @@ #. :class:`FileHandler` instances send error messages to disk files. -#. :class:`handlers.BaseRotatingHandler` is the base class for handlers that +.. module:: logging.handlers + +#. :class:`BaseRotatingHandler` is the base class for handlers that rotate log files at a certain point. It is not meant to be instantiated directly. Instead, use :class:`RotatingFileHandler` or :class:`TimedRotatingFileHandler`. -#. :class:`handlers.RotatingFileHandler` instances send error messages to disk files, - with support for maximum log file sizes and log file rotation. +#. :class:`RotatingFileHandler` instances send error messages to disk + files, with support for maximum log file sizes and log file rotation. -#. :class:`handlers.TimedRotatingFileHandler` instances send error messages to disk files - rotating the log file at certain timed intervals. +#. :class:`TimedRotatingFileHandler` instances send error messages to + disk files, rotating the log file at certain timed intervals. -#. :class:`handlers.SocketHandler` instances send error messages to TCP/IP sockets. +#. :class:`SocketHandler` instances send error messages to TCP/IP + sockets. -#. :class:`handlers.DatagramHandler` instances send error messages to UDP sockets. +#. :class:`DatagramHandler` instances send error messages to UDP + sockets. -#. :class:`handlers.SMTPHandler` instances send error messages to a designated email - address. +#. :class:`SMTPHandler` instances send error messages to a designated + email address. -#. :class:`handlers.SysLogHandler` instances send error messages to a Unix syslog daemon, - possibly on a remote machine. +#. :class:`SysLogHandler` instances send error messages to a Unix + syslog daemon, possibly on a remote machine. -#. :class:`handlers.NTEventLogHandler` instances send error messages to a Windows - NT/2000/XP event log. +#. :class:`NTEventLogHandler` instances send error messages to a + Windows NT/2000/XP event log. -#. :class:`handlers.MemoryHandler` instances send error messages to a buffer in memory, - which is flushed whenever specific criteria are met. +#. :class:`MemoryHandler` instances send error messages to a buffer + in memory, which is flushed whenever specific criteria are met. -#. :class:`handlers.HTTPHandler` instances send error messages to an HTTP server using - either ``GET`` or ``POST`` semantics. +#. :class:`HTTPHandler` instances send error messages to an HTTP + server using either ``GET`` or ``POST`` semantics. -#. :class:`handlers.WatchedFileHandler` instances watch the file they are logging to. If -the file changes, it is closed and reopened using the file name. This handler -is only useful on Unix-like systems; Windows does not support the underlying -mechanism used. +#. :class:`WatchedFileHandler` instances watch the file they are + logging to. If the file changes, it is closed and reopened using the file + name. This handler is only useful on Unix-like systems; Windows does not + support the underlying mechanism used. The :class:`StreamHandler` and :class:`FileHandler` classes are defined in the core logging package. The other handlers are @@ -586,6 +593,9 @@ name. If this feature is used, messages sent to the named logger and its children are allowed through the filter, and all others dropped. +Module-Level Functions +---------------------- + In addition to the classes described above, there are a number of module- level functions. From python-checkins at python.org Tue Oct 27 14:15:21 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:15:21 -0000 Subject: [Python-checkins] r75755 - in python/branches/release26-maint: Doc/library/ctypes.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:15:21 2009 New Revision: 75755 Log: Merged revisions 68633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68633 | thomas.heller | 2009-01-16 19:53:44 +0100 (Fr, 16 Jan 2009) | 3 lines Change an example in the docs to avoid a mistake when the code is copy pasted and changed afterwards. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/ctypes.rst Modified: python/branches/release26-maint/Doc/library/ctypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ctypes.rst (original) +++ python/branches/release26-maint/Doc/library/ctypes.rst Tue Oct 27 14:15:21 2009 @@ -2442,10 +2442,10 @@ ("hreftype", HREFTYPE)] class TYPEDESC(Structure): + _anonymous_ = ("u",) _fields_ = [("u", _U), ("vt", VARTYPE)] - _anonymous_ = ("u",) The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field specifies which one of the union fields is valid. Since the ``u`` field From python-checkins at python.org Tue Oct 27 14:16:08 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:16:08 -0000 Subject: [Python-checkins] r75756 - in python/branches/release26-maint: Lib/test/test__locale.py Message-ID: Author: georg.brandl Date: Tue Oct 27 14:16:07 2009 New Revision: 75756 Log: Merged revisions 68628 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68628 | benjamin.peterson | 2009-01-16 03:55:24 +0100 (Fr, 16 Jan 2009) | 1 line compare with == not is #4946 ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test__locale.py Modified: python/branches/release26-maint/Lib/test/test__locale.py ============================================================================== --- python/branches/release26-maint/Lib/test/test__locale.py (original) +++ python/branches/release26-maint/Lib/test/test__locale.py Tue Oct 27 14:16:07 2009 @@ -45,7 +45,7 @@ except Error: set_locale = "" known_value = known_numerics.get(used_locale, - ('', ''))[data_type is 'thousands_sep'] + ('', ''))[data_type == 'thousands_sep'] if known_value and calc_value: self.assertEquals(calc_value, known_value, self.lc_numeric_err_msg % ( From python-checkins at python.org Tue Oct 27 14:17:27 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:17:27 -0000 Subject: [Python-checkins] r75757 - in python/branches/release26-maint: Doc/reference/datamodel.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:17:27 2009 New Revision: 75757 Log: Merged revisions 68705-68706 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68705 | benjamin.peterson | 2009-01-18 02:28:09 +0100 (So, 18 Jan 2009) | 1 line bytearrays are mutable sequences ........ r68706 | benjamin.peterson | 2009-01-18 02:28:46 +0100 (So, 18 Jan 2009) | 1 line fix grammar ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/reference/datamodel.rst Modified: python/branches/release26-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release26-maint/Doc/reference/datamodel.rst Tue Oct 27 14:17:27 2009 @@ -360,7 +360,7 @@ slicing notations can be used as the target of assignment and :keyword:`del` (delete) statements. - There is currently a single intrinsic mutable sequence type: + There are currently two intrinsic mutable sequence types: Lists .. index:: object: list @@ -369,6 +369,14 @@ comma-separated list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.) + Byte Arrays + .. index:: bytearray + + A bytearray object is a mutable array. They are created by the built-in + :func:`bytearray` constructor. Aside from being mutable (and hence + unhashable), byte arrays otherwise provide the same interface and + functionality as immutable bytes objects. + .. index:: module: array The extension module :mod:`array` provides an additional example of a mutable From python-checkins at python.org Tue Oct 27 14:19:20 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:19:20 -0000 Subject: [Python-checkins] r75758 - in python/branches/release26-maint: Doc/library/logging.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:19:20 2009 New Revision: 75758 Log: Merged revisions 68760 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68760 | vinay.sajip | 2009-01-19 07:49:19 +0100 (Mo, 19 Jan 2009) | 1 line Added more cross-reference targets and tidied up list of useful handlers. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/logging.rst 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 Tue Oct 27 14:19:20 2009 @@ -310,7 +310,7 @@ with the milliseconds tacked on at the end. The message format string uses ``%()s`` styled string -substitution; the possible keys are documented in :ref:`formatter-objects`. +substitution; the possible keys are documented in :ref:`formatter`. The following message format string will log the time in a human-readable format, the severity of the message, and the contents of the message, in that @@ -524,46 +524,44 @@ In addition to the base :class:`Handler` class, many useful subclasses are provided: -#. :class:`StreamHandler` instances send error messages to streams (file-like +#. :ref:`stream-handler` instances send error messages to streams (file-like objects). -#. :class:`FileHandler` instances send error messages to disk files. - -.. module:: logging.handlers +#. :ref:`file-handler` instances send error messages to disk files. #. :class:`BaseRotatingHandler` is the base class for handlers that rotate log files at a certain point. It is not meant to be instantiated - directly. Instead, use :class:`RotatingFileHandler` or - :class:`TimedRotatingFileHandler`. + directly. Instead, use :ref:`rotating-file-handler` or + :ref:`timed-rotating-file-handler`. -#. :class:`RotatingFileHandler` instances send error messages to disk +#. :ref:`rotating-file-handler` instances send error messages to disk files, with support for maximum log file sizes and log file rotation. -#. :class:`TimedRotatingFileHandler` instances send error messages to +#. :ref:`timed-rotating-file-handler` instances send error messages to disk files, rotating the log file at certain timed intervals. -#. :class:`SocketHandler` instances send error messages to TCP/IP +#. :ref:`socket-handler` instances send error messages to TCP/IP sockets. -#. :class:`DatagramHandler` instances send error messages to UDP +#. :ref:`datagram-handler` instances send error messages to UDP sockets. -#. :class:`SMTPHandler` instances send error messages to a designated +#. :ref:`smtp-handler` instances send error messages to a designated email address. -#. :class:`SysLogHandler` instances send error messages to a Unix +#. :ref:`syslog-handler` instances send error messages to a Unix syslog daemon, possibly on a remote machine. -#. :class:`NTEventLogHandler` instances send error messages to a +#. :ref:`nt-eventlog-handler` instances send error messages to a Windows NT/2000/XP event log. -#. :class:`MemoryHandler` instances send error messages to a buffer +#. :ref:`memory-handler` instances send error messages to a buffer in memory, which is flushed whenever specific criteria are met. -#. :class:`HTTPHandler` instances send error messages to an HTTP +#. :ref:`http-handler` instances send error messages to an HTTP server using either ``GET`` or ``POST`` semantics. -#. :class:`WatchedFileHandler` instances watch the file they are +#. :ref:`watched-file-handler` instances watch the file they are logging to. If the file changes, it is closed and reopened using the file name. This handler is only useful on Unix-like systems; Windows does not support the underlying mechanism used. @@ -816,6 +814,7 @@ and 2.2.x, which do not include the :mod:`logging` package in the standard library. +.. _logger: Logger Objects -------------- @@ -1454,6 +1453,8 @@ 69 myapp.area2 ERROR The five boxing wizards jump quickly. +.. _handler: + Handler Objects --------------- @@ -1559,6 +1560,8 @@ :exc:`NotImplementedError`. +.. _stream-handler: + StreamHandler ^^^^^^^^^^^^^ @@ -1592,6 +1595,8 @@ no output, so an explicit :meth:`flush` call may be needed at times. +.. _file-handler: + FileHandler ^^^^^^^^^^^ @@ -1618,10 +1623,13 @@ Outputs the record to the file. +.. _null-handler: See :ref:`library-config` for more information on how to use :class:`NullHandler`. +.. _watched-file-handler: + WatchedFileHandler ^^^^^^^^^^^^^^^^^^ @@ -1660,6 +1668,7 @@ changed. If it has, the existing stream is flushed and closed and the file opened again, before outputting the record to the file. +.. _rotating-file-handler: RotatingFileHandler ^^^^^^^^^^^^^^^^^^^ @@ -1700,6 +1709,7 @@ Outputs the record to the file, catering for rollover as described previously. +.. _timed-rotating-file-handler: TimedRotatingFileHandler ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1758,6 +1768,8 @@ Outputs the record to the file, catering for rollover as described above. +.. _socket-handler: + SocketHandler ^^^^^^^^^^^^^ @@ -1811,6 +1823,8 @@ partial sends which can happen when the network is busy. +.. _datagram-handler: + DatagramHandler ^^^^^^^^^^^^^^^ @@ -1844,6 +1858,8 @@ Send a pickled string to a socket. +.. _syslog-handler: + SysLogHandler ^^^^^^^^^^^^^ @@ -1881,6 +1897,8 @@ used to convert them to integers. +.. _nt-eventlog-handler: + NTEventLogHandler ^^^^^^^^^^^^^^^^^ @@ -1946,6 +1964,7 @@ lookup to get the message ID. This version returns 1, which is the base message ID in :file:`win32service.pyd`. +.. _smtp-handler: SMTPHandler ^^^^^^^^^^^ @@ -1977,6 +1996,7 @@ If you want to specify a subject line which is record-dependent, override this method. +.. _memory-handler: MemoryHandler ^^^^^^^^^^^^^ @@ -2047,6 +2067,8 @@ Checks for buffer full or a record at the *flushLevel* or higher. +.. _http-handler: + HTTPHandler ^^^^^^^^^^^ @@ -2068,7 +2090,7 @@ Sends the record to the Web server as an URL-encoded dictionary. -.. _formatter-objects: +.. _formatter: Formatter Objects ----------------- @@ -2192,11 +2214,12 @@ just uses :func:`traceback.print_exception`. The resulting string is returned. +.. _filter: Filter Objects -------------- -:class:`Filter`\ s can be used by :class:`Handler`\ s and :class:`Logger`\ s for +Filters can be used by :class:`Handler`\ s and :class:`Logger`\ s for more sophisticated filtering than is provided by levels. The base filter class only allows events which are below a certain point in the logger hierarchy. For example, a filter initialized with "A.B" will allow events logged by loggers @@ -2217,6 +2240,7 @@ yes. If deemed appropriate, the record may be modified in-place by this method. +.. _log-record: LogRecord Objects ----------------- @@ -2251,6 +2275,7 @@ Returns the message for this :class:`LogRecord` instance after merging any user-supplied arguments with the message. +.. _logger-adapter: LoggerAdapter Objects --------------------- From python-checkins at python.org Tue Oct 27 14:20:10 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:20:10 -0000 Subject: [Python-checkins] r75759 - in python/branches/release26-maint: Doc/library/io.rst Doc/library/symtable.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:20:10 2009 New Revision: 75759 Log: Merged revisions 68776-68777 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68776 | benjamin.peterson | 2009-01-19 17:17:54 +0100 (Mo, 19 Jan 2009) | 1 line move BufferedIOBase into the base class section ........ r68777 | benjamin.peterson | 2009-01-19 17:18:27 +0100 (Mo, 19 Jan 2009) | 1 line add email address ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/io.rst python/branches/release26-maint/Doc/library/symtable.rst Modified: python/branches/release26-maint/Doc/library/io.rst ============================================================================== --- python/branches/release26-maint/Doc/library/io.rst (original) +++ python/branches/release26-maint/Doc/library/io.rst Tue Oct 27 14:20:10 2009 @@ -329,59 +329,6 @@ ``len(b)``, since if the write fails, an :exc:`IOError` will be raised). -Raw File I/O ------------- - -.. class:: FileIO(name[, mode]) - - :class:`FileIO` represents a file containing bytes data. It implements - the :class:`RawIOBase` interface (and therefore the :class:`IOBase` - interface, too). - - The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, - or appending. The file will be created if it doesn't exist when opened for - writing or appending; it will be truncated when opened for writing. Add a - ``'+'`` to the mode to allow simultaneous reading and writing. - - In addition to the attributes and methods from :class:`IOBase` and - :class:`RawIOBase`, :class:`FileIO` provides the following data - attributes and methods: - - .. attribute:: mode - - The mode as given in the constructor. - - .. attribute:: name - - The file name. This is the file descriptor of the file when no name is - given in the constructor. - - .. method:: read([n]) - - Read and return at most *n* bytes. Only one system call is made, so it is - possible that less data than was requested is returned. Use :func:`len` - on the returned bytes object to see how many bytes were actually returned. - (In non-blocking mode, ``None`` is returned when no data is available.) - - .. method:: readall() - - Read and return the entire file's contents in a single bytes object. As - much as immediately available is returned in non-blocking mode. If the - EOF has been reached, ``b''`` is returned. - - .. method:: write(b) - - Write the bytes or bytearray object, *b*, to the file, and return - the number actually written. Only one system call is made, so it - is possible that only some of the data is written. - - Note that the inherited ``readinto()`` method should not be used on - :class:`FileIO` objects. - - -Buffered Streams ----------------- - .. class:: BufferedIOBase Base class for streams that support buffering. It inherits :class:`IOBase`. @@ -439,6 +386,59 @@ underlying raw stream cannot accept more data at the moment. +Raw File I/O +------------ + +.. class:: FileIO(name[, mode]) + + :class:`FileIO` represents a file containing bytes data. It implements + the :class:`RawIOBase` interface (and therefore the :class:`IOBase` + interface, too). + + The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, + or appending. The file will be created if it doesn't exist when opened for + writing or appending; it will be truncated when opened for writing. Add a + ``'+'`` to the mode to allow simultaneous reading and writing. + + In addition to the attributes and methods from :class:`IOBase` and + :class:`RawIOBase`, :class:`FileIO` provides the following data + attributes and methods: + + .. attribute:: mode + + The mode as given in the constructor. + + .. attribute:: name + + The file name. This is the file descriptor of the file when no name is + given in the constructor. + + .. method:: read([n]) + + Read and return at most *n* bytes. Only one system call is made, so it is + possible that less data than was requested is returned. Use :func:`len` + on the returned bytes object to see how many bytes were actually returned. + (In non-blocking mode, ``None`` is returned when no data is available.) + + .. method:: readall() + + Read and return the entire file's contents in a single bytes object. As + much as immediately available is returned in non-blocking mode. If the + EOF has been reached, ``b''`` is returned. + + .. method:: write(b) + + Write the bytes or bytearray object, *b*, to the file, and return + the number actually written. Only one system call is made, so it + is possible that only some of the data is written. + + Note that the inherited ``readinto()`` method should not be used on + :class:`FileIO` objects. + + +Buffered Streams +---------------- + .. class:: BytesIO([initial_bytes]) A stream implementation using an in-memory bytes buffer. It inherits Modified: python/branches/release26-maint/Doc/library/symtable.rst ============================================================================== --- python/branches/release26-maint/Doc/library/symtable.rst (original) +++ python/branches/release26-maint/Doc/library/symtable.rst Tue Oct 27 14:20:10 2009 @@ -5,7 +5,7 @@ :synopsis: Interface to the compiler's internal symbol tables. .. moduleauthor:: Jeremy Hylton -.. sectionauthor:: Benjamin Peterson +.. sectionauthor:: Benjamin Peterson Symbol tables are generated by the compiler from AST just before bytecode is From python-checkins at python.org Tue Oct 27 14:21:23 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:21:23 -0000 Subject: [Python-checkins] r75760 - in python/branches/release26-maint: Doc/library/collections.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:21:23 2009 New Revision: 75760 Log: Merged revisions 68797 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68797 | raymond.hettinger | 2009-01-20 08:11:47 +0100 (Di, 20 Jan 2009) | 11 lines Don't disrupt automatic url target name generation with manually specified, conflicting names. Before: http://docs.python.org/dev/library/collections.html#id1 After: http://docs.python.org/dev/library/collections.html#counter-objects ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/collections.rst Modified: python/branches/release26-maint/Doc/library/collections.rst ============================================================================== --- python/branches/release26-maint/Doc/library/collections.rst (original) +++ python/branches/release26-maint/Doc/library/collections.rst Tue Oct 27 14:21:23 2009 @@ -155,12 +155,9 @@ * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. -.. _deque-objects: - :class:`deque` objects ---------------------- - .. class:: deque([iterable[, maxlen]]) Returns a new deque object initialized left-to-right (using :meth:`append`) with @@ -309,8 +306,6 @@ deque(['c', 'b', 'a']) -.. _deque-recipes: - :class:`deque` Recipes ^^^^^^^^^^^^^^^^^^^^^^ @@ -355,12 +350,10 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, ``rot``, and ``roll``. -.. _defaultdict-objects: :class:`defaultdict` objects ---------------------------- - .. class:: defaultdict([default_factory[, ...]]) Returns a new dictionary-like object. :class:`defaultdict` is a subclass of the @@ -406,8 +399,6 @@ ``None``, if absent. -.. _defaultdict-examples: - :class:`defaultdict` Examples ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -477,8 +468,6 @@ [('blue', set([2, 4])), ('red', set([1, 3]))] -.. _named-tuple-factory: - :func:`namedtuple` Factory Function for Tuples with Named Fields ---------------------------------------------------------------- From python-checkins at python.org Tue Oct 27 14:22:19 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:22:19 -0000 Subject: [Python-checkins] r75761 - in python/branches/release26-maint: Doc/library/multiprocessing.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:22:19 2009 New Revision: 75761 Log: Merged revisions 68842,68862 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r68842 | andrew.kuchling | 2009-01-21 03:16:26 +0100 (Mi, 21 Jan 2009) | 1 line Markup fixes ........ r68862 | jesse.noller | 2009-01-22 22:53:22 +0100 (Do, 22 Jan 2009) | 1 line Issue 4593: apply() documentation is unclear ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/multiprocessing.rst 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 Tue Oct 27 14:22:19 2009 @@ -1539,7 +1539,9 @@ .. method:: apply(func[, args[, kwds]]) Equivalent of the :func:`apply` builtin function. It blocks till the - result is ready. + result is ready. Given this blocks - :meth:`apply_async` is better suited + for performing work in parallel. Additionally, the passed + in function is only executed in one of the workers of the pool. .. method:: apply_async(func[, args[, kwds[, callback]]]) From python-checkins at python.org Tue Oct 27 14:24:10 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:24:10 -0000 Subject: [Python-checkins] r75762 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:24:10 2009 New Revision: 75762 Log: Blocked revisions 68942 via svnmerge ........ r68942 | raymond.hettinger | 2009-01-25 22:31:47 +0100 (So, 25 Jan 2009) | 1 line Improved itertools recipe for generating powerset(). ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:25:31 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:25:31 -0000 Subject: [Python-checkins] r75763 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:25:31 2009 New Revision: 75763 Log: Blocked revisions 69074 via svnmerge ........ r69074 | raymond.hettinger | 2009-01-29 00:58:16 +0100 (Do, 29 Jan 2009) | 1 line Correct docs for ABCs (MutableSequence was missing __setiem). Simplify the table by taking out inherited requirements for abstract methods. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:28:11 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:28:11 -0000 Subject: [Python-checkins] r75764 - in python/branches/release26-maint: Doc/c-api/exceptions.rst Doc/tutorial/floatingpoint.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:28:11 2009 New Revision: 75764 Log: Merged revisions 69131,69140-69141,69155 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69131 | andrew.kuchling | 2009-01-31 04:26:02 +0100 (Sa, 31 Jan 2009) | 1 line Text edits and markup fixes ........ r69140 | benjamin.peterson | 2009-01-31 17:52:03 +0100 (Sa, 31 Jan 2009) | 1 line PyErr_BadInternalCall() raises a SystemError, not TypeError #5112 ........ r69141 | benjamin.peterson | 2009-01-31 21:01:48 +0100 (Sa, 31 Jan 2009) | 1 line fix indentation ........ r69155 | david.goodger | 2009-01-31 23:53:46 +0100 (Sa, 31 Jan 2009) | 1 line markup fix ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/exceptions.rst python/branches/release26-maint/Doc/tutorial/floatingpoint.rst 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 Tue Oct 27 14:28:11 2009 @@ -291,9 +291,10 @@ .. cfunction:: void PyErr_BadInternalCall() - This is a shorthand for ``PyErr_SetString(PyExc_TypeError, message)``, where - *message* indicates that an internal operation (e.g. a Python/C API function) - was invoked with an illegal argument. It is mostly for internal use. + This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``, + where *message* indicates that an internal operation (e.g. a Python/C API + function) was invoked with an illegal argument. It is mostly for internal + use. .. cfunction:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel) Modified: python/branches/release26-maint/Doc/tutorial/floatingpoint.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/floatingpoint.rst (original) +++ python/branches/release26-maint/Doc/tutorial/floatingpoint.rst Tue Oct 27 14:28:11 2009 @@ -157,7 +157,7 @@ machines today (November 2000) use IEEE-754 floating point arithmetic, and almost all platforms map Python floats to IEEE-754 "double precision". 754 doubles contain 53 bits of precision, so on input the computer strives to -convert 0.1 to the closest fraction it can of the form *J*/2\*\**N* where *J* is +convert 0.1 to the closest fraction it can of the form *J*/2**\ *N* where *J* is an integer containing exactly 53 bits. Rewriting :: 1 / 10 ~= J / (2**N) From python-checkins at python.org Tue Oct 27 14:29:01 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:29:01 -0000 Subject: [Python-checkins] r75765 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:29:01 2009 New Revision: 75765 Log: Recorded merge of revisions 69159,69161,69240,69271-69273,69276 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69159 | gregory.p.smith | 2009-02-01 01:16:01 +0100 (So, 01 Feb 2009) | 2 lines Update doc wording as suggested in issue4903. ........ r69161 | gregory.p.smith | 2009-02-01 01:24:21 +0100 (So, 01 Feb 2009) | 2 lines wording for for issue4903. ........ r69240 | raymond.hettinger | 2009-02-03 04:18:14 +0100 (Di, 03 Feb 2009) | 1 line Record operator deprecations in docs. ........ r69271 | raymond.hettinger | 2009-02-04 11:52:32 +0100 (Mi, 04 Feb 2009) | 1 line Minor doc fixups. ........ r69272 | raymond.hettinger | 2009-02-04 12:14:18 +0100 (Mi, 04 Feb 2009) | 1 line Doc fixes. Remove overbroad, redundant warnings. Fixup example code. ........ r69273 | raymond.hettinger | 2009-02-04 12:31:30 +0100 (Mi, 04 Feb 2009) | 1 line Tweak the docs for Counter() objects. ........ r69276 | raymond.hettinger | 2009-02-04 20:25:17 +0100 (Mi, 04 Feb 2009) | 1 line Clarify that named tuples do not have to subclass tuple. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:31:19 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:31:19 -0000 Subject: [Python-checkins] r75766 - in python/branches/release26-maint: Doc/library/2to3.rst Doc/tools/sphinxext/pyspecific.py Message-ID: Author: georg.brandl Date: Tue Oct 27 14:31:19 2009 New Revision: 75766 Log: Merged revisions 69417,69435,69442 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69417 | benjamin.peterson | 2009-02-08 00:01:19 +0100 (So, 08 Feb 2009) | 1 line document individual 2to3 fixers ........ r69435 | benjamin.peterson | 2009-02-08 15:38:13 +0100 (So, 08 Feb 2009) | 1 line document numliterals fixer ........ r69442 | benjamin.peterson | 2009-02-08 16:14:57 +0100 (So, 08 Feb 2009) | 1 line a few edits and typos ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/2to3.rst python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Modified: python/branches/release26-maint/Doc/library/2to3.rst ============================================================================== --- python/branches/release26-maint/Doc/library/2to3.rst (original) +++ python/branches/release26-maint/Doc/library/2to3.rst Tue Oct 27 14:31:19 2009 @@ -14,6 +14,8 @@ automatically. +.. _2to3-using: + Using 2to3 ---------- @@ -52,10 +54,10 @@ Comments and exact indentation are preserved throughout the translation process. -By default, 2to3 runs a set of predefined fixers. The :option:`-l` flag lists -all available fixers. An explicit set of fixers to run can be given with -:option:`-f`. Likewise the :option:`-x` explicitly disables a fixer. The -following example runs only the ``imports`` and ``has_key`` fixers:: +By default, 2to3 runs a set of :ref:`predefined fixers <2to3-fixers>`. The +:option:`-l` flag lists all available fixers. An explicit set of fixers to run +can be given with :option:`-f`. Likewise the :option:`-x` explicitly disables a +fixer. The following example runs only the ``imports`` and ``has_key`` fixers:: $ 2to3 -f imports -f has_key example.py @@ -85,6 +87,257 @@ process. +.. _2to3-fixers: + +Fixers +------ + +Each step of tranforming code is encapsulated in a fixer. The command ``2to3 +-l`` lists them. As :ref:`documented above <2to3-using>`, each can be turned on +and off individually. They are described here in more detail. + + +.. 2to3fixer:: apply + + Removes usage of :func:`apply`. For example ``apply(function, *args, + **kwargs)`` is converted to ``function(*args, **kwargs)``. + +.. 2to3fixer:: basestring + + Converts :class:`basestring` to :class:`str`. + +.. 2to3fixer:: buffer + + Converts :class:`buffer` to :class:`memoryview`. This fixer is optional + because the :class:`memoryview` API is similar but not exactly the same as + that of :class:`buffer`. + +.. 2to3fixer:: callable + + Converts ``callable(x)`` to ``hasattr(x, "__call_")``. + +.. 2to3fixer:: dict + + Fixes dictionary iteration methods. :meth:`dict.iteritems` is converted to + :meth:`dict.items`, :meth:`dict.iterkeys` to :meth:`dict.keys`, and + :meth:`dict.itervalues` to :meth:`dict.values`. It also wraps existing + usages of :meth:`dict.items`, :meth:`dict.keys`, and :meth:`dict.values` in a + call to :class:`list`. + +.. 2to3fixer:: except + + Converts ``except X, T`` to ``except X as T``. + +.. 2to3fixer:: exec + + Converts the :keyword:`exec` statement to the :func:`exec` function. + +.. 2to3fixer:: execfile + + Removes usage of :func:`execfile`. The argument to :func:`execfile` is + wrapped in calls to :func:`open`, :func:`compile`, and :func:`exec`. + +.. 2to3fixer:: filter + + Wraps :func:`filter` usage in a :class:`list` call. + +.. 2to3fixer:: funcattrs + + Fixes function attributes that have been renamed. For example, + ``my_function.func_closure`` is converted to ``my_function.__closure__``. + +.. 2to3fixer:: future + + Removes ``from __future__ import new_feature`` statements. + +.. 2to3fixer:: getcwdu + + Renames :func:`os.getcwdu` to :func:`os.getcwd`. + +.. 2to3fixer:: has_key + + Changes ``dict.has_key(key)`` to ``key in dict``. + +.. 2to3fixer:: idioms + + This optional fixer preforms several transformations that make Python code + more idiomatic. Type comparisions like ``type(x) is SomeClass`` and + ``type(x) == SomeClass`` are converted to ``isinstance(x, SomeClass)``. + ``while 1`` becomes ``while True``. This fixer also tries to make use of + :func:`sorted` in appropiate places. For example, this block :: + + L = list(some_iterable) + L.sort() + + is changed to :: + + L = sorted(some_iterable) + +.. 2to3fixer:: import + + Detects sibling imports and converts them to relative imports. + +.. 2to3fixer:: imports + + Handles module renames in the standard library. + +.. 2to3fixer:: imports2 + + Handles other modules renames in the standard library. It is separate from + the :2to3fixer:`imports` fixer only because of technical limitations. + +.. 2to3fixer:: input + + Converts ``input(prompt)`` to ``eval(input(prompt))`` + +.. 2to3fixer:: intern + + Converts :func:`intern` to :func:`sys.intern`. + +.. 2to3fixer:: isinstance + + Fixes duplicate types in the second argument of :func:`isinstance`. For + example, ``isinstance(x, (int, int))`` is converted to ``isinstance(x, + (int))``. + +.. 2to3fixer:: itertools_imports + + Removes imports of :func:`itertools.ifilter`, :func:`itertools.izip`, and + :func:`itertools.imap`. Imports of :func:`itertools.ifilterfalse` are also + changed to :func:`itertools.filterfalse`. + +.. 2to3fixer:: itertools + + Changes usage of :func:`itertools.ifilter`, :func:`itertools.izip`, and + :func:`itertools.imap` to their builtin equivalents. + :func:`itertools.ifilterfalse` is changed to :func:`itertools.filterfalse`. + +.. 2to3fixer:: long + + Strips the ``L`` prefix on long literals and renames :class:`long` to + :class:`int`. + +.. 2to3fixer:: map + + Wraps :func:`map` in a :class:`list` call. It also changes ``map(None, x)`` + to ``list(x)``. Using ``from future_builtins import map`` disables this + fixer. + +.. 2to3fixer:: metaclass + + Converts the old metaclass syntax (``__metaclass__ = Meta`` in the class + body) to the new (``class X(metaclass=Meta)``). + +.. 2to3fixer:: methodattrs + + Fixes old method attribute names. For example, ``meth.im_func`` is converted + to ``meth.__func__``. + +.. 2to3fixer:: ne + + Converts the old not-equal syntax, ``<>``, to ``!=``. + +.. 2to3fixer:: next + + Converts the use of iterator's :meth:`next` methods to the :func:`next` + function. It also renames :meth:`next` methods to :meth:`~object.__next__`. + +.. 2to3fixer:: nonzero + + Renames :meth:`~object.__nonzero__` to :meth:`~object.__bool__`. + +.. 2to3fixer:: numliterals + + Converts octal literals into the new syntax. + +.. 2to3fixer:: paren + + Add extra parenthesis where they are required in list comprehensions. For + example, ``[x for x in 1, 2]`` becomes ``[x for x in (1, 2)]``. + +.. 2to3fixer:: print + + Converts the :keyword:`print` statement to the :func:`print` function. + +.. 2to3fixer:: raises + + Converts ``raise E, V`` to ``raise E(V)``, and ``raise E, V, T`` to ``raise + E(V).with_traceback(T)``. If ``E`` is a tuple, the translation will be + incorrect because substituting tuples for exceptions has been removed in 3.0. + +.. 2to3fixer:: raw_input + + Converts :func:`raw_input` to :func:`input`. + +.. 2to3fixer:: reduce + + Handles the move of :func:`reduce` to :func:`functools.reduce`. + +.. 2to3fixer:: renames + + Changes :data:`sys.maxint` to :data:`sys.maxsize`. + +.. 2to3fixer:: repr + + Replaces backtick repr with the :func:`repr` function. + +.. 2to3fixer:: set_literal + + Replaces use of the :class:`set` constructor with set literals. This fixer + is optional. + +.. 2to3fixer:: standard_error + + Renames :exc:`StandardError` to :exc:`Exception`. + +.. 2to3fixer:: sys_exc + + Changes the deprecated :data:`sys.exc_value`, :data:`sys.exc_type`, + :data:`sys.exc_traceback` to use :func:`sys.exc_info`. + +.. 2to3fixer:: throw + + Fixes the API change in generator's :meth:`throw` method. + +.. 2to3fixer:: tuple_params + + Removes implicit tuple parameter unpacking. This fixer inserts temporary + variables. + +.. 2to3fixer:: types + + Fixes code broken from the removal of some members in the :mod:`types` + module. + +.. 2to3fixer:: unicode + + Renames :class:`unicode` to :class:`str`. + +.. 2to3fixer:: urllib + + Handles the rename of :mod:`urllib` and :mod:`urllib2` to the :mod:`urllib` + package. + +.. 2to3fixer:: ws_comma + + Removes excess whitespace from comma separated items. This fixer is + optional. + +.. 2to3fixer:: xrange + + Renames :func:`xrange` to :func:`range` and wraps existing :func:`range` + calls with :class:`list`. + +.. 2to3fixer:: xreadlines + + Changes ``for x in file.xreadlines()`` to ``for x in file``. + +.. 2to3fixer:: zip + + Wraps :func:`zip` usage in a :class:`list` call. This is disabled when + ``from future_builtins import zip`` appears. + + :mod:`lib2to3` - 2to3's library ------------------------------- Modified: python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 14:31:19 2009 @@ -135,3 +135,4 @@ app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) + app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') From python-checkins at python.org Tue Oct 27 14:31:50 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:31:50 -0000 Subject: [Python-checkins] r75767 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:31:50 2009 New Revision: 75767 Log: Blocked revisions 69480 via svnmerge ........ r69480 | raymond.hettinger | 2009-02-10 02:24:05 +0100 (Di, 10 Feb 2009) | 1 line Issue 1818: collections.namedtuple() to support automatic renaming of invalid fieldnames. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:32:22 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:32:22 -0000 Subject: [Python-checkins] r75768 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:32:21 2009 New Revision: 75768 Log: Recorded merge of revisions 69509 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69509 | raymond.hettinger | 2009-02-11 01:06:17 +0100 (Mi, 11 Feb 2009) | 1 line Clean-up named tuple docs. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:38:33 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:38:33 -0000 Subject: [Python-checkins] r75769 - in python/branches/release26-maint: Doc/c-api/string.rst Doc/library/io.rst Doc/library/platform.rst Doc/library/socket.rst Doc/library/stdtypes.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:38:33 2009 New Revision: 75769 Log: Merged revisions 69520,69633,69672,69703-69704,69717,69731 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69520 | benjamin.peterson | 2009-02-12 04:50:00 +0100 (Do, 12 Feb 2009) | 1 line os.fsync() should be used to ensure that data is written to disk ........ r69633 | hirokazu.yamamoto | 2009-02-15 10:19:48 +0100 (So, 15 Feb 2009) | 1 line Fixed typo. ........ r69672 | benjamin.peterson | 2009-02-16 15:54:34 +0100 (Mo, 16 Feb 2009) | 1 line note functions that are not aliased to PyBytes_ #5280 ........ r69703 | raymond.hettinger | 2009-02-16 23:42:54 +0100 (Mo, 16 Feb 2009) | 3 lines Issue 5229: Documentation for super() neglects to say what super() actually does ........ r69704 | raymond.hettinger | 2009-02-17 00:00:25 +0100 (Di, 17 Feb 2009) | 1 line Add explanation for super(type1, type2). ........ r69717 | marc-andre.lemburg | 2009-02-17 13:48:19 +0100 (Di, 17 Feb 2009) | 5 lines Clarify the deprecation of platform.dist(). Add versionadded tags. ........ r69731 | gregory.p.smith | 2009-02-18 06:46:11 +0100 (Mi, 18 Feb 2009) | 3 lines Clarify socket timeout behavior vs system network stack behavior on connect for issue5293. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/string.rst python/branches/release26-maint/Doc/library/io.rst python/branches/release26-maint/Doc/library/platform.rst python/branches/release26-maint/Doc/library/socket.rst python/branches/release26-maint/Doc/library/stdtypes.rst Modified: python/branches/release26-maint/Doc/c-api/string.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/string.rst (original) +++ python/branches/release26-maint/Doc/c-api/string.rst Tue Oct 27 14:38:33 2009 @@ -9,8 +9,10 @@ called with a non-string parameter. .. note:: - These functions have been renamed to PyBytes_* in Python 3.x. The PyBytes - names are also available in 2.6. + + These functions have been renamed to PyBytes_* in Python 3.x. Unless + otherwise noted, the PyBytes functions available in 3.x are aliased to their + PyString_* equivalents to help porting. .. index:: object: string @@ -238,6 +240,10 @@ reference-count-neutral; you own the object after the call if and only if you owned it before the call.) + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. + .. cfunction:: PyObject* PyString_InternFromString(const char *v) @@ -246,6 +252,10 @@ been interned, or a new ("owned") reference to an earlier interned string object with the same value. + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. + .. cfunction:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) @@ -255,6 +265,10 @@ The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. + .. versionchanged:: 2.5 This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. @@ -268,6 +282,10 @@ The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. + .. cfunction:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) @@ -277,6 +295,10 @@ :meth:`encode` method. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. + .. versionchanged:: 2.5 This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. @@ -289,3 +311,7 @@ parameters of the same name in the string :meth:`encode` method. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. + + .. note:: + + This function is not available in 3.x and does not have a PyBytes alias. Modified: python/branches/release26-maint/Doc/library/io.rst ============================================================================== --- python/branches/release26-maint/Doc/library/io.rst (original) +++ python/branches/release26-maint/Doc/library/io.rst Tue Oct 27 14:38:33 2009 @@ -633,7 +633,7 @@ .. class:: StringIO([initial_value[, encoding[, errors[, newline]]]]) - An in-memory stream for text. It in inherits :class:`TextIOWrapper`. + An in-memory stream for text. It inherits :class:`TextIOWrapper`. Create a new StringIO stream with an inital value, encoding, error handling, and newline setting. See :class:`TextIOWrapper`\'s constructor for more Modified: python/branches/release26-maint/Doc/library/platform.rst ============================================================================== --- python/branches/release26-maint/Doc/library/platform.rst (original) +++ python/branches/release26-maint/Doc/library/platform.rst Tue Oct 27 14:38:33 2009 @@ -234,7 +234,15 @@ .. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...)) - This is another name for :func:`linux_distribution`. + This is an old version of the functionality now provided by + :func:`linux_distribution`. For new code, please use the + :func:`linux_distribution`. + + The only difference between the two is that ``dist()`` always + returns the short name of the distribution taken from the + ``supported_dists`` parameter. + + .. deprecated:: 2.6 .. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1) @@ -252,6 +260,8 @@ parameters. ``id`` is the item in parentheses after the version number. It is usually the version codename. + .. versionadded:: 2.6 + .. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048) Tries to determine the libc version against which the file executable (defaults Modified: python/branches/release26-maint/Doc/library/socket.rst ============================================================================== --- python/branches/release26-maint/Doc/library/socket.rst (original) +++ python/branches/release26-maint/Doc/library/socket.rst Tue Oct 27 14:38:33 2009 @@ -731,12 +731,13 @@ Some notes on socket blocking and timeouts: A socket object can be in one of three modes: blocking, non-blocking, or timeout. Sockets are always created in -blocking mode. In blocking mode, operations block until complete. In +blocking mode. In blocking mode, operations block until complete or +the system returns an error (such as connection timed out). In non-blocking mode, operations fail (with an error that is unfortunately system-dependent) if they cannot be completed immediately. In timeout mode, operations fail if they cannot be completed within the timeout specified for the -socket. The :meth:`setblocking` method is simply a shorthand for certain -:meth:`settimeout` calls. +socket or if the system returns an error. The :meth:`setblocking` method is simply +a shorthand for certain :meth:`settimeout` calls. Timeout mode internally sets the socket in non-blocking mode. The blocking and timeout modes are shared between file descriptors and socket objects that refer @@ -747,7 +748,9 @@ Note that the :meth:`connect` operation is subject to the timeout setting, and in general it is recommended to call :meth:`settimeout` before calling -:meth:`connect`. +:meth:`connect` or pass a timeout parameter to :meth:`create_connection`. +The system network stack may return a connection timeout error +of its own regardless of any python socket timeout setting. .. method:: socket.setsockopt(level, optname, value) Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 14:38:33 2009 @@ -2114,6 +2114,11 @@ Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`. This may be a no-op on some file-like objects. + .. note:: + + :meth:`flush` does not necessarily write the file's data to disk. Use + :meth:`flush` followed by :func:`os.fsync` to ensure this behavior. + .. method:: file.fileno() From python-checkins at python.org Tue Oct 27 14:39:59 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:39:59 -0000 Subject: [Python-checkins] r75770 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:39:59 2009 New Revision: 75770 Log: Blocked revisions 69522,69604,69709,69715,69739,69757,69761,69765,69777,69795 via svnmerge ........ r69522 | raymond.hettinger | 2009-02-12 06:39:46 +0100 (Do, 12 Feb 2009) | 3 lines Issue 5032: added a step argument to itertools.count() and allowed non-integer arguments. ........ r69604 | raymond.hettinger | 2009-02-14 01:25:51 +0100 (Sa, 14 Feb 2009) | 1 line Add keyword argument support to itertools.count(). ........ r69709 | raymond.hettinger | 2009-02-17 09:33:01 +0100 (Di, 17 Feb 2009) | 1 line Fix-up intro paragraph for collections docs. ........ r69715 | raymond.hettinger | 2009-02-17 12:00:27 +0100 (Di, 17 Feb 2009) | 1 line Fixup intro paragraphs for the itertools docs. Add some tables for quick reference. ........ r69739 | raymond.hettinger | 2009-02-18 21:54:53 +0100 (Mi, 18 Feb 2009) | 1 line Generalize the itertools.tee() recipe. ........ r69757 | raymond.hettinger | 2009-02-19 06:34:35 +0100 (Do, 19 Feb 2009) | 1 line Add some cross-references to the docs. Simplify the python code equivalent for izip(). Supply an optional argument for the nth() recipe. ........ r69761 | raymond.hettinger | 2009-02-19 06:51:41 +0100 (Do, 19 Feb 2009) | 1 line Add an example for math.fsum() and elaborate on the accurary note. ........ r69765 | raymond.hettinger | 2009-02-19 07:55:03 +0100 (Do, 19 Feb 2009) | 1 line Add links to helpful external resources. ........ r69777 | jeroen.ruigrok | 2009-02-19 19:52:21 +0100 (Do, 19 Feb 2009) | 3 lines Since we recommend one module per import line, reflect this also in the documentation. ........ r69795 | benjamin.peterson | 2009-02-20 04:31:23 +0100 (Fr, 20 Feb 2009) | 1 line revert r69777 since all the experts agree that extra import lines distract from the code ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:44:06 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:44:06 -0000 Subject: [Python-checkins] r75771 - in python/branches/release26-maint: Doc/howto/curses.rst Doc/library/mmap.rst Doc/library/stdtypes.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:44:06 2009 New Revision: 75771 Log: Merged revisions 69987,70002,70061 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r69987 | benjamin.peterson | 2009-02-26 01:30:11 +0100 (Do, 26 Feb 2009) | 1 line fix str.format()'s first arg #5371 ........ r70002 | andrew.kuchling | 2009-02-26 23:34:30 +0100 (Do, 26 Feb 2009) | 1 line The curses panel library is now supported ........ r70061 | hirokazu.yamamoto | 2009-02-28 16:24:00 +0100 (Sa, 28 Feb 2009) | 1 line Binary flag is needed on windows. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/howto/curses.rst python/branches/release26-maint/Doc/library/mmap.rst python/branches/release26-maint/Doc/library/stdtypes.rst Modified: python/branches/release26-maint/Doc/howto/curses.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/curses.rst (original) +++ python/branches/release26-maint/Doc/howto/curses.rst Tue Oct 27 14:44:06 2009 @@ -426,7 +426,7 @@ Because the curses API is so large, some functions aren't supported in the Python interface, not because they're difficult to implement, but because no one has needed them yet. Feel free to add them and then submit a patch. Also, we -don't yet have support for the menus or panels libraries associated with +don't yet have support for the menu library associated with ncurses; feel free to add that. If you write an interesting little program, feel free to contribute it as Modified: python/branches/release26-maint/Doc/library/mmap.rst ============================================================================== --- python/branches/release26-maint/Doc/library/mmap.rst (original) +++ python/branches/release26-maint/Doc/library/mmap.rst Tue Oct 27 14:44:06 2009 @@ -99,10 +99,10 @@ import mmap # write a simple example file - with open("hello.txt", "w") as f: + with open("hello.txt", "wb") as f: f.write("Hello Python!\n") - with open("hello.txt", "r+") as f: + with open("hello.txt", "r+b") as f: # memory-map the file, size 0 means whole file map = mmap.mmap(f.fileno(), 0) # read content via standard file methods Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 14:44:06 2009 @@ -861,7 +861,7 @@ found. -.. method:: str.format(format_string, *args, **kwargs) +.. method:: str.format(*args, **kwargs) Perform a string formatting operation. The *format_string* argument can contain literal text or replacement fields delimited by braces ``{}``. Each From python-checkins at python.org Tue Oct 27 14:45:32 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:45:32 -0000 Subject: [Python-checkins] r75772 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:45:32 2009 New Revision: 75772 Log: Blocked revisions 69908,69952-69953,69955,69959,69981,69983,70071,70081,70090,70120-70123,70126,70131-70132 via svnmerge ........ r69908 | raymond.hettinger | 2009-02-23 20:32:55 +0100 (Mo, 23 Feb 2009) | 1 line Update itertools recipes to use next(). ........ r69952 | raymond.hettinger | 2009-02-25 01:37:57 +0100 (Mi, 25 Feb 2009) | 1 line Sync-up py3.1 doc updates for super(). ........ r69953 | raymond.hettinger | 2009-02-25 01:39:47 +0100 (Mi, 25 Feb 2009) | 1 line Restore Py2.x version of sample call to super(). ........ r69955 | raymond.hettinger | 2009-02-25 01:52:37 +0100 (Mi, 25 Feb 2009) | 1 line More markup and spelling fixes. ........ r69959 | raymond.hettinger | 2009-02-25 02:06:52 +0100 (Mi, 25 Feb 2009) | 1 line Remove reference to zero argument form of super() in 2.x docs. ........ r69981 | raymond.hettinger | 2009-02-25 23:48:24 +0100 (Mi, 25 Feb 2009) | 1 line Clarify Counter() docs. ........ r69983 | raymond.hettinger | 2009-02-26 01:05:24 +0100 (Do, 26 Feb 2009) | 1 line Fix typo. ........ r70071 | jeffrey.yasskin | 2009-02-28 20:03:21 +0100 (Sa, 28 Feb 2009) | 5 lines Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} with POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing a POP_TOP on each conditional and sometimes allows the peephole optimizer to skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly. ........ r70081 | raymond.hettinger | 2009-03-01 03:04:32 +0100 (So, 01 M?r 2009) | 1 line Fix docs for ConfigParser. ........ r70090 | gregory.p.smith | 2009-03-02 06:13:57 +0100 (Mo, 02 M?r 2009) | 3 lines Adds an optional flags argument to re.split, re.sub and re.subn to be consistent with the other re module functions. ........ r70120 | raymond.hettinger | 2009-03-03 05:45:34 +0100 (Di, 03 M?r 2009) | 1 line Backport PEP 372: OrderedDict() ........ r70121 | raymond.hettinger | 2009-03-03 05:51:24 +0100 (Di, 03 M?r 2009) | 3 lines Backport 70106: Add OrderedDict support to collections.namedtuple(). ........ r70122 | raymond.hettinger | 2009-03-03 06:00:37 +0100 (Di, 03 M?r 2009) | 3 lines Backport 70111: Let configparser use ordered dicts by default. ........ r70123 | raymond.hettinger | 2009-03-03 06:11:56 +0100 (Di, 03 M?r 2009) | 1 line Fix markup. ........ r70126 | raymond.hettinger | 2009-03-03 08:12:09 +0100 (Di, 03 M?r 2009) | 1 line Beef-up tests. ........ r70131 | raymond.hettinger | 2009-03-03 21:53:51 +0100 (Di, 03 M?r 2009) | 1 line Make the underlying data structure more private. ........ r70132 | raymond.hettinger | 2009-03-03 22:13:51 +0100 (Di, 03 M?r 2009) | 1 line Minor simplification. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 14:54:57 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:54:57 -0000 Subject: [Python-checkins] r75773 - in python/branches/release26-maint: Doc/library/decimal.rst Doc/library/functions.rst Doc/library/struct.rst Doc/library/symtable.rst Doc/reference/datamodel.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 14:54:57 2009 New Revision: 75773 Log: Merged revisions 70171,70183,70290,70292,70315,70438,70464 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r70171 | facundo.batista | 2009-03-04 22:18:17 +0100 (Mi, 04 M?r 2009) | 3 lines Fixed a typo. ........ r70183 | benjamin.peterson | 2009-03-05 01:17:57 +0100 (Do, 05 M?r 2009) | 1 line add example ........ r70290 | raymond.hettinger | 2009-03-10 02:07:30 +0100 (Di, 10 M?r 2009) | 1 line Update url for the spec. ........ r70292 | raymond.hettinger | 2009-03-10 05:40:24 +0100 (Di, 10 M?r 2009) | 1 line Clarify the meaning of normal and subnormal. ........ r70315 | raymond.hettinger | 2009-03-12 01:25:03 +0100 (Do, 12 M?r 2009) | 1 line Add reference to solution for a commonly asked question. ........ r70438 | benjamin.peterson | 2009-03-17 21:29:51 +0100 (Di, 17 M?r 2009) | 1 line I thought this was begging for an example ........ r70464 | benjamin.peterson | 2009-03-18 21:58:09 +0100 (Mi, 18 M?r 2009) | 1 line a much better example ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/decimal.rst python/branches/release26-maint/Doc/library/functions.rst python/branches/release26-maint/Doc/library/struct.rst python/branches/release26-maint/Doc/library/symtable.rst python/branches/release26-maint/Doc/reference/datamodel.rst Modified: python/branches/release26-maint/Doc/library/decimal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/decimal.rst (original) +++ python/branches/release26-maint/Doc/library/decimal.rst Tue Oct 27 14:54:57 2009 @@ -108,7 +108,7 @@ .. seealso:: * IBM's General Decimal Arithmetic Specification, `The General Decimal Arithmetic - Specification `_. + Specification `_. * IEEE standard 854-1987, `Unofficial IEEE 854 Text `_. @@ -531,8 +531,11 @@ .. method:: is_normal() - Return :const:`True` if the argument is a *normal* finite number. Return - :const:`False` if the argument is zero, subnormal, infinite or a NaN. + Return :const:`True` if the argument is a *normal* finite non-zero + number with an adjusted exponent greater than or equal to *Emin*. + Return :const:`False` if the argument is zero, subnormal, infinite or a + NaN. Note, the term *normal* is used here in a different sense with + the :meth:`normalize` method which is used to create canonical values. .. versionadded:: 2.6 @@ -560,7 +563,8 @@ .. method:: is_subnormal() Return :const:`True` if the argument is subnormal, and :const:`False` - otherwise. + otherwise. A number is subnormal is if it is nonzero, finite, and has an + adjusted exponent less than *Emin*. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Tue Oct 27 14:54:57 2009 @@ -603,6 +603,14 @@ its :meth:`next` method; if the value returned is equal to *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned. + One useful application of the second form of :func:`iter` is to read lines of + a file until a certain line is reached. The following example reads a file + until ``"STOP"`` is reached: :: + + with open("mydata.txt") as fp: + for line in iter(fp.readline, "STOP"): + process_line(line) + .. versionadded:: 2.2 Modified: python/branches/release26-maint/Doc/library/struct.rst ============================================================================== --- python/branches/release26-maint/Doc/library/struct.rst (original) +++ python/branches/release26-maint/Doc/library/struct.rst Tue Oct 27 14:54:57 2009 @@ -50,7 +50,7 @@ .. function:: unpack_from(fmt, buffer[,offset=0]) - Unpack the *buffer* according to tthe given format. The result is a tuple even + Unpack the *buffer* according to the given format. The result is a tuple even if it contains exactly one item. The *buffer* must contain at least the amount of data required by the format (``len(buffer[offset:])`` must be at least ``calcsize(fmt)``). Modified: python/branches/release26-maint/Doc/library/symtable.rst ============================================================================== --- python/branches/release26-maint/Doc/library/symtable.rst (original) +++ python/branches/release26-maint/Doc/library/symtable.rst Tue Oct 27 14:54:57 2009 @@ -164,6 +164,12 @@ If the name is used as the target of a function or class statement, this will be true. + For example:: + + >>> table = symtable.symtable("def some_func(): pass", "string", "exec") + >>> table.lookup("some_func").is_namespace() + True + Note that a single name can be bound to multiple objects. If the result is ``True``, the name may also be bound to other objects, like an int or list, that does not introduce a new namespace. Modified: python/branches/release26-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release26-maint/Doc/reference/datamodel.rst Tue Oct 27 14:54:57 2009 @@ -1347,6 +1347,9 @@ Arguments to rich comparison methods are never coerced. + To automatically generate ordering operations from a single root operation, + see the `Total Ordering recipe in the ASPN cookbook + `_\. .. method:: object.__cmp__(self, other) From python-checkins at python.org Tue Oct 27 14:57:34 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 13:57:34 -0000 Subject: [Python-checkins] r75774 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 14:57:34 2009 New Revision: 75774 Log: Blocked revisions 70145,70261,70267,70271,70281,70286,70295,70298,70300,70305,70319,70471,70473,70485,70546,70555,70558,70561-70564,70568-70571,70574,70578,70588-70589 via svnmerge ........ r70145 | benjamin.peterson | 2009-03-03 23:51:57 +0100 (Di, 03 M?r 2009) | 1 line making the writing more formal ........ r70261 | raymond.hettinger | 2009-03-09 12:31:39 +0100 (Mo, 09 M?r 2009) | 1 line Issue 5443: Fix typo. ........ r70267 | raymond.hettinger | 2009-03-09 12:57:29 +0100 (Mo, 09 M?r 2009) | 1 line Add consume() recipe to itertools docs. ........ r70271 | raymond.hettinger | 2009-03-09 13:56:23 +0100 (Mo, 09 M?r 2009) | 1 line Add cross-reference to the collections docs. ........ r70281 | benjamin.peterson | 2009-03-09 21:38:56 +0100 (Mo, 09 M?r 2009) | 1 line gzip and bz2 are context managers ........ r70286 | raymond.hettinger | 2009-03-10 01:06:05 +0100 (Di, 10 M?r 2009) | 1 line Fix markup. ........ r70295 | raymond.hettinger | 2009-03-10 09:16:05 +0100 (Di, 10 M?r 2009) | 1 line Update the decimal FAQ for the from_float() classmethod and improve the recipe for remove_exponent() to make it cut and pasteable. ........ r70298 | raymond.hettinger | 2009-03-10 13:50:59 +0100 (Di, 10 M?r 2009) | 1 line For collections.deque() objects, expose the maxlen parameter as a read-only attribute. ........ r70300 | raymond.hettinger | 2009-03-10 14:04:30 +0100 (Di, 10 M?r 2009) | 1 line Fix typo. ........ r70305 | brett.cannon | 2009-03-11 05:51:06 +0100 (Mi, 11 M?r 2009) | 5 lines Require implementations for warnings.showwarning() support the 'line' argument. Was a DeprecationWarning for not supporting it since Python 2.6. Closes issue #3652. ........ r70319 | raymond.hettinger | 2009-03-12 01:31:58 +0100 (Do, 12 M?r 2009) | 1 line Issue 5477: Fix buglet in the itertools documentation. ........ r70471 | raymond.hettinger | 2009-03-19 20:19:03 +0100 (Do, 19 M?r 2009) | 3 lines Issue 5381: Add object_pairs_hook to the json module. ........ r70473 | raymond.hettinger | 2009-03-19 20:59:58 +0100 (Do, 19 M?r 2009) | 6 lines * Add clearer comment to initialization code. * Add optional argument to popitem() -- modeled after Anthon van der Neut's C version. * Fix method markup in docs. ........ r70485 | raymond.hettinger | 2009-03-20 19:25:49 +0100 (Fr, 20 M?r 2009) | 1 line Add MutableSet example. ........ r70546 | antoine.pitrou | 2009-03-23 19:41:45 +0100 (Mo, 23 M?r 2009) | 9 lines Issue #4688: Add a heuristic so that tuples and dicts containing only untrackable objects are not tracked by the garbage collector. This can reduce the size of collections and therefore the garbage collection overhead on long-running programs, depending on their particular use of datatypes. (trivia: this makes the "binary_trees" benchmark from the Computer Language Shootout 40% faster) ........ r70555 | benjamin.peterson | 2009-03-23 22:50:21 +0100 (Mo, 23 M?r 2009) | 4 lines implement test skipping and expected failures patch by myself #1034053 ........ r70558 | benjamin.peterson | 2009-03-23 23:29:45 +0100 (Mo, 23 M?r 2009) | 4 lines comply with the evilJavaNamingScheme for attribute names It seems my love of PEP 8 overrode the need for consistentcy ........ r70561 | benjamin.peterson | 2009-03-24 00:10:14 +0100 (Di, 24 M?r 2009) | 1 line refactor unittest docs ........ r70562 | benjamin.peterson | 2009-03-24 00:13:36 +0100 (Di, 24 M?r 2009) | 1 line forgot to document that setUp can be skipped (silly me...) ........ r70563 | benjamin.peterson | 2009-03-24 00:19:03 +0100 (Di, 24 M?r 2009) | 1 line update from CVS ........ r70564 | raymond.hettinger | 2009-03-24 01:17:11 +0100 (Di, 24 M?r 2009) | 1 line Add links to related resources. ........ r70568 | benjamin.peterson | 2009-03-24 01:35:20 +0100 (Di, 24 M?r 2009) | 1 line some cleanup and modernization ........ r70569 | benjamin.peterson | 2009-03-24 01:36:16 +0100 (Di, 24 M?r 2009) | 1 line remove special metadata ........ r70570 | benjamin.peterson | 2009-03-24 01:37:12 +0100 (Di, 24 M?r 2009) | 1 line update docstring ........ r70571 | benjamin.peterson | 2009-03-24 01:39:24 +0100 (Di, 24 M?r 2009) | 1 line add new skipping things to __all__ ........ r70574 | benjamin.peterson | 2009-03-24 02:11:37 +0100 (Di, 24 M?r 2009) | 1 line fix typo ........ r70578 | benjamin.peterson | 2009-03-24 04:24:56 +0100 (Di, 24 M?r 2009) | 1 line this is better written using assertRaises ........ r70588 | benjamin.peterson | 2009-03-24 23:56:32 +0100 (Di, 24 M?r 2009) | 1 line fix newline issue in test summary ........ r70589 | benjamin.peterson | 2009-03-25 00:07:07 +0100 (Mi, 25 M?r 2009) | 1 line another style nit ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:03:07 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:03:07 -0000 Subject: [Python-checkins] r75775 - in python/branches/release26-maint: Doc/library/csv.rst Doc/library/json.rst Doc/library/os.rst Doc/library/string.rst Doc/library/webbrowser.rst Doc/whatsnew/2.6.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:03:07 2009 New Revision: 75775 Log: Merged revisions 70590,70650,70704,70768-70769,70776,71008,71010-71011 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r70590 | skip.montanaro | 2009-03-25 01:52:11 +0100 (Mi, 25 M?r 2009) | 1 line clarify the type of data returned ........ r70650 | benjamin.peterson | 2009-03-28 20:16:10 +0100 (Sa, 28 M?r 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70704 | benjamin.peterson | 2009-03-30 04:49:32 +0200 (Mo, 30 M?r 2009) | 1 line there's actually three methods here #5600 ........ r70768 | andrew.kuchling | 2009-03-31 00:29:15 +0200 (Di, 31 M?r 2009) | 1 line Typo fixes ........ r70769 | andrew.kuchling | 2009-03-31 00:29:53 +0200 (Di, 31 M?r 2009) | 1 line Remove comment ........ r70776 | andrew.kuchling | 2009-03-31 01:08:24 +0200 (Di, 31 M?r 2009) | 1 line typo fix ........ r71008 | andrew.kuchling | 2009-04-02 02:02:14 +0200 (Do, 02 Apr 2009) | 1 line Typo fix ........ r71010 | benjamin.peterson | 2009-04-02 02:11:52 +0200 (Do, 02 Apr 2009) | 1 line fix markup ........ r71011 | benjamin.peterson | 2009-04-02 02:12:47 +0200 (Do, 02 Apr 2009) | 1 line this should be :noindex: ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/csv.rst python/branches/release26-maint/Doc/library/json.rst python/branches/release26-maint/Doc/library/os.rst python/branches/release26-maint/Doc/library/string.rst python/branches/release26-maint/Doc/library/webbrowser.rst python/branches/release26-maint/Doc/whatsnew/2.6.rst Modified: python/branches/release26-maint/Doc/library/csv.rst ============================================================================== --- python/branches/release26-maint/Doc/library/csv.rst (original) +++ python/branches/release26-maint/Doc/library/csv.rst Tue Oct 27 15:03:07 2009 @@ -72,8 +72,8 @@ dialect. For full details about the dialect and formatting parameters, see section :ref:`csv-fmt-params`. - All data read are returned as strings. No automatic data type conversion is - performed. + Each row read from the csv file is returned as a list of strings. No + automatic data type conversion is performed. A short usage example:: 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 Tue Oct 27 15:03:07 2009 @@ -178,7 +178,7 @@ to a :class:`unicode` object and passed to :func:`loads`. *object_hook* is an optional function that will be called with the result of - any object literal decode (a :class:`dict`). The return value of + any object literal decoded (a :class:`dict`). The return value of *object_hook* will be used instead of the :class:`dict`. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting). Modified: python/branches/release26-maint/Doc/library/os.rst ============================================================================== --- python/branches/release26-maint/Doc/library/os.rst (original) +++ python/branches/release26-maint/Doc/library/os.rst Tue Oct 27 15:03:07 2009 @@ -915,9 +915,10 @@ .. versionadded:: 2.3 -.. function:: link(src, dst) +.. function:: link(source, link_name) - Create a hard link pointing to *src* named *dst*. Availability: Unix. + Create a hard link pointing to *source* named *link_name*. Availability: + Unix. .. function:: listdir(path) @@ -1238,9 +1239,10 @@ Added access to values as attributes of the returned object. -.. function:: symlink(src, dst) +.. function:: symlink(source, link_name) - Create a symbolic link pointing to *src* named *dst*. Availability: Unix. + Create a symbolic link pointing to *source* named *link_name*. Availability: + Unix. .. function:: tempnam([dir[, prefix]]) Modified: python/branches/release26-maint/Doc/library/string.rst ============================================================================== --- python/branches/release26-maint/Doc/library/string.rst (original) +++ python/branches/release26-maint/Doc/library/string.rst Tue Oct 27 15:03:07 2009 @@ -243,6 +243,7 @@ Some simple format string examples:: "First, thou shalt count to {0}" # References first positional argument + "Bring me a {}" # Implicitly references the first positional argument "My quest is {name}" # References keyword argument 'name' "Weight in tons {0.weight}" # 'weight' attribute of first positional arg "Units destroyed: {players[0]}" # First element of keyword argument 'players'. 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 Tue Oct 27 15:03:07 2009 @@ -176,8 +176,8 @@ Browser Controller Objects -------------------------- -Browser controllers provide these methods which parallel two of the module-level -convenience functions: +Browser controllers provide these methods which parallel three of the +module-level convenience functions: .. method:: controller.open(url[, new[, autoraise=1]]) Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.6.rst Tue Oct 27 15:03:07 2009 @@ -84,8 +84,6 @@ .. ======================================================================== .. Large, PEP-level features and changes should be described here. -.. Should there be a new section here for 3k migration? -.. Or perhaps a more general section describing module changes/deprecation? .. ======================================================================== Python 3.0 From python-checkins at python.org Tue Oct 27 15:04:39 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:04:39 -0000 Subject: [Python-checkins] r75776 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 15:04:39 2009 New Revision: 75776 Log: Blocked revisions 70598,70605,70616,70668-70669,70671,70771-70772,70837,70878,70918,70939,70986,71031-71032,71036,71070,71075 via svnmerge ........ r70598 | benjamin.peterson | 2009-03-25 22:24:04 +0100 (Mi, 25 M?r 2009) | 1 line add shorthands for expected failures and unexpected success ........ r70605 | benjamin.peterson | 2009-03-26 17:32:23 +0100 (Do, 26 M?r 2009) | 1 line remove uneeded function ........ r70616 | benjamin.peterson | 2009-03-26 21:05:50 +0100 (Do, 26 M?r 2009) | 1 line rename TestCase.skip() to skipTest() because it causes annoying problems with trial #5571 ........ r70668 | benjamin.peterson | 2009-03-29 05:16:57 +0200 (So, 29 M?r 2009) | 1 line a more realistic example ........ r70669 | benjamin.peterson | 2009-03-29 05:31:40 +0200 (So, 29 M?r 2009) | 1 line stop the versionchanged directive from hiding the docs ........ r70671 | benjamin.peterson | 2009-03-29 05:39:58 +0200 (So, 29 M?r 2009) | 1 line fix consistency ........ r70771 | andrew.kuchling | 2009-03-31 00:31:11 +0200 (Di, 31 M?r 2009) | 1 line Many edits ........ r70772 | barry.warsaw | 2009-03-31 00:42:17 +0200 (Di, 31 M?r 2009) | 5 lines A fix for issue 1974, inspired by the patch from Andi Albrecht (aalbrecht), though with some changes by me. This patch should not be back ported or forward ported. It's a bit too risky for 2.6 and 3.x does things fairly differently. ........ r70837 | gregory.p.smith | 2009-03-31 18:54:10 +0200 (Di, 31 M?r 2009) | 9 lines The unittest.TestCase.assertEqual() now displays the differences in lists, tuples, dicts and sets on failure. Many new handy type and comparison specific assert* methods have been added that fail with error messages actually useful for debugging. Contributed in by Google and completed with help from mfoord and GvR at PyCon 2009 sprints. Discussion lives in http://bugs.python.org/issue2578. ........ r70878 | gregory.p.smith | 2009-03-31 21:59:14 +0200 (Di, 31 M?r 2009) | 3 lines Issue an actual PendingDeprecationWarning for the TestCase.fail* methods. Document the deprecation. ........ r70918 | raymond.hettinger | 2009-04-01 00:43:03 +0200 (Mi, 01 Apr 2009) | 1 line Improve examples for collections.deque() ........ r70939 | jesse.noller | 2009-04-01 05:45:50 +0200 (Mi, 01 Apr 2009) | 1 line Fix multiprocessing.event to match the new threading.Event API ........ r70986 | raymond.hettinger | 2009-04-01 22:50:58 +0200 (Mi, 01 Apr 2009) | 1 line Add link to an alternative generator with a long-period. ........ r71031 | brett.cannon | 2009-04-02 05:17:39 +0200 (Do, 02 Apr 2009) | 6 lines PyImport_AppendInittab() took a char * as a first argument even though that string was stored beyond the life of the call. Changed the signature to be const char * to help make this point. Closes issue #1419652. ........ r71032 | michael.foord | 2009-04-02 05:20:38 +0200 (Do, 02 Apr 2009) | 13 lines Better exception messages for unittest assert methods. - unittest.assertNotEqual() now uses the inequality operator (!=) instead of the equality operator. - Default assertTrue and assertFalse messages are now useful. - TestCase has a longMessage attribute. This defaults to False, but if set to True useful error messages are shown in addition to explicit messages passed to assert methods. Issue #5663 ........ r71036 | jesse.noller | 2009-04-02 06:22:09 +0200 (Do, 02 Apr 2009) | 1 line Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES ........ r71070 | antoine.pitrou | 2009-04-02 23:18:34 +0200 (Do, 02 Apr 2009) | 3 lines Issue #2396: backport the memoryview object. ........ r71075 | raymond.hettinger | 2009-04-03 00:34:17 +0200 (Fr, 03 Apr 2009) | 1 line Update docs for namedtuple's renaming change. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:08:19 2009 From: python-checkins at python.org (barry.warsaw) Date: Tue, 27 Oct 2009 14:08:19 -0000 Subject: [Python-checkins] r75777 - python/branches/release26-maint/Include/patchlevel.h Message-ID: Author: barry.warsaw Date: Tue Oct 27 15:08:18 2009 New Revision: 75777 Log: bump version number Modified: python/branches/release26-maint/Include/patchlevel.h Modified: python/branches/release26-maint/Include/patchlevel.h ============================================================================== --- python/branches/release26-maint/Include/patchlevel.h (original) +++ python/branches/release26-maint/Include/patchlevel.h Tue Oct 27 15:08:18 2009 @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.6.4" +#define PY_VERSION "2.6.4+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository) */ From python-checkins at python.org Tue Oct 27 15:10:28 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:10:28 -0000 Subject: [Python-checkins] r75778 - in python/branches/release26-maint: Doc/library/2to3.rst Doc/library/difflib.rst Doc/library/logging.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:10:28 2009 New Revision: 75778 Log: Merged revisions 71094,71102-71103,71106,71486,71962,72053,72221,72418-72419 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r71094 | vinay.sajip | 2009-04-03 12:23:18 +0200 (Fr, 03 Apr 2009) | 1 line Added warning about logging use from asynchronous signal handlers. ........ r71102 | andrew.kuchling | 2009-04-03 23:44:49 +0200 (Fr, 03 Apr 2009) | 1 line Fix 'the the'; grammar fix ........ r71103 | andrew.kuchling | 2009-04-03 23:45:29 +0200 (Fr, 03 Apr 2009) | 1 line Fix 'the the' duplication ........ r71106 | vinay.sajip | 2009-04-03 23:58:16 +0200 (Fr, 03 Apr 2009) | 1 line Clarified warning about logging use from asynchronous signal handlers. ........ r71486 | andrew.kuchling | 2009-04-11 18:18:14 +0200 (Sa, 11 Apr 2009) | 1 line Re-word ........ r71962 | eric.smith | 2009-04-26 12:05:11 +0200 (So, 26 Apr 2009) | 1 line Note that the caller is resposible for freeing the result of PyOS_double_to_string. ........ r72053 | raymond.hettinger | 2009-04-27 23:12:54 +0200 (Mo, 27 Apr 2009) | 1 line Add example to the seealso section. ........ r72221 | benjamin.peterson | 2009-05-02 22:26:53 +0200 (Sa, 02 Mai 2009) | 1 line add myself ........ r72418 | r.david.murray | 2009-05-07 03:39:25 +0200 (Do, 07 Mai 2009) | 3 lines Document how to pass a 'decode' argument to get_payload when is_multipart is False. ........ r72419 | r.david.murray | 2009-05-07 03:43:57 +0200 (Do, 07 Mai 2009) | 2 lines Revert inappropriate doc change. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/2to3.rst python/branches/release26-maint/Doc/library/difflib.rst python/branches/release26-maint/Doc/library/logging.rst Modified: python/branches/release26-maint/Doc/library/2to3.rst ============================================================================== --- python/branches/release26-maint/Doc/library/2to3.rst (original) +++ python/branches/release26-maint/Doc/library/2to3.rst Tue Oct 27 15:10:28 2009 @@ -345,6 +345,7 @@ :synopsis: the 2to3 library .. moduleauthor:: Guido van Rossum .. moduleauthor:: Collin Winter +.. moduleauthor:: Benjamin Peterson .. note:: Modified: python/branches/release26-maint/Doc/library/difflib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/difflib.rst (original) +++ python/branches/release26-maint/Doc/library/difflib.rst Tue Oct 27 15:10:28 2009 @@ -577,8 +577,15 @@ insert a[8:8] b[8:17] equal a[8:29] b[17:38] -See also the function :func:`get_close_matches` in this module, which shows how -simple code building on :class:`SequenceMatcher` can be used to do useful work. +.. seealso:: + + * The :func:`get_close_matches` function in this module which shows how + simple code building on :class:`SequenceMatcher` can be used to do useful + work. + + * `Simple version control recipe + `_ for a small application + built with :class:`SequenceMatcher`. .. _differ-objects: 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 Tue Oct 27 15:10:28 2009 @@ -2316,6 +2316,10 @@ locks; there is one lock to serialize access to the module's shared data, and each handler also creates a lock to serialize access to its underlying I/O. +If you are implementing asynchronous signal handlers using the :mod:`signal` +module, you may not be able to use logging from within such handlers. This is +because lock implementations in the :mod:`threading` module are not always +re-entrant, and so cannot be invoked from such signal handlers. Configuration ------------- From python-checkins at python.org Tue Oct 27 15:12:28 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:12:28 -0000 Subject: [Python-checkins] r75779 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 15:12:28 2009 New Revision: 75779 Log: Blocked revisions 71119,71263,71406,71419,71430,71435,71448,71771,72173,72191,72198,72219,72225,72267,72487-72489,72494 via svnmerge ................ r71119 | raymond.hettinger | 2009-04-04 07:37:47 +0200 (Sa, 04 Apr 2009) | 1 line Add helpful link. ................ r71263 | michael.foord | 2009-04-05 21:19:28 +0200 (So, 05 Apr 2009) | 4 lines Adding assertIs and assertIsNot methods to unittest.TestCase Issue #2578 ................ r71406 | andrew.kuchling | 2009-04-09 13:23:36 +0200 (Do, 09 Apr 2009) | 1 line Typo fixes ................ r71419 | raymond.hettinger | 2009-04-10 00:31:51 +0200 (Fr, 10 Apr 2009) | 1 line Add note on using keyword arguments with OrderedDict. ................ r71430 | raymond.hettinger | 2009-04-10 06:25:45 +0200 (Fr, 10 Apr 2009) | 1 line Clarify the table entries for combinatorics. ................ r71435 | raymond.hettinger | 2009-04-10 08:38:39 +0200 (Fr, 10 Apr 2009) | 1 line Fix the count of datatypes. ................ r71448 | raymond.hettinger | 2009-04-10 15:16:50 +0200 (Fr, 10 Apr 2009) | 1 line Add examples. ................ r71771 | raymond.hettinger | 2009-04-20 20:23:57 +0200 (Mo, 20 Apr 2009) | 1 line Fix typo ................ r72173 | gregory.p.smith | 2009-05-01 21:59:52 +0200 (Fr, 01 Mai 2009) | 5 lines Adds the ipaddr module to the standard library. Issue #3959. Based off of subversion r69 from http://code.google.com/p/ipaddr-py/ This code is 2to3 safe, I'll merge it into py3k later this afternoon. ................ r72191 | michael.foord | 2009-05-02 13:43:06 +0200 (Sa, 02 Mai 2009) | 9 lines Adds an exit parameter to unittest.main(). If False main no longer calls sys.exit. Closes issue 3379. Michael Foord ................ r72198 | andrew.kuchling | 2009-05-02 19:12:15 +0200 (Sa, 02 Mai 2009) | 1 line Add items ................ r72219 | michael.foord | 2009-05-02 22:15:05 +0200 (Sa, 02 Mai 2009) | 8 lines Add addCleanup and doCleanups to unittest.TestCase. Closes issue 5679. Michael Foord ................ r72225 | michael.foord | 2009-05-03 00:43:34 +0200 (So, 03 Mai 2009) | 1 line ................ r72267 | gregory.p.smith | 2009-05-04 02:16:49 +0200 (Mo, 04 Mai 2009) | 3 lines Issue #4751: For hashlib algorithms provided by OpenSSL, the Python GIL is now released during computation on data lengths >= 2048 bytes. ................ r72487 | jeffrey.yasskin | 2009-05-08 23:51:06 +0200 (Fr, 08 Mai 2009) | 7 lines PyCode_NewEmpty: Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New are trying to build an empty code object, usually to put it in a dummy frame object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify just the filename, function name, and first line number, instead of also requiring lots of code internals. ................ r72488 | jeffrey.yasskin | 2009-05-09 00:23:21 +0200 (Sa, 09 Mai 2009) | 13 lines Issue 5954, PyFrame_GetLineNumber: Most uses of PyCode_Addr2Line (http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get the line number of a specified frame, but there's no way to do that directly. Forcing people to go through the code object makes them know more about the guts of the interpreter than they should need. The remaining uses of PyCode_Addr2Line seem to be getting the line from a traceback (for example, http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line), which is replaced by the tb_lineno field. So we may be able to deprecate PyCode_Addr2Line entirely for external use. ................ r72489 | gregory.p.smith | 2009-05-09 01:16:47 +0200 (Sa, 09 Mai 2009) | 3 lines Fix an off by one error on negative indexs to __getitem__ http://code.google.com/p/ipaddr-py/issues/detail?id=15 ................ r72494 | benjamin.peterson | 2009-05-09 03:01:14 +0200 (Sa, 09 Mai 2009) | 21 lines Merged revisions 72491-72493 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r72491 | benjamin.peterson | 2009-05-08 19:33:27 -0500 (Fri, 08 May 2009) | 7 lines make 2to3 use unicode internally on 2.x This started out as a fix for #2660, but became this large refactoring when I realized the dire state this was in. 2to3 now uses tokenize.detect_encoding to decode the files correctly into unicode. ........ r72492 | benjamin.peterson | 2009-05-08 19:35:38 -0500 (Fri, 08 May 2009) | 1 line remove compat code ........ r72493 | benjamin.peterson | 2009-05-08 19:54:15 -0500 (Fri, 08 May 2009) | 1 line add a test for \r\n newlines ........ ................ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:19:50 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:19:50 -0000 Subject: [Python-checkins] r75780 - in python/branches/release26-maint: Doc/c-api/buffer.rst Doc/c-api/list.rst Doc/c-api/sequence.rst Doc/conf.py Doc/howto/regex.rst Doc/howto/sockets.rst Doc/includes/email-unpack.py Doc/includes/mp_pool.py Doc/includes/mp_synchronize.py Doc/library/crypt.rst Doc/library/ctypes.rst Doc/library/easydialogs.rst Doc/library/exceptions.rst Doc/library/fcntl.rst Doc/library/imputil.rst Doc/library/os.rst Doc/library/platform.rst Doc/library/rexec.rst Doc/library/rlcompleter.rst Doc/library/shutil.rst Doc/library/signal.rst Doc/library/socket.rst Doc/library/tkinter.rst Doc/reference/simple_stmts.rst Doc/tools/roman.py Doc/tools/sphinxext/suspicious.py Doc/tutorial/controlflow.rst Doc/whatsnew/2.6.rst Lib/imputil.py Objects/unicodeobject.c Message-ID: Author: georg.brandl Date: Tue Oct 27 15:19:50 2009 New Revision: 75780 Log: Merged revisions 72558,72745,72750,72876,73042,73045-73048,73069,73089,73163,73186,73213,73215,73217,73257-73258,73260 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r72558 | benjamin.peterson | 2009-05-11 01:52:09 +0200 (Mo, 11 Mai 2009) | 1 line sys.setdefaultencoding() strikes me as a bad example ........ r72745 | benjamin.peterson | 2009-05-17 16:16:29 +0200 (So, 17 Mai 2009) | 1 line ignore .rst files in sphinx its self ........ r72750 | benjamin.peterson | 2009-05-17 18:59:27 +0200 (So, 17 Mai 2009) | 1 line chop off slash ........ r72876 | benjamin.peterson | 2009-05-23 22:59:09 +0200 (Sa, 23 Mai 2009) | 1 line remove mention of old ctypes version ........ r73042 | benjamin.peterson | 2009-05-30 05:10:52 +0200 (Sa, 30 Mai 2009) | 1 line no fdatasync on macos ........ r73045 | georg.brandl | 2009-05-30 09:26:04 +0200 (Sa, 30 Mai 2009) | 1 line #6146: fix markup bug. ........ r73046 | georg.brandl | 2009-05-30 09:31:25 +0200 (Sa, 30 Mai 2009) | 1 line Use preferred form of raising exceptions. ........ r73047 | georg.brandl | 2009-05-30 12:33:23 +0200 (Sa, 30 Mai 2009) | 1 line Fix some more small markup problems. ........ r73048 | georg.brandl | 2009-05-30 12:34:25 +0200 (Sa, 30 Mai 2009) | 1 line Fix markup problem. ........ r73069 | benjamin.peterson | 2009-05-31 02:42:42 +0200 (So, 31 Mai 2009) | 1 line fix signature ........ r73089 | andrew.kuchling | 2009-06-01 02:14:19 +0200 (Mo, 01 Jun 2009) | 1 line The class for regexes isn't called RegexObject any more; correct the text ........ r73163 | georg.brandl | 2009-06-03 09:25:35 +0200 (Mi, 03 Jun 2009) | 1 line Use the preferred form of raise statements in the docs. ........ r73186 | georg.brandl | 2009-06-03 23:21:09 +0200 (Mi, 03 Jun 2009) | 1 line #6174: fix indentation in code example. ........ r73213 | georg.brandl | 2009-06-04 12:15:57 +0200 (Do, 04 Jun 2009) | 1 line #5967: note that the C slicing APIs do not support negative indices. ........ r73215 | georg.brandl | 2009-06-04 12:22:31 +0200 (Do, 04 Jun 2009) | 1 line #6176: fix man page section for flock(2). ........ r73217 | georg.brandl | 2009-06-04 12:27:21 +0200 (Do, 04 Jun 2009) | 1 line #6175: document that inet_aton supports alternate input formats with less than three dots. ........ r73257 | georg.brandl | 2009-06-06 19:50:05 +0200 (Sa, 06 Jun 2009) | 1 line #6211: elaborate a bit on ways to call the function. ........ r73258 | georg.brandl | 2009-06-06 19:51:31 +0200 (Sa, 06 Jun 2009) | 1 line #6204: use a real reference instead of "see later". ........ r73260 | georg.brandl | 2009-06-06 20:21:58 +0200 (Sa, 06 Jun 2009) | 1 line #6224: s/JPython/Jython/, and remove one link to a module nine years old. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/buffer.rst python/branches/release26-maint/Doc/c-api/list.rst python/branches/release26-maint/Doc/c-api/sequence.rst python/branches/release26-maint/Doc/conf.py python/branches/release26-maint/Doc/howto/regex.rst python/branches/release26-maint/Doc/howto/sockets.rst python/branches/release26-maint/Doc/includes/email-unpack.py python/branches/release26-maint/Doc/includes/mp_pool.py python/branches/release26-maint/Doc/includes/mp_synchronize.py python/branches/release26-maint/Doc/library/crypt.rst python/branches/release26-maint/Doc/library/ctypes.rst python/branches/release26-maint/Doc/library/easydialogs.rst python/branches/release26-maint/Doc/library/exceptions.rst python/branches/release26-maint/Doc/library/fcntl.rst python/branches/release26-maint/Doc/library/imputil.rst python/branches/release26-maint/Doc/library/os.rst python/branches/release26-maint/Doc/library/platform.rst python/branches/release26-maint/Doc/library/rexec.rst python/branches/release26-maint/Doc/library/rlcompleter.rst python/branches/release26-maint/Doc/library/shutil.rst python/branches/release26-maint/Doc/library/signal.rst python/branches/release26-maint/Doc/library/socket.rst python/branches/release26-maint/Doc/library/tkinter.rst python/branches/release26-maint/Doc/reference/simple_stmts.rst python/branches/release26-maint/Doc/tools/roman.py python/branches/release26-maint/Doc/tools/sphinxext/suspicious.py python/branches/release26-maint/Doc/tutorial/controlflow.rst python/branches/release26-maint/Doc/whatsnew/2.6.rst python/branches/release26-maint/Lib/imputil.py python/branches/release26-maint/Objects/unicodeobject.c Modified: python/branches/release26-maint/Doc/c-api/buffer.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/buffer.rst (original) +++ python/branches/release26-maint/Doc/c-api/buffer.rst Tue Oct 27 15:19:50 2009 @@ -140,7 +140,7 @@ Return 1 if *obj* supports the buffer interface otherwise 0. -.. cfunction:: int PyObject_GetBuffer(PyObject *obj, PyObject *view, int flags) +.. cfunction:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) Export *obj* into a :ctype:`Py_buffer`, *view*. These arguments must never be *NULL*. The *flags* argument is a bit field indicating what Modified: python/branches/release26-maint/Doc/c-api/list.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/list.rst (original) +++ python/branches/release26-maint/Doc/c-api/list.rst Tue Oct 27 15:19:50 2009 @@ -149,9 +149,10 @@ .. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high) - Return a list of the objects in *list* containing the objects *between* - *low* and *high*. Return *NULL* and set an exception if unsuccessful. - Analogous to ``list[low:high]``. + Return a list of the objects in *list* containing the objects *between* *low* + and *high*. Return *NULL* and set an exception if unsuccessful. Analogous + to ``list[low:high]``. Negative indices, as when slicing from Python, are not + supported. .. versionchanged:: 2.5 This function used an :ctype:`int` for *low* and *high*. This might @@ -163,7 +164,8 @@ Set the slice of *list* between *low* and *high* to the contents of *itemlist*. Analogous to ``list[low:high] = itemlist``. The *itemlist* may be *NULL*, indicating the assignment of an empty list (slice deletion). - Return ``0`` on success, ``-1`` on failure. + Return ``0`` on success, ``-1`` on failure. Negative indices, as when + slicing from Python, are not supported. .. versionchanged:: 2.5 This function used an :ctype:`int` for *low* and *high*. This might Modified: python/branches/release26-maint/Doc/c-api/sequence.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/sequence.rst (original) +++ python/branches/release26-maint/Doc/c-api/sequence.rst Tue Oct 27 15:19:50 2009 @@ -62,7 +62,7 @@ .. cfunction:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i) - Return the *i*th element of *o*, or *NULL* on failure. This is the equivalent of + Return the *i*\ th element of *o*, or *NULL* on failure. This is the equivalent of the Python expression ``o[i]``. .. versionchanged:: 2.5 @@ -82,7 +82,7 @@ .. cfunction:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v) - Assign object *v* to the *i*th element of *o*. Returns ``-1`` on failure. This + Assign object *v* to the *i*\ th element of *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o[i] = v``. This function *does not* steal a reference to *v*. @@ -93,7 +93,7 @@ .. cfunction:: int PySequence_DelItem(PyObject *o, Py_ssize_t i) - Delete the *i*th element of object *o*. Returns ``-1`` on failure. This is the + Delete the *i*\ th element of object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o[i]``. .. versionchanged:: 2.5 @@ -175,7 +175,7 @@ .. cfunction:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i) - Return the *i*th element of *o*, assuming that *o* was returned by + Return the *i*\ th element of *o*, assuming that *o* was returned by :cfunc:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds. .. versionchanged:: 2.5 @@ -197,7 +197,7 @@ .. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i) - Return the *i*th element of *o* or *NULL* on failure. Macro form of + Return the *i*\ th element of *o* or *NULL* on failure. Macro form of :cfunc:`PySequence_GetItem` but without checking that :cfunc:`PySequence_Check(o)` is true and without adjustment for negative indices. Modified: python/branches/release26-maint/Doc/conf.py ============================================================================== --- python/branches/release26-maint/Doc/conf.py (original) +++ python/branches/release26-maint/Doc/conf.py Tue Oct 27 15:19:50 2009 @@ -46,6 +46,9 @@ 'library/xml.etree', ] +# Ignore .rst in Sphinx its self. +exclude_trees = ['tools/sphinx'] + # Relative filename of the reference count data file. refcount_file = 'data/refcounts.dat' Modified: python/branches/release26-maint/Doc/howto/regex.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/regex.rst (original) +++ python/branches/release26-maint/Doc/howto/regex.rst Tue Oct 27 15:19:50 2009 @@ -257,7 +257,7 @@ Compiling Regular Expressions ----------------------------- -Regular expressions are compiled into :class:`RegexObject` instances, which have +Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. :: @@ -336,7 +336,7 @@ ------------------ Once you have an object representing a compiled regular expression, what do you -do with it? :class:`RegexObject` instances have several methods and attributes. +do with it? Pattern objects have several methods and attributes. Only the most significant ones will be covered here; consult the :mod:`re` docs for a complete listing. @@ -427,8 +427,8 @@ and :meth:`end` return the starting and ending index of the match. :meth:`span` returns both start and end indexes in a single tuple. Since the :meth:`match` method only checks if the RE matches at the start of a string, :meth:`start` -will always be zero. However, the :meth:`search` method of :class:`RegexObject` -instances scans through the string, so the match may not start at zero in that +will always be zero. However, the :meth:`search` method of patterns +scans through the string, so the match may not start at zero in that case. :: >>> print p.match('::: message') @@ -450,7 +450,7 @@ else: print 'No match' -Two :class:`RegexObject` methods return all of the matches for a pattern. +Two pattern methods return all of the matches for a pattern. :meth:`findall` returns a list of matching strings:: >>> p = re.compile('\d+') @@ -475,10 +475,10 @@ Module-Level Functions ---------------------- -You don't have to create a :class:`RegexObject` and call its methods; the +You don't have to create a pattern object and call its methods; the :mod:`re` module also provides top-level functions called :func:`match`, :func:`search`, :func:`findall`, :func:`sub`, and so forth. These functions -take the same arguments as the corresponding :class:`RegexObject` method, with +take the same arguments as the corresponding pattern method, with the RE string added as the first argument, and still return either ``None`` or a :class:`MatchObject` instance. :: @@ -487,12 +487,12 @@ >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998') -Under the hood, these functions simply produce a :class:`RegexObject` for you +Under the hood, these functions simply create a pattern object for you and call the appropriate method on it. They also store the compiled object in a cache, so future calls using the same RE are faster. Should you use these module-level functions, or should you get the -:class:`RegexObject` and call its methods yourself? That choice depends on how +pattern and call its methods yourself? That choice depends on how frequently the RE will be used, and on your personal coding style. If the RE is being used at only one point in the code, then the module functions are probably more convenient. If a program contains a lot of regular expressions, or re-uses @@ -1030,7 +1030,7 @@ Up to this point, we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, -using the following :class:`RegexObject` methods: +using the following pattern methods: +------------------+-----------------------------------------------+ | Method/Attribute | Purpose | @@ -1050,7 +1050,7 @@ Splitting Strings ----------------- -The :meth:`split` method of a :class:`RegexObject` splits a string apart +The :meth:`split` method of a pattern splits a string apart wherever the RE matches, returning a list of the pieces. It's similar to the :meth:`split` method of strings but provides much more generality in the delimiters that you can split by; :meth:`split` only supports splitting by @@ -1195,10 +1195,10 @@ 'Call 0xffd2 for printing, 0xc000 for user code.' When using the module-level :func:`re.sub` function, the pattern is passed as -the first argument. The pattern may be a string or a :class:`RegexObject`; if +the first argument. The pattern may be provided as an object or as a string; if you need to specify regular expression flags, you must either use a -:class:`RegexObject` as the first parameter, or use embedded modifiers in the -pattern, e.g. ``sub("(?i)b+", "x", "bbbb BBBB")`` returns ``'x x'``. +pattern object as the first parameter, or use embedded modifiers in the +pattern string, e.g. ``sub("(?i)b+", "x", "bbbb BBBB")`` returns ``'x x'``. Common Problems Modified: python/branches/release26-maint/Doc/howto/sockets.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/sockets.rst (original) +++ python/branches/release26-maint/Doc/howto/sockets.rst Tue Oct 27 15:19:50 2009 @@ -204,8 +204,7 @@ while totalsent < MSGLEN: sent = self.sock.send(msg[totalsent:]) if sent == 0: - raise RuntimeError, \ - "socket connection broken" + raise RuntimeError("socket connection broken") totalsent = totalsent + sent def myreceive(self): @@ -213,8 +212,7 @@ while len(msg) < MSGLEN: chunk = self.sock.recv(MSGLEN-len(msg)) if chunk == '': - raise RuntimeError, \ - "socket connection broken" + raise RuntimeError("socket connection broken") msg = msg + chunk return msg Modified: python/branches/release26-maint/Doc/includes/email-unpack.py ============================================================================== --- python/branches/release26-maint/Doc/includes/email-unpack.py (original) +++ python/branches/release26-maint/Doc/includes/email-unpack.py Tue Oct 27 15:19:50 2009 @@ -37,7 +37,7 @@ os.mkdir(opts.directory) except OSError, e: # Ignore directory exists error - if e.errno <> errno.EEXIST: + if e.errno != errno.EEXIST: raise fp = open(msgfile) Modified: python/branches/release26-maint/Doc/includes/mp_pool.py ============================================================================== --- python/branches/release26-maint/Doc/includes/mp_pool.py (original) +++ python/branches/release26-maint/Doc/includes/mp_pool.py Tue Oct 27 15:19:50 2009 @@ -149,21 +149,21 @@ except ZeroDivisionError: print '\tGot ZeroDivisionError as expected from pool.apply()' else: - raise AssertionError, 'expected ZeroDivisionError' + raise AssertionError('expected ZeroDivisionError') try: print pool.map(f, range(10)) except ZeroDivisionError: print '\tGot ZeroDivisionError as expected from pool.map()' else: - raise AssertionError, 'expected ZeroDivisionError' + raise AssertionError('expected ZeroDivisionError') try: print list(pool.imap(f, range(10))) except ZeroDivisionError: print '\tGot ZeroDivisionError as expected from list(pool.imap())' else: - raise AssertionError, 'expected ZeroDivisionError' + raise AssertionError('expected ZeroDivisionError') it = pool.imap(f, range(10)) for i in range(10): @@ -176,7 +176,7 @@ break else: if i == 5: - raise AssertionError, 'expected ZeroDivisionError' + raise AssertionError('expected ZeroDivisionError') assert i == 9 print '\tGot ZeroDivisionError as expected from IMapIterator.next()' Modified: python/branches/release26-maint/Doc/includes/mp_synchronize.py ============================================================================== --- python/branches/release26-maint/Doc/includes/mp_synchronize.py (original) +++ python/branches/release26-maint/Doc/includes/mp_synchronize.py Tue Oct 27 15:19:50 2009 @@ -249,7 +249,7 @@ info = multiprocessing._debug_info() if info: print info - raise ValueError, 'there should be no positive refcounts left' + raise ValueError('there should be no positive refcounts left') if __name__ == '__main__': @@ -271,6 +271,6 @@ import multiprocessing.dummy as namespace else: print 'Usage:\n\t%s [processes | manager | threads]' % sys.argv[0] - raise SystemExit, 2 + raise SystemExit(2) test(namespace) Modified: python/branches/release26-maint/Doc/library/crypt.rst ============================================================================== --- python/branches/release26-maint/Doc/library/crypt.rst (original) +++ python/branches/release26-maint/Doc/library/crypt.rst Tue Oct 27 15:19:50 2009 @@ -52,7 +52,8 @@ cryptedpasswd = pwd.getpwnam(username)[1] if cryptedpasswd: if cryptedpasswd == 'x' or cryptedpasswd == '*': - raise "Sorry, currently no support for shadow passwords" + raise NotImplementedError( + "Sorry, currently no support for shadow passwords") cleartext = getpass.getpass() return crypt.crypt(cleartext, cryptedpasswd) == cryptedpasswd else: Modified: python/branches/release26-maint/Doc/library/ctypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ctypes.rst (original) +++ python/branches/release26-maint/Doc/library/ctypes.rst Tue Oct 27 15:19:50 2009 @@ -1210,8 +1210,7 @@ Variable-sized data types ^^^^^^^^^^^^^^^^^^^^^^^^^ -``ctypes`` provides some support for variable-sized arrays and structures (this -was added in version 0.9.9.7). +``ctypes`` provides some support for variable-sized arrays and structures. The ``resize`` function can be used to resize the memory buffer of an existing ctypes object. The function takes the object as first argument, and the Modified: python/branches/release26-maint/Doc/library/easydialogs.rst ============================================================================== --- python/branches/release26-maint/Doc/library/easydialogs.rst (original) +++ python/branches/release26-maint/Doc/library/easydialogs.rst Tue Oct 27 15:19:50 2009 @@ -100,7 +100,7 @@ +----------------------+------------------------------------------+ *commandlist* is a list of items of the form *cmdstr* or ``(cmdstr, descr)``, - where *descr* is as above. The *cmdstr*s will appear in a popup menu. When + where *descr* is as above. The *cmdstr*\ s will appear in a popup menu. When chosen, the text of *cmdstr* will be appended to the command line as is, except that a trailing ``':'`` or ``'='`` (if present) will be trimmed off. Modified: python/branches/release26-maint/Doc/library/exceptions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/exceptions.rst (original) +++ python/branches/release26-maint/Doc/library/exceptions.rst Tue Oct 27 15:19:50 2009 @@ -84,9 +84,9 @@ .. exception:: LookupError - The base class for the exceptions that are raised when a key or index used on a - mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. This can be - raised directly by :func:`sys.setdefaultencoding`. + The base class for the exceptions that are raised when a key or index used on + a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. This + can be raised directly by :func:`codecs.lookup`. .. exception:: EnvironmentError Modified: python/branches/release26-maint/Doc/library/fcntl.rst ============================================================================== --- python/branches/release26-maint/Doc/library/fcntl.rst (original) +++ python/branches/release26-maint/Doc/library/fcntl.rst Tue Oct 27 15:19:50 2009 @@ -96,7 +96,7 @@ Perform the lock operation *op* on file descriptor *fd* (file objects providing a :meth:`fileno` method are accepted as well). See the Unix manual - :manpage:`flock(3)` for details. (On some systems, this function is emulated + :manpage:`flock(2)` for details. (On some systems, this function is emulated using :cfunc:`fcntl`.) Modified: python/branches/release26-maint/Doc/library/imputil.rst ============================================================================== --- python/branches/release26-maint/Doc/library/imputil.rst (original) +++ python/branches/release26-maint/Doc/library/imputil.rst Tue Oct 27 15:19:50 2009 @@ -160,7 +160,7 @@ parent = None q = import_module(head, qname, parent) if q: return q, tail - raise ImportError, "No module named " + qname + raise ImportError("No module named " + qname) def load_tail(q, tail): m = q @@ -171,7 +171,7 @@ mname = "%s.%s" % (m.__name__, head) m = import_module(head, mname, m) if not m: - raise ImportError, "No module named " + mname + raise ImportError("No module named " + mname) return m def ensure_fromlist(m, fromlist, recursive=0): @@ -189,7 +189,7 @@ subname = "%s.%s" % (m.__name__, sub) submod = import_module(sub, subname, m) if not submod: - raise ImportError, "No module named " + subname + raise ImportError("No module named " + subname) def import_module(partname, fqname, parent): try: Modified: python/branches/release26-maint/Doc/library/os.rst ============================================================================== --- python/branches/release26-maint/Doc/library/os.rst (original) +++ python/branches/release26-maint/Doc/library/os.rst Tue Oct 27 15:19:50 2009 @@ -528,6 +528,9 @@ Force write of file with filedescriptor *fd* to disk. Does not force update of metadata. Availability: Unix. + .. note:: + This function is not available on MacOS. + .. function:: fpathconf(fd, name) Modified: python/branches/release26-maint/Doc/library/platform.rst ============================================================================== --- python/branches/release26-maint/Doc/library/platform.rst (original) +++ python/branches/release26-maint/Doc/library/platform.rst Tue Oct 27 15:19:50 2009 @@ -169,7 +169,7 @@ .. function:: java_ver(release='', vendor='', vminfo=('','',''), osinfo=('','','')) - Version interface for JPython. + Version interface for Jython. Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple Modified: python/branches/release26-maint/Doc/library/rexec.rst ============================================================================== --- python/branches/release26-maint/Doc/library/rexec.rst (original) +++ python/branches/release26-maint/Doc/library/rexec.rst Tue Oct 27 15:19:50 2009 @@ -272,11 +272,11 @@ elif mode in ('w', 'wb', 'a', 'ab'): # check filename : must begin with /tmp/ if file[:5]!='/tmp/': - raise IOError, "can't write outside /tmp" + raise IOError("can't write outside /tmp") elif (string.find(file, '/../') >= 0 or file[:3] == '../' or file[-3:] == '/..'): - raise IOError, "'..' in filename forbidden" - else: raise IOError, "Illegal open() mode" + raise IOError("'..' in filename forbidden") + else: raise IOError("Illegal open() mode") return open(file, mode, buf) Notice that the above code will occasionally forbid a perfectly valid filename; Modified: python/branches/release26-maint/Doc/library/rlcompleter.rst ============================================================================== --- python/branches/release26-maint/Doc/library/rlcompleter.rst (original) +++ python/branches/release26-maint/Doc/library/rlcompleter.rst Tue Oct 27 15:19:50 2009 @@ -52,7 +52,7 @@ .. method:: Completer.complete(text, state) - Return the *state*th completion for *text*. + Return the *state*\ th completion for *text*. If called for *text* that doesn't include a period character (``'.'``), it will complete from names currently defined in :mod:`__main__`, :mod:`__builtin__` and Modified: python/branches/release26-maint/Doc/library/shutil.rst ============================================================================== --- python/branches/release26-maint/Doc/library/shutil.rst (original) +++ python/branches/release26-maint/Doc/library/shutil.rst Tue Oct 27 15:19:50 2009 @@ -216,7 +216,7 @@ except OSError, why: errors.extend((src, dst, str(why))) if errors: - raise Error, errors + raise Error(errors) Another example that uses the :func:`ignore_patterns` helper:: Modified: python/branches/release26-maint/Doc/library/signal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/signal.rst (original) +++ python/branches/release26-maint/Doc/library/signal.rst Tue Oct 27 15:19:50 2009 @@ -232,7 +232,7 @@ def handler(signum, frame): print 'Signal handler called with signal', signum - raise IOError, "Couldn't open device!" + raise IOError("Couldn't open device!") # Set the signal handler and a 5-second alarm signal.signal(signal.SIGALRM, handler) Modified: python/branches/release26-maint/Doc/library/socket.rst ============================================================================== --- python/branches/release26-maint/Doc/library/socket.rst (original) +++ python/branches/release26-maint/Doc/library/socket.rst Tue Oct 27 15:19:50 2009 @@ -401,6 +401,9 @@ library and needs objects of type :ctype:`struct in_addr`, which is the C type for the 32-bit packed binary this function returns. + :func:`inet_aton` also accepts strings with less than three dots; see the + Unix manual page :manpage:`inet(3)` for details. + If the IPv4 address string passed to this function is invalid, :exc:`socket.error` will be raised. Note that exactly what is valid depends on the underlying C implementation of :cfunc:`inet_aton`. Modified: python/branches/release26-maint/Doc/library/tkinter.rst ============================================================================== --- python/branches/release26-maint/Doc/library/tkinter.rst (original) +++ python/branches/release26-maint/Doc/library/tkinter.rst Tue Oct 27 15:19:50 2009 @@ -29,9 +29,6 @@ `Tkinter reference: a GUI for Python `_ On-line reference material. - `Tkinter for JPython `_ - The Jython interface to Tkinter. - `Python and Tkinter Programming `_ The book by John Grayson (ISBN 1-884777-81-3). Modified: python/branches/release26-maint/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/simple_stmts.rst (original) +++ python/branches/release26-maint/Doc/reference/simple_stmts.rst Tue Oct 27 15:19:50 2009 @@ -288,7 +288,7 @@ The extended form, ``assert expression1, expression2``, is equivalent to :: if __debug__: - if not expression1: raise AssertionError, expression2 + if not expression1: raise AssertionError(expression2) .. index:: single: __debug__ Modified: python/branches/release26-maint/Doc/tools/roman.py ============================================================================== --- python/branches/release26-maint/Doc/tools/roman.py (original) +++ python/branches/release26-maint/Doc/tools/roman.py Tue Oct 27 15:19:50 2009 @@ -40,9 +40,9 @@ def toRoman(n): """convert integer to Roman numeral""" if not (0 < n < 5000): - raise OutOfRangeError, "number out of range (must be 1..4999)" - if int(n) <> n: - raise NotIntegerError, "decimals can not be converted" + raise OutOfRangeError("number out of range (must be 1..4999)") + if int(n) != n: + raise NotIntegerError("decimals can not be converted") result = "" for numeral, integer in romanNumeralMap: @@ -67,9 +67,9 @@ def fromRoman(s): """convert Roman numeral to integer""" if not s: - raise InvalidRomanNumeralError, 'Input can not be blank' + raise InvalidRomanNumeralError('Input can not be blank') if not romanNumeralPattern.search(s): - raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s + raise InvalidRomanNumeralError('Invalid Roman numeral: %s' % s) result = 0 index = 0 Modified: python/branches/release26-maint/Doc/tools/sphinxext/suspicious.py ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/suspicious.py (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/suspicious.py Tue Oct 27 15:19:50 2009 @@ -164,7 +164,7 @@ except IOError: return for i, row in enumerate(csv.reader(f)): if len(row) != 4: - raise ValueError, "wrong format in %s, line %d: %s" % (filename, i+1, row) + raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row)) docname, lineno, issue, text = row docname = docname.decode('utf-8') if lineno: lineno = int(lineno) Modified: python/branches/release26-maint/Doc/tutorial/controlflow.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/controlflow.rst (original) +++ python/branches/release26-maint/Doc/tutorial/controlflow.rst Tue Oct 27 15:19:50 2009 @@ -285,7 +285,7 @@ and ``methodname`` is the name of a method that is defined by the object's type. Different types define different methods. Methods of different types may have the same name without causing ambiguity. (It is possible to define your own - object types and methods, using *classes*, as discussed later in this tutorial.) + object types and methods, using *classes*, see :ref:`tut-classes`) The method :meth:`append` shown in the example is defined for list objects; it adds a new element at the end of the list. In this example it is equivalent to ``result = result + [b]``, but more efficient. @@ -312,14 +312,23 @@ def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): while True: ok = raw_input(prompt) - if ok in ('y', 'ye', 'yes'): return True - if ok in ('n', 'no', 'nop', 'nope'): return False + if ok in ('y', 'ye', 'yes'): + return True + if ok in ('n', 'no', 'nop', 'nope'): + return False retries = retries - 1 - if retries < 0: raise IOError, 'refusenik user' + if retries < 0: + raise IOError('refusenik user') print complaint -This function can be called either like this: ``ask_ok('Do you really want to -quit?')`` or like this: ``ask_ok('OK to overwrite the file?', 2)``. +This function can be called in several ways: + +* giving only the mandatory argument: + ``ask_ok('Do you really want to quit?')`` +* giving one of the optional arguments: + ``ask_ok('OK to overwrite the file?', 2)`` +* or even giving all arguments: + ``ask_ok('OK to overwrite the file?', 2, 'Come on, only yes or no!')`` This example also introduces the :keyword:`in` keyword. This tests whether or not a sequence contains a certain value. Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.6.rst Tue Oct 27 15:19:50 2009 @@ -678,15 +678,15 @@ for N in range(1, 1000, 10): p.apply_async(factorial, (N, d)) - # Mark pool as closed -- no more tasks can be added. - p.close() + # Mark pool as closed -- no more tasks can be added. + p.close() - # Wait for tasks to exit - p.join() + # Wait for tasks to exit + p.join() - # Output results - for k, v in sorted(d.items()): - print k, v + # Output results + for k, v in sorted(d.items()): + print k, v This will produce the output:: Modified: python/branches/release26-maint/Lib/imputil.py ============================================================================== --- python/branches/release26-maint/Lib/imputil.py (original) +++ python/branches/release26-maint/Lib/imputil.py Tue Oct 27 15:19:50 2009 @@ -14,7 +14,7 @@ del warnpy3k # note: avoid importing non-builtin modules -import imp ### not available in JPython? +import imp ### not available in Jython? import sys import __builtin__ @@ -25,7 +25,7 @@ __all__ = ["ImportManager","Importer","BuiltinImporter"] _StringType = type('') -_ModuleType = type(sys) ### doesn't work in JPython... +_ModuleType = type(sys) ### doesn't work in Jython... class ImportManager: "Manage the import process." @@ -639,8 +639,8 @@ # TODO # # from Finn Bock: -# type(sys) is not a module in JPython. what to use instead? -# imp.C_EXTENSION is not in JPython. same for get_suffixes and new_module +# type(sys) is not a module in Jython. what to use instead? +# imp.C_EXTENSION is not in Jython. same for get_suffixes and new_module # # given foo.py of: # import sys Modified: python/branches/release26-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release26-maint/Objects/unicodeobject.c (original) +++ python/branches/release26-maint/Objects/unicodeobject.c Tue Oct 27 15:19:50 2009 @@ -6194,7 +6194,7 @@ /* This code should go into some future Unicode collation support module. The basic comparison should compare ordinals on a naive - basis (this is what Java does and thus JPython too). */ + basis (this is what Java does and thus Jython too). */ /* speedy UTF-16 code point order comparison */ /* gleaned from: */ From python-checkins at python.org Tue Oct 27 15:21:22 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:21:22 -0000 Subject: [Python-checkins] r75781 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 15:21:22 2009 New Revision: 75781 Log: Blocked revisions 72570,72616,72786,72813,72879-72880,72890,72905,72912,72956,73002,73027,73029,73049,73060,73068,73071-73072,73272 via svnmerge ........ r72570 | michael.foord | 2009-05-11 19:59:43 +0200 (Mo, 11 Mai 2009) | 7 lines Adds a verbosity keyword argument to unittest.main plus a minor fix allowing you to specify test modules / classes from the command line. Closes issue 5995. Michael Foord ........ r72616 | benjamin.peterson | 2009-05-14 02:33:10 +0200 (Do, 14 Mai 2009) | 1 line importlib.import_module is better these days ........ r72786 | raymond.hettinger | 2009-05-19 19:43:59 +0200 (Di, 19 Mai 2009) | 1 line Note that ordered dictionaries work with reversed(). ........ r72813 | raymond.hettinger | 2009-05-22 03:06:44 +0200 (Fr, 22 Mai 2009) | 1 line Fix-up moving average example. ........ r72879 | jeffrey.yasskin | 2009-05-24 01:23:01 +0200 (So, 24 Mai 2009) | 14 lines Issue #6042: lnotab-based tracing is very complicated and isn't documented very well. There were at least 3 comment blocks purporting to document co_lnotab, and none did a very good job. This patch unifies them into Objects/lnotab_notes.txt which tries to completely capture the current state of affairs. I also discovered that we've attached 2 layers of patches to the basic tracing scheme. The first layer avoids jumping to instructions that don't start a line, to avoid problems in if statements and while loops. The second layer discovered that jumps backward do need to trace at instructions that don't start a line, so it added extra lnotab entries for 'while' and 'for' loops, and added a special case for backward jumps within the same line. I replaced these patches by just treating forward and backward jumps differently. ........ r72880 | senthil.kumaran | 2009-05-24 11:14:50 +0200 (So, 24 Mai 2009) | 3 lines Fixed Issue1424152, urllib2 fails with HTTPS over Proxy. ........ r72890 | gregory.p.smith | 2009-05-24 20:00:13 +0200 (So, 24 Mai 2009) | 2 lines add a versionadded tag for set_tunnel ........ r72905 | benjamin.peterson | 2009-05-25 02:48:58 +0200 (Mo, 25 Mai 2009) | 4 lines make class skipping decorators the same as skipping every test of the class This removes ClassTestSuite and a good bit of hacks. ........ r72912 | benjamin.peterson | 2009-05-25 15:13:44 +0200 (Mo, 25 Mai 2009) | 5 lines add a SETUP_WITH opcode It speeds up the with statement and correctly looks up the special methods involved. ........ r72956 | raymond.hettinger | 2009-05-27 04:24:45 +0200 (Mi, 27 Mai 2009) | 3 lines Fix field name conflicts for named tuples. ........ r73002 | raymond.hettinger | 2009-05-29 03:46:48 +0200 (Fr, 29 Mai 2009) | 3 lines Deprecate contextlib.nested(). The with-statement now provides this functionality directly. ........ r73027 | michael.foord | 2009-05-29 22:33:46 +0200 (Fr, 29 Mai 2009) | 1 line Add test discovery to unittest. Issue 6001. ........ r73029 | raymond.hettinger | 2009-05-29 23:20:41 +0200 (Fr, 29 Mai 2009) | 1 line Move the basic examples section back to the beginning. ........ r73049 | georg.brandl | 2009-05-30 12:45:40 +0200 (Sa, 30 Mai 2009) | 1 line Rewrap a few long lines. ........ r73060 | gregory.p.smith | 2009-05-30 21:58:11 +0200 (Sa, 30 Mai 2009) | 2 lines Add more examples to the ipaddr documentation. ........ r73068 | antoine.pitrou | 2009-05-30 23:45:40 +0200 (Sa, 30 Mai 2009) | 3 lines Update ACKS ........ r73071 | georg.brandl | 2009-05-31 16:15:25 +0200 (So, 31 Mai 2009) | 1 line Fix markup. ........ r73072 | antoine.pitrou | 2009-05-31 16:20:14 +0200 (So, 31 Mai 2009) | 4 lines Issue #6152: New option '-j'/'--multiprocess' for regrtest allows running regression tests in parallel, shortening the total runtime. ........ r73272 | kristjan.jonsson | 2009-06-07 18:43:23 +0200 (So, 07 Jun 2009) | 2 lines http://bugs.python.org/issue6192 Add a feature to disable the Nagle algorithm on sockets in TCPServer ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:29:23 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:29:23 -0000 Subject: [Python-checkins] r75782 - in python/branches/release26-maint: Doc/c-api/import.rst Doc/c-api/int.rst Doc/extending/extending.rst Doc/library/array.rst Doc/library/cgi.rst Doc/library/contextlib.rst Doc/library/ctypes.rst Doc/library/curses.panel.rst Doc/library/curses.rst Doc/library/decimal.rst Doc/library/fcntl.rst Doc/library/imp.rst Doc/library/locale.rst Doc/library/multiprocessing.rst Doc/library/optparse.rst Doc/library/pickletools.rst Doc/library/platform.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/subprocess.rst Doc/library/symtable.rst Doc/library/timeit.rst Doc/library/warnings.rst Doc/using/cmdline.rst Misc/HISTORY Misc/NEWS Misc/Porting Misc/cheatsheet Misc/developers.txt Misc/python.man Message-ID: Author: georg.brandl Date: Tue Oct 27 15:29:22 2009 New Revision: 75782 Log: Merged revisions 73286,73294,73296,73459,73462-73463,73544,73576-73577,73595-73596,73693-73694,73704-73705,73707,73713,73937-73940,73945,73951,73979 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r73286 | georg.brandl | 2009-06-08 09:57:35 +0200 (Mo, 08 Jun 2009) | 1 line Remove period from end of headings. ........ r73294 | georg.brandl | 2009-06-08 15:34:52 +0200 (Mo, 08 Jun 2009) | 1 line #6194: O_SHLOCK/O_EXLOCK are not really more platform independent than lockf(). ........ r73296 | georg.brandl | 2009-06-08 18:03:41 +0200 (Mo, 08 Jun 2009) | 1 line #6238: add fillchar to string.just function family. ........ r73459 | raymond.hettinger | 2009-06-17 03:43:47 +0200 (Mi, 17 Jun 2009) | 1 line Add usage note. ........ r73462 | georg.brandl | 2009-06-17 11:36:21 +0200 (Mi, 17 Jun 2009) | 1 line #6295: clarify blocking behavior of getch(). ........ r73463 | georg.brandl | 2009-06-17 11:43:31 +0200 (Mi, 17 Jun 2009) | 1 line #6255: document PyInt_FromSize_t. ........ r73544 | georg.brandl | 2009-06-24 08:41:19 +0200 (Mi, 24 Jun 2009) | 1 line #6332: fix word dupes throughout the source. ........ r73576 | benjamin.peterson | 2009-06-27 01:37:06 +0200 (Sa, 27 Jun 2009) | 1 line document is_declared_global() ........ r73577 | benjamin.peterson | 2009-06-27 16:16:23 +0200 (Sa, 27 Jun 2009) | 1 line link to extensive generator docs in the reference manual ........ r73595 | ezio.melotti | 2009-06-28 01:45:39 +0200 (So, 28 Jun 2009) | 1 line stmt and setup can contain multiple statements, see #5896 ........ r73596 | ezio.melotti | 2009-06-28 02:07:45 +0200 (So, 28 Jun 2009) | 1 line Fixed a wrong apostrophe ........ r73693 | jesse.noller | 2009-06-29 20:20:34 +0200 (Mo, 29 Jun 2009) | 1 line Bug 5906: add a documentation note for unix daemons vs. multiprocessing daemons ........ r73694 | jesse.noller | 2009-06-29 20:24:26 +0200 (Mo, 29 Jun 2009) | 1 line Issue 5740: multiprocessing.connection.* authkey fixes ........ r73704 | georg.brandl | 2009-06-30 18:15:43 +0200 (Di, 30 Jun 2009) | 1 line #6376: fix copy-n-paste oversight. ........ r73705 | georg.brandl | 2009-06-30 18:17:28 +0200 (Di, 30 Jun 2009) | 1 line #6374: add a bit of explanation about shell=True on Windows. ........ r73707 | georg.brandl | 2009-06-30 18:35:11 +0200 (Di, 30 Jun 2009) | 1 line #6371: fix link targets. ........ r73713 | ezio.melotti | 2009-07-01 00:56:16 +0200 (Mi, 01 Jul 2009) | 1 line Fixed a backslash that was not supposed to be there ........ r73937 | georg.brandl | 2009-07-11 12:12:36 +0200 (Sa, 11 Jul 2009) | 1 line Fix style. ........ r73938 | georg.brandl | 2009-07-11 12:14:54 +0200 (Sa, 11 Jul 2009) | 1 line #6446: fix import_spam() function to use correct error and reference handling. ........ r73939 | georg.brandl | 2009-07-11 12:18:10 +0200 (Sa, 11 Jul 2009) | 1 line #6448: clarify docs for find_module(). ........ r73940 | georg.brandl | 2009-07-11 12:37:38 +0200 (Sa, 11 Jul 2009) | 1 line #6430: add note about size of "u" type. ........ r73945 | georg.brandl | 2009-07-11 12:51:31 +0200 (Sa, 11 Jul 2009) | 1 line #6456: clarify the meaning of constants used as arguments to nl_langinfo(). ........ r73951 | georg.brandl | 2009-07-11 16:23:38 +0200 (Sa, 11 Jul 2009) | 2 lines array.array is actually a class. ........ r73979 | benjamin.peterson | 2009-07-12 18:56:54 +0200 (So, 12 Jul 2009) | 1 line add versionadded ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/import.rst python/branches/release26-maint/Doc/c-api/int.rst python/branches/release26-maint/Doc/extending/extending.rst python/branches/release26-maint/Doc/library/array.rst python/branches/release26-maint/Doc/library/cgi.rst python/branches/release26-maint/Doc/library/contextlib.rst python/branches/release26-maint/Doc/library/ctypes.rst python/branches/release26-maint/Doc/library/curses.panel.rst python/branches/release26-maint/Doc/library/curses.rst python/branches/release26-maint/Doc/library/decimal.rst python/branches/release26-maint/Doc/library/fcntl.rst python/branches/release26-maint/Doc/library/imp.rst python/branches/release26-maint/Doc/library/locale.rst python/branches/release26-maint/Doc/library/multiprocessing.rst python/branches/release26-maint/Doc/library/optparse.rst python/branches/release26-maint/Doc/library/pickletools.rst python/branches/release26-maint/Doc/library/platform.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/string.rst python/branches/release26-maint/Doc/library/subprocess.rst python/branches/release26-maint/Doc/library/symtable.rst python/branches/release26-maint/Doc/library/timeit.rst python/branches/release26-maint/Doc/library/warnings.rst python/branches/release26-maint/Doc/using/cmdline.rst python/branches/release26-maint/Misc/HISTORY python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Misc/Porting python/branches/release26-maint/Misc/cheatsheet python/branches/release26-maint/Misc/developers.txt python/branches/release26-maint/Misc/python.man Modified: python/branches/release26-maint/Doc/c-api/import.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/import.rst (original) +++ python/branches/release26-maint/Doc/c-api/import.rst Tue Oct 27 15:29:22 2009 @@ -28,10 +28,10 @@ leaves the module in ``sys.modules``. .. versionchanged:: 2.4 - failing imports remove incomplete module objects. + Failing imports remove incomplete module objects. .. versionchanged:: 2.6 - always use absolute imports + Always uses absolute imports. .. cfunction:: PyObject* PyImport_ImportModuleNoBlock(const char *name) @@ -62,7 +62,7 @@ unless a non-empty *fromlist* was given. .. versionchanged:: 2.4 - failing imports remove incomplete module objects. + Failing imports remove incomplete module objects. .. versionchanged:: 2.6 The function is an alias for :cfunc:`PyImport_ImportModuleLevel` with @@ -95,7 +95,7 @@ are installed in the current environment, e.g. by :mod:`rexec` or :mod:`ihooks`. .. versionchanged:: 2.6 - always use absolute imports + Always uses absolute imports. .. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m) Modified: python/branches/release26-maint/Doc/c-api/int.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/int.rst (original) +++ python/branches/release26-maint/Doc/c-api/int.rst Tue Oct 27 15:29:22 2009 @@ -68,6 +68,15 @@ .. cfunction:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival) + Create a new integer object with a value of *ival*. If the value is larger + than ``LONG_MAX`` or smaller than ``LONG_MIN``, a long integer object is + returned. + + .. versionadded:: 2.5 + + +.. cfunction:: PyObject* PyInt_FromSize_t(size_t ival) + Create a new integer object with a value of *ival*. If the value exceeds ``LONG_MAX``, a long integer object is returned. Modified: python/branches/release26-maint/Doc/extending/extending.rst ============================================================================== --- python/branches/release26-maint/Doc/extending/extending.rst (original) +++ python/branches/release26-maint/Doc/extending/extending.rst Tue Oct 27 15:29:22 2009 @@ -1219,16 +1219,23 @@ static int import_spam(void) { - PyObject *module = PyImport_ImportModule("spam"); + PyObject *c_api_object; + PyObject *module; - if (module != NULL) { - PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API"); - if (c_api_object == NULL) - return -1; - if (PyCObject_Check(c_api_object)) - PySpam_API = (void **)PyCObject_AsVoidPtr(c_api_object); - Py_DECREF(c_api_object); + module = PyImport_ImportModule("spam"); + if (module == NULL) + return -1; + + c_api_object = PyObject_GetAttrString(module, "_C_API"); + if (c_api_object == NULL) { + Py_DECREF(module); + return -1; } + if (PyCObject_Check(c_api_object)) + PySpam_API = (void **)PyCObject_AsVoidPtr(c_api_object); + + Py_DECREF(c_api_object); + Py_DECREF(module); return 0; } Modified: python/branches/release26-maint/Doc/library/array.rst ============================================================================== --- python/branches/release26-maint/Doc/library/array.rst (original) +++ python/branches/release26-maint/Doc/library/array.rst Tue Oct 27 15:29:22 2009 @@ -24,7 +24,7 @@ +-----------+----------------+-------------------+-----------------------+ | ``'B'`` | unsigned char | int | 1 | +-----------+----------------+-------------------+-----------------------+ -| ``'u'`` | Py_UNICODE | Unicode character | 2 | +| ``'u'`` | Py_UNICODE | Unicode character | 2 (see note) | +-----------+----------------+-------------------+-----------------------+ | ``'h'`` | signed short | int | 2 | +-----------+----------------+-------------------+-----------------------+ @@ -43,6 +43,11 @@ | ``'d'`` | double | float | 8 | +-----------+----------------+-------------------+-----------------------+ +.. note:: + + The ``'u'`` typecode corresponds to Python's unicode character. On narrow + Unicode builds this is 2-bytes, on wide builds this is 4-bytes. + The actual representation of values is determined by the machine architecture (strictly speaking, by the C implementation). The actual size can be accessed through the :attr:`itemsize` attribute. The values stored for ``'L'`` and @@ -53,9 +58,9 @@ The module defines the following type: -.. function:: array(typecode[, initializer]) +.. class:: array(typecode[, initializer]) - Return a new array whose items are restricted by *typecode*, and initialized + A new array whose items are restricted by *typecode*, and initialized from the optional *initializer* value, which must be a list, string, or iterable over elements of the appropriate type. @@ -70,7 +75,7 @@ .. data:: ArrayType - Obsolete alias for :func:`array`. + Obsolete alias for :class:`array`. Array objects support the ordinary sequence operations of indexing, slicing, concatenation, and multiplication. When using slice assignment, the assigned @@ -80,7 +85,6 @@ The following data items and methods are also supported: - .. attribute:: array.typecode The typecode character used to create the array. Modified: python/branches/release26-maint/Doc/library/cgi.rst ============================================================================== --- python/branches/release26-maint/Doc/library/cgi.rst (original) +++ python/branches/release26-maint/Doc/library/cgi.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`cgi` --- Common Gateway Interface support. -================================================ +:mod:`cgi` --- Common Gateway Interface support +=============================================== .. module:: cgi :synopsis: Helpers for running Python scripts via the Common Gateway Interface. Modified: python/branches/release26-maint/Doc/library/contextlib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/contextlib.rst (original) +++ python/branches/release26-maint/Doc/library/contextlib.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`contextlib` --- Utilities for :keyword:`with`\ -statement contexts. -========================================================================= +:mod:`contextlib` --- Utilities for :keyword:`with`\ -statement contexts +======================================================================== .. module:: contextlib :synopsis: Utilities for with-statement contexts. Modified: python/branches/release26-maint/Doc/library/ctypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ctypes.rst (original) +++ python/branches/release26-maint/Doc/library/ctypes.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`ctypes` --- A foreign function library for Python. -======================================================== +:mod:`ctypes` --- A foreign function library for Python +======================================================= .. module:: ctypes :synopsis: A foreign function library for Python. Modified: python/branches/release26-maint/Doc/library/curses.panel.rst ============================================================================== --- python/branches/release26-maint/Doc/library/curses.panel.rst (original) +++ python/branches/release26-maint/Doc/library/curses.panel.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`curses.panel` --- A panel stack extension for curses. -=========================================================== +:mod:`curses.panel` --- A panel stack extension for curses +========================================================== .. module:: curses.panel :synopsis: A panel stack extension that adds depth to curses windows. Modified: python/branches/release26-maint/Doc/library/curses.rst ============================================================================== --- python/branches/release26-maint/Doc/library/curses.rst (original) +++ python/branches/release26-maint/Doc/library/curses.rst Tue Oct 27 15:29:22 2009 @@ -796,7 +796,8 @@ Get a character. Note that the integer returned does *not* have to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. In - no-delay mode, -1 is returned if there is no input. + no-delay mode, -1 is returned if there is no input, else :func:`getch` waits + until a key is pressed. .. method:: window.getkey([y, x]) Modified: python/branches/release26-maint/Doc/library/decimal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/decimal.rst (original) +++ python/branches/release26-maint/Doc/library/decimal.rst Tue Oct 27 15:29:22 2009 @@ -607,10 +607,9 @@ .. versionadded:: 2.6 - .. method:: logical_invert(other[, context]) + .. method:: logical_invert([context]) - :meth:`logical_invert` is a logical operation. The argument must - be a *logical operand* (see :ref:`logical_operands_label`). The + :meth:`logical_invert` is a logical operation. The result is the digit-wise inversion of the operand. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/fcntl.rst ============================================================================== --- python/branches/release26-maint/Doc/library/fcntl.rst (original) +++ python/branches/release26-maint/Doc/library/fcntl.rst Tue Oct 27 15:29:22 2009 @@ -151,7 +151,6 @@ Module :mod:`os` If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present - in the :mod:`os` module, the :func:`os.open` function provides a more - platform-independent alternative to the :func:`lockf` and :func:`flock` - functions. + in the :mod:`os` module (on BSD only), the :func:`os.open` function + provides an alternative to the :func:`lockf` and :func:`flock` functions. Modified: python/branches/release26-maint/Doc/library/imp.rst ============================================================================== --- python/branches/release26-maint/Doc/library/imp.rst (original) +++ python/branches/release26-maint/Doc/library/imp.rst Tue Oct 27 15:29:22 2009 @@ -34,16 +34,17 @@ .. function:: find_module(name[, path]) - Try to find the module *name* on the search path *path*. If *path* is a list - of directory names, each directory is searched for files with any of the - suffixes returned by :func:`get_suffixes` above. Invalid names in the list - are silently ignored (but all list items must be strings). If *path* is - omitted or ``None``, the list of directory names given by ``sys.path`` is - searched, but first it searches a few special places: it tries to find a - built-in module with the given name (:const:`C_BUILTIN`), then a frozen - module (:const:`PY_FROZEN`), and on some systems some other places are looked - in as well (on Windows, it looks in the registry which may point to a - specific file). + Try to find the module *name*. If *path* is omitted or ``None``, the list of + directory names given by ``sys.path`` is searched, but first a few special + places are searched: the function tries to find a built-in module with the + given name (:const:`C_BUILTIN`), then a frozen module (:const:`PY_FROZEN`), + and on some systems some other places are looked in as well (on Windows, it + looks in the registry which may point to a specific file). + + Otherwise, *path* must be a list of directory names; each directory is + searched for files with any of the suffixes returned by :func:`get_suffixes` + above. Invalid names in the list are silently ignored (but all list items + must be strings). If search is successful, the return value is a 3-element tuple ``(file, pathname, description)``: Modified: python/branches/release26-maint/Doc/library/locale.rst ============================================================================== --- python/branches/release26-maint/Doc/library/locale.rst (original) +++ python/branches/release26-maint/Doc/library/locale.rst Tue Oct 27 15:29:22 2009 @@ -148,10 +148,124 @@ .. function:: nl_langinfo(option) - Return some locale-specific information as a string. This function is not - available on all systems, and the set of possible options might also vary across - platforms. The possible argument values are numbers, for which symbolic - constants are available in the locale module. + Return some locale-specific information as a string. This function is not + available on all systems, and the set of possible options might also vary + across platforms. The possible argument values are numbers, for which + symbolic constants are available in the locale module. + + The :func:`nl_langinfo` function accepts one of the following keys. Most + descriptions are taken from the corresponding description in the GNU C + library. + + .. data:: CODESET + + Get a string with the name of the character encoding used in the + selected locale. + + .. data:: D_T_FMT + + Get a string that can be used as a format string for :func:`strftime` to + represent time and date in a locale-specific way. + + .. data:: D_FMT + + Get a string that can be used as a format string for :func:`strftime` to + represent a date in a locale-specific way. + + .. data:: T_FMT + + Get a string that can be used as a format string for :func:`strftime` to + represent a time in a locale-specific way. + + .. data:: T_FMT_AMPM + + Get a format string for :func:`strftime` to represent time in the am/pm + format. + + .. data:: DAY_1 ... DAY_7 + + Get the name of the n-th day of the week. + + .. note:: + + This follows the US convention of :const:`DAY_1` being Sunday, not the + international convention (ISO 8601) that Monday is the first day of the + week. + + .. data:: ABDAY_1 ... ABDAY_7 + + Get the abbreviated name of the n-th day of the week. + + .. data:: MON_1 ... MON_12 + + Get the name of the n-th month. + + .. data:: ABMON_1 ... ABMON_12 + + Get the abbreviated name of the n-th month. + + .. data:: RADIXCHAR + + Get the radix character (decimal dot, decimal comma, etc.) + + .. data:: THOUSEP + + Get the separator character for thousands (groups of three digits). + + .. data:: YESEXPR + + Get a regular expression that can be used with the regex function to + recognize a positive response to a yes/no question. + + .. note:: + + The expression is in the syntax suitable for the :cfunc:`regex` function + from the C library, which might differ from the syntax used in :mod:`re`. + + .. data:: NOEXPR + + Get a regular expression that can be used with the regex(3) function to + recognize a negative response to a yes/no question. + + .. data:: CRNCYSTR + + Get the currency symbol, preceded by "-" if the symbol should appear before + the value, "+" if the symbol should appear after the value, or "." if the + symbol should replace the radix character. + + .. data:: ERA + + Get a string that represents the era used in the current locale. + + Most locales do not define this value. An example of a locale which does + define this value is the Japanese one. In Japan, the traditional + representation of dates includes the name of the era corresponding to the + then-emperor's reign. + + Normally it should not be necessary to use this value directly. Specifying + the ``E`` modifier in their format strings causes the :func:`strftime` + function to use this information. The format of the returned string is not + 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 + locale-specific era-based way. + + .. data:: ERA_D_FMT + + Get a format string for :func:`strftime` to represent time in a + locale-specific era-based way. + + .. data:: ALT_DIGITS + + Get a representation of up to 100 values used to represent the values + 0 to 99. .. function:: getdefaultlocale([envvars]) @@ -360,140 +474,13 @@ This is a symbolic constant used for different values returned by :func:`localeconv`. -The :func:`nl_langinfo` function accepts one of the following keys. Most -descriptions are taken from the corresponding description in the GNU C library. - - -.. data:: CODESET - - Return a string with the name of the character encoding used in the selected - locale. - - -.. data:: D_T_FMT - - Return a string that can be used as a format string for strftime(3) to represent - time and date in a locale-specific way. - - -.. data:: D_FMT - - Return a string that can be used as a format string for strftime(3) to represent - a date in a locale-specific way. - - -.. data:: T_FMT - - Return a string that can be used as a format string for strftime(3) to represent - a time in a locale-specific way. - - -.. data:: T_FMT_AMPM - - The return value can be used as a format string for 'strftime' to represent time - in the am/pm format. - - -.. data:: DAY_1 ... DAY_7 - - Return name of the n-th day of the week. - - .. note:: - - This follows the US convention of :const:`DAY_1` being Sunday, not the - international convention (ISO 8601) that Monday is the first day of the week. - - -.. data:: ABDAY_1 ... ABDAY_7 - - Return abbreviated name of the n-th day of the week. - - -.. data:: MON_1 ... MON_12 - - Return name of the n-th month. - - -.. data:: ABMON_1 ... ABMON_12 - - Return abbreviated name of the n-th month. - - -.. data:: RADIXCHAR - - Return radix character (decimal dot, decimal comma, etc.) - - -.. data:: THOUSEP - - Return separator character for thousands (groups of three digits). - - -.. data:: YESEXPR - - Return a regular expression that can be used with the regex function to - recognize a positive response to a yes/no question. - - .. note:: - - The expression is in the syntax suitable for the :cfunc:`regex` function from - the C library, which might differ from the syntax used in :mod:`re`. - - -.. data:: NOEXPR - - Return a regular expression that can be used with the regex(3) function to - recognize a negative response to a yes/no question. - - -.. data:: CRNCYSTR - - Return the currency symbol, preceded by "-" if the symbol should appear before - the value, "+" if the symbol should appear after the value, or "." if the symbol - should replace the radix character. - - -.. data:: ERA - - The return value represents the era used in the current locale. - - Most locales do not define this value. An example of a locale which does define - this value is the Japanese one. In Japan, the traditional representation of - dates includes the name of the era corresponding to the then-emperor's reign. - - Normally it should not be necessary to use this value directly. Specifying the - ``E`` modifier in their format strings causes the :func:`strftime` function to - use this information. The format of the returned string is not specified, and - therefore you should not assume knowledge of it on different systems. - - -.. data:: ERA_YEAR - - The return value gives the year in the relevant era of the locale. - - -.. data:: ERA_D_T_FMT - - This return value can be used as a format string for :func:`strftime` to - represent dates and times in a locale-specific era-based way. - - -.. data:: ERA_D_FMT - - This return value can be used as a format string for :func:`strftime` to - represent time in a locale-specific era-based way. - - -.. data:: ALT_DIGITS - - The return value is a representation of up to 100 values used to represent the - values 0 to 99. Example:: >>> import locale >>> loc = locale.getlocale() # get current locale - >>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform + # use German locale; name might vary with platform + >>> locale.setlocale(locale.LC_ALL, 'de_DE') >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale 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 Tue Oct 27 15:29:22 2009 @@ -374,7 +374,9 @@ Note that a daemonic process is not allowed to create child processes. Otherwise a daemonic process would leave its children orphaned if it gets - terminated when its parent process exits. + terminated when its parent process exits. Additionally, these are **not** + Unix daemons or services, they are normal processes that will be + terminated (and not joined) if non-dameonic processes have exited. In addition to the :class:`Threading.Thread` API, :class:`Process` objects also support the following attributes and methods: @@ -1700,7 +1702,7 @@ generally be omitted since it can usually be inferred from the format of *address*. (See :ref:`multiprocessing-address-formats`) - If *authentication* is ``True`` or *authkey* is a string then digest + If *authenticate* is ``True`` or *authkey* is a string then digest authentication is used. The key used for authentication will be either *authkey* or ``current_process().authkey)`` if *authkey* is ``None``. If authentication fails then :exc:`AuthenticationError` is raised. See @@ -1742,7 +1744,7 @@ If *authkey* is ``None`` and *authenticate* is ``True`` then ``current_process().authkey`` is used as the authentication key. If - *authkey* is ``None`` and *authentication* is ``False`` then no + *authkey* is ``None`` and *authenticate* is ``False`` then no authentication is done. If authentication fails then :exc:`AuthenticationError` is raised. See :ref:`multiprocessing-auth-keys`. Modified: python/branches/release26-maint/Doc/library/optparse.rst ============================================================================== --- python/branches/release26-maint/Doc/library/optparse.rst (original) +++ python/branches/release26-maint/Doc/library/optparse.rst Tue Oct 27 15:29:22 2009 @@ -645,8 +645,8 @@ :func:`OptionParser.error` from your application code. If :mod:`optparse`'s default error-handling behaviour does not suit your needs, -you'll need to subclass OptionParser and override its :meth:`exit` and/or -:meth:`error` methods. +you'll need to subclass OptionParser and override its :meth:`~OptionParser.exit` +and/or :meth:`~OptionParser.error` methods. .. _optparse-putting-it-all-together: Modified: python/branches/release26-maint/Doc/library/pickletools.rst ============================================================================== --- python/branches/release26-maint/Doc/library/pickletools.rst (original) +++ python/branches/release26-maint/Doc/library/pickletools.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`pickletools` --- Tools for pickle developers. -=================================================== +:mod:`pickletools` --- Tools for pickle developers +================================================== .. module:: pickletools :synopsis: Contains extensive comments about the pickle protocols and pickle-machine Modified: python/branches/release26-maint/Doc/library/platform.rst ============================================================================== --- python/branches/release26-maint/Doc/library/platform.rst (original) +++ python/branches/release26-maint/Doc/library/platform.rst Tue Oct 27 15:29:22 2009 @@ -1,6 +1,5 @@ - -:mod:`platform` --- Access to underlying platform's identifying data. -====================================================================== +:mod:`platform` --- Access to underlying platform's identifying data +===================================================================== .. module:: platform :synopsis: Retrieves as much platform identifying data as possible. Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 15:29:22 2009 @@ -588,10 +588,18 @@ constraint was added in Python 2.3; in Python 2.2, various iterators are broken according to this rule.) + +.. _generator-types: + +Generator Types +--------------- + Python's :term:`generator`\s provide a convenient way to implement the iterator protocol. If a container object's :meth:`__iter__` method is implemented as a generator, it will automatically return an iterator object (technically, a -generator object) supplying the :meth:`__iter__` and :meth:`next` methods. +generator object) supplying the :meth:`__iter__` and :meth:`next` methods. More +information about generators can be found in :ref:`the documentation for the +yield expression `. .. _typesseq: Modified: python/branches/release26-maint/Doc/library/string.rst ============================================================================== --- python/branches/release26-maint/Doc/library/string.rst (original) +++ python/branches/release26-maint/Doc/library/string.rst Tue Oct 27 15:29:22 2009 @@ -825,14 +825,15 @@ Return a copy of *s*, but with lower case letters converted to upper case. -.. function:: ljust(s, width) - rjust(s, width) - center(s, width) +.. function:: ljust(s, width[, fillchar]) + rjust(s, width[, fillchar]) + center(s, width[, fillchar]) These functions respectively left-justify, right-justify and center a string in a field of given width. They return a string that is at least *width* - characters wide, created by padding the string *s* with spaces until the given - width on the right, left or both sides. The string is never truncated. + characters wide, created by padding the string *s* with the character *fillchar* + (default is a space) until the given width on the right, left or both sides. + The string is never truncated. .. function:: zfill(s, width) Modified: python/branches/release26-maint/Doc/library/subprocess.rst ============================================================================== --- python/branches/release26-maint/Doc/library/subprocess.rst (original) +++ python/branches/release26-maint/Doc/library/subprocess.rst Tue Oct 27 15:29:22 2009 @@ -73,7 +73,11 @@ needed: Usually, the program to execute is defined by the *args* argument. If ``shell=True``, the *executable* argument specifies which shell to use. On Unix, the default shell is :file:`/bin/sh`. On Windows, the default shell is - specified by the :envvar:`COMSPEC` environment variable. + specified by the :envvar:`COMSPEC` environment variable. The only reason you + would need to specify ``shell=True`` on Windows is where the command you + wish to execute is actually built in to the shell, eg ``dir``, ``copy``. + You don't need ``shell=True`` to run a batch file, nor to run a console-based + executable. *stdin*, *stdout* and *stderr* specify the executed programs' standard input, standard output and standard error file handles, respectively. Valid values Modified: python/branches/release26-maint/Doc/library/symtable.rst ============================================================================== --- python/branches/release26-maint/Doc/library/symtable.rst (original) +++ python/branches/release26-maint/Doc/library/symtable.rst Tue Oct 27 15:29:22 2009 @@ -144,6 +144,10 @@ Return ``True`` if the symbol is global. + .. method:: is_declared_global() + + Return ``True`` if the symbol is declared global with a global statement. + .. method:: is_local() Return ``True`` if the symbol is local to its block. Modified: python/branches/release26-maint/Doc/library/timeit.rst ============================================================================== --- python/branches/release26-maint/Doc/library/timeit.rst (original) +++ python/branches/release26-maint/Doc/library/timeit.rst Tue Oct 27 15:29:22 2009 @@ -26,8 +26,9 @@ The constructor takes a statement to be timed, an additional statement used for setup, and a timer function. Both statements default to ``'pass'``; the timer - function is platform-dependent (see the module doc string). The statements may - contain newlines, as long as they don't contain multi-line string literals. + function is platform-dependent (see the module doc string). *stmt* and *setup* + may also contain multiple statements separated by ``;`` or newlines, as long as + they don't contain multi-line string literals. To measure the execution time of the first statement, use the :meth:`timeit` method. The :meth:`repeat` method is a convenience to call :meth:`timeit` Modified: python/branches/release26-maint/Doc/library/warnings.rst ============================================================================== --- python/branches/release26-maint/Doc/library/warnings.rst (original) +++ python/branches/release26-maint/Doc/library/warnings.rst Tue Oct 27 15:29:22 2009 @@ -279,6 +279,8 @@ be a string and *category* a subclass of :exc:`Warning`. :func:`warnpy3k` is using :exc:`DeprecationWarning` as default warning class. + .. versionadded:: 2.6 + .. function:: showwarning(message, category, filename, lineno[, file[, line]]) Modified: python/branches/release26-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release26-maint/Doc/using/cmdline.rst (original) +++ python/branches/release26-maint/Doc/using/cmdline.rst Tue Oct 27 15:29:22 2009 @@ -319,7 +319,7 @@ warning is triggered repeatedly for the same source line, such as inside a loop). ``module`` - Print each warning only only the first time it occurs in each module. + Print each warning only the first time it occurs in each module. ``once`` Print each warning only the first time it occurs in the program. ``error`` Modified: python/branches/release26-maint/Misc/HISTORY ============================================================================== --- python/branches/release26-maint/Misc/HISTORY (original) +++ python/branches/release26-maint/Misc/HISTORY Tue Oct 27 15:29:22 2009 @@ -16184,7 +16184,7 @@ fixes old code: demo/scripts/classfix.py. * There's a new reserved word: "access". The syntax and semantics are -still subject of of research and debate (as well as undocumented), but +still subject of research and debate (as well as undocumented), but the parser knows about the keyword so you must not use it as a variable, function, or attribute name. @@ -16434,7 +16434,7 @@ (a) define a function of one argument and call it with any number of arguments; if the actual argument count wasn't one, the function would receive a tuple containing the - arguments arguments (an empty tuple if there were none). + arguments (an empty tuple if there were none). (b) define a function of two arguments, and call it with more than two arguments; if there were more than two arguments, @@ -16756,7 +16756,7 @@ ---------------------------------------------------------- The function strdup() no longer exists (it was used only in one places -and is somewhat of a a portability problem sice some systems have the +and is somewhat of a portability problem since some systems have the same function in their C library. The functions NEW() and RENEW() allocate one spare byte to guard Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 15:29:22 2009 @@ -3576,7 +3576,7 @@ - Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. -- Made the error message for time.strptime when the data data and +- Made the error message for time.strptime when the data and format do match be more clear. - Fix a bug in traceback.format_exception_only() that led to an error Modified: python/branches/release26-maint/Misc/Porting ============================================================================== --- python/branches/release26-maint/Misc/Porting (original) +++ python/branches/release26-maint/Misc/Porting Tue Oct 27 15:29:22 2009 @@ -37,6 +37,6 @@ Then bang on it until it executes very simple Python statements. Now bang on it some more. At some point you'll want to use the os -module; this is the time to start thinking about what to to with the +module; this is the time to start thinking about what to do with the posix module. It's okay to simply #ifdef out those functions that cause problems; the remaining ones will be quite useful. Modified: python/branches/release26-maint/Misc/cheatsheet ============================================================================== --- python/branches/release26-maint/Misc/cheatsheet (original) +++ python/branches/release26-maint/Misc/cheatsheet Tue Oct 27 15:29:22 2009 @@ -1145,7 +1145,7 @@ Standard methods & operators redefinition in classes Standard methods & operators map to special '__methods__' and thus may be - redefined (mostly in in user-defined classes), e.g.: + redefined (mostly in user-defined classes), e.g.: class x: def __init__(self, v): self.value = v def __add__(self, r): return self.value + r Modified: python/branches/release26-maint/Misc/developers.txt ============================================================================== --- python/branches/release26-maint/Misc/developers.txt (original) +++ python/branches/release26-maint/Misc/developers.txt Tue Oct 27 15:29:22 2009 @@ -41,7 +41,7 @@ - Heiko Weinen was given SVN access on 29 April 2008 by MvL, for GSoC contributions. -- Jesus Cea was was given SVN access on 24 April 2008 by MvL, +- Jesus Cea was given SVN access on 24 April 2008 by MvL, for maintenance of bsddb. - Guilherme Polo was given SVN access on 24 April 2008 by MvL, Modified: python/branches/release26-maint/Misc/python.man ============================================================================== --- python/branches/release26-maint/Misc/python.man (original) +++ python/branches/release26-maint/Misc/python.man Tue Oct 27 15:29:22 2009 @@ -204,7 +204,7 @@ messages if a warning is triggered repeatedly for the same source line, such as inside a loop); .B module -to print each warning only only the first time it occurs in each +to print each warning only the first time it occurs in each module; .B once to print each warning only the first time it occurs in the program; or From python-checkins at python.org Tue Oct 27 15:30:58 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:30:58 -0000 Subject: [Python-checkins] r75783 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 15:30:57 2009 New Revision: 75783 Log: Blocked revisions 73325-73326,73340,73367,73370,73447,73534,73537,73546,73638,73712,73714,73717,73720,73725,73818,73916,73962-73963 via svnmerge ................ r73325 | amaury.forgeotdarc | 2009-06-10 01:08:13 +0200 (Mi, 10 Jun 2009) | 8 lines #6201: Fix test_winreg on Windows: since the introduction of the SETUP_WITH opcode, __enter__ and __exit__ methods must belong to the type, and are not retrieved at the instance level (__dict__ or __getattr__). Add a note in whatsnew about this incompatibility; old style classes are not affected. ................ r73326 | amaury.forgeotdarc | 2009-06-10 01:18:50 +0200 (Mi, 10 Jun 2009) | 2 lines Both kind of types are concerned. ................ r73340 | amaury.forgeotdarc | 2009-06-10 22:30:19 +0200 (Mi, 10 Jun 2009) | 2 lines Fix a typo spotted by Nick Coghlan. ................ r73367 | raymond.hettinger | 2009-06-12 00:04:00 +0200 (Fr, 12 Jun 2009) | 1 line Add example of how to do key lookups with bisect(). ................ r73370 | benjamin.peterson | 2009-06-12 00:06:46 +0200 (Fr, 12 Jun 2009) | 105 lines Merged revisions 72523,72950-72951,72994,73003,73033,73036-73040,73091-73093,73096,73179-73181,73192,73231,73244,73255-73256,73365 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r72523 | benjamin.peterson | 2009-05-09 14:42:26 -0500 (Sat, 09 May 2009) | 1 line remove parenthesis ........ r72950 | benjamin.peterson | 2009-05-26 18:19:45 -0500 (Tue, 26 May 2009) | 1 line remove unused imports ........ r72951 | benjamin.peterson | 2009-05-26 18:27:00 -0500 (Tue, 26 May 2009) | 1 line this is no longer executable ........ r72994 | benjamin.peterson | 2009-05-28 15:32:54 -0500 (Thu, 28 May 2009) | 1 line fix test_all_fixers on Windows #6134 ........ r73003 | benjamin.peterson | 2009-05-28 21:57:28 -0500 (Thu, 28 May 2009) | 4 lines make 2to3 test utilities easier to use with other applications (3to2) Patch by Joe Amenta ........ r73033 | benjamin.peterson | 2009-05-29 16:58:32 -0500 (Fri, 29 May 2009) | 1 line update grammar for multi with statement ........ r73036 | benjamin.peterson | 2009-05-29 17:33:20 -0500 (Fri, 29 May 2009) | 1 line simplify fix_unicode ........ r73037 | benjamin.peterson | 2009-05-29 17:53:03 -0500 (Fri, 29 May 2009) | 1 line add custom error for pattern syntax errors ........ r73038 | benjamin.peterson | 2009-05-29 17:55:00 -0500 (Fri, 29 May 2009) | 1 line complain if details are attached to a token ........ r73039 | benjamin.peterson | 2009-05-29 18:00:28 -0500 (Fri, 29 May 2009) | 1 line add a test for whitespace ........ r73040 | benjamin.peterson | 2009-05-29 18:01:17 -0500 (Fri, 29 May 2009) | 1 line a fix for emacs highlighting ........ r73091 | benjamin.peterson | 2009-05-31 20:55:25 -0500 (Sun, 31 May 2009) | 1 line deprecate set_prefix() and get_prefix() in favor of a prefix property ........ r73092 | benjamin.peterson | 2009-05-31 21:00:51 -0500 (Sun, 31 May 2009) | 1 line change hideous java naming scheme ........ r73093 | benjamin.peterson | 2009-05-31 21:01:39 -0500 (Sun, 31 May 2009) | 1 line remove dated comment ........ r73096 | benjamin.peterson | 2009-05-31 21:40:53 -0500 (Sun, 31 May 2009) | 1 line group tests ........ r73179 | benjamin.peterson | 2009-06-03 13:09:53 -0500 (Wed, 03 Jun 2009) | 1 line handle the case where there's multiple trailers #6185 ........ r73180 | benjamin.peterson | 2009-06-03 13:18:05 -0500 (Wed, 03 Jun 2009) | 1 line scrap __main__ section ........ r73181 | benjamin.peterson | 2009-06-03 13:24:48 -0500 (Wed, 03 Jun 2009) | 1 line remove shebang lines and __main__ sections ........ r73192 | benjamin.peterson | 2009-06-03 19:16:30 -0500 (Wed, 03 Jun 2009) | 4 lines actually test something here Thanks to Joe Amenta for noticing.y ........ r73231 | benjamin.peterson | 2009-06-04 13:38:50 -0500 (Thu, 04 Jun 2009) | 1 line remove unused variable ........ r73244 | benjamin.peterson | 2009-06-05 08:39:25 -0500 (Fri, 05 Jun 2009) | 1 line allow fixers to give different options in setUp ........ r73255 | benjamin.peterson | 2009-06-06 11:23:46 -0500 (Sat, 06 Jun 2009) | 1 line fix the except fixer on one line suites #6222 ........ r73256 | benjamin.peterson | 2009-06-06 11:27:40 -0500 (Sat, 06 Jun 2009) | 1 line test one-line else and finally clauses ........ r73365 | benjamin.peterson | 2009-06-11 17:01:32 -0500 (Thu, 11 Jun 2009) | 1 line normalize whitespace ........ ................ r73447 | georg.brandl | 2009-06-16 19:41:33 +0200 (Di, 16 Jun 2009) | 1 line Add tabularcolumns directive for tables with bullet lists in them. ................ r73534 | amaury.forgeotdarc | 2009-06-23 23:09:09 +0200 (Di, 23 Jun 2009) | 2 lines Remove the ipaddr module per discussion on python-dev ................ r73537 | amaury.forgeotdarc | 2009-06-23 23:53:46 +0200 (Di, 23 Jun 2009) | 3 lines Remove last remnants of the ipaddr package. The changes in mcast.py come from the first version of the patch for issue5379. ................ r73546 | kristjan.jonsson | 2009-06-24 11:17:04 +0200 (Mi, 24 Jun 2009) | 2 lines http://bugs.python.org/issue6192 Move the newly introduced disable_nagle_algorithm flag into the StreamRequestHandler, where it is more appropriate. ................ r73638 | kristjan.jonsson | 2009-06-28 23:04:17 +0200 (So, 28 Jun 2009) | 2 lines http://bugs.python.org/issue6267 Cumulative patch to http and xmlrpc ................ r73712 | ezio.melotti | 2009-07-01 00:51:06 +0200 (Mi, 01 Jul 2009) | 1 line Fixed defaultTestCase -> defaultTestResult ................ r73714 | benjamin.peterson | 2009-07-01 00:57:08 +0200 (Mi, 01 Jul 2009) | 1 line convert usage of fail* to assert* ................ r73717 | benjamin.peterson | 2009-07-01 01:30:12 +0200 (Mi, 01 Jul 2009) | 1 line use assert* methods in test_unittest ................ r73720 | benjamin.peterson | 2009-07-01 02:36:41 +0200 (Mi, 01 Jul 2009) | 4 lines fix a few cases where automated fail -> assert translation messed up Thanks Joe Amenta ................ r73725 | benjamin.peterson | 2009-07-01 02:49:09 +0200 (Mi, 01 Jul 2009) | 21 lines Merged revisions 73379,73388,73507,73722 via svnmerge from svn+ssh://pythondev at svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r73379 | benjamin.peterson | 2009-06-11 18:06:21 -0500 (Thu, 11 Jun 2009) | 1 line use a real conditional expresion ........ r73388 | benjamin.peterson | 2009-06-12 09:44:29 -0500 (Fri, 12 Jun 2009) | 1 line fix typo in last fix ........ r73507 | benjamin.peterson | 2009-06-22 13:32:04 -0500 (Mon, 22 Jun 2009) | 1 line remove svn:executable property ........ r73722 | benjamin.peterson | 2009-06-30 19:44:30 -0500 (Tue, 30 Jun 2009) | 1 line replace fail* with assert* ........ ................ r73818 | gregory.p.smith | 2009-07-03 22:48:31 +0200 (Fr, 03 Jul 2009) | 2 lines Adds the select.PIPE_BUF attribute to expose the system constant. ................ r73916 | amaury.forgeotdarc | 2009-07-10 00:37:22 +0200 (Fr, 10 Jul 2009) | 5 lines #6416: Fix compilation of the select module on Windows, as well as test_subprocess: PIPE_BUF is not defined on Windows, and probably has no meaning there. Anyway the subprocess module uses another way to perform non-blocking reads (with a thread) ................ r73962 | benjamin.peterson | 2009-07-12 00:15:13 +0200 (So, 12 Jul 2009) | 1 line put downloaded test support files in Lib/test/data instead of the cwd ................ r73963 | benjamin.peterson | 2009-07-12 00:25:24 +0200 (So, 12 Jul 2009) | 1 line ignore things in Lib/test/data/ ................ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:34:22 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:34:22 -0000 Subject: [Python-checkins] r75784 - in python/branches/release26-maint: Doc/c-api/arg.rst Doc/c-api/float.rst Doc/c-api/int.rst Doc/c-api/method.rst Doc/c-api/sys.rst Doc/c-api/tuple.rst Doc/c-api/type.rst Doc/c-api/unicode.rst Doc/copyright.rst Doc/howto/urllib2.rst Doc/library/cgi.rst Doc/library/intro.rst Doc/library/re.rst Doc/library/stdtypes.rst Doc/library/subprocess.rst Doc/library/warnings.rst Doc/library/webbrowser.rst Doc/library/xml.etree.elementtree.rst Doc/tutorial/errors.rst Doc/tutorial/inputoutput.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:34:21 2009 New Revision: 75784 Log: Merged revisions 74008,74021-74022,74074-74075,74077,74148,74179,74188,74192-74194,74200,74205 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74008 | benjamin.peterson | 2009-07-15 02:46:42 +0200 (Mi, 15 Jul 2009) | 1 line update year ........ r74021 | georg.brandl | 2009-07-16 09:33:04 +0200 (Do, 16 Jul 2009) | 1 line #6486: start with built in functions rather than "built in objects". ........ r74022 | georg.brandl | 2009-07-16 09:38:35 +0200 (Do, 16 Jul 2009) | 1 line #6481: fix typo in os.system() replacement. ........ r74074 | georg.brandl | 2009-07-18 11:03:10 +0200 (Sa, 18 Jul 2009) | 1 line #6513: fix example code: warning categories are classes, not instances. ........ r74075 | georg.brandl | 2009-07-18 11:06:31 +0200 (Sa, 18 Jul 2009) | 1 line #6505: fix typos. ........ r74077 | georg.brandl | 2009-07-18 11:43:40 +0200 (Sa, 18 Jul 2009) | 1 line #6489: fix an ambiguity in getiterator() documentation. ........ r74148 | ezio.melotti | 2009-07-21 22:18:27 +0200 (Di, 21 Jul 2009) | 1 line #6536 fixed typo ........ r74179 | ezio.melotti | 2009-07-22 23:08:49 +0200 (Mi, 22 Jul 2009) | 1 line #6423 has_key -> in ........ r74188 | benjamin.peterson | 2009-07-23 16:25:31 +0200 (Do, 23 Jul 2009) | 1 line use bools ........ r74192 | georg.brandl | 2009-07-24 18:28:38 +0200 (Fr, 24 Jul 2009) | 1 line Fix arg types of et#. ........ r74193 | georg.brandl | 2009-07-24 18:46:38 +0200 (Fr, 24 Jul 2009) | 1 line Dont put "void" in signature for nullary functions. ........ r74194 | georg.brandl | 2009-07-24 22:09:46 +0200 (Fr, 24 Jul 2009) | 1 line #6564: fix section about the two raise syntaxes. ........ r74200 | georg.brandl | 2009-07-25 15:02:15 +0200 (Sa, 25 Jul 2009) | 1 line #6571: add index entries for more operators. ........ r74205 | georg.brandl | 2009-07-26 15:36:39 +0200 (So, 26 Jul 2009) | 1 line #6576: fix cross-refs in re docs. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/arg.rst python/branches/release26-maint/Doc/c-api/float.rst python/branches/release26-maint/Doc/c-api/int.rst python/branches/release26-maint/Doc/c-api/method.rst python/branches/release26-maint/Doc/c-api/sys.rst python/branches/release26-maint/Doc/c-api/tuple.rst python/branches/release26-maint/Doc/c-api/type.rst python/branches/release26-maint/Doc/c-api/unicode.rst python/branches/release26-maint/Doc/copyright.rst python/branches/release26-maint/Doc/howto/urllib2.rst python/branches/release26-maint/Doc/library/cgi.rst python/branches/release26-maint/Doc/library/intro.rst python/branches/release26-maint/Doc/library/re.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/subprocess.rst python/branches/release26-maint/Doc/library/warnings.rst python/branches/release26-maint/Doc/library/webbrowser.rst python/branches/release26-maint/Doc/library/xml.etree.elementtree.rst python/branches/release26-maint/Doc/tutorial/errors.rst python/branches/release26-maint/Doc/tutorial/inputoutput.rst 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 Tue Oct 27 15:34:21 2009 @@ -136,7 +136,7 @@ In both cases, *\*buffer_length* is set to the length of the encoded data without the trailing NUL byte. -``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer] +``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length] Same as ``es#`` except that string objects are passed through without recoding them. Instead, the implementation assumes that the string object uses the encoding passed in as parameter. Modified: python/branches/release26-maint/Doc/c-api/float.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/float.rst (original) +++ python/branches/release26-maint/Doc/c-api/float.rst Tue Oct 27 15:34:21 2009 @@ -72,21 +72,21 @@ .. versionadded:: 2.6 -.. cfunction:: double PyFloat_GetMax(void) +.. cfunction:: double PyFloat_GetMax() Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`. .. versionadded:: 2.6 -.. cfunction:: double PyFloat_GetMin(void) +.. cfunction:: double PyFloat_GetMin() Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. .. versionadded:: 2.6 -.. cfunction:: int PyFloat_ClearFreeList(void) +.. cfunction:: int PyFloat_ClearFreeList() Clear the float free list. Return the number of items that could not be freed. Modified: python/branches/release26-maint/Doc/c-api/int.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/int.rst (original) +++ python/branches/release26-maint/Doc/c-api/int.rst Tue Oct 27 15:34:21 2009 @@ -131,7 +131,7 @@ (:const:`LONG_MAX`, as defined in the system header files). -.. cfunction:: int PyInt_ClearFreeList(void) +.. cfunction:: int PyInt_ClearFreeList() Clear the integer free list. Return the number of items that could not be freed. Modified: python/branches/release26-maint/Doc/c-api/method.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/method.rst (original) +++ python/branches/release26-maint/Doc/c-api/method.rst Tue Oct 27 15:34:21 2009 @@ -65,7 +65,7 @@ Macro version of :cfunc:`PyMethod_Self` which avoids error checking. -.. cfunction:: int PyMethod_ClearFreeList(void) +.. cfunction:: int PyMethod_ClearFreeList() Clear the free list. Return the total number of freed items. Modified: python/branches/release26-maint/Doc/c-api/sys.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/sys.rst (original) +++ python/branches/release26-maint/Doc/c-api/sys.rst Tue Oct 27 15:34:21 2009 @@ -80,7 +80,7 @@ case *name* is deleted from the sys module. Returns ``0`` on success, ``-1`` on error. -.. cfunction:: void PySys_ResetWarnOptions(void) +.. cfunction:: void PySys_ResetWarnOptions() Reset :data:`sys.warnoptions` to an empty list. Modified: python/branches/release26-maint/Doc/c-api/tuple.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/tuple.rst (original) +++ python/branches/release26-maint/Doc/c-api/tuple.rst Tue Oct 27 15:34:21 2009 @@ -157,7 +157,7 @@ require changes in your code for properly supporting 64-bit systems. -.. cfunction:: int PyTuple_ClearFreeList(void) +.. cfunction:: int PyTuple_ClearFreeList() Clear the free list. Return the total number of freed items. Modified: python/branches/release26-maint/Doc/c-api/type.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/type.rst (original) +++ python/branches/release26-maint/Doc/c-api/type.rst Tue Oct 27 15:34:21 2009 @@ -35,7 +35,7 @@ .. versionadded:: 2.2 -.. cfunction:: unsigned int PyType_ClearCache(void) +.. cfunction:: unsigned int PyType_ClearCache() Clear the internal lookup cache. Return the current version tag. Modified: python/branches/release26-maint/Doc/c-api/unicode.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/unicode.rst (original) +++ python/branches/release26-maint/Doc/c-api/unicode.rst Tue Oct 27 15:34:21 2009 @@ -98,12 +98,13 @@ :ctype:`PyUnicodeObject` (not checked). -.. cfunction:: int PyUnicode_ClearFreeList(void) +.. cfunction:: int PyUnicode_ClearFreeList() Clear the free list. Return the total number of freed items. .. versionadded:: 2.6 + Unicode provides many different character properties. The most often needed ones are available through these macros which are mapped to C functions depending on the Python configuration. Modified: python/branches/release26-maint/Doc/copyright.rst ============================================================================== --- python/branches/release26-maint/Doc/copyright.rst (original) +++ python/branches/release26-maint/Doc/copyright.rst Tue Oct 27 15:34:21 2009 @@ -4,7 +4,7 @@ Python and this documentation is: -Copyright ? 2001-2008 Python Software Foundation. All rights reserved. +Copyright ? 2001-2009 Python Software Foundation. All rights reserved. Copyright ? 2000 BeOpen.com. All rights reserved. Modified: python/branches/release26-maint/Doc/howto/urllib2.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/urllib2.rst (original) +++ python/branches/release26-maint/Doc/howto/urllib2.rst Tue Oct 27 15:34:21 2009 @@ -488,7 +488,7 @@ .. note:: - In the above example we only supplied our ``HHTPBasicAuthHandler`` to + In the above example we only supplied our ``HTTPBasicAuthHandler`` to ``build_opener``. By default openers have the handlers for normal situations -- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``, ``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``, Modified: python/branches/release26-maint/Doc/library/cgi.rst ============================================================================== --- python/branches/release26-maint/Doc/library/cgi.rst (original) +++ python/branches/release26-maint/Doc/library/cgi.rst Tue Oct 27 15:34:21 2009 @@ -91,12 +91,13 @@ various environment variables set according to the CGI standard). Since it may consume standard input, it should be instantiated only once. -The :class:`FieldStorage` instance can be indexed like a Python dictionary, and -also supports the standard dictionary methods :meth:`has_key` and :meth:`keys`. -The built-in :func:`len` is also supported. Form fields containing empty -strings are ignored and do not appear in the dictionary; to keep such values, -provide a true value for the optional *keep_blank_values* keyword parameter when -creating the :class:`FieldStorage` instance. +The :class:`FieldStorage` instance can be indexed like a Python dictionary. +It allows membership testing with the :keyword:`in` operator, and also supports +the standard dictionary method :meth:`keys` and the built-in function +:func:`len`. Form fields containing empty strings are ignored and do not appear +in the dictionary; to keep such values, provide a true value for the optional +*keep_blank_values* keyword parameter when creating the :class:`FieldStorage` +instance. For instance, the following code (which assumes that the :mailheader:`Content-Type` header and blank line have already been printed) @@ -104,7 +105,7 @@ string:: form = cgi.FieldStorage() - if not (form.has_key("name") and form.has_key("addr")): + if "name" not in form or "addr" not in form: print "

            Error

            " print "Please fill in the name and addr fields." return Modified: python/branches/release26-maint/Doc/library/intro.rst ============================================================================== --- python/branches/release26-maint/Doc/library/intro.rst (original) +++ python/branches/release26-maint/Doc/library/intro.rst Tue Oct 27 15:34:21 2009 @@ -44,8 +44,9 @@ function, module or term in the index (in the back). And finally, if you enjoy learning about random subjects, you choose a random page number (see module :mod:`random`) and read a section or two. Regardless of the order in which you -read the sections of this manual, it helps to start with chapter :ref:`builtin`, -as the remainder of the manual assumes familiarity with this material. +read the sections of this manual, it helps to start with chapter +:ref:`built-in-funcs`, as the remainder of the manual assumes familiarity with +this material. Let the show begin! Modified: python/branches/release26-maint/Doc/library/re.rst ============================================================================== --- python/branches/release26-maint/Doc/library/re.rst (original) +++ python/branches/release26-maint/Doc/library/re.rst Tue Oct 27 15:34:21 2009 @@ -216,7 +216,7 @@ flags are described in :ref:`contents-of-module-re`.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a *flag* argument to the - :func:`compile` function. + :func:`re.compile` function. Note that the ``(?x)`` flag changes how the expression is parsed. It should be used first in the expression string, or after one or more whitespace characters. @@ -443,9 +443,9 @@ result = re.match(pattern, string) - but using :func:`compile` and saving the resulting regular expression object - for reuse is more efficient when the expression will be used several times - in a single program. + but using :func:`re.compile` and saving the resulting regular expression + object for reuse is more efficient when the expression will be used several + times in a single program. .. note:: @@ -532,7 +532,7 @@ .. note:: - If you want to locate a match anywhere in *string*, use :meth:`search` + If you want to locate a match anywhere in *string*, use :func:`search` instead. @@ -686,8 +686,8 @@ .. note:: - If you want to locate a match anywhere in *string*, use :meth:`search` - instead. + If you want to locate a match anywhere in *string*, use + :meth:`~RegexObject.search` instead. The optional second parameter *pos* gives an index in the string where the search is to start; it defaults to ``0``. This is not completely equivalent to @@ -716,7 +716,7 @@ is different from finding a zero-length match at some point in the string. The optional *pos* and *endpos* parameters have the same meaning as for the - :meth:`match` method. + :meth:`~RegexObject.match` method. .. method:: RegexObject.split(string[, maxsplit=0]) @@ -780,10 +780,10 @@ .. method:: MatchObject.expand(template) Return the string obtained by doing backslash substitution on the template - string *template*, as done by the :meth:`sub` method. Escapes such as ``\n`` are - converted to the appropriate characters, and numeric backreferences (``\1``, - ``\2``) and named backreferences (``\g<1>``, ``\g``) are replaced by the - contents of the corresponding group. + string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes + such as ``\n`` are converted to the appropriate characters, and numeric + backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``, + ``\g``) are replaced by the contents of the corresponding group. .. method:: MatchObject.group([group1, ...]) @@ -907,16 +907,16 @@ .. attribute:: MatchObject.pos - The value of *pos* which was passed to the :func:`search` or :func:`match` - method of the :class:`RegexObject`. This is the index into the string at which - the RE engine started looking for a match. + The value of *pos* which was passed to the :meth:`~RegexObject.search` or + :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the + index into the string at which the RE engine started looking for a match. .. attribute:: MatchObject.endpos - The value of *endpos* which was passed to the :func:`search` or :func:`match` - method of the :class:`RegexObject`. This is the index into the string beyond - which the RE engine will not go. + The value of *endpos* which was passed to the :meth:`~RegexObject.search` or + :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the + index into the string beyond which the RE engine will not go. .. attribute:: MatchObject.lastindex @@ -936,13 +936,15 @@ .. attribute:: MatchObject.re - The regular expression object whose :meth:`match` or :meth:`search` method - produced this :class:`MatchObject` instance. + The regular expression object whose :meth:`~RegexObject.match` or + :meth:`~RegexObject.search` method produced this :class:`MatchObject` + instance. .. attribute:: MatchObject.string - The string passed to :func:`match` or :func:`search`. + The string passed to :meth:`~RegexObject.match` or + :meth:`~RegexObject.search`. Examples @@ -987,8 +989,9 @@ >>> displaymatch(pair.match("354aa")) # Pair of aces. "" -To find out what card the pair consists of, one could use the :func:`group` -method of :class:`MatchObject` in the following manner: +To find out what card the pair consists of, one could use the +:meth:`~MatchObject.group` method of :class:`MatchObject` in the following +manner: .. doctest:: Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 15:34:21 2009 @@ -129,7 +129,17 @@ Comparisons =========== -.. index:: pair: chaining; comparisons +.. index:: + pair: chaining; comparisons + pair: operator; comparison + operator: == + operator: < + operator: <= + operator: > + operator: >= + operator: != + operator: is + operator: is not Comparison operations are supported by all objects. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can @@ -159,17 +169,6 @@ | ``is not`` | negated object identity | | +------------+-------------------------+-------+ -.. index:: - pair: operator; comparison - operator: == - operator: < - operator: <= - operator: > - operator: >= - operator: != - operator: is - operator: is not - Notes: (1) @@ -262,6 +261,13 @@ builtin: long builtin: float builtin: complex + operator: + + operator: - + operator: * + operator: / + operator: // + operator: % + operator: ** Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the "narrower" type is @@ -394,7 +400,15 @@ Bit-string Operations on Integer Types -------------------------------------- -.. _bit-string-operations: +.. index:: + triple: operations on; integer; types + pair: bit-string; operations + pair: shifting; operations + pair: masking; operations + operator: ^ + operator: & + operator: << + operator: >> Plain and long integer types support additional operations that make sense only for bit-strings. Negative numbers are treated as their 2's complement value @@ -426,12 +440,6 @@ | ``~x`` | the bits of *x* inverted | | +------------+--------------------------------+----------+ -.. index:: - triple: operations on; integer; types - pair: bit-string; operations - pair: shifting; operations - pair: masking; operations - Notes: (1) Modified: python/branches/release26-maint/Doc/library/subprocess.rst ============================================================================== --- python/branches/release26-maint/Doc/library/subprocess.rst (original) +++ python/branches/release26-maint/Doc/library/subprocess.rst Tue Oct 27 15:34:21 2009 @@ -369,7 +369,7 @@ sts = os.system("mycmd" + " myarg") ==> p = Popen("mycmd" + " myarg", shell=True) - sts = os.waitpid(p.pid, 0) + sts = os.waitpid(p.pid, 0)[1] Notes: Modified: python/branches/release26-maint/Doc/library/warnings.rst ============================================================================== --- python/branches/release26-maint/Doc/library/warnings.rst (original) +++ python/branches/release26-maint/Doc/library/warnings.rst Tue Oct 27 15:34:21 2009 @@ -204,7 +204,7 @@ fxn() # Verify some things assert len(w) == 1 - assert isinstance(w[-1].category, DeprecationWarning) + assert issubclass(w[-1].category, DeprecationWarning) assert "deprecated" in str(w[-1].message) One can also cause all warnings to be exceptions by using ``error`` instead of 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 Tue Oct 27 15:34:21 2009 @@ -46,14 +46,14 @@ The following functions are defined: -.. function:: open(url[, new=0[, autoraise=1]]) +.. function:: open(url[, new=0[, autoraise=True]]) - Display *url* using the default browser. If *new* is 0, the *url* is opened in - the same browser window if possible. If *new* is 1, a new browser window is - opened if possible. If *new* is 2, a new browser page ("tab") is opened if - possible. If *autoraise* is true, the window is raised if possible (note that - under many window managers this will occur regardless of the setting of this - variable). + Display *url* using the default browser. If *new* is 0, the *url* is opened + in the same browser window if possible. If *new* is 1, a new browser window + is opened if possible. If *new* is 2, a new browser page ("tab") is opened + if possible. If *autoraise* is ``True``, the window is raised if possible + (note that under many window managers this will occur regardless of the + setting of this variable). Note that on some platforms, trying to open a filename using this function, may work and start the operating system's associated program. However, this @@ -180,7 +180,7 @@ module-level convenience functions: -.. method:: controller.open(url[, new[, autoraise=1]]) +.. method:: controller.open(url[, new[, autoraise=True]]) Display *url* using the browser handled by this controller. If *new* is 1, a new browser window is opened if possible. If *new* is 2, a new browser page ("tab") 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 Tue Oct 27 15:34:21 2009 @@ -262,9 +262,9 @@ .. method:: Element.getiterator([tag=None]) Creates a tree iterator with the current element as the root. The iterator - iterates over this element and all elements below it that match the given tag. - If tag is ``None`` or ``'*'`` then all elements are iterated over. Returns an - iterable that provides element objects in document (depth first) order. + iterates over this element and all elements below it, in document (depth first) + order. If *tag* is not ``None`` or ``'*'``, only elements whose tag equals + *tag* are returned from the iterator. .. method:: Element.insert(index, element) Modified: python/branches/release26-maint/Doc/tutorial/errors.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/errors.rst (original) +++ python/branches/release26-maint/Doc/tutorial/errors.rst Tue Oct 27 15:34:21 2009 @@ -221,9 +221,11 @@ File "", line 1, in ? NameError: HiThere -The sole argument to :keyword:`raise` indicates the exception to be raised. -This must be either an exception instance or an exception class (a class that -derives from :class:`Exception`). +The argument to :keyword:`raise` is an exception class or instance to be +raised. There is a deprecated alternate syntax that separates class and +constructor arguments; the above could be written as ``raise NameError, +'HiThere'``. Since it once was the only one available, the latter form is +prevalent in older code. If you need to determine whether an exception was raised but don't intend to handle it, a simpler form of the :keyword:`raise` statement allows you to Modified: python/branches/release26-maint/Doc/tutorial/inputoutput.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/inputoutput.rst (original) +++ python/branches/release26-maint/Doc/tutorial/inputoutput.rst Tue Oct 27 15:34:21 2009 @@ -148,9 +148,9 @@ ... other='Georg') The story of Bill, Manfred, and Georg. -An optional ``':'`` and format specifier can follow the field name. This also +An optional ``':'`` and format specifier can follow the field name. This allows greater control over how the value is formatted. The following example -truncates the Pi to three places after the decimal. +truncates Pi to three places after the decimal. >>> import math >>> print 'The value of PI is approximately {0:.3f}.'.format(math.pi) @@ -204,8 +204,8 @@ The value of PI is approximately 3.142. Since :meth:`str.format` is quite new, a lot of Python code still uses the ``%`` -operator. However, because this old style of formatting will eventually removed -from the language :meth:`str.format` should generally be used. +operator. However, because this old style of formatting will eventually be +removed from the language, :meth:`str.format` should generally be used. More information can be found in the :ref:`string-formatting` section. From python-checkins at python.org Tue Oct 27 15:36:51 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:36:51 -0000 Subject: [Python-checkins] r75785 - in python/branches/release26-maint: Doc/library/2to3.rst Doc/library/aifc.rst Doc/library/anydbm.rst Doc/library/audioop.rst Doc/library/cd.rst Doc/library/cgi.rst Doc/library/csv.rst Doc/library/curses.rst Doc/library/dbhash.rst Doc/library/decimal.rst Doc/library/dis.rst Doc/library/dl.rst Doc/library/exceptions.rst Doc/library/fileinput.rst Doc/library/functions.rst Doc/library/io.rst Doc/library/locale.rst Doc/library/logging.rst Doc/library/mailbox.rst Doc/library/multifile.rst Doc/library/multiprocessing.rst Doc/library/os.rst Doc/library/ossaudiodev.rst Doc/library/posixfile.rst Doc/library/pyclbr.rst Doc/library/repr.rst Doc/library/shelve.rst Doc/library/stdtypes.rst Doc/library/sunau.rst Doc/library/sunaudio.rst Doc/library/tempfile.rst Doc/library/threading.rst Doc/library/tkinter.rst Doc/library/wave.rst Doc/library/webbrowser.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:36:50 2009 New Revision: 75785 Log: Merged revisions 74207 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74207 | georg.brandl | 2009-07-26 16:19:57 +0200 (So, 26 Jul 2009) | 1 line #6577: fix (hopefully) all links to builtin instead of module/class-specific objects. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/library/2to3.rst python/branches/release26-maint/Doc/library/aifc.rst python/branches/release26-maint/Doc/library/anydbm.rst python/branches/release26-maint/Doc/library/audioop.rst python/branches/release26-maint/Doc/library/cd.rst python/branches/release26-maint/Doc/library/cgi.rst python/branches/release26-maint/Doc/library/csv.rst python/branches/release26-maint/Doc/library/curses.rst python/branches/release26-maint/Doc/library/dbhash.rst python/branches/release26-maint/Doc/library/decimal.rst python/branches/release26-maint/Doc/library/dis.rst python/branches/release26-maint/Doc/library/dl.rst python/branches/release26-maint/Doc/library/exceptions.rst python/branches/release26-maint/Doc/library/fileinput.rst python/branches/release26-maint/Doc/library/functions.rst python/branches/release26-maint/Doc/library/io.rst python/branches/release26-maint/Doc/library/locale.rst python/branches/release26-maint/Doc/library/logging.rst python/branches/release26-maint/Doc/library/mailbox.rst python/branches/release26-maint/Doc/library/multifile.rst python/branches/release26-maint/Doc/library/multiprocessing.rst python/branches/release26-maint/Doc/library/os.rst python/branches/release26-maint/Doc/library/ossaudiodev.rst python/branches/release26-maint/Doc/library/posixfile.rst python/branches/release26-maint/Doc/library/pyclbr.rst python/branches/release26-maint/Doc/library/repr.rst python/branches/release26-maint/Doc/library/shelve.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/sunau.rst python/branches/release26-maint/Doc/library/sunaudio.rst python/branches/release26-maint/Doc/library/tempfile.rst python/branches/release26-maint/Doc/library/threading.rst python/branches/release26-maint/Doc/library/tkinter.rst python/branches/release26-maint/Doc/library/wave.rst python/branches/release26-maint/Doc/library/webbrowser.rst Modified: python/branches/release26-maint/Doc/library/2to3.rst ============================================================================== --- python/branches/release26-maint/Doc/library/2to3.rst (original) +++ python/branches/release26-maint/Doc/library/2to3.rst Tue Oct 27 15:36:50 2009 @@ -239,8 +239,9 @@ .. 2to3fixer:: next - Converts the use of iterator's :meth:`next` methods to the :func:`next` - function. It also renames :meth:`next` methods to :meth:`~object.__next__`. + Converts the use of iterator's :meth:`~iterator.next` methods to the + :func:`next` function. It also renames :meth:`next` methods to + :meth:`~object.__next__`. .. 2to3fixer:: nonzero Modified: python/branches/release26-maint/Doc/library/aifc.rst ============================================================================== --- python/branches/release26-maint/Doc/library/aifc.rst (original) +++ python/branches/release26-maint/Doc/library/aifc.rst Tue Oct 27 15:36:50 2009 @@ -48,7 +48,7 @@ time how many samples you are going to write in total and use :meth:`writeframesraw` and :meth:`setnframes`. -Objects returned by :func:`open` when a file is opened for reading have the +Objects returned by :func:`.open` when a file is opened for reading have the following methods: @@ -131,7 +131,7 @@ Close the AIFF file. After calling this method, the object can no longer be used. -Objects returned by :func:`open` when a file is opened for writing have all the +Objects returned by :func:`.open` when a file is opened for writing have all the above methods, except for :meth:`readframes` and :meth:`setpos`. In addition the following methods exist. The :meth:`get\*` methods can only be called after the corresponding :meth:`set\*` methods have been called. Before the first Modified: python/branches/release26-maint/Doc/library/anydbm.rst ============================================================================== --- python/branches/release26-maint/Doc/library/anydbm.rst (original) +++ python/branches/release26-maint/Doc/library/anydbm.rst Tue Oct 27 15:36:50 2009 @@ -62,7 +62,7 @@ modules, with a unique exception also named :exc:`anydbm.error` as the first item --- the latter is used when :exc:`anydbm.error` is raised. -The object returned by :func:`open` supports most of the same functionality as +The object returned by :func:`.open` supports most of the same functionality as dictionaries; keys and their corresponding values can be stored, retrieved, and deleted, and the :meth:`has_key` and :meth:`keys` methods are available. Keys and values must always be strings. Modified: python/branches/release26-maint/Doc/library/audioop.rst ============================================================================== --- python/branches/release26-maint/Doc/library/audioop.rst (original) +++ python/branches/release26-maint/Doc/library/audioop.rst Tue Oct 27 15:36:50 2009 @@ -228,7 +228,7 @@ u-LAW encoding always uses 8 bits samples, so *width* refers only to the sample width of the output fragment here. -Note that operations such as :func:`mul` or :func:`max` make no distinction +Note that operations such as :func:`.mul` or :func:`.max` make no distinction between mono and stereo fragments, i.e. all samples are treated equal. If this is a problem the stereo fragment should be split into two mono fragments first and recombined later. Here is an example of how to do that:: Modified: python/branches/release26-maint/Doc/library/cd.rst ============================================================================== --- python/branches/release26-maint/Doc/library/cd.rst (original) +++ python/branches/release26-maint/Doc/library/cd.rst Tue Oct 27 15:36:50 2009 @@ -16,8 +16,8 @@ available only on Silicon Graphics systems. The way the library works is as follows. A program opens the CD-ROM device with -:func:`open` and creates a parser to parse the data from the CD with -:func:`createparser`. The object returned by :func:`open` can be used to read +:func:`.open` and creates a parser to parse the data from the CD with +:func:`createparser`. The object returned by :func:`.open` can be used to read data from the CD, but also to get status information for the CD-ROM device, and to get information about the CD, such as the table of contents. Data from the CD is passed to the parser, which parses the frames, and calls any callback @@ -133,7 +133,7 @@ Player Objects -------------- -Player objects (returned by :func:`open`) have the following methods: +Player objects (returned by :func:`.open`) have the following methods: .. method:: CD player.allowremoval() Modified: python/branches/release26-maint/Doc/library/cgi.rst ============================================================================== --- python/branches/release26-maint/Doc/library/cgi.rst (original) +++ python/branches/release26-maint/Doc/library/cgi.rst Tue Oct 27 15:36:50 2009 @@ -136,8 +136,8 @@ If a field represents an uploaded file, accessing the value via the :attr:`value` attribute or the :func:`getvalue` method reads the entire file in memory as a string. This may not be what you want. You can test for an uploaded -file by testing either the :attr:`filename` attribute or the :attr:`file` -attribute. You can then read the data at leisure from the :attr:`file` +file by testing either the :attr:`filename` attribute or the :attr:`!file` +attribute. You can then read the data at leisure from the :attr:`!file` attribute:: fileitem = form["userfile"] @@ -157,7 +157,7 @@ The file upload draft standard entertains the possibility of uploading multiple files from one field (using a recursive :mimetype:`multipart/\*` encoding). When this occurs, the item will be a dictionary-like :class:`FieldStorage` item. -This can be determined by testing its :attr:`type` attribute, which should be +This can be determined by testing its :attr:`!type` attribute, which should be :mimetype:`multipart/form-data` (or perhaps another MIME type matching :mimetype:`multipart/\*`). In this case, it can be iterated over recursively just like the top-level form object. @@ -165,7 +165,7 @@ When a form is submitted in the "old" format (as the query string or as a single data part of type :mimetype:`application/x-www-form-urlencoded`), the items will actually be instances of the class :class:`MiniFieldStorage`. In this case, the -:attr:`list`, :attr:`file`, and :attr:`filename` attributes are always ``None``. +:attr:`!list`, :attr:`!file`, and :attr:`filename` attributes are always ``None``. A form submitted via POST that also has a query string will contain both :class:`FieldStorage` and :class:`MiniFieldStorage` items. Modified: python/branches/release26-maint/Doc/library/csv.rst ============================================================================== --- python/branches/release26-maint/Doc/library/csv.rst (original) +++ python/branches/release26-maint/Doc/library/csv.rst Tue Oct 27 15:36:50 2009 @@ -61,7 +61,7 @@ Return a reader object which will iterate over lines in the given *csvfile*. *csvfile* can be any object which supports the :term:`iterator` protocol and returns a - string each time its :meth:`next` method is called --- file objects and list + string each time its :meth:`!next` method is called --- file objects and list objects are both suitable. If *csvfile* is a file object, it must be opened with the 'b' flag on platforms where that makes a difference. An optional *dialect* parameter can be given which is used to define a set of parameters Modified: python/branches/release26-maint/Doc/library/curses.rst ============================================================================== --- python/branches/release26-maint/Doc/library/curses.rst (original) +++ python/branches/release26-maint/Doc/library/curses.rst Tue Oct 27 15:36:50 2009 @@ -186,7 +186,7 @@ .. function:: filter() - The :func:`filter` routine, if used, must be called before :func:`initscr` is + The :func:`.filter` routine, if used, must be called before :func:`initscr` is called. The effect is that, during those calls, LINES is set to 1; the capabilities clear, cup, cud, cud1, cuu1, cuu, vpa are disabled; and the home string is set to the value of cr. The effect is that the cursor is confined to Modified: python/branches/release26-maint/Doc/library/dbhash.rst ============================================================================== --- python/branches/release26-maint/Doc/library/dbhash.rst (original) +++ python/branches/release26-maint/Doc/library/dbhash.rst Tue Oct 27 15:36:50 2009 @@ -72,7 +72,7 @@ Database Objects ---------------- -The database objects returned by :func:`open` provide the methods common to all +The database objects returned by :func:`.open` provide the methods common to all the DBM-style databases and mapping objects. The following methods are available in addition to the standard methods. @@ -80,7 +80,7 @@ .. method:: dbhash.first() It's possible to loop over every key/value pair in the database using this - method and the :meth:`next` method. The traversal is ordered by the databases + method and the :meth:`!next` method. The traversal is ordered by the databases internal hash values, and won't be sorted by the key values. This method returns the starting key. Modified: python/branches/release26-maint/Doc/library/decimal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/decimal.rst (original) +++ python/branches/release26-maint/Doc/library/decimal.rst Tue Oct 27 15:36:50 2009 @@ -639,7 +639,7 @@ .. method:: max_mag(other[, context]) - Similar to the :meth:`max` method, but the comparison is done using the + Similar to the :meth:`.max` method, but the comparison is done using the absolute values of the operands. .. versionadded:: 2.6 @@ -653,7 +653,7 @@ .. method:: min_mag(other[, context]) - Similar to the :meth:`min` method, but the comparison is done using the + Similar to the :meth:`.min` method, but the comparison is done using the absolute values of the operands. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/dis.rst ============================================================================== --- python/branches/release26-maint/Doc/library/dis.rst (original) +++ python/branches/release26-maint/Doc/library/dis.rst Tue Oct 27 15:36:50 2009 @@ -668,7 +668,7 @@ .. opcode:: FOR_ITER (delta) - ``TOS`` is an :term:`iterator`. Call its :meth:`next` method. If this + ``TOS`` is an :term:`iterator`. Call its :meth:`!next` method. If this yields a new value, push it on the stack (leaving the iterator below it). If the iterator indicates it is exhausted ``TOS`` is popped, and the bytecode counter is incremented by *delta*. Modified: python/branches/release26-maint/Doc/library/dl.rst ============================================================================== --- python/branches/release26-maint/Doc/library/dl.rst (original) +++ python/branches/release26-maint/Doc/library/dl.rst Tue Oct 27 15:36:50 2009 @@ -44,12 +44,12 @@ .. data:: RTLD_LAZY - Useful as an argument to :func:`open`. + Useful as an argument to :func:`.open`. .. data:: RTLD_NOW - Useful as an argument to :func:`open`. Note that on systems which do not + Useful as an argument to :func:`.open`. Note that on systems which do not support immediate binding, this constant will not appear in the module. For maximum portability, use :func:`hasattr` to determine if the system supports immediate binding. @@ -78,7 +78,7 @@ Dl Objects ---------- -Dl objects, as returned by :func:`open` above, have the following methods: +Dl objects, as returned by :func:`.open` above, have the following methods: .. method:: dl.close() Modified: python/branches/release26-maint/Doc/library/exceptions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/exceptions.rst (original) +++ python/branches/release26-maint/Doc/library/exceptions.rst Tue Oct 27 15:36:50 2009 @@ -281,10 +281,10 @@ .. exception:: StopIteration - Raised by an :term:`iterator`\'s :meth:`next` method to signal that there are - no further values. This is derived from :exc:`Exception` rather than - :exc:`StandardError`, since this is not considered an error in its normal - application. + Raised by an :term:`iterator`\'s :meth:`~iterator.next` method to signal that + there are no further values. This is derived from :exc:`Exception` rather + than :exc:`StandardError`, since this is not considered an error in its + normal application. .. versionadded:: 2.2 Modified: python/branches/release26-maint/Doc/library/fileinput.rst ============================================================================== --- python/branches/release26-maint/Doc/library/fileinput.rst (original) +++ python/branches/release26-maint/Doc/library/fileinput.rst Tue Oct 27 15:36:50 2009 @@ -20,10 +20,10 @@ This iterates over the lines of all files listed in ``sys.argv[1:]``, defaulting to ``sys.stdin`` if the list is empty. If a filename is ``'-'``, it is also replaced by ``sys.stdin``. To specify an alternative list of filenames, pass it -as the first argument to :func:`input`. A single file name is also allowed. +as the first argument to :func:`.input`. A single file name is also allowed. All files are opened in text mode by default, but you can override this by -specifying the *mode* parameter in the call to :func:`input` or +specifying the *mode* parameter in the call to :func:`.input` or :class:`FileInput()`. If an I/O error occurs during opening or reading a file, :exc:`IOError` is raised. Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Tue Oct 27 15:36:50 2009 @@ -291,7 +291,7 @@ Return an enumerate object. *sequence* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The - :meth:`next` method of the iterator returned by :func:`enumerate` returns a + :meth:`!next` method of the iterator returned by :func:`enumerate` returns a tuple containing a count (from *start* which defaults to 0) and the corresponding value obtained from iterating over *iterable*. :func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``, @@ -600,7 +600,7 @@ does not support either of those protocols, :exc:`TypeError` is raised. If the second argument, *sentinel*, is given, then *o* must be a callable object. The iterator created in this case will call *o* with no arguments for each call to - its :meth:`next` method; if the value returned is equal to *sentinel*, + its :meth:`~iterator.next` method; if the value returned is equal to *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned. One useful application of the second form of :func:`iter` is to read lines of @@ -704,9 +704,9 @@ .. function:: next(iterator[, default]) - Retrieve the next item from the *iterator* by calling its :meth:`next` - method. If *default* is given, it is returned if the iterator is exhausted, - otherwise :exc:`StopIteration` is raised. + Retrieve the next item from the *iterator* by calling its + :meth:`~iterator.next` method. If *default* is given, it is returned if the + iterator is exhausted, otherwise :exc:`StopIteration` is raised. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/io.rst ============================================================================== --- python/branches/release26-maint/Doc/library/io.rst (original) +++ python/branches/release26-maint/Doc/library/io.rst Tue Oct 27 15:36:50 2009 @@ -37,7 +37,7 @@ stream for text. Argument names are not part of the specification, and only the arguments of -:func:`open` are intended to be used as keyword arguments. +:func:`.open` are intended to be used as keyword arguments. Module Interface @@ -46,7 +46,7 @@ .. data:: DEFAULT_BUFFER_SIZE An int containing the default buffer size used by the module's buffered I/O - classes. :func:`open` uses the file's blksize (as obtained by + classes. :func:`.open` uses the file's blksize (as obtained by :func:`os.stat`) if possible. .. function:: open(file[, mode[, buffering[, encoding[, errors[, newline[, closefd=True]]]]]]) @@ -138,8 +138,8 @@ when the file is closed. If a filename is given *closefd* has no effect but must be ``True`` (the default). - The type of file object returned by the :func:`open` function depends - on the mode. When :func:`open` is used to open a file in a text mode + The type of file object returned by the :func:`.open` function depends + on the mode. When :func:`.open` is used to open a file in a text mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a :class:`TextIOWrapper`. When used to open a file in a binary mode, the returned class varies: in read binary mode, it returns a @@ -250,7 +250,7 @@ most *limit* bytes will be read. The line terminator is always ``b'\n'`` for binary files; for text files, - the *newlines* argument to :func:`open` can be used to select the line + the *newlines* argument to :func:`.open` can be used to select the line terminator(s) recognized. .. method:: readlines([hint]) Modified: python/branches/release26-maint/Doc/library/locale.rst ============================================================================== --- python/branches/release26-maint/Doc/library/locale.rst (original) +++ python/branches/release26-maint/Doc/library/locale.rst Tue Oct 27 15:36:50 2009 @@ -454,8 +454,8 @@ .. data:: LC_NUMERIC - Locale category for formatting numbers. The functions :func:`format`, - :func:`atoi`, :func:`atof` and :func:`str` of the :mod:`locale` module are + Locale category for formatting numbers. The functions :func:`.format`, + :func:`atoi`, :func:`atof` and :func:`.str` of the :mod:`locale` module are affected by that category. All other numeric formatting operations are not affected. @@ -523,7 +523,7 @@ The only way to perform numeric operations according to the locale is to use the special functions defined by this module: :func:`atof`, :func:`atoi`, -:func:`format`, :func:`str`. +:func:`.format`, :func:`.str`. .. _embedding-locale: 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 Tue Oct 27 15:36:50 2009 @@ -996,7 +996,7 @@ Handles a record by passing it to all handlers associated with this logger and its ancestors (until a false value of *propagate* is found). This method is used for unpickled records received from a socket, as well as those created locally. - Logger-level filtering is applied using :meth:`filter`. + Logger-level filtering is applied using :meth:`~Logger.filter`. .. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info [, func, extra]) Modified: python/branches/release26-maint/Doc/library/mailbox.rst ============================================================================== --- python/branches/release26-maint/Doc/library/mailbox.rst (original) +++ python/branches/release26-maint/Doc/library/mailbox.rst Tue Oct 27 15:36:50 2009 @@ -1530,7 +1530,7 @@ Most of the older mailbox classes have names that differ from the current mailbox class names, except for :class:`Maildir`. For this reason, the new -:class:`Maildir` class defines a :meth:`next` method and its constructor differs +:class:`Maildir` class defines a :meth:`!next` method and its constructor differs slightly from those of the other new mailbox classes. The older mailbox classes whose names are not the same as their newer @@ -1543,7 +1543,7 @@ single file and separated by ``From`` (a.k.a. ``From_``) lines. The file object *fp* points to the mailbox file. The optional *factory* parameter is a callable that should create new message objects. *factory* is called with one argument, - *fp* by the :meth:`next` method of the mailbox object. The default is the + *fp* by the :meth:`!next` method of the mailbox object. The default is the :class:`rfc822.Message` class (see the :mod:`rfc822` module -- and the note below). Modified: python/branches/release26-maint/Doc/library/multifile.rst ============================================================================== --- python/branches/release26-maint/Doc/library/multifile.rst (original) +++ python/branches/release26-maint/Doc/library/multifile.rst Tue Oct 27 15:36:50 2009 @@ -109,7 +109,7 @@ an input line, it will be interpreted as a section-divider or end-marker (depending on the decoration, see :rfc:`2045`). All subsequent reads will return the empty string to indicate end-of-file, until a call to :meth:`pop` - removes the boundary a or :meth:`next` call reenables it. + removes the boundary a or :meth:`.next` call reenables it. It is possible to push more than one boundary. Encountering the most-recently-pushed boundary will return EOF; encountering any other 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 Tue Oct 27 15:36:50 2009 @@ -1565,7 +1565,7 @@ .. method:: map_async(func, iterable[, chunksize[, callback]]) - A variant of the :meth:`map` method which returns a result object. + A variant of the :meth:`.map` method which returns a result object. If *callback* is specified then it should be a callable which accepts a single argument. When the result becomes ready *callback* is applied to @@ -1581,7 +1581,7 @@ make make the job complete **much** faster than using the default value of ``1``. - Also if *chunksize* is ``1`` then the :meth:`next` method of the iterator + Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator returned by the :meth:`imap` method has an optional *timeout* parameter: ``next(timeout)`` will raise :exc:`multiprocessing.TimeoutError` if the result cannot be returned within *timeout* seconds. Modified: python/branches/release26-maint/Doc/library/os.rst ============================================================================== --- python/branches/release26-maint/Doc/library/os.rst (original) +++ python/branches/release26-maint/Doc/library/os.rst Tue Oct 27 15:36:50 2009 @@ -606,10 +606,10 @@ .. note:: - This function is intended for low-level I/O. For normal usage, use the built-in - function :func:`open`, which returns a "file object" with :meth:`~file.read` and - :meth:`~file.write` methods (and many more). To wrap a file descriptor in a "file - object", use :func:`fdopen`. + This function is intended for low-level I/O. For normal usage, use the + built-in function :func:`open`, which returns a "file object" with + :meth:`~file.read` and :meth:`~file.write` methods (and many more). To + wrap a file descriptor in a "file object", use :func:`fdopen`. .. function:: openpty() @@ -754,10 +754,10 @@ .. note:: - Using :func:`access` to check if a user is authorized to e.g. open a file before - actually doing so using :func:`open` creates a security hole, because the user - might exploit the short time interval between checking and opening the file to - manipulate it. + Using :func:`access` to check if a user is authorized to e.g. open a file + before actually doing so using :func:`open` creates a security hole, + because the user might exploit the short time interval between checking + and opening the file to manipulate it. .. note:: Modified: python/branches/release26-maint/Doc/library/ossaudiodev.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ossaudiodev.rst (original) +++ python/branches/release26-maint/Doc/library/ossaudiodev.rst Tue Oct 27 15:36:50 2009 @@ -120,7 +120,7 @@ parameters at once. This is more convenient, but may not be as flexible in all cases. -The audio device objects returned by :func:`open` define the following methods +The audio device objects returned by :func:`.open` define the following methods and (read-only) attributes: Modified: python/branches/release26-maint/Doc/library/posixfile.rst ============================================================================== --- python/branches/release26-maint/Doc/library/posixfile.rst (original) +++ python/branches/release26-maint/Doc/library/posixfile.rst Tue Oct 27 15:36:50 2009 @@ -24,9 +24,8 @@ methods and adds the methods described below. This module only works for certain flavors of Unix, since it uses :func:`fcntl.fcntl` for file locking. -To instantiate a posixfile object, use the :func:`open` function in the -:mod:`posixfile` module. The resulting object looks and feels roughly the same -as a standard file object. +To instantiate a posixfile object, use the :func:`posixfile.open` function. The +resulting object looks and feels roughly the same as a standard file object. The :mod:`posixfile` module defines the following constants: Modified: python/branches/release26-maint/Doc/library/pyclbr.rst ============================================================================== --- python/branches/release26-maint/Doc/library/pyclbr.rst (original) +++ python/branches/release26-maint/Doc/library/pyclbr.rst Tue Oct 27 15:36:50 2009 @@ -78,7 +78,7 @@ .. attribute:: Class.lineno The line number of the ``class`` statement within the file named by - :attr:`file`. + :attr:`~Class.file`. .. _pyclbr-function-objects: @@ -109,5 +109,5 @@ .. attribute:: Function.lineno The line number of the ``def`` statement within the file named by - :attr:`file`. + :attr:`~Function.file`. Modified: python/branches/release26-maint/Doc/library/repr.rst ============================================================================== --- python/branches/release26-maint/Doc/library/repr.rst (original) +++ python/branches/release26-maint/Doc/library/repr.rst Tue Oct 27 15:36:50 2009 @@ -27,16 +27,16 @@ .. data:: aRepr - This is an instance of :class:`Repr` which is used to provide the :func:`repr` + This is an instance of :class:`Repr` which is used to provide the :func:`.repr` function described below. Changing the attributes of this object will affect - the size limits used by :func:`repr` and the Python debugger. + the size limits used by :func:`.repr` and the Python debugger. .. function:: repr(obj) - This is the :meth:`repr` method of ``aRepr``. It returns a string similar to - that returned by the built-in function of the same name, but with limits on - most sizes. + This is the :meth:`~Repr.repr` method of ``aRepr``. It returns a string + similar to that returned by the built-in function of the same name, but with + limits on most sizes. .. _repr-objects: @@ -99,7 +99,7 @@ .. method:: Repr.repr1(obj, level) - Recursive implementation used by :meth:`repr`. This uses the type of *obj* to + Recursive implementation used by :meth:`.repr`. This uses the type of *obj* to determine which formatting method to call, passing it *obj* and *level*. The type-specific methods should call :meth:`repr1` to perform recursive formatting, with ``level - 1`` for the value of *level* in the recursive call. Modified: python/branches/release26-maint/Doc/library/shelve.rst ============================================================================== --- python/branches/release26-maint/Doc/library/shelve.rst (original) +++ python/branches/release26-maint/Doc/library/shelve.rst Tue Oct 27 15:36:50 2009 @@ -108,7 +108,7 @@ .. class:: BsdDbShelf(dict[, protocol=None[, writeback=False]]) - A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`next`, + A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`, :meth:`previous`, :meth:`last` and :meth:`set_location` which are available in the :mod:`bsddb` module but not in other database modules. The *dict* object passed to the constructor must support those methods. This is generally @@ -122,7 +122,7 @@ A subclass of :class:`Shelf` which accepts a *filename* instead of a dict-like object. The underlying file will be opened using :func:`anydbm.open`. By default, the file will be created and opened for both read and write. The - optional *flag* parameter has the same interpretation as for the :func:`open` + optional *flag* parameter has the same interpretation as for the :func:`.open` function. The optional *protocol* and *writeback* parameters have the same interpretation as for the :class:`Shelf` class. @@ -174,8 +174,8 @@ BSD ``db`` database interface. Module :mod:`dbhash` - Thin layer around the :mod:`bsddb` which provides an :func:`open` function like - the other database modules. + Thin layer around the :mod:`bsddb` which provides an :func:`~dbhash.open` + function like the other database modules. Module :mod:`dbm` Standard Unix database interface. Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 15:36:50 2009 @@ -2168,12 +2168,12 @@ A file object is its own iterator, for example ``iter(f)`` returns *f* (unless *f* is closed). When a file is used as an iterator, typically in a :keyword:`for` loop (for example, ``for line in f: print line``), the - :meth:`next` method is called repeatedly. This method returns the next input + :meth:`.next` method is called repeatedly. This method returns the next input line, or raises :exc:`StopIteration` when EOF is hit when the file is open for reading (behavior is undefined when the file is open for writing). In order to make a :keyword:`for` loop the most efficient way of looping over the lines of a file (a very common operation), the :meth:`next` method uses a hidden read-ahead - buffer. As a consequence of using a read-ahead buffer, combining :meth:`next` + buffer. As a consequence of using a read-ahead buffer, combining :meth:`.next` with other file methods (like :meth:`readline`) does not work right. However, using :meth:`seek` to reposition the file to an absolute position will flush the read-ahead buffer. Modified: python/branches/release26-maint/Doc/library/sunau.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sunau.rst (original) +++ python/branches/release26-maint/Doc/library/sunau.rst Tue Oct 27 15:36:50 2009 @@ -58,18 +58,18 @@ .. function:: openfp(file, mode) - A synonym for :func:`open`, maintained for backwards compatibility. + A synonym for :func:`.open`, maintained for backwards compatibility. -The :mod:`sunau` module defines the following exception: +The :mod:`sunau` module defines the following exception: .. exception:: Error An error raised when something is impossible because of Sun AU specs or implementation deficiency. -The :mod:`sunau` module defines the following data items: +The :mod:`sunau` module defines the following data items: .. data:: AUDIO_FILE_MAGIC @@ -104,7 +104,7 @@ AU_read Objects --------------- -AU_read objects, as returned by :func:`open` above, have the following methods: +AU_read objects, as returned by :func:`.open` above, have the following methods: .. method:: AU_read.close() @@ -197,7 +197,7 @@ AU_write Objects ---------------- -AU_write objects, as returned by :func:`open` above, have the following methods: +AU_write objects, as returned by :func:`.open` above, have the following methods: .. method:: AU_write.setnchannels(n) Modified: python/branches/release26-maint/Doc/library/sunaudio.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sunaudio.rst (original) +++ python/branches/release26-maint/Doc/library/sunaudio.rst Tue Oct 27 15:36:50 2009 @@ -54,7 +54,7 @@ Audio Device Objects -------------------- -The audio device objects are returned by :func:`open` define the following +The audio device objects are returned by :func:`.open` define the following methods (except ``control`` objects which only provide :meth:`getinfo`, :meth:`setinfo`, :meth:`fileno`, and :meth:`drain`): Modified: python/branches/release26-maint/Doc/library/tempfile.rst ============================================================================== --- python/branches/release26-maint/Doc/library/tempfile.rst (original) +++ python/branches/release26-maint/Doc/library/tempfile.rst Tue Oct 27 15:36:50 2009 @@ -51,7 +51,7 @@ The *dir*, *prefix* and *suffix* parameters are passed to :func:`mkstemp`. The returned object is a true file object on POSIX platforms. On other - platforms, it is a file-like object whose :attr:`file` attribute is the + platforms, it is a file-like object whose :attr:`!file` attribute is the underlying true file object. This file-like object can be used in a :keyword:`with` statement, just like a normal file. @@ -67,7 +67,7 @@ on Windows NT or later). If *delete* is true (the default), the file is deleted as soon as it is closed. - The returned object is always a file-like object whose :attr:`file` + The returned object is always a file-like object whose :attr:`!file` attribute is the underlying true file object. This file-like object can be used in a :keyword:`with` statement, just like a normal file. Modified: python/branches/release26-maint/Doc/library/threading.rst ============================================================================== --- python/branches/release26-maint/Doc/library/threading.rst (original) +++ python/branches/release26-maint/Doc/library/threading.rst Tue Oct 27 15:36:50 2009 @@ -65,8 +65,9 @@ :noindex: A factory function that returns a new event object. An event manages a flag - that can be set to true with the :meth:`set` method and reset to false with the - :meth:`clear` method. The :meth:`wait` method blocks until the flag is true. + that can be set to true with the :meth:`~Event.set` method and reset to false + with the :meth:`clear` method. The :meth:`wait` method blocks until the flag + is true. .. class:: local @@ -666,7 +667,7 @@ thread signals an event and other threads wait for it. An event object manages an internal flag that can be set to true with the -:meth:`set` method and reset to false with the :meth:`clear` method. The +:meth:`~Event.set` method and reset to false with the :meth:`clear` method. The :meth:`wait` method blocks until the flag is true. @@ -691,14 +692,15 @@ .. method:: Event.clear() Reset the internal flag to false. Subsequently, threads calling :meth:`wait` - will block until :meth:`set` is called to set the internal flag to true again. + will block until :meth:`.set` is called to set the internal flag to true + again. .. method:: Event.wait([timeout]) - Block until the internal flag is true. If the internal flag is true on entry, - return immediately. Otherwise, block until another thread calls :meth:`set` to - set the flag to true, or until the optional timeout occurs. + Block until the internal flag is true. If the internal flag is true on + entry, return immediately. Otherwise, block until another thread calls + :meth:`.set` to set the flag to true, or until the optional timeout occurs. When the timeout argument is present and not ``None``, it should be a floating point number specifying a timeout for the operation in seconds (or fractions Modified: python/branches/release26-maint/Doc/library/tkinter.rst ============================================================================== --- python/branches/release26-maint/Doc/library/tkinter.rst (original) +++ python/branches/release26-maint/Doc/library/tkinter.rst Tue Oct 27 15:36:50 2009 @@ -524,7 +524,7 @@ There are many useful subclasses of Variable already defined: :class:`StringVar`, :class:`IntVar`, :class:`DoubleVar`, and :class:`BooleanVar`. To read the current value of such a variable, call the -:meth:`get` method on it, and to change its value you call the :meth:`set` +:meth:`get` method on it, and to change its value you call the :meth:`!set` method. If you follow this protocol, the widget will always track the value of the variable, with no further intervention on your part. @@ -665,7 +665,7 @@ ``"raised"``, ``"sunken"``, ``"flat"``, ``"groove"``, and ``"ridge"``. scrollcommand - This is almost always the :meth:`set` method of some scrollbar widget, but can + This is almost always the :meth:`!set` method of some scrollbar widget, but can be any widget method that takes a single argument. Refer to the file :file:`Demo/tkinter/matt/canvas-with-scrollbars.py` in the Python source distribution for an example. Modified: python/branches/release26-maint/Doc/library/wave.rst ============================================================================== --- python/branches/release26-maint/Doc/library/wave.rst (original) +++ python/branches/release26-maint/Doc/library/wave.rst Tue Oct 27 15:36:50 2009 @@ -33,7 +33,7 @@ .. function:: openfp(file, mode) - A synonym for :func:`open`, maintained for backwards compatibility. + A synonym for :func:`.open`, maintained for backwards compatibility. .. exception:: Error @@ -47,7 +47,7 @@ Wave_read Objects ----------------- -Wave_read objects, as returned by :func:`open`, have the following methods: +Wave_read objects, as returned by :func:`.open`, have the following methods: .. method:: Wave_read.close() @@ -134,7 +134,7 @@ Wave_write Objects ------------------ -Wave_write objects, as returned by :func:`open`, have the following methods: +Wave_write objects, as returned by :func:`.open`, have the following methods: .. method:: Wave_write.close() 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 Tue Oct 27 15:36:50 2009 @@ -10,7 +10,7 @@ The :mod:`webbrowser` module provides a high-level interface to allow displaying Web-based documents to users. Under most circumstances, simply calling the -:func:`open` function from this module will do the right thing. +:func:`.open` function from this module will do the right thing. Under Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn't From python-checkins at python.org Tue Oct 27 15:37:49 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:37:49 -0000 Subject: [Python-checkins] r75786 - in python/branches/release26-maint: Doc/c-api/buffer.rst Doc/c-api/import.rst Doc/c-api/unicode.rst Doc/distutils/apiref.rst Doc/extending/newtypes.rst Doc/glossary.rst Doc/howto/doanddont.rst Doc/howto/urllib2.rst Doc/includes/sqlite3/text_factory.py Doc/library/2to3.rst Doc/library/__future__.rst Doc/library/_winreg.rst Doc/library/ast.rst Doc/library/collections.rst Doc/library/compiler.rst Doc/library/configparser.rst Doc/library/curses.rst Doc/library/functions.rst Doc/library/future_builtins.rst Doc/library/gc.rst Doc/library/gettext.rst Doc/library/heapq.rst Doc/library/imputil.rst Doc/library/io.rst Doc/library/multiprocessing.rst Doc/library/numbers.rst Doc/library/pprint.rst Doc/library/sets.rst Doc/library/sqlite3.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/sys.rst Doc/library/undoc.rst Doc/library/weakref.rst Doc/library/xmlrpclib.rst Doc/library/zipimport.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/using/cmdline.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.6.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:37:48 2009 New Revision: 75786 Log: Merged revisions 74209 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74209 | georg.brandl | 2009-07-26 16:37:28 +0200 (So, 26 Jul 2009) | 1 line builtin -> built-in. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/buffer.rst python/branches/release26-maint/Doc/c-api/import.rst python/branches/release26-maint/Doc/c-api/unicode.rst python/branches/release26-maint/Doc/distutils/apiref.rst python/branches/release26-maint/Doc/extending/newtypes.rst python/branches/release26-maint/Doc/glossary.rst python/branches/release26-maint/Doc/howto/doanddont.rst python/branches/release26-maint/Doc/howto/urllib2.rst python/branches/release26-maint/Doc/includes/sqlite3/text_factory.py python/branches/release26-maint/Doc/library/2to3.rst python/branches/release26-maint/Doc/library/__future__.rst python/branches/release26-maint/Doc/library/_winreg.rst python/branches/release26-maint/Doc/library/ast.rst python/branches/release26-maint/Doc/library/collections.rst python/branches/release26-maint/Doc/library/compiler.rst python/branches/release26-maint/Doc/library/configparser.rst python/branches/release26-maint/Doc/library/curses.rst python/branches/release26-maint/Doc/library/functions.rst python/branches/release26-maint/Doc/library/future_builtins.rst python/branches/release26-maint/Doc/library/gc.rst python/branches/release26-maint/Doc/library/gettext.rst python/branches/release26-maint/Doc/library/heapq.rst python/branches/release26-maint/Doc/library/imputil.rst python/branches/release26-maint/Doc/library/io.rst python/branches/release26-maint/Doc/library/multiprocessing.rst python/branches/release26-maint/Doc/library/numbers.rst python/branches/release26-maint/Doc/library/pprint.rst python/branches/release26-maint/Doc/library/sets.rst python/branches/release26-maint/Doc/library/sqlite3.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/string.rst python/branches/release26-maint/Doc/library/sys.rst python/branches/release26-maint/Doc/library/undoc.rst python/branches/release26-maint/Doc/library/weakref.rst python/branches/release26-maint/Doc/library/xmlrpclib.rst python/branches/release26-maint/Doc/library/zipimport.rst python/branches/release26-maint/Doc/reference/datamodel.rst python/branches/release26-maint/Doc/reference/executionmodel.rst python/branches/release26-maint/Doc/reference/expressions.rst python/branches/release26-maint/Doc/reference/simple_stmts.rst python/branches/release26-maint/Doc/using/cmdline.rst python/branches/release26-maint/Doc/whatsnew/2.2.rst python/branches/release26-maint/Doc/whatsnew/2.6.rst Modified: python/branches/release26-maint/Doc/c-api/buffer.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/buffer.rst (original) +++ python/branches/release26-maint/Doc/c-api/buffer.rst Tue Oct 27 15:37:48 2009 @@ -30,7 +30,7 @@ returning data from the target object. Starting from version 1.6, Python has been providing Python-level buffer -objects and a C-level buffer API so that any builtin or used-defined type can +objects and a C-level buffer API so that any built-in or used-defined type can expose its characteristics. Both, however, have been deprecated because of various shortcomings, and have been officially removed in Python 3.0 in favour of a new C-level buffer API and a new Python-level object named Modified: python/branches/release26-maint/Doc/c-api/import.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/import.rst (original) +++ python/branches/release26-maint/Doc/c-api/import.rst Tue Oct 27 15:37:48 2009 @@ -167,7 +167,7 @@ *path*, possibly by fetching it from the :data:`sys.path_importer_cache` dict. If it wasn't yet cached, traverse :data:`sys.path_hooks` until a hook is found that can handle the path item. Return ``None`` if no hook could; - this tells our caller it should fall back to the builtin import mechanism. + this tells our caller it should fall back to the built-in import mechanism. Cache the result in :data:`sys.path_importer_cache`. Return a new reference to the importer object. Modified: python/branches/release26-maint/Doc/c-api/unicode.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/unicode.rst (original) +++ python/branches/release26-maint/Doc/c-api/unicode.rst Tue Oct 27 15:37:48 2009 @@ -292,12 +292,12 @@ Built-in Codecs ^^^^^^^^^^^^^^^ -Python provides a set of builtin codecs which are written in C for speed. All of +Python provides a set of built-in codecs which are written in C for speed. All of these codecs are directly usable via the following functions. Many of the following APIs take two arguments encoding and errors. These parameters encoding and errors have the same semantics as the ones of the -builtin unicode() Unicode object constructor. +built-in :func:`unicode` Unicode object constructor. Setting encoding to *NULL* causes the default encoding to be used which is ASCII. The file system calls should use :cdata:`Py_FileSystemDefaultEncoding` @@ -307,7 +307,7 @@ Error handling is set by errors which may also be set to *NULL* meaning to use the default handling defined for the codec. Default error handling for all -builtin codecs is "strict" (:exc:`ValueError` is raised). +built-in codecs is "strict" (:exc:`ValueError` is raised). The codecs all use a similar interface. Only deviation from the following generic ones are documented for simplicity. @@ -321,7 +321,7 @@ Create a Unicode object by decoding *size* bytes of the encoded string *s*. *encoding* and *errors* have the same meaning as the parameters of the same name - in the :func:`unicode` builtin function. The codec to be used is looked up + in the :func:`unicode` built-in function. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. 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 Tue Oct 27 15:37:48 2009 @@ -1623,7 +1623,7 @@ +------------------+--------------------------------+---------+ Note that since *rstrip_ws* can strip the trailing newline, the semantics of - :meth:`readline` must differ from those of the builtin file object's + :meth:`readline` must differ from those of the built-in file object's :meth:`readline` method! In particular, :meth:`readline` returns ``None`` for end-of-file: an empty string might just be a blank line (or an all-whitespace line), if *rstrip_ws* is true but *skip_blanks* is not. @@ -1631,8 +1631,8 @@ .. method:: TextFile.open(filename) - Open a new file *filename*. This overrides any *file* or *filename* constructor - arguments. + Open a new file *filename*. This overrides any *file* or *filename* + constructor arguments. .. method:: TextFile.close() Modified: python/branches/release26-maint/Doc/extending/newtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/extending/newtypes.rst (original) +++ python/branches/release26-maint/Doc/extending/newtypes.rst Tue Oct 27 15:37:48 2009 @@ -819,7 +819,7 @@ these :class:`PyTypeObject` structures between extension modules. In this example we will create a :class:`Shoddy` type that inherits from the -builtin :class:`list` type. The new type will be completely compatible with +built-in :class:`list` type. The new type will be completely compatible with regular lists, but will have an additional :meth:`increment` method that increases an internal counter. :: Modified: python/branches/release26-maint/Doc/glossary.rst ============================================================================== --- python/branches/release26-maint/Doc/glossary.rst (original) +++ python/branches/release26-maint/Doc/glossary.rst Tue Oct 27 15:37:48 2009 @@ -28,11 +28,11 @@ abstract base class Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by - providing a way to define interfaces when other techniques like :func:`hasattr` - would be clumsy. Python comes with many builtin ABCs for data structures - (in the :mod:`collections` module), numbers (in the :mod:`numbers` - module), and streams (in the :mod:`io` module). You can create your own - ABC with the :mod:`abc` module. + providing a way to define interfaces when other techniques like + :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for + data structures (in the :mod:`collections` module), numbers (in the + :mod:`numbers` module), and streams (in the :mod:`io` module). You can + create your own ABC with the :mod:`abc` module. argument A value passed to a function or method, assigned to a named local @@ -79,7 +79,7 @@ in ``3+4.5``, each argument is of a different type (one int, one float), and both must be converted to the same type before they can be added or it will raise a ``TypeError``. Coercion between two operands can be - performed with the ``coerce`` builtin function; thus, ``3+4.5`` is + performed with the ``coerce`` built-in function; thus, ``3+4.5`` is equivalent to calling ``operator.add(*coerce(3, 4.5))`` and results in ``operator.add(3.0, 4.5)``. Without coercion, all arguments of even compatible types would have to be normalized to the same value by the @@ -90,7 +90,7 @@ expressed as a sum of a real part and an imaginary part. Imaginary numbers are real multiples of the imaginary unit (the square root of ``-1``), often written ``i`` in mathematics or ``j`` in - engineering. Python has builtin support for complex numbers, which are + engineering. Python has built-in support for complex numbers, which are written with this latter notation; the imaginary part is written with a ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly @@ -322,7 +322,7 @@ define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be used in a :keyword:`for` loop and in many other places where a sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable - object is passed as an argument to the builtin function :func:`iter`, it + object is passed as an argument to the built-in function :func:`iter`, it returns an iterator for the object. This iterator is good for one pass over the set of values. When using iterables, it is usually not necessary to call :func:`iter` or deal with iterator objects yourself. The ``for`` @@ -424,7 +424,7 @@ namespace The place where a variable is stored. Namespaces are implemented as - dictionaries. There are the local, global and builtin namespaces as well + dictionaries. There are the local, global and built-in namespaces as well as nested namespaces in objects (in methods). Namespaces support modularity by preventing naming conflicts. For instance, the functions :func:`__builtin__.open` and :func:`os.open` are distinguished by their Modified: python/branches/release26-maint/Doc/howto/doanddont.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/doanddont.rst (original) +++ python/branches/release26-maint/Doc/howto/doanddont.rst Tue Oct 27 15:37:48 2009 @@ -261,7 +261,7 @@ More useful functions in :mod:`os.path`: :func:`basename`, :func:`dirname` and :func:`splitext`. -There are also many useful builtin functions people seem not to be aware of for +There are also many useful built-in functions people seem not to be aware of for some reason: :func:`min` and :func:`max` can find the minimum/maximum of any sequence with comparable semantics, for example, yet many people write their own :func:`max`/:func:`min`. Another highly useful function is :func:`reduce`. A Modified: python/branches/release26-maint/Doc/howto/urllib2.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/urllib2.rst (original) +++ python/branches/release26-maint/Doc/howto/urllib2.rst Tue Oct 27 15:37:48 2009 @@ -182,10 +182,9 @@ Handling Exceptions =================== -*urlopen* raises :exc:`URLError` when it cannot handle a response (though as usual -with Python APIs, builtin exceptions such as -:exc:`ValueError`, :exc:`TypeError` etc. may also -be raised). +*urlopen* raises :exc:`URLError` when it cannot handle a response (though as +usual with Python APIs, built-in exceptions such as :exc:`ValueError`, +:exc:`TypeError` etc. may also be raised). :exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific case of HTTP URLs. Modified: python/branches/release26-maint/Doc/includes/sqlite3/text_factory.py ============================================================================== --- python/branches/release26-maint/Doc/includes/sqlite3/text_factory.py (original) +++ python/branches/release26-maint/Doc/includes/sqlite3/text_factory.py Tue Oct 27 15:37:48 2009 @@ -31,7 +31,7 @@ row = cur.fetchone() assert type(row[0]) == unicode -# sqlite3 offers a builtin optimized text_factory that will return bytestring +# sqlite3 offers a built-in optimized text_factory that will return bytestring # objects, if the data is in ASCII only, and otherwise return unicode objects con.text_factory = sqlite3.OptimizedUnicode cur.execute("select ?", (AUSTRIA,)) Modified: python/branches/release26-maint/Doc/library/2to3.rst ============================================================================== --- python/branches/release26-maint/Doc/library/2to3.rst (original) +++ python/branches/release26-maint/Doc/library/2to3.rst Tue Oct 27 15:37:48 2009 @@ -209,7 +209,7 @@ .. 2to3fixer:: itertools Changes usage of :func:`itertools.ifilter`, :func:`itertools.izip`, and - :func:`itertools.imap` to their builtin equivalents. + :func:`itertools.imap` to their built-in equivalents. :func:`itertools.ifilterfalse` is changed to :func:`itertools.filterfalse`. .. 2to3fixer:: long Modified: python/branches/release26-maint/Doc/library/__future__.rst ============================================================================== --- python/branches/release26-maint/Doc/library/__future__.rst (original) +++ python/branches/release26-maint/Doc/library/__future__.rst Tue Oct 27 15:37:48 2009 @@ -52,7 +52,7 @@ :meth:`getOptionalRelease` and :meth:`getMandatoryRelease`. *CompilerFlag* is the (bitfield) flag that should be passed in the fourth -argument to the builtin function :func:`compile` to enable the feature in +argument to the built-in function :func:`compile` to enable the feature in dynamically compiled code. This flag is stored in the :attr:`compiler_flag` attribute on :class:`_Feature` instances. Modified: python/branches/release26-maint/Doc/library/_winreg.rst ============================================================================== --- python/branches/release26-maint/Doc/library/_winreg.rst (original) +++ python/branches/release26-maint/Doc/library/_winreg.rst Tue Oct 27 15:37:48 2009 @@ -408,7 +408,7 @@ The object also support comparison semantics, so handle objects will compare true if they both reference the same underlying Windows handle value. -Handle objects can be converted to an integer (e.g., using the builtin +Handle objects can be converted to an integer (e.g., using the built-in :func:`int` function), in which case the underlying Windows handle value is returned. You can also use the :meth:`Detach` method to return the integer handle, and also disconnect the Windows handle from the handle object. Modified: python/branches/release26-maint/Doc/library/ast.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ast.rst (original) +++ python/branches/release26-maint/Doc/library/ast.rst Tue Oct 27 15:37:48 2009 @@ -22,7 +22,7 @@ grammar looks like. An abstract syntax tree can be generated by passing :data:`ast.PyCF_ONLY_AST` as -a flag to the :func:`compile` builtin function, or using the :func:`parse` +a flag to the :func:`compile` built-in function, or using the :func:`parse` helper provided in this module. The result will be a tree of objects whose classes all inherit from :class:`ast.AST`. An abstract syntax tree can be compiled into a Python code object using the built-in :func:`compile` function. Modified: python/branches/release26-maint/Doc/library/collections.rst ============================================================================== --- python/branches/release26-maint/Doc/library/collections.rst (original) +++ python/branches/release26-maint/Doc/library/collections.rst Tue Oct 27 15:37:48 2009 @@ -357,7 +357,7 @@ .. class:: defaultdict([default_factory[, ...]]) Returns a new dictionary-like object. :class:`defaultdict` is a subclass of the - builtin :class:`dict` class. It overrides one method and adds one writable + built-in :class:`dict` class. It overrides one method and adds one writable instance variable. The remaining functionality is the same as for the :class:`dict` class and is not documented here. Modified: python/branches/release26-maint/Doc/library/compiler.rst ============================================================================== --- python/branches/release26-maint/Doc/library/compiler.rst (original) +++ python/branches/release26-maint/Doc/library/compiler.rst Tue Oct 27 15:37:48 2009 @@ -21,11 +21,11 @@ generated a concrete syntax tree. This tree is used to generate an abstract syntax tree (AST) and then Python bytecode. -The full functionality of the package duplicates the builtin compiler provided +The full functionality of the package duplicates the built-in compiler provided with the Python interpreter. It is intended to match its behavior almost exactly. Why implement another compiler that does the same thing? The package is useful for a variety of purposes. It can be modified more easily than the -builtin compiler. The AST it generates is useful for analyzing Python source +built-in compiler. The AST it generates is useful for analyzing Python source code. This chapter explains how the various components of the :mod:`compiler` package @@ -118,7 +118,7 @@ introduced by Python's precedence rules. The abstract syntax tree is created by the :mod:`compiler.transformer` module. -The transformer relies on the builtin Python parser to generate a concrete +The transformer relies on the built-in Python parser to generate a concrete syntax tree. It generates an abstract syntax tree from the concrete tree. .. index:: Modified: python/branches/release26-maint/Doc/library/configparser.rst ============================================================================== --- python/branches/release26-maint/Doc/library/configparser.rst (original) +++ python/branches/release26-maint/Doc/library/configparser.rst Tue Oct 27 15:37:48 2009 @@ -56,7 +56,7 @@ constructor as a dictionary. Additional defaults may be passed into the :meth:`get` method which will override all others. -Sections are normally stored in a builtin dictionary. An alternative dictionary +Sections are normally stored in a built-in dictionary. An alternative dictionary type can be passed to the :class:`ConfigParser` constructor. For example, if a dictionary type is passed that sorts its keys, the sections will be sorted on write-back, as will be the keys within each section. Modified: python/branches/release26-maint/Doc/library/curses.rst ============================================================================== --- python/branches/release26-maint/Doc/library/curses.rst (original) +++ python/branches/release26-maint/Doc/library/curses.rst Tue Oct 27 15:37:48 2009 @@ -609,9 +609,9 @@ .. note:: A *character* means a C character (an ASCII code), rather then a Python - character (a string of length 1). (This note is true whenever the documentation - mentions a character.) The builtin :func:`ord` is handy for conveying strings to - codes. + character (a string of length 1). (This note is true whenever the + documentation mentions a character.) The built-in :func:`ord` is handy for + conveying strings to codes. Paint character *ch* at ``(y, x)`` with attributes *attr*, overwriting any character previously painter at that location. By default, the character Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Tue Oct 27 15:37:48 2009 @@ -846,7 +846,7 @@ .. note:: - This function is not normally available as a builtin since the name + This function is not normally available as a built-in since the name ``print`` is recognized as the :keyword:`print` statement. To disable the statement and use the :func:`print` function, use this future statement at the top of your module:: Modified: python/branches/release26-maint/Doc/library/future_builtins.rst ============================================================================== --- python/branches/release26-maint/Doc/library/future_builtins.rst (original) +++ python/branches/release26-maint/Doc/library/future_builtins.rst Tue Oct 27 15:37:48 2009 @@ -1,14 +1,14 @@ -:mod:`future_builtins` --- Python 3 builtins -============================================ +:mod:`future_builtins` --- Python 3 built-ins +============================================= .. module:: future_builtins .. sectionauthor:: Georg Brandl .. versionadded:: 2.6 This module provides functions that exist in 2.x, but have different behavior in -Python 3, so they cannot be put into the 2.x builtin namespace. +Python 3, so they cannot be put into the 2.x builtins namespace. -Instead, if you want to write code compatible with Python 3 builtins, import +Instead, if you want to write code compatible with Python 3 built-ins, import them from this module, like this:: from future_builtins import map, filter @@ -16,17 +16,17 @@ ... code using Python 3-style map and filter ... The :term:`2to3` tool that ports Python 2 code to Python 3 will recognize -this usage and leave the new builtins alone. +this usage and leave the new built-ins alone. .. note:: - The Python 3 :func:`print` function is already in the builtins, but cannot be + The Python 3 :func:`print` function is already in the built-ins, but cannot be accessed from Python 2 code unless you use the appropriate future statement:: from __future__ import print_function -Available builtins are: +Available built-ins are: .. function:: ascii(object) @@ -42,7 +42,7 @@ .. function:: hex(object) - Works like the builtin :func:`hex`, but instead of :meth:`__hex__` it will + Works like the built-in :func:`hex`, but instead of :meth:`__hex__` it will use the :meth:`__index__` method on its argument to get an integer that is then converted to hexadecimal. @@ -52,7 +52,7 @@ .. function:: oct(object) - Works like the builtin :func:`oct`, but instead of :meth:`__oct__` it will + Works like the built-in :func:`oct`, but instead of :meth:`__oct__` it will use the :meth:`__index__` method on its argument to get an integer that is then converted to octal. Modified: python/branches/release26-maint/Doc/library/gc.rst ============================================================================== --- python/branches/release26-maint/Doc/library/gc.rst (original) +++ python/branches/release26-maint/Doc/library/gc.rst Tue Oct 27 15:37:48 2009 @@ -48,7 +48,7 @@ The optional *generation* argument was added. .. versionchanged:: 2.6 - The free lists maintained for a number of builtin types are cleared + The free lists maintained for a number of built-in types are cleared whenever a full collection or collection of the highest generation (2) is run. Not all items in some free lists may be freed due to the particular implementation, in particular :class:`int` and :class:`float`. Modified: python/branches/release26-maint/Doc/library/gettext.rst ============================================================================== --- python/branches/release26-maint/Doc/library/gettext.rst (original) +++ python/branches/release26-maint/Doc/library/gettext.rst Tue Oct 27 15:37:48 2009 @@ -205,7 +205,7 @@ .. function:: install(domain[, localedir[, unicode [, codeset[, names]]]]) - This installs the function :func:`_` in Python's builtin namespace, based on + This installs the function :func:`_` in Python's builtins namespace, based on *domain*, *localedir*, and *codeset* which are passed to the function :func:`translation`. The *unicode* flag is passed to the resulting translation object's :meth:`install` method. @@ -220,7 +220,7 @@ print _('This string will be translated.') For convenience, you want the :func:`_` function to be installed in Python's - builtin namespace, so it is easily accessible in all modules of your + builtins namespace, so it is easily accessible in all modules of your application. .. versionchanged:: 2.4 @@ -347,7 +347,7 @@ it binds :meth:`self.ugettext` instead. By default, *unicode* is false. If the *names* parameter is given, it must be a sequence containing the - names of functions you want to install in the builtin namespace in + names of functions you want to install in the builtins namespace in addition to :func:`_`. Supported names are ``'gettext'`` (bound to :meth:`self.gettext` or :meth:`self.ugettext` according to the *unicode* flag), ``'ngettext'`` (bound to :meth:`self.ngettext` or Modified: python/branches/release26-maint/Doc/library/heapq.rst ============================================================================== --- python/branches/release26-maint/Doc/library/heapq.rst (original) +++ python/branches/release26-maint/Doc/library/heapq.rst Tue Oct 27 15:37:48 2009 @@ -147,7 +147,7 @@ The latter two functions perform best for smaller values of *n*. For larger values, it is more efficient to use the :func:`sorted` function. Also, when -``n==1``, it is more efficient to use the builtin :func:`min` and :func:`max` +``n==1``, it is more efficient to use the built-in :func:`min` and :func:`max` functions. Modified: python/branches/release26-maint/Doc/library/imputil.rst ============================================================================== --- python/branches/release26-maint/Doc/library/imputil.rst (original) +++ python/branches/release26-maint/Doc/library/imputil.rst Tue Oct 27 15:37:48 2009 @@ -79,7 +79,7 @@ .. class:: BuiltinImporter() - Emulate the import mechanism for builtin and frozen modules. This is a + Emulate the import mechanism for built-in and frozen modules. This is a sub-class of the :class:`Importer` class. .. method:: BuiltinImporter.get_code(parent, modname, fqname) Modified: python/branches/release26-maint/Doc/library/io.rst ============================================================================== --- python/branches/release26-maint/Doc/library/io.rst (original) +++ python/branches/release26-maint/Doc/library/io.rst Tue Oct 27 15:37:48 2009 @@ -10,7 +10,7 @@ .. versionadded:: 2.6 The :mod:`io` module provides the Python interfaces to stream handling. The -builtin :func:`open` function is defined in this module. +built-in :func:`open` function is defined in this module. At the top of the I/O hierarchy is the abstract base class :class:`IOBase`. It defines the basic interface to a stream. Note, however, that there is no 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 Tue Oct 27 15:37:48 2009 @@ -1540,8 +1540,8 @@ .. method:: apply(func[, args[, kwds]]) - Equivalent of the :func:`apply` builtin function. It blocks till the - result is ready. Given this blocks - :meth:`apply_async` is better suited + Equivalent of the :func:`apply` built-in function. It blocks till the + result is ready. Given this blocks, :meth:`apply_async` is better suited for performing work in parallel. Additionally, the passed in function is only executed in one of the workers of the pool. @@ -1556,7 +1556,7 @@ .. method:: map(func, iterable[, chunksize]) - A parallel equivalent of the :func:`map` builtin function (it supports only + A parallel equivalent of the :func:`map` built-in function (it supports only one *iterable* argument though). It blocks till the result is ready. This method chops the iterable into a number of chunks which it submits to Modified: python/branches/release26-maint/Doc/library/numbers.rst ============================================================================== --- python/branches/release26-maint/Doc/library/numbers.rst (original) +++ python/branches/release26-maint/Doc/library/numbers.rst Tue Oct 27 15:37:48 2009 @@ -24,7 +24,7 @@ .. class:: Complex Subclasses of this type describe complex numbers and include the operations - that work on the builtin :class:`complex` type. These are: conversions to + that work on the built-in :class:`complex` type. These are: conversions to :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``, ``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All except ``-`` and ``!=`` are abstract. Modified: python/branches/release26-maint/Doc/library/pprint.rst ============================================================================== --- python/branches/release26-maint/Doc/library/pprint.rst (original) +++ python/branches/release26-maint/Doc/library/pprint.rst Tue Oct 27 15:37:48 2009 @@ -13,7 +13,7 @@ If the formatted structures include objects which are not fundamental Python types, the representation may not be loadable. This may be the case if objects such as files, sockets, classes, or instances are included, as well as many -other builtin objects which are not representable as Python constants. +other built-in objects which are not representable as Python constants. The formatted representation keeps objects on a single line if it can, and breaks them onto multiple lines if they don't fit within the allowed width. Modified: python/branches/release26-maint/Doc/library/sets.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sets.rst (original) +++ python/branches/release26-maint/Doc/library/sets.rst Tue Oct 27 15:37:48 2009 @@ -184,7 +184,7 @@ Also note, the module also includes a :meth:`union_update` method which is an alias for :meth:`update`. The method is included for backwards compatibility. Programmers should prefer the :meth:`update` method because it is supported by -the builtin :class:`set()` and :class:`frozenset()` types. +the built-in :class:`set()` and :class:`frozenset()` types. .. _set-example: Modified: python/branches/release26-maint/Doc/library/sqlite3.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sqlite3.rst (original) +++ python/branches/release26-maint/Doc/library/sqlite3.rst Tue Oct 27 15:37:48 2009 @@ -840,7 +840,7 @@ Accessing columns by name instead of by index ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -One useful feature of the :mod:`sqlite3` module is the builtin +One useful feature of the :mod:`sqlite3` module is the built-in :class:`sqlite3.Row` class designed to be used as a row factory. Rows wrapped with this class can be accessed both by index (like tuples) and Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 15:37:48 2009 @@ -277,7 +277,7 @@ :func:`long`, :func:`float`, and :func:`complex` can be used to produce numbers of a specific type. -All builtin numeric types support the following operations. See +All built-in numeric types support the following operations. See :ref:`power` and later sections for the operators' priorities. +--------------------+---------------------------------+--------+ @@ -644,7 +644,7 @@ single item tuple must have a trailing comma, such as ``(d,)``. Buffer objects are not directly supported by Python syntax, but can be created -by calling the builtin function :func:`buffer`. They don't support +by calling the built-in function :func:`buffer`. They don't support concatenation or repetition. Objects of type xrange are similar to buffers in that there is no specific syntax to @@ -1621,7 +1621,7 @@ order of insertion. Accordingly, sets do not support indexing, slicing, or other sequence-like behavior. -There are currently two builtin set types, :class:`set` and :class:`frozenset`. +There are currently two built-in set types, :class:`set` and :class:`frozenset`. The :class:`set` type is mutable --- the contents can be changed using methods like :meth:`add` and :meth:`remove`. Since it is mutable, it has no hash value and cannot be used as either a dictionary key or as an element of another set. Modified: python/branches/release26-maint/Doc/library/string.rst ============================================================================== --- python/branches/release26-maint/Doc/library/string.rst (original) +++ python/branches/release26-maint/Doc/library/string.rst Tue Oct 27 15:37:48 2009 @@ -306,7 +306,7 @@ "Format specifications" are used within replacement fields contained within a format string to define how individual values are presented (see -:ref:`formatstrings`.) They can also be passed directly to the builtin +:ref:`formatstrings`.) They can also be passed directly to the built-in :func:`format` function. Each formattable type may define how the format specification is to be interpreted. Modified: python/branches/release26-maint/Doc/library/sys.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sys.rst (original) +++ python/branches/release26-maint/Doc/library/sys.rst Tue Oct 27 15:37:48 2009 @@ -795,7 +795,7 @@ ``'c_call'`` A C function is about to be called. This may be an extension function or - a builtin. *arg* is the C function object. + a built-in. *arg* is the C function object. ``'c_return'`` A C function has returned. *arg* is ``None``. Modified: python/branches/release26-maint/Doc/library/undoc.rst ============================================================================== --- python/branches/release26-maint/Doc/library/undoc.rst (original) +++ python/branches/release26-maint/Doc/library/undoc.rst Tue Oct 27 15:37:48 2009 @@ -113,7 +113,7 @@ :deprecated: -Importing :mod:`icopen` will replace the builtin :meth:`open` with a version +Importing :mod:`icopen` will replace the built-in :meth:`open` with a version that uses Internet Config to set file type and creator for new files. .. deprecated:: 2.6 Modified: python/branches/release26-maint/Doc/library/weakref.rst ============================================================================== --- python/branches/release26-maint/Doc/library/weakref.rst (original) +++ python/branches/release26-maint/Doc/library/weakref.rst Tue Oct 27 15:37:48 2009 @@ -65,7 +65,7 @@ .. versionchanged:: 2.4 Added support for files, sockets, arrays, and patterns. -Several builtin types such as :class:`list` and :class:`dict` do not directly +Several built-in types such as :class:`list` and :class:`dict` do not directly support weak references but can add support through subclassing:: class Dict(dict): Modified: python/branches/release26-maint/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/xmlrpclib.rst (original) +++ python/branches/release26-maint/Doc/library/xmlrpclib.rst Tue Oct 27 15:37:48 2009 @@ -94,7 +94,7 @@ :exc:`ProtocolError` used to signal an error in the HTTP/HTTPS transport layer. Both :exc:`Fault` and :exc:`ProtocolError` derive from a base class called :exc:`Error`. Note that even though starting with Python 2.2 you can subclass - builtin types, the xmlrpclib module currently does not marshal instances of such + built-in types, the xmlrpclib module currently does not marshal instances of such subclasses. When passing strings, characters special to XML such as ``<``, ``>``, and ``&`` Modified: python/branches/release26-maint/Doc/library/zipimport.rst ============================================================================== --- python/branches/release26-maint/Doc/library/zipimport.rst (original) +++ python/branches/release26-maint/Doc/library/zipimport.rst Tue Oct 27 15:37:48 2009 @@ -12,7 +12,7 @@ This module adds the ability to import Python modules (:file:`\*.py`, :file:`\*.py[co]`) and packages from ZIP-format archives. It is usually not needed to use the :mod:`zipimport` module explicitly; it is automatically used -by the builtin :keyword:`import` mechanism for ``sys.path`` items that are paths +by the built-in :keyword:`import` mechanism for ``sys.path`` items that are paths to ZIP archives. Typically, ``sys.path`` is a list of directory names as strings. This module Modified: python/branches/release26-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release26-maint/Doc/reference/datamodel.rst Tue Oct 27 15:37:48 2009 @@ -1437,7 +1437,7 @@ .. index:: builtin: unicode - Called to implement :func:`unicode` builtin; should return a Unicode object. + Called to implement :func:`unicode` built-in; should return a Unicode object. When this method is not defined, string conversion is attempted, and the result of string conversion is converted to Unicode using the system default encoding. @@ -1516,7 +1516,7 @@ .. note:: This method may still be bypassed when looking up special methods as the - result of implicit invocation via language syntax or builtin functions. + result of implicit invocation via language syntax or built-in functions. See :ref:`new-style-special-lookup`. @@ -1865,12 +1865,12 @@ .. method:: object.__reversed__(self) - Called (if present) by the :func:`reversed` builtin to implement + Called (if present) by the :func:`reversed` built-in to implement reverse iteration. It should return a new iterator object that iterates over all the objects in the container in reverse order. If the :meth:`__reversed__` method is not provided, the :func:`reversed` - builtin will fall back to using the sequence protocol (:meth:`__len__` and + built-in will fall back to using the sequence protocol (:meth:`__len__` and :meth:`__getitem__`). Objects that support the sequence protocol should only provide :meth:`__reversed__` if they can provide an implementation that is more efficient than the one provided by :func:`reversed`. Modified: python/branches/release26-maint/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/executionmodel.rst (original) +++ python/branches/release26-maint/Doc/reference/executionmodel.rst Tue Oct 27 15:37:48 2009 @@ -112,9 +112,9 @@ If the global statement occurs within a block, all uses of the name specified in the statement refer to the binding of that name in the top-level namespace. Names are resolved in the top-level namespace by searching the global namespace, -i.e. the namespace of the module containing the code block, and the builtin +i.e. the namespace of the module containing the code block, and the builtins namespace, the namespace of the module :mod:`__builtin__`. The global namespace -is searched first. If the name is not found there, the builtin namespace is +is searched first. If the name is not found there, the builtins namespace is searched. The global statement must precede all uses of the name. .. index:: pair: restricted; execution Modified: python/branches/release26-maint/Doc/reference/expressions.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/expressions.rst (original) +++ python/branches/release26-maint/Doc/reference/expressions.rst Tue Oct 27 15:37:48 2009 @@ -665,7 +665,7 @@ .. note:: - An implementation may provide builtin functions whose positional parameters do + An implementation may provide built-in functions whose positional parameters do not have names, even if they are 'named' for the purpose of documentation, and which therefore cannot be supplied by keyword. In CPython, this is the case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their @@ -1032,7 +1032,7 @@ values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types *always* compare unequal, and are ordered consistently but arbitrarily. -You can control comparison behavior of objects of non-builtin types by defining +You can control comparison behavior of objects of non-built-in types by defining a ``__cmp__`` method or rich comparison methods like ``__gt__``, described in section :ref:`specialnames`. @@ -1063,7 +1063,7 @@ lists compare equal. [#]_ Outcomes other than equality are resolved consistently, but are not otherwise defined. [#]_ -* Most other objects of builtin types compare unequal unless they are the same +* Most other objects of built-in types compare unequal unless they are the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program. Modified: python/branches/release26-maint/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/simple_stmts.rst (original) +++ python/branches/release26-maint/Doc/reference/simple_stmts.rst Tue Oct 27 15:37:48 2009 @@ -895,7 +895,7 @@ That is not a future statement; it's an ordinary import statement with no special semantics or syntax restrictions. -Code compiled by an :keyword:`exec` statement or calls to the builtin functions +Code compiled by an :keyword:`exec` statement or calls to the built-in functions :func:`compile` and :func:`execfile` that occur in a module :mod:`M` containing a future statement will, by default, use the new syntax or semantics associated with the future statement. This can, starting with Python 2.2 be controlled by Modified: python/branches/release26-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release26-maint/Doc/using/cmdline.rst (original) +++ python/branches/release26-maint/Doc/using/cmdline.rst Tue Oct 27 15:37:48 2009 @@ -80,7 +80,7 @@ .. note:: - This option cannot be used with builtin modules and extension modules + This option cannot be used with built-in modules and extension modules written in C, since they do not have Python module files. However, it can still be used for precompiled modules, even if the original source file is not available. Modified: python/branches/release26-maint/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.2.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.2.rst Tue Oct 27 15:37:48 2009 @@ -1173,7 +1173,7 @@ can uncomment them. Gestalt and Internet Config modules are enabled by default. -* Keyword arguments passed to builtin functions that don't take them now cause a +* Keyword arguments passed to built-in functions that don't take them now cause a :exc:`TypeError` exception to be raised, with the message "*function* takes no keyword arguments". Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.6.rst Tue Oct 27 15:37:48 2009 @@ -2819,7 +2819,7 @@ often used in web applications. For more information about JSON, see http://www.json.org. -:mod:`json` comes with support for decoding and encoding most builtin Python +:mod:`json` comes with support for decoding and encoding most built-in Python types. The following example encodes and decodes a dictionary:: >>> import json From python-checkins at python.org Tue Oct 27 15:41:51 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:41:51 -0000 Subject: [Python-checkins] r75787 - in python/branches/release26-maint: Doc/c-api/buffer.rst Doc/c-api/typeobj.rst Doc/library/gettext.rst Doc/library/logging.rst Doc/library/select.rst Doc/library/socket.rst Doc/library/threading.rst Doc/library/urllib.rst Doc/tutorial/classes.rst Doc/tutorial/inputoutput.rst Doc/tutorial/interactive.rst Doc/tutorial/modules.rst Doc/tutorial/stdlib2.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:41:50 2009 New Revision: 75787 Log: Merged revisions 74210,74239,74252-74253,74256,74258-74261,74332-74333,74404,74411,74445,74465,74467,74488 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74210 | georg.brandl | 2009-07-26 16:44:23 +0200 (So, 26 Jul 2009) | 1 line Move member descriptions inside the classes. ........ r74239 | georg.brandl | 2009-07-28 20:55:32 +0200 (Di, 28 Jul 2009) | 1 line Clarify quote_plus() usage. ........ r74252 | georg.brandl | 2009-07-29 18:06:31 +0200 (Mi, 29 Jul 2009) | 1 line #6593: fix link targets. ........ r74253 | georg.brandl | 2009-07-29 18:09:17 +0200 (Mi, 29 Jul 2009) | 1 line #6591: add reference to ioctl in fcntl module for platforms other than Windows. ........ r74256 | georg.brandl | 2009-07-29 18:32:30 +0200 (Mi, 29 Jul 2009) | 1 line #6336: Add nb_divide. ........ r74258 | georg.brandl | 2009-07-29 18:57:05 +0200 (Mi, 29 Jul 2009) | 1 line Add a link to readline, and mention IPython and bpython. ........ r74259 | georg.brandl | 2009-07-29 19:07:21 +0200 (Mi, 29 Jul 2009) | 1 line Fix some markup and small factual glitches found by M. Markert. ........ r74260 | georg.brandl | 2009-07-29 19:15:20 +0200 (Mi, 29 Jul 2009) | 1 line Fix a few markup glitches. ........ r74261 | georg.brandl | 2009-07-29 19:50:25 +0200 (Mi, 29 Jul 2009) | 1 line Rewrite the section about classes a bit; mostly tidbits, and a larger update to the section about "private" variables to reflect the Pythonic consensus better. ........ r74332 | georg.brandl | 2009-08-06 19:23:21 +0200 (Do, 06 Aug 2009) | 1 line Fix punctuation and one copy-paste error. ........ r74333 | georg.brandl | 2009-08-06 19:43:55 +0200 (Do, 06 Aug 2009) | 1 line #6658: fix two typos. ........ r74404 | georg.brandl | 2009-08-13 14:05:52 +0200 (Do, 13 Aug 2009) | 1 line Use locale.format_string() for more than one specifier. ........ r74411 | georg.brandl | 2009-08-13 14:57:25 +0200 (Do, 13 Aug 2009) | 2 lines Remove potentially confusing sentence in __mangling description. ........ r74445 | vinay.sajip | 2009-08-14 13:33:54 +0200 (Fr, 14 Aug 2009) | 1 line Added versionchanged notices for optional 'delay' parameter to file handler classes. ........ r74465 | vinay.sajip | 2009-08-16 01:23:12 +0200 (So, 16 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-16 01:34:47 +0200 (So, 16 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 15:14:37 +0200 (Mo, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/buffer.rst python/branches/release26-maint/Doc/c-api/typeobj.rst python/branches/release26-maint/Doc/library/gettext.rst python/branches/release26-maint/Doc/library/logging.rst python/branches/release26-maint/Doc/library/select.rst python/branches/release26-maint/Doc/library/socket.rst python/branches/release26-maint/Doc/library/threading.rst python/branches/release26-maint/Doc/library/urllib.rst python/branches/release26-maint/Doc/tutorial/classes.rst python/branches/release26-maint/Doc/tutorial/inputoutput.rst python/branches/release26-maint/Doc/tutorial/interactive.rst python/branches/release26-maint/Doc/tutorial/modules.rst python/branches/release26-maint/Doc/tutorial/stdlib2.rst Modified: python/branches/release26-maint/Doc/c-api/buffer.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/buffer.rst (original) +++ python/branches/release26-maint/Doc/c-api/buffer.rst Tue Oct 27 15:41:50 2009 @@ -147,7 +147,7 @@ kind of buffer the caller is prepared to deal with and therefore what kind of buffer the exporter is allowed to return. The buffer interface allows for complicated memory sharing possibilities, but some caller may - not be able to handle all the complexibity but may want to see if the + not be able to handle all the complexity but may want to see if the exporter will let them take a simpler view to its memory. Some exporters may not be able to share memory in every possible way and @@ -255,7 +255,7 @@ .. cfunction:: void PyBuffer_Release(PyObject *obj, Py_buffer *view) - Release the buffer *view* over *obj*. This shouldd be called when the buffer + Release the buffer *view* over *obj*. This should be called when the buffer is no longer being used as it may free memory from it. Modified: python/branches/release26-maint/Doc/c-api/typeobj.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/typeobj.rst (original) +++ python/branches/release26-maint/Doc/c-api/typeobj.rst Tue Oct 27 15:41:50 2009 @@ -1160,6 +1160,7 @@ binaryfunc nb_add; binaryfunc nb_subtract; binaryfunc nb_multiply; + binaryfunc nb_divide; binaryfunc nb_remainder; binaryfunc nb_divmod; ternaryfunc nb_power; Modified: python/branches/release26-maint/Doc/library/gettext.rst ============================================================================== --- python/branches/release26-maint/Doc/library/gettext.rst (original) +++ python/branches/release26-maint/Doc/library/gettext.rst Tue Oct 27 15:41:50 2009 @@ -208,10 +208,10 @@ This installs the function :func:`_` in Python's builtins namespace, based on *domain*, *localedir*, and *codeset* which are passed to the function :func:`translation`. The *unicode* flag is passed to the resulting translation - object's :meth:`install` method. + object's :meth:`~NullTranslations.install` method. For the *names* parameter, please see the description of the translation - object's :meth:`install` method. + object's :meth:`~NullTranslations.install` method. As seen below, you usually mark the strings in your application that are candidates for translation, by wrapping them in a call to the :func:`_` 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 Tue Oct 27 15:41:50 2009 @@ -1321,6 +1321,31 @@ The :class:`LoggerAdapter` class was not present in previous versions. +.. _multiple-processes: + +Logging to a single file from multiple processes +------------------------------------------------ + +Although logging is thread-safe, and logging to a single file from multiple +threads in a single process *is* supported, logging to a single file from +*multiple processes* is *not* supported, because there is no standard way to +serialize access to a single file across multiple processes in Python. If you +need to log to a single file from multiple processes, the best way of doing +this is to have all the processes log to a :class:`SocketHandler`, and have a +separate process which implements a socket server which reads from the socket +and logs to file. (If you prefer, you can dedicate one thread in one of the +existing processes to perform this function.) The following section documents +this approach in more detail and includes a working socket receiver which can +be used as a starting point for you to adapt in your own applications. + +If you are using a recent version of Python which includes the +:mod:`multiprocessing` module, you can write your own handler which uses the +:class:`Lock` class from this module to serialize access to the file from +your processes. The existing :class:`FileHandler` and subclasses do not make +use of :mod:`multiprocessing` at present, though they may do so in the future. +Note that at present, the :mod:`multiprocessing` module does not provide +working lock functionality on all platforms (see +http://bugs.python.org/issue3770). .. _network-logging: @@ -1613,6 +1638,8 @@ with that encoding. If *delay* is true, then file opening is deferred until the first call to :meth:`emit`. By default, the file grows indefinitely. + .. versionchanged:: 2.6 + *delay* was added. .. method:: close() @@ -1661,6 +1688,9 @@ with that encoding. If *delay* is true, then file opening is deferred until the first call to :meth:`emit`. By default, the file grows indefinitely. + .. versionchanged:: 2.6 + *delay* was added. + .. method:: emit(record) @@ -1698,6 +1728,8 @@ :file:`app.log.1`, :file:`app.log.2`, etc. exist, then they are renamed to :file:`app.log.2`, :file:`app.log.3` etc. respectively. + .. versionchanged:: 2.6 + *delay* was added. .. method:: doRollover() @@ -1757,6 +1789,11 @@ one is deleted. The deletion logic uses the interval to determine which files to delete, so changing the interval may leave old files lying around. + If *delay* is true, then file opening is deferred until the first call to + :meth:`emit`. + + .. versionchanged:: 2.6 + *delay* was added. .. method:: doRollover() Modified: python/branches/release26-maint/Doc/library/select.rst ============================================================================== --- python/branches/release26-maint/Doc/library/select.rst (original) +++ python/branches/release26-maint/Doc/library/select.rst Tue Oct 27 15:41:50 2009 @@ -307,7 +307,7 @@ .. attribute:: kevent.filter - Name of the kernel filter + Name of the kernel filter. +---------------------------+---------------------------------------------+ | Constant | Meaning | @@ -316,7 +316,7 @@ | | there is data available to read | +---------------------------+---------------------------------------------+ | :const:`KQ_FILTER_WRITE` | Takes a descriptor and returns whenever | - | | there is data available to read | + | | there is data available to write | +---------------------------+---------------------------------------------+ | :const:`KQ_FILTER_AIO` | AIO requests | +---------------------------+---------------------------------------------+ @@ -336,7 +336,7 @@ .. attribute:: kevent.flags - Filter action + Filter action. +---------------------------+---------------------------------------------+ | Constant | Meaning | @@ -365,10 +365,9 @@ .. attribute:: kevent.fflags - Filter specific flags - + Filter specific flags. - :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags + :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags: +----------------------------+--------------------------------------------+ | Constant | Meaning | @@ -376,8 +375,7 @@ | :const:`KQ_NOTE_LOWAT` | low water mark of a socket buffer | +----------------------------+--------------------------------------------+ - - :const:`KQ_FILTER_VNODE` filter flags + :const:`KQ_FILTER_VNODE` filter flags: +----------------------------+--------------------------------------------+ | Constant | Meaning | @@ -397,8 +395,7 @@ | :const:`KQ_NOTE_REVOKE` | access to the file was revoked | +----------------------------+--------------------------------------------+ - - :const:`KQ_FILTER_PROC` filter flags + :const:`KQ_FILTER_PROC` filter flags: +----------------------------+--------------------------------------------+ | Constant | Meaning | @@ -421,7 +418,7 @@ | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child | +----------------------------+--------------------------------------------+ - :const:`KQ_FILTER_NETDEV` filter flags [not available on Mac OS X] + :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X): +----------------------------+--------------------------------------------+ | Constant | Meaning | @@ -436,9 +433,9 @@ .. attribute:: kevent.data - Filter specific data + Filter specific data. .. attribute:: kevent.udata - User defined value + User defined value. Modified: python/branches/release26-maint/Doc/library/socket.rst ============================================================================== --- python/branches/release26-maint/Doc/library/socket.rst (original) +++ python/branches/release26-maint/Doc/library/socket.rst Tue Oct 27 15:41:50 2009 @@ -604,6 +604,9 @@ The :meth:`ioctl` method is a limited interface to the WSAIoctl system interface. Please refer to the MSDN documentation for more information. + On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl` + functions may be used; they accept a socket object as their first argument. + .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/threading.rst ============================================================================== --- python/branches/release26-maint/Doc/library/threading.rst (original) +++ python/branches/release26-maint/Doc/library/threading.rst Tue Oct 27 15:41:50 2009 @@ -231,7 +231,8 @@ .. class:: Thread(group=None, target=None, name=None, args=(), kwargs={}) - This constructor should always be called with keyword arguments. Arguments are: + This constructor should always be called with keyword arguments. Arguments + are: *group* should be ``None``; reserved for future extension when a :class:`ThreadGroup` class is implemented. @@ -239,112 +240,104 @@ *target* is the callable object to be invoked by the :meth:`run` method. Defaults to ``None``, meaning nothing is called. - *name* is the thread name. By default, a unique name is constructed of the form - "Thread-*N*" where *N* is a small decimal number. + *name* is the thread name. By default, a unique name is constructed of the + form "Thread-*N*" where *N* is a small decimal number. *args* is the argument tuple for the target invocation. Defaults to ``()``. *kwargs* is a dictionary of keyword arguments for the target invocation. Defaults to ``{}``. - If the subclass overrides the constructor, it must make sure to invoke the base - class constructor (``Thread.__init__()``) before doing anything else to the - thread. + If the subclass overrides the constructor, it must make sure to invoke the + base class constructor (``Thread.__init__()``) before doing anything else to + the thread. + .. method:: start() -.. method:: Thread.start() + Start the thread's activity. - Start the thread's activity. + It must be called at most once per thread object. It arranges for the + object's :meth:`run` method to be invoked in a separate thread of control. - It must be called at most once per thread object. It arranges for the object's - :meth:`run` method to be invoked in a separate thread of control. + This method will raise a :exc:`RuntimeException` if called more than once + on the same thread object. - This method will raise a :exc:`RuntimeException` if called more than once on the - same thread object. + .. method:: run() + Method representing the thread's activity. -.. method:: Thread.run() + You may override this method in a subclass. The standard :meth:`run` + method invokes the callable object passed to the object's constructor as + the *target* argument, if any, with sequential and keyword arguments taken + from the *args* and *kwargs* arguments, respectively. - Method representing the thread's activity. + .. method:: join([timeout]) - You may override this method in a subclass. The standard :meth:`run` method - invokes the callable object passed to the object's constructor as the *target* - argument, if any, with sequential and keyword arguments taken from the *args* - and *kwargs* arguments, respectively. + Wait until the thread terminates. This blocks the calling thread until the + thread whose :meth:`join` method is called terminates -- either normally + or through an unhandled exception -- or until the optional timeout occurs. + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). As :meth:`join` always returns ``None``, you must + call :meth:`isAlive` after :meth:`join` to decide whether a timeout + happened -- if the thread is still alive, the :meth:`join` call timed out. -.. method:: Thread.join([timeout]) + When the *timeout* argument is not present or ``None``, the operation will + block until the thread terminates. - Wait until the thread terminates. This blocks the calling thread until the - thread whose :meth:`join` method is called terminates -- either normally or - through an unhandled exception -- or until the optional timeout occurs. + A thread can be :meth:`join`\ ed many times. - When the *timeout* argument is present and not ``None``, it should be a floating - point number specifying a timeout for the operation in seconds (or fractions - thereof). As :meth:`join` always returns ``None``, you must call :meth:`isAlive` - after :meth:`join` to decide whether a timeout happened -- if the thread is - still alive, the :meth:`join` call timed out. + :meth:`join` raises a :exc:`RuntimeError` if an attempt is made to join + the current thread as that would cause a deadlock. It is also an error to + :meth:`join` a thread before it has been started and attempts to do so + raises the same exception. - When the *timeout* argument is not present or ``None``, the operation will block - until the thread terminates. + .. method:: getName() + setName() - A thread can be :meth:`join`\ ed many times. + Old API for :attr:`~Thread.name`. - :meth:`join` raises a :exc:`RuntimeError` if an attempt is made to join - the current thread as that would cause a deadlock. It is also an error to - :meth:`join` a thread before it has been started and attempts to do so - raises the same exception. + .. attribute:: name + A string used for identification purposes only. It has no semantics. + Multiple threads may be given the same name. The initial name is set by + the constructor. -.. method:: Thread.getName() - Thread.setName() + .. attribute:: ident - Old API for :attr:`~Thread.name`. + The 'thread identifier' of this thread or ``None`` if the thread has not + been started. This is a nonzero integer. See the + :func:`thread.get_ident()` function. Thread identifiers may be recycled + when a thread exits and another thread is created. The identifier is + available even after the thread has exited. + .. versionadded:: 2.6 -.. attribute:: Thread.name + .. method:: is_alive() + isAlive() - A string used for identification purposes only. It has no semantics. - Multiple threads may be given the same name. The initial name is set by the - constructor. + Return whether the thread is alive. + Roughly, a thread is alive from the moment the :meth:`start` method + returns until its :meth:`run` method terminates. The module function + :func:`enumerate` returns a list of all alive threads. -.. attribute:: Thread.ident + .. method:: isDaemon() + setDaemon() - The 'thread identifier' of this thread or ``None`` if the thread has not been - started. This is a nonzero integer. See the :func:`thread.get_ident()` - function. Thread identifiers may be recycled when a thread exits and another - thread is created. The identifier is available even after the thread has - exited. + Old API for :attr:`~Thread.daemon`. - .. versionadded:: 2.6 + .. attribute:: daemon + A boolean value indicating whether this thread is a daemon thread (True) + or not (False). This must be set before :meth:`start` is called, + otherwise :exc:`RuntimeError` is raised. Its initial value is inherited + from the creating thread; the main thread is not a daemon thread and + therefore all threads created in the main thread default to :attr:`daemon` + = ``False``. -.. method:: Thread.is_alive() - Thread.isAlive() - - Return whether the thread is alive. - - Roughly, a thread is alive from the moment the :meth:`start` method returns - until its :meth:`run` method terminates. The module function :func:`enumerate` - returns a list of all alive threads. - - -.. method:: Thread.isDaemon() - Thread.setDaemon() - - Old API for :attr:`~Thread.daemon`. - - -.. attribute:: Thread.daemon - - A boolean value indicating whether this thread is a daemon thread (True) or - not (False). This must be set before :meth:`start` is called, otherwise - :exc:`RuntimeError` is raised. Its initial value is inherited from the - creating thread; the main thread is not a daemon thread and therefore all - threads created in the main thread default to :attr:`daemon` = ``False``. - - The entire Python program exits when no alive non-daemon threads are left. + The entire Python program exits when no alive non-daemon threads are left. .. _lock-objects: @@ -515,70 +508,66 @@ .. class:: Condition([lock]) - If the *lock* argument is given and not ``None``, it must be a :class:`Lock` or - :class:`RLock` object, and it is used as the underlying lock. Otherwise, a new - :class:`RLock` object is created and used as the underlying lock. - - -.. method:: Condition.acquire(*args) - - Acquire the underlying lock. This method calls the corresponding method on the - underlying lock; the return value is whatever that method returns. + If the *lock* argument is given and not ``None``, it must be a :class:`Lock` + or :class:`RLock` object, and it is used as the underlying lock. Otherwise, + a new :class:`RLock` object is created and used as the underlying lock. + .. method:: acquire(*args) -.. method:: Condition.release() + Acquire the underlying lock. This method calls the corresponding method on + the underlying lock; the return value is whatever that method returns. - Release the underlying lock. This method calls the corresponding method on the - underlying lock; there is no return value. + .. method:: release() + Release the underlying lock. This method calls the corresponding method on + the underlying lock; there is no return value. -.. method:: Condition.wait([timeout]) + .. method:: wait([timeout]) - Wait until notified or until a timeout occurs. If the calling thread has not - acquired the lock when this method is called, a :exc:`RuntimeError` is raised. + Wait until notified or until a timeout occurs. If the calling thread has not + acquired the lock when this method is called, a :exc:`RuntimeError` is raised. - This method releases the underlying lock, and then blocks until it is awakened - by a :meth:`notify` or :meth:`notifyAll` call for the same condition variable in - another thread, or until the optional timeout occurs. Once awakened or timed - out, it re-acquires the lock and returns. + This method releases the underlying lock, and then blocks until it is + awakened by a :meth:`notify` or :meth:`notifyAll` call for the same + condition variable in another thread, or until the optional timeout + occurs. Once awakened or timed out, it re-acquires the lock and returns. - When the *timeout* argument is present and not ``None``, it should be a floating - point number specifying a timeout for the operation in seconds (or fractions - thereof). + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). - When the underlying lock is an :class:`RLock`, it is not released using its - :meth:`release` method, since this may not actually unlock the lock when it was - acquired multiple times recursively. Instead, an internal interface of the - :class:`RLock` class is used, which really unlocks it even when it has been - recursively acquired several times. Another internal interface is then used to - restore the recursion level when the lock is reacquired. + When the underlying lock is an :class:`RLock`, it is not released using + its :meth:`release` method, since this may not actually unlock the lock + when it was acquired multiple times recursively. Instead, an internal + interface of the :class:`RLock` class is used, which really unlocks it + even when it has been recursively acquired several times. Another internal + interface is then used to restore the recursion level when the lock is + reacquired. + .. method:: notify() -.. method:: Condition.notify() + Wake up a thread waiting on this condition, if any. If the calling thread + has not acquired the lock when this method is called, a + :exc:`RuntimeError` is raised. - Wake up a thread waiting on this condition, if any. If the calling thread - has not acquired the lock when this method is called, a :exc:`RuntimeError` - is raised. + This method wakes up one of the threads waiting for the condition + variable, if any are waiting; it is a no-op if no threads are waiting. - This method wakes up one of the threads waiting for the condition variable, - if any are waiting; it is a no-op if no threads are waiting. + The current implementation wakes up exactly one thread, if any are + waiting. However, it's not safe to rely on this behavior. A future, + optimized implementation may occasionally wake up more than one thread. - The current implementation wakes up exactly one thread, if any are waiting. - However, it's not safe to rely on this behavior. A future, optimized - implementation may occasionally wake up more than one thread. + Note: the awakened thread does not actually return from its :meth:`wait` + call until it can reacquire the lock. Since :meth:`notify` does not + release the lock, its caller should. - Note: the awakened thread does not actually return from its :meth:`wait` call - until it can reacquire the lock. Since :meth:`notify` does not release the - lock, its caller should. + .. method:: notify_all() + notifyAll() - -.. method:: Condition.notify_all() - Condition.notifyAll() - - Wake up all threads waiting on this condition. This method acts like - :meth:`notify`, but wakes up all waiting threads instead of one. If the calling - thread has not acquired the lock when this method is called, a - :exc:`RuntimeError` is raised. + Wake up all threads waiting on this condition. This method acts like + :meth:`notify`, but wakes up all waiting threads instead of one. If the + calling thread has not acquired the lock when this method is called, a + :exc:`RuntimeError` is raised. .. _semaphore-objects: @@ -602,33 +591,31 @@ defaults to ``1``. If the *value* given is less than 0, :exc:`ValueError` is raised. + .. method:: acquire([blocking]) -.. method:: Semaphore.acquire([blocking]) - - Acquire a semaphore. - - When invoked without arguments: if the internal counter is larger than zero on - entry, decrement it by one and return immediately. If it is zero on entry, - block, waiting until some other thread has called :meth:`release` to make it - larger than zero. This is done with proper interlocking so that if multiple - :meth:`acquire` calls are blocked, :meth:`release` will wake exactly one of them - up. The implementation may pick one at random, so the order in which blocked - threads are awakened should not be relied on. There is no return value in this - case. - - When invoked with *blocking* set to true, do the same thing as when called - without arguments, and return true. - - When invoked with *blocking* set to false, do not block. If a call without an - argument would block, return false immediately; otherwise, do the same thing as - when called without arguments, and return true. + Acquire a semaphore. - -.. method:: Semaphore.release() - - Release a semaphore, incrementing the internal counter by one. When it was zero - on entry and another thread is waiting for it to become larger than zero again, - wake up that thread. + When invoked without arguments: if the internal counter is larger than + zero on entry, decrement it by one and return immediately. If it is zero + on entry, block, waiting until some other thread has called + :meth:`release` to make it larger than zero. This is done with proper + interlocking so that if multiple :meth:`acquire` calls are blocked, + :meth:`release` will wake exactly one of them up. The implementation may + pick one at random, so the order in which blocked threads are awakened + should not be relied on. There is no return value in this case. + + When invoked with *blocking* set to true, do the same thing as when called + without arguments, and return true. + + When invoked with *blocking* set to false, do not block. If a call + without an argument would block, return false immediately; otherwise, do + the same thing as when called without arguments, and return true. + + .. method:: release() + + Release a semaphore, incrementing the internal counter by one. When it + was zero on entry and another thread is waiting for it to become larger + than zero again, wake up that thread. .. _semaphore-examples: @@ -675,36 +662,39 @@ The internal flag is initially false. + .. method:: is_set() + isSet() -.. method:: Event.is_set() - Event.isSet() - - Return true if and only if the internal flag is true. + Return true if and only if the internal flag is true. + .. method:: set() -.. method:: Event.set() + Set the internal flag to true. All threads waiting for it to become true + are awakened. Threads that call :meth:`wait` once the flag is true will + not block at all. - Set the internal flag to true. All threads waiting for it to become true are - awakened. Threads that call :meth:`wait` once the flag is true will not block at - all. + .. method:: clear() + Reset the internal flag to false. Subsequently, threads calling + :meth:`wait` will block until :meth:`.set` is called to set the internal + flag to true again. -.. method:: Event.clear() + .. method:: wait([timeout]) - Reset the internal flag to false. Subsequently, threads calling :meth:`wait` - will block until :meth:`.set` is called to set the internal flag to true - again. + Block until the internal flag is true. If the internal flag is true on + entry, return immediately. Otherwise, block until another thread calls + :meth:`.set` to set the flag to true, or until the optional timeout + occurs. + When the timeout argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). -.. method:: Event.wait([timeout]) + This method returns the internal flag on exit, so it will always return + ``True`` except if a timeout is given and the operation times out. - Block until the internal flag is true. If the internal flag is true on - entry, return immediately. Otherwise, block until another thread calls - :meth:`.set` to set the flag to true, or until the optional timeout occurs. - - When the timeout argument is present and not ``None``, it should be a floating - point number specifying a timeout for the operation in seconds (or fractions - thereof). + .. versionchanged:: 2.7 + Previously, the method always returned ``None``. .. _timer-objects: @@ -735,11 +725,10 @@ Create a timer that will run *function* with arguments *args* and keyword arguments *kwargs*, after *interval* seconds have passed. + .. method:: cancel() -.. method:: Timer.cancel() - - Stop the timer, and cancel the execution of the timer's action. This will only - work if the timer is still in its waiting stage. + Stop the timer, and cancel the execution of the timer's action. This will + only work if the timer is still in its waiting stage. .. _with-locks: Modified: python/branches/release26-maint/Doc/library/urllib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/urllib.rst (original) +++ python/branches/release26-maint/Doc/library/urllib.rst Tue Oct 27 15:41:50 2009 @@ -215,8 +215,9 @@ .. function:: quote_plus(string[, safe]) Like :func:`quote`, but also replaces spaces by plus signs, as required for - quoting HTML form values. Plus signs in the original string are escaped unless - they are included in *safe*. It also does not have *safe* default to ``'/'``. + quoting HTML form values when building up a query string to go into a URL. + Plus signs in the original string are escaped unless they are included in + *safe*. It also does not have *safe* default to ``'/'``. .. function:: unquote(string) Modified: python/branches/release26-maint/Doc/tutorial/classes.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/classes.rst (original) +++ python/branches/release26-maint/Doc/tutorial/classes.rst Tue Oct 27 15:41:50 2009 @@ -12,43 +12,40 @@ are retained with full power, however: the class inheritance mechanism allows multiple base classes, a derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same -name. Objects can contain an arbitrary amount of private data. +name. Objects can contain an arbitrary amount of data. In C++ terminology, all class members (including the data members) are *public*, -and all member functions are *virtual*. There are no special constructors or -destructors. As in Modula-3, there are no shorthands for referencing the -object's members from its methods: the method function is declared with an -explicit first argument representing the object, which is provided implicitly by -the call. As in Smalltalk, classes themselves are objects, albeit in the wider -sense of the word: in Python, all data types are objects. This provides -semantics for importing and renaming. Unlike C++ and Modula-3, built-in types -can be used as base classes for extension by the user. Also, like in C++ but -unlike in Modula-3, most built-in operators with special syntax (arithmetic +and all member functions are *virtual*. As in Modula-3, there are no shorthands +for referencing the object's members from its methods: the method function is +declared with an explicit first argument representing the object, which is +provided implicitly by the call. As in Smalltalk, classes themselves are +objects. This provides semantics for importing and renaming. Unlike C++ and +Modula-3, built-in types can be used as base classes for extension by the user. +Also, like in C++, most built-in operators with special syntax (arithmetic operators, subscripting etc.) can be redefined for class instances. +(Lacking universally accepted terminology to talk about classes, I will make +occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since +its object-oriented semantics are closer to those of Python than C++, but I +expect that few readers have heard of it.) -.. _tut-terminology: -A Word About Terminology -======================== +.. _tut-object: -Lacking universally accepted terminology to talk about classes, I will make -occasional use of Smalltalk and C++ terms. (I would use Modula-3 terms, since -its object-oriented semantics are closer to those of Python than C++, but I -expect that few readers have heard of it.) +A Word About Names and Objects +============================== Objects have individuality, and multiple names (in multiple scopes) can be bound to the same object. This is known as aliasing in other languages. This is usually not appreciated on a first glance at Python, and can be safely ignored when dealing with immutable basic types (numbers, strings, tuples). However, -aliasing has an (intended!) effect on the semantics of Python code involving -mutable objects such as lists, dictionaries, and most types representing -entities outside the program (files, windows, etc.). This is usually used to -the benefit of the program, since aliases behave like pointers in some respects. -For example, passing an object is cheap since only a pointer is passed by the -implementation; and if a function modifies an object passed as an argument, the -caller will see the change --- this eliminates the need for two different -argument passing mechanisms as in Pascal. +aliasing has a possibly surprising effect on the semantics of Python code +involving mutable objects such as lists, dictionaries, and most other types. +This is usually used to the benefit of the program, since aliases behave like +pointers in some respects. For example, passing an object is cheap since only a +pointer is passed by the implementation; and if a function modifies an object +passed as an argument, the caller will see the change --- this eliminates the +need for two different argument passing mechanisms as in Pascal. .. _tut-scopes: @@ -72,7 +69,7 @@ a function invocation. In a sense the set of attributes of an object also form a namespace. The important thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two -different modules may both define a function "maximize" without confusion --- +different modules may both define a function ``maximize`` without confusion --- users of the modules must prefix it with the module name. By the way, I use the word *attribute* for any name following a dot --- for @@ -111,11 +108,13 @@ Although scopes are determined statically, they are used dynamically. At any time during execution, there are at least three nested scopes whose namespaces -are directly accessible: the innermost scope, which is searched first, contains -the local names; the namespaces of any enclosing functions, which are searched -starting with the nearest enclosing scope; the middle scope, searched next, -contains the current module's global names; and the outermost scope (searched -last) is the namespace containing built-in names. +are directly accessible: + +* the innermost scope, which is searched first, contains the local names +* the scopes of any enclosing functions, which are searched starting with the + nearest enclosing scope, contains non-local, but also non-global names +* the next-to-last scope contains the current module's global names +* the outermost scope (searched last) is the namespace containing built-in names If a name is declared global, then all references and assignments go directly to the middle scope containing the module's global names. Otherwise, all variables @@ -136,15 +135,15 @@ time, so don't rely on dynamic name resolution! (In fact, local variables are already determined statically.) -A special quirk of Python is that -- if no :keyword:`global` -statement is in effect -- assignments to names always go -into the innermost scope. Assignments do not copy data --- they just bind names -to objects. The same is true for deletions: the statement ``del x`` removes the -binding of ``x`` from the namespace referenced by the local scope. In fact, all -operations that introduce new names use the local scope: in particular, import -statements and function definitions bind the module or function name in the -local scope. (The :keyword:`global` statement can be used to indicate that -particular variables live in the global scope.) +A special quirk of Python is that -- if no :keyword:`global` statement is in +effect -- assignments to names always go into the innermost scope. Assignments +do not copy data --- they just bind names to objects. The same is true for +deletions: the statement ``del x`` removes the binding of ``x`` from the +namespace referenced by the local scope. In fact, all operations that introduce +new names use the local scope: in particular, :keyword:`import` statements and +function definitions bind the module or function name in the local scope. (The +:keyword:`global` statement can be used to indicate that particular variables +live in the global scope.) .. _tut-firstclasses: @@ -372,9 +371,9 @@ Often, the first argument of a method is called ``self``. This is nothing more than a convention: the name ``self`` has absolutely no special meaning to -Python. (Note, however, that by not following the convention your code may be +Python. Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a -*class browser* program might be written that relies upon such a convention.) +*class browser* program might be written that relies upon such a convention. Any function object that is a class attribute defines a method for instances of that class. It is not necessary that the function definition is textually @@ -410,13 +409,13 @@ Methods may reference global names in the same way as ordinary functions. The global scope associated with a method is the module containing the class -definition. (The class itself is never used as a global scope!) While one +definition. (The class itself is never used as a global scope.) While one rarely encounters a good reason for using global data in a method, there are many legitimate uses of the global scope: for one thing, functions and modules imported into the global scope can be used by methods, as well as functions and classes defined in it. Usually, the class containing the method is itself defined in this global scope, and in the next section we'll find some good -reasons why a method would want to reference its own class! +reasons why a method would want to reference its own class. Each value is an object, and therefore has a *class* (also called its *type*). It is stored as ``object.__class__``. @@ -467,12 +466,12 @@ simply replace the base class method of the same name. There is a simple way to call the base class method directly: just call ``BaseClassName.methodname(self, arguments)``. This is occasionally useful to clients as well. (Note that this -only works if the base class is defined or imported directly in the global +only works if the base class is accessible as ``BaseClassName`` in the global scope.) Python has two built-in functions that work with inheritance: -* Use :func:`isinstance` to check an object's type: ``isinstance(obj, int)`` +* Use :func:`isinstance` to check an instance's type: ``isinstance(obj, int)`` will be ``True`` only if ``obj.__class__`` is :class:`int` or some class derived from :class:`int`. @@ -537,26 +536,25 @@ Private Variables ================= -There is limited support for class-private identifiers. Any identifier of the -form ``__spam`` (at least two leading underscores, at most one trailing -underscore) is textually replaced with ``_classname__spam``, where ``classname`` -is the current class name with leading underscore(s) stripped. This mangling is -done without regard to the syntactic position of the identifier, so it can be -used to define class-private instance and class variables, methods, variables -stored in globals, and even variables stored in instances. private to this class -on instances of *other* classes. Truncation may occur when the mangled name -would be longer than 255 characters. Outside classes, or when the class name -consists of only underscores, no mangling occurs. - -Name mangling is intended to give classes an easy way to define "private" -instance variables and methods, without having to worry about instance variables -defined by derived classes, or mucking with instance variables by code outside -the class. Note that the mangling rules are designed mostly to avoid accidents; -it still is possible for a determined soul to access or modify a variable that -is considered private. This can even be useful in special circumstances, such -as in the debugger, and that's one reason why this loophole is not closed. -(Buglet: derivation of a class with the same name as the base class makes use of -private variables of the base class possible.) +"Private" instance variables that cannot be accessed except from inside an +object, don't exist in Python. However, there is a convention that is followed +by most Python code: a name prefixed with an underscore (e.g. ``_spam``) should +be treated as a non-public part of the API (whether it is a function, a method +or a data member). It should be considered an implementation detail and subject +to change without notice. + +Since there is a valid use-case for class-private members (namely to avoid name +clashes of names with names defined by subclasses), there is limited support for +such a mechanism, called :dfn:`name mangling`. Any identifier of the form +``__spam`` (at least two leading underscores, at most one trailing underscore) +is textually replaced with ``_classname__spam``, where ``classname`` is the +current class name with leading underscore(s) stripped. This mangling is done +without regard to the syntactic position of the identifier, as long as it +occurs within the definition of a class. + +Note that the mangling rules are designed mostly to avoid accidents; it still is +possible to access or modify a variable that is considered private. This can +even be useful in special circumstances, such as in the debugger. Notice that code passed to ``exec``, ``eval()`` or ``execfile()`` does not consider the classname of the invoking class to be the current class; this is @@ -609,7 +607,7 @@ User-defined exceptions are identified by classes as well. Using this mechanism it is possible to create extensible hierarchies of exceptions. -There are two new valid (semantic) forms for the raise statement:: +There are two new valid (semantic) forms for the :keyword:`raise` statement:: raise Class, instance @@ -620,10 +618,10 @@ raise instance.__class__, instance -A class in an except clause is compatible with an exception if it is the same -class or a base class thereof (but not the other way around --- an except clause -listing a derived class is not compatible with a base class). For example, the -following code will print B, C, D in that order:: +A class in an :keyword:`except` clause is compatible with an exception if it is +the same class or a base class thereof (but not the other way around --- an +except clause listing a derived class is not compatible with a base class). For +example, the following code will print B, C, D in that order:: class B: pass Modified: python/branches/release26-maint/Doc/tutorial/inputoutput.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/inputoutput.rst (original) +++ python/branches/release26-maint/Doc/tutorial/inputoutput.rst Tue Oct 27 15:41:50 2009 @@ -127,16 +127,17 @@ We are the knights who say "Ni!" The brackets and characters within them (called format fields) are replaced with -the objects passed into the format method. The number in the brackets refers to -the position of the object passed into the format method. :: +the objects passed into the :meth:`~str.format` method. The number in the +brackets refers to the position of the object passed into the +:meth:`~str.format` method. :: >>> print '{0} and {1}'.format('spam', 'eggs') spam and eggs >>> print '{1} and {0}'.format('spam', 'eggs') eggs and spam -If keyword arguments are used in the format method, their values are referred to -by using the name of the argument. :: +If keyword arguments are used in the :meth:`~str.format` method, their values +are referred to by using the name of the argument. :: >>> print 'This {food} is {adjective}.'.format( ... food='spam', adjective='absolutely horrible') @@ -157,7 +158,7 @@ The value of PI is approximately 3.142. Passing an integer after the ``':'`` will cause that field to be a minimum -number of characters wide. This is useful for making tables pretty.:: +number of characters wide. This is useful for making tables pretty. :: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} >>> for name, phone in table.items(): @@ -178,7 +179,7 @@ Jack: 4098; Sjoerd: 4127; Dcab: 8637678 This could also be done by passing the table as keyword arguments with the '**' -notation.:: +notation. :: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} >>> print 'Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table) @@ -356,9 +357,9 @@ >>> f.closed True -File objects have some additional methods, such as :meth:`isatty` and -:meth:`truncate` which are less frequently used; consult the Library Reference -for a complete guide to file objects. +File objects have some additional methods, such as :meth:`~file.isatty` and +:meth:`~file.truncate` which are less frequently used; consult the Library +Reference for a complete guide to file objects. .. _tut-pickle: Modified: python/branches/release26-maint/Doc/tutorial/interactive.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/interactive.rst (original) +++ python/branches/release26-maint/Doc/tutorial/interactive.rst Tue Oct 27 15:41:50 2009 @@ -6,8 +6,8 @@ Some versions of the Python interpreter support editing of the current input line and history substitution, similar to facilities found in the Korn shell and -the GNU Bash shell. This is implemented using the *GNU Readline* library, which -supports Emacs-style and vi-style editing. This library has its own +the GNU Bash shell. This is implemented using the `GNU Readline`_ library, +which supports Emacs-style and vi-style editing. This library has its own documentation which I won't duplicate here; however, the basics are easily explained. The interactive editing and history described here are optionally available in the Unix and Cygwin versions of the interpreter. @@ -148,8 +148,8 @@ .. _tut-commentary: -Commentary -========== +Alternatives to the Interactive Interpreter +=========================================== This facility is an enormous step forward compared to earlier versions of the interpreter; however, some wishes are left: It would be nice if the proper @@ -158,6 +158,12 @@ symbol table. A command to check (or even suggest) matching parentheses, quotes, etc., would also be useful. +One alternative enhanced interactive interpreter that has been around for quite +some time is `IPython`_, which features tab completion, object exploration and +advanced history management. It can also be thoroughly customized and embedded +into other applications. Another similar enhanced interactive environment is +`bpython`_. + .. rubric:: Footnotes @@ -165,3 +171,7 @@ :envvar:`PYTHONSTARTUP` environment variable when you start an interactive interpreter. + +.. _GNU Readline: http://tiswww.case.edu/php/chet/readline/rltop.html +.. _IPython: http://ipython.scipy.org/ +.. _bpython: http://www.bpython-interpreter.org/ Modified: python/branches/release26-maint/Doc/tutorial/modules.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/modules.rst (original) +++ python/branches/release26-maint/Doc/tutorial/modules.rst Tue Oct 27 15:41:50 2009 @@ -446,14 +446,14 @@ submodules are present in the package, and imports them all. Unfortunately, this operation does not work very well on Windows platforms, where the filesystem does not always have accurate information about the case of a -filename! On these platforms, there is no guaranteed way to know whether a file +filename. On these platforms, there is no guaranteed way to know whether a file :file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or :mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all file names with a capitalized first letter.) The DOS 8+3 filename restriction adds another interesting problem for long module names. The only solution is for the package author to provide an explicit index of the -package. The import statement uses the following convention: if a package's +package. The :keyword:`import` statement uses the following convention: if a package's :file:`__init__.py` code defines a list named ``__all__``, it is taken to be the list of module names that should be imported when ``from package import *`` is encountered. It is up to the package author to keep this list up-to-date when a @@ -474,16 +474,16 @@ and then imports whatever names are defined in the package. This includes any names defined (and submodules explicitly loaded) by :file:`__init__.py`. It also includes any submodules of the package that were explicitly loaded by -previous import statements. Consider this code:: +previous :keyword:`import` statements. Consider this code:: import sound.effects.echo import sound.effects.surround from sound.effects import * -In this example, the echo and surround modules are imported in the current -namespace because they are defined in the :mod:`sound.effects` package when the -``from...import`` statement is executed. (This also works when ``__all__`` is -defined.) +In this example, the :mod:`echo` and :mod:`surround` modules are imported in the +current namespace because they are defined in the :mod:`sound.effects` package +when the ``from...import`` statement is executed. (This also works when +``__all__`` is defined.) Note that in general the practice of importing ``*`` from a module or package is frowned upon, since it often causes poorly readable code. However, it is okay to @@ -546,5 +546,6 @@ .. rubric:: Footnotes .. [#] In fact function definitions are also 'statements' that are 'executed'; the - execution enters the function name in the module's global symbol table. + execution of a module-level function enters the function name in the module's + global symbol table. Modified: python/branches/release26-maint/Doc/tutorial/stdlib2.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/stdlib2.rst (original) +++ python/branches/release26-maint/Doc/tutorial/stdlib2.rst Tue Oct 27 15:41:50 2009 @@ -61,8 +61,8 @@ >>> x = 1234567.8 >>> locale.format("%d", x, grouping=True) '1,234,567' - >>> locale.format("%s%.*f", (conv['currency_symbol'], - ... conv['frac_digits'], x), grouping=True) + >>> locale.format_string("%s%.*f", (conv['currency_symbol'], + ... conv['frac_digits'], x), grouping=True) '$1,234,567.80' @@ -347,12 +347,15 @@ The :mod:`decimal` module offers a :class:`Decimal` datatype for decimal floating point arithmetic. Compared to the built-in :class:`float` -implementation of binary floating point, the new class is especially helpful for -financial applications and other uses which require exact decimal -representation, control over precision, control over rounding to meet legal or -regulatory requirements, tracking of significant decimal places, or for -applications where the user expects the results to match calculations done by -hand. +implementation of binary floating point, the class is especially helpful for + +* financial applications and other uses which require exact decimal + representation, +* control over precision, +* control over rounding to meet legal or regulatory requirements, +* tracking of significant decimal places, or +* applications where the user expects the results to match calculations done by + hand. For example, calculating a 5% tax on a 70 cent phone charge gives different results in decimal floating point and binary floating point. The difference From python-checkins at python.org Tue Oct 27 15:50:21 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:50:21 -0000 Subject: [Python-checkins] r75788 - in python/branches/release26-maint: Doc/c-api/buffer.rst Doc/conf.py Doc/distutils/builtdist.rst Doc/howto/unicode.rst Doc/library/__future__.rst Doc/library/cgi.rst Doc/library/codecs.rst Doc/library/constants.rst Doc/library/copy.rst Doc/library/ctypes.rst Doc/library/ftplib.rst Doc/library/hashlib.rst Doc/library/inspect.rst Doc/library/logging.rst Doc/library/marshal.rst Doc/library/math.rst Doc/library/os.rst Doc/library/readline.rst Doc/library/signal.rst Doc/library/socketserver.rst Doc/library/ssl.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/sys.rst Doc/library/thread.rst Doc/library/urllib.rst Doc/library/warnings.rst Doc/reference/datamodel.rst Doc/reference/simple_stmts.rst Doc/tutorial/classes.rst Doc/tutorial/errors.rst Doc/tutorial/inputoutput.rst Doc/tutorial/introduction.rst Doc/tutorial/modules.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:50:20 2009 New Revision: 75788 Log: Merged revisions 74492,74531,74545-74550,74553-74555,74588,74603,74608,74614,74616-74618,74631-74633,74652-74653,74666,74671,74737,74739,74779,74781-74782,74784,74791,74793,74818-74820,74822,74832 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74492 | r.david.murray | 2009-08-17 21:26:49 +0200 (Mo, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74531 | vinay.sajip | 2009-08-21 00:04:32 +0200 (Fr, 21 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74545 | georg.brandl | 2009-08-24 19:14:29 +0200 (Mo, 24 Aug 2009) | 1 line #6772: mention utf-8 as utf8 alias. ........ r74546 | georg.brandl | 2009-08-24 19:20:40 +0200 (Mo, 24 Aug 2009) | 1 line #6725: spell "namespace" consistently. ........ r74547 | georg.brandl | 2009-08-24 19:22:05 +0200 (Mo, 24 Aug 2009) | 1 line #6718: fix example. ........ r74548 | georg.brandl | 2009-08-24 19:24:27 +0200 (Mo, 24 Aug 2009) | 1 line #6677: mention "deleting" as an alias for removing files. ........ r74549 | benjamin.peterson | 2009-08-24 19:42:36 +0200 (Mo, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74550 | georg.brandl | 2009-08-24 19:48:40 +0200 (Mo, 24 Aug 2009) | 1 line #6677: note that rmdir only removes empty directories. ........ r74553 | r.david.murray | 2009-08-27 03:04:59 +0200 (Do, 27 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74554 | georg.brandl | 2009-08-27 20:59:02 +0200 (Do, 27 Aug 2009) | 1 line Typo fix. ........ r74555 | georg.brandl | 2009-08-27 21:02:43 +0200 (Do, 27 Aug 2009) | 1 line #6787: reference fix. ........ r74588 | georg.brandl | 2009-08-30 10:35:01 +0200 (So, 30 Aug 2009) | 1 line #6803: fix old name. ........ r74603 | georg.brandl | 2009-08-31 08:38:29 +0200 (Mo, 31 Aug 2009) | 1 line other -> others where multiple arguments are accepted. ........ r74608 | senthil.kumaran | 2009-08-31 18:40:27 +0200 (Mo, 31 Aug 2009) | 3 lines Doc fix for the issue2637. ........ r74614 | georg.brandl | 2009-09-01 09:40:54 +0200 (Di, 01 Sep 2009) | 1 line #6813: better documentation for numberless string formats. ........ r74616 | georg.brandl | 2009-09-01 09:46:26 +0200 (Di, 01 Sep 2009) | 1 line #6808: clarification. ........ r74617 | georg.brandl | 2009-09-01 09:53:37 +0200 (Di, 01 Sep 2009) | 1 line #6765: hint that log(x, base) is not very sophisticated. ........ r74618 | georg.brandl | 2009-09-01 10:00:47 +0200 (Di, 01 Sep 2009) | 1 line #6810: add a link to the section about frame objects instead of just a description where to find it. ........ r74631 | georg.brandl | 2009-09-02 22:37:16 +0200 (Mi, 02 Sep 2009) | 1 line #6821: fix signature of PyBuffer_Release(). ........ r74632 | georg.brandl | 2009-09-03 09:27:26 +0200 (Do, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74633 | georg.brandl | 2009-09-03 14:31:39 +0200 (Do, 03 Sep 2009) | 1 line #6757: complete the list of types that marshal can serialize. ........ r74652 | georg.brandl | 2009-09-04 13:25:37 +0200 (Fr, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74653 | georg.brandl | 2009-09-04 13:32:18 +0200 (Fr, 04 Sep 2009) | 1 line #6777: dont discourage usage of Exception.args or promote usage of Exception.message. ........ r74666 | georg.brandl | 2009-09-05 11:04:09 +0200 (Sa, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 18:47:17 +0200 (Sa, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74737 | georg.brandl | 2009-09-09 18:49:13 +0200 (Mi, 09 Sep 2009) | 1 line Properly document copy and deepcopy as functions. ........ r74739 | georg.brandl | 2009-09-11 09:55:20 +0200 (Fr, 11 Sep 2009) | 1 line Move function back to its section. ........ r74779 | michael.foord | 2009-09-13 18:13:36 +0200 (So, 13 Sep 2009) | 1 line Change to tutorial wording for reading text / binary files on Windows. Issue #6301. ........ r74781 | michael.foord | 2009-09-13 18:46:19 +0200 (So, 13 Sep 2009) | 1 line Note that sys._getframe is not guaranteed to exist in all implementations of Python, and a corresponding note in inspect.currentframe. Issue 6712. ........ r74782 | michael.foord | 2009-09-13 19:07:46 +0200 (So, 13 Sep 2009) | 1 line Tutorial tweaks. Issue 6849. ........ r74784 | georg.brandl | 2009-09-13 20:15:07 +0200 (So, 13 Sep 2009) | 1 line Typo fix. ........ r74791 | georg.brandl | 2009-09-14 16:08:54 +0200 (Mo, 14 Sep 2009) | 1 line #6574: list the future features in a table. ........ r74793 | georg.brandl | 2009-09-14 16:50:47 +0200 (Mo, 14 Sep 2009) | 1 line #6908: fix association of hashlib hash attributes. ........ r74818 | georg.brandl | 2009-09-16 11:23:04 +0200 (Mi, 16 Sep 2009) | 1 line #6880: add reference to classes section in exceptions section, which comes earlier. ........ r74819 | georg.brandl | 2009-09-16 11:24:57 +0200 (Mi, 16 Sep 2009) | 1 line #6876: fix base class constructor invocation in example. ........ r74820 | georg.brandl | 2009-09-16 11:30:48 +0200 (Mi, 16 Sep 2009) | 1 line #6891: comment out dead link to Unicode article. ........ r74822 | georg.brandl | 2009-09-16 12:12:06 +0200 (Mi, 16 Sep 2009) | 1 line #5621: refactor description of how class/instance attributes interact on a.x=a.x+1 or augassign. ........ r74832 | georg.brandl | 2009-09-16 17:57:46 +0200 (Mi, 16 Sep 2009) | 1 line Rewrap long lines. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/buffer.rst python/branches/release26-maint/Doc/conf.py python/branches/release26-maint/Doc/distutils/builtdist.rst python/branches/release26-maint/Doc/howto/unicode.rst python/branches/release26-maint/Doc/library/__future__.rst python/branches/release26-maint/Doc/library/cgi.rst python/branches/release26-maint/Doc/library/codecs.rst python/branches/release26-maint/Doc/library/constants.rst python/branches/release26-maint/Doc/library/copy.rst python/branches/release26-maint/Doc/library/ctypes.rst python/branches/release26-maint/Doc/library/ftplib.rst python/branches/release26-maint/Doc/library/hashlib.rst python/branches/release26-maint/Doc/library/inspect.rst python/branches/release26-maint/Doc/library/logging.rst python/branches/release26-maint/Doc/library/marshal.rst python/branches/release26-maint/Doc/library/math.rst python/branches/release26-maint/Doc/library/os.rst python/branches/release26-maint/Doc/library/readline.rst python/branches/release26-maint/Doc/library/signal.rst python/branches/release26-maint/Doc/library/socketserver.rst python/branches/release26-maint/Doc/library/ssl.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/string.rst python/branches/release26-maint/Doc/library/sys.rst python/branches/release26-maint/Doc/library/thread.rst python/branches/release26-maint/Doc/library/urllib.rst python/branches/release26-maint/Doc/library/warnings.rst python/branches/release26-maint/Doc/reference/datamodel.rst python/branches/release26-maint/Doc/reference/simple_stmts.rst python/branches/release26-maint/Doc/tutorial/classes.rst python/branches/release26-maint/Doc/tutorial/errors.rst python/branches/release26-maint/Doc/tutorial/inputoutput.rst python/branches/release26-maint/Doc/tutorial/introduction.rst python/branches/release26-maint/Doc/tutorial/modules.rst Modified: python/branches/release26-maint/Doc/c-api/buffer.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/buffer.rst (original) +++ python/branches/release26-maint/Doc/c-api/buffer.rst Tue Oct 27 15:50:20 2009 @@ -253,9 +253,9 @@ +------------------------------+---------------------------------------------------+ -.. cfunction:: void PyBuffer_Release(PyObject *obj, Py_buffer *view) +.. cfunction:: void PyBuffer_Release(Py_buffer *view) - Release the buffer *view* over *obj*. This should be called when the buffer + Release the buffer *view*. This should be called when the buffer is no longer being used as it may free memory from it. Modified: python/branches/release26-maint/Doc/conf.py ============================================================================== --- python/branches/release26-maint/Doc/conf.py (original) +++ python/branches/release26-maint/Doc/conf.py Tue Oct 27 15:50:20 2009 @@ -148,7 +148,8 @@ # Documents to append as an appendix to all manuals. latex_appendices = ['glossary', 'about', 'license', 'copyright'] -latex_elements = {'inputenc': '\\usepackage[utf8x]{inputenc}'} +# Get LaTeX to handle Unicode correctly +latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}'} # Options for the coverage checker # -------------------------------- Modified: python/branches/release26-maint/Doc/distutils/builtdist.rst ============================================================================== --- python/branches/release26-maint/Doc/distutils/builtdist.rst (original) +++ python/branches/release26-maint/Doc/distutils/builtdist.rst Tue Oct 27 15:50:20 2009 @@ -426,13 +426,6 @@ also the configuration. For details refer to Microsoft's documentation of the :cfunc:`SHGetSpecialFolderPath` function. -Vista User Access Control (UAC) -=============================== - -Starting with Python 2.6, bdist_wininst supports a :option:`--user-access-control` -option. The default is 'none' (meaning no UAC handling is done), and other -valid values are 'auto' (meaning prompt for UAC elevation if Python was -installed for all users) and 'force' (meaning always prompt for elevation) .. function:: create_shortcut(target, description, filename[, arguments[, workdir[, iconpath[, iconindex]]]]) @@ -444,3 +437,12 @@ and *iconindex* is the index of the icon in the file *iconpath*. Again, for details consult the Microsoft documentation for the :class:`IShellLink` interface. + + +Vista User Access Control (UAC) +=============================== + +Starting with Python 2.6, bdist_wininst supports a :option:`--user-access-control` +option. The default is 'none' (meaning no UAC handling is done), and other +valid values are 'auto' (meaning prompt for UAC elevation if Python was +installed for all users) and 'force' (meaning always prompt for elevation). 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 Tue Oct 27 15:50:20 2009 @@ -210,11 +210,12 @@ to reading the Unicode character tables, available at . -Two other good introductory articles were written by Joel Spolsky - and Jason Orendorff -. If this introduction didn't make -things clear to you, you should try reading one of these alternate articles -before continuing. +Another good introductory article was written by Joel Spolsky +. +If this introduction didn't make things clear to you, you should try reading this +alternate article before continuing. + +.. Jason Orendorff XXX http://www.jorendorff.com/articles/unicode/ is broken Wikipedia entries are often helpful; see the entries for "character encoding" and UTF-8 Modified: python/branches/release26-maint/Doc/library/__future__.rst ============================================================================== --- python/branches/release26-maint/Doc/library/__future__.rst (original) +++ python/branches/release26-maint/Doc/library/__future__.rst Tue Oct 27 15:50:20 2009 @@ -10,9 +10,9 @@ * To avoid confusing existing tools that analyze import statements and expect to find the modules they're importing. -* To ensure that future_statements run under releases prior to 2.1 at least - yield runtime exceptions (the import of :mod:`__future__` will fail, because - there was no module of that name prior to 2.1). +* To ensure that :ref:`future statements ` run under releases prior to + 2.1 at least yield runtime exceptions (the import of :mod:`__future__` will + fail, because there was no module of that name prior to 2.1). * To document when incompatible changes were introduced, and when they will be --- or were --- made mandatory. This is a form of executable documentation, and @@ -56,7 +56,34 @@ dynamically compiled code. This flag is stored in the :attr:`compiler_flag` attribute on :class:`_Feature` instances. -No feature description will ever be deleted from :mod:`__future__`. +No feature description will ever be deleted from :mod:`__future__`. Since its +introduction in Python 2.1 the following features have found their way into the +language using this mechanism: + ++------------------+-------------+--------------+---------------------------------------------+ +| feature | optional in | mandatory in | effect | ++==================+=============+==============+=============================================+ +| nested_scopes | 2.1.0b1 | 2.2 | :pep:`227`: | +| | | | *Statically Nested Scopes* | ++------------------+-------------+--------------+---------------------------------------------+ +| generators | 2.2.0a1 | 2.3 | :pep:`255`: | +| | | | *Simple Generators* | ++------------------+-------------+--------------+---------------------------------------------+ +| division | 2.2.0a2 | 3.0 | :pep:`238`: | +| | | | *Changing the Division Operator* | ++------------------+-------------+--------------+---------------------------------------------+ +| absolute_import | 2.5.0a1 | 2.7 | :pep:`328`: | +| | | | *Imports: Multi-Line and Absolute/Relative* | ++------------------+-------------+--------------+---------------------------------------------+ +| with_statement | 2.5.0a1 | 2.6 | :pep:`343`: | +| | | | *The "with" Statement* | ++------------------+-------------+--------------+---------------------------------------------+ +| print_function | 2.6.0a2 | 3.0 | :pep:`3105`: | +| | | | *Make print a function* | ++------------------+-------------+--------------+---------------------------------------------+ +| unicode_literals | 2.6.0a2 | 3.0 | :pep:`3112`: | +| | | | *Bytes literals in Python 3000* | ++------------------+-------------+--------------+---------------------------------------------+ .. seealso:: Modified: python/branches/release26-maint/Doc/library/cgi.rst ============================================================================== --- python/branches/release26-maint/Doc/library/cgi.rst (original) +++ python/branches/release26-maint/Doc/library/cgi.rst Tue Oct 27 15:50:20 2009 @@ -213,7 +213,7 @@ provide valid input to your scripts. For example, if a curious user appends another ``user=foo`` pair to the query string, then the script would crash, because in this situation the ``getvalue("user")`` method call returns a list -instead of a string. Calling the :meth:`toupper` method on a list is not valid +instead of a string. Calling the :meth:`~str.upper` method on a list is not valid (since lists do not have a method of this name) and results in an :exc:`AttributeError` exception. Modified: python/branches/release26-maint/Doc/library/codecs.rst ============================================================================== --- python/branches/release26-maint/Doc/library/codecs.rst (original) +++ python/branches/release26-maint/Doc/library/codecs.rst Tue Oct 27 15:50:20 2009 @@ -863,7 +863,8 @@ name, together with a few common aliases, and the languages for which the encoding is likely used. Neither the list of aliases nor the list of languages is meant to be exhaustive. Notice that spelling alternatives that only differ in -case or use a hyphen instead of an underscore are also valid aliases. +case or use a hyphen instead of an underscore are also valid aliases; therefore, +e.g. ``'utf-8'`` is a valid alias for the ``'utf_8'`` codec. Many of the character sets support the same languages. They vary in individual characters (e.g. whether the EURO SIGN is supported or not), and in the Modified: python/branches/release26-maint/Doc/library/constants.rst ============================================================================== --- python/branches/release26-maint/Doc/library/constants.rst (original) +++ python/branches/release26-maint/Doc/library/constants.rst Tue Oct 27 15:50:20 2009 @@ -62,7 +62,7 @@ Objects that when printed, print a message like "Use quit() or Ctrl-D (i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the - specified exit code, and when . + specified exit code. .. data:: copyright license Modified: python/branches/release26-maint/Doc/library/copy.rst ============================================================================== --- python/branches/release26-maint/Doc/library/copy.rst (original) +++ python/branches/release26-maint/Doc/library/copy.rst Tue Oct 27 15:50:20 2009 @@ -1,25 +1,28 @@ - :mod:`copy` --- Shallow and deep copy operations ================================================ .. module:: copy :synopsis: Shallow and deep copy operations. +This module provides generic (shallow and deep) copying operations. -.. index:: - single: copy() (in copy) - single: deepcopy() (in copy) -This module provides generic (shallow and deep) copying operations. +Interface summary: + +.. function:: copy(x) + + Return a shallow copy of *x*. + + +.. function:: deepcopy(x) + + Return a deep copy of *x*. -Interface summary:: - import copy +.. exception:: error - x = copy.copy(y) # make a shallow copy of y - x = copy.deepcopy(y) # make a deep copy of y + Raised for module specific errors. -For module specific errors, :exc:`copy.error` is raised. The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): Modified: python/branches/release26-maint/Doc/library/ctypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ctypes.rst (original) +++ python/branches/release26-maint/Doc/library/ctypes.rst Tue Oct 27 15:50:20 2009 @@ -1601,7 +1601,7 @@ The returned function prototype creates functions that use the standard C calling convention. The function will release the GIL during the call. If *use_errno* is set to True, the ctypes private copy of the system - :data:`errno` variable is exchanged with the real :data:`errno` value bafore + :data:`errno` variable is exchanged with the real :data:`errno` value before and after the call; *use_last_error* does the same for the Windows error code. Modified: python/branches/release26-maint/Doc/library/ftplib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ftplib.rst (original) +++ python/branches/release26-maint/Doc/library/ftplib.rst Tue Oct 27 15:50:20 2009 @@ -147,7 +147,8 @@ ``'anonymous@'``. This function should be called only once for each instance, after a connection has been established; it should not be called at all if a host and user were given when the instance was created. Most FTP commands are - only allowed after the client has logged in. + only allowed after the client has logged in. The *acct* parameter supplies + "accounting information"; few systems implement this. .. method:: FTP.abort() Modified: python/branches/release26-maint/Doc/library/hashlib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/hashlib.rst (original) +++ python/branches/release26-maint/Doc/library/hashlib.rst Tue Oct 27 15:50:20 2009 @@ -78,11 +78,11 @@ returned by the constructors: -.. data:: digest_size +.. data:: hash.digest_size The size of the resulting hash in bytes. -.. data:: block_size +.. data:: hash.block_size The internal block size of the hash algorithm in bytes. Modified: python/branches/release26-maint/Doc/library/inspect.rst ============================================================================== --- python/branches/release26-maint/Doc/library/inspect.rst (original) +++ python/branches/release26-maint/Doc/library/inspect.rst Tue Oct 27 15:50:20 2009 @@ -567,6 +567,11 @@ Return the frame object for the caller's stack frame. + This function relies on Python stack frame support in the interpreter, which + isn't guaranteed to exist in all implementations of Python. If running in + an implementation without Python stack frame support this function returns + ``None``. + .. function:: stack([context]) 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 Tue Oct 27 15:50:20 2009 @@ -1195,6 +1195,28 @@ This example uses console and file handlers, but you can use any number and combination of handlers you choose. +.. _logging-exceptions: + +Exceptions raised during logging +-------------------------------- + +The logging package is designed to swallow exceptions which occur while logging +in production. This is so that errors which occur while handling logging events +- such as logging misconfiguration, network or other similar errors - do not +cause the application using logging to terminate prematurely. + +:class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never +swallowed. Other exceptions which occur during the :meth:`emit` method of a +:class:`Handler` subclass are passed to its :meth:`handleError` method. + +The default implementation of :meth:`handleError` in :class:`Handler` checks +to see if a module-level variable, `raiseExceptions`, is set. If set, a +traceback is printed to `sys.stderr`. If not set, the exception is swallowed. + +**Note:** The default value of `raiseExceptions` is `True`. This is because +during development, you typically want to be notified of any exceptions that +occur. It's advised that you set `raiseExceptions` to `False` for production +usage. .. _context-info: Modified: python/branches/release26-maint/Doc/library/marshal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/marshal.rst (original) +++ python/branches/release26-maint/Doc/library/marshal.rst Tue Oct 27 15:50:20 2009 @@ -37,12 +37,14 @@ Not all Python object types are supported; in general, only objects whose value is independent from a particular invocation of Python can be written and read by -this module. The following types are supported: ``None``, integers, long -integers, floating point numbers, strings, Unicode objects, tuples, lists, sets, -dictionaries, and code objects, where it should be understood that tuples, lists -and dictionaries are only supported as long as the values contained therein are -themselves supported; and recursive lists and dictionaries should not be written -(they will cause infinite loops). +this module. The following types are supported: booleans, integers, long +integers, floating point numbers, complex numbers, strings, Unicode objects, +tuples, lists, sets, frozensets, dictionaries, and code objects, where it should +be understood that tuples, lists, sets, frozensets and dictionaries are only +supported as long as the values contained therein are themselves supported; and +recursive lists, sets and dictionaries should not be written (they will cause +infinite loops). The singletons :const:`None`, :const:`Ellipsis` and +:exc:`StopIteration` can also be marshalled and unmarshalled. .. warning:: Modified: python/branches/release26-maint/Doc/library/math.rst ============================================================================== --- python/branches/release26-maint/Doc/library/math.rst (original) +++ python/branches/release26-maint/Doc/library/math.rst Tue Oct 27 15:50:20 2009 @@ -166,8 +166,10 @@ .. function:: log(x[, base]) - Return the logarithm of *x* to the given *base*. If the *base* is not specified, - return the natural logarithm of *x* (that is, the logarithm to base *e*). + With one argument, return the natural logarithm of *x* (to base *e*). + + With two arguments, return the logarithm of *x* to the given *base*, + calculated as ``log(x)/log(base)``. .. versionchanged:: 2.3 *base* argument added. @@ -183,7 +185,8 @@ .. function:: log10(x) - Return the base-10 logarithm of *x*. + Return the base-10 logarithm of *x*. This is usually more accurate + than ``log(x, 10)``. .. function:: pow(x, y) Modified: python/branches/release26-maint/Doc/library/os.rst ============================================================================== --- python/branches/release26-maint/Doc/library/os.rst (original) +++ python/branches/release26-maint/Doc/library/os.rst Tue Oct 27 15:50:20 2009 @@ -1067,12 +1067,12 @@ .. function:: remove(path) - Remove the file *path*. If *path* is a directory, :exc:`OSError` is raised; see - :func:`rmdir` below to remove a directory. This is identical to the - :func:`unlink` function documented below. On Windows, attempting to remove a - file that is in use causes an exception to be raised; on Unix, the directory - entry is removed but the storage allocated to the file is not made available - until the original file is no longer in use. Availability: Unix, + Remove (delete) the file *path*. If *path* is a directory, :exc:`OSError` is + raised; see :func:`rmdir` below to remove a directory. This is identical to + the :func:`unlink` function documented below. On Windows, attempting to + remove a file that is in use causes an exception to be raised; on Unix, the + directory entry is removed but the storage allocated to the file is not made + available until the original file is no longer in use. Availability: Unix, Windows. @@ -1121,7 +1121,10 @@ .. function:: rmdir(path) - Remove the directory *path*. Availability: Unix, Windows. + Remove (delete) the directory *path*. Only works when the directory is + empty, otherwise, :exc:`OSError` is raised. In order to remove whole + directory trees, :func:`shutil.rmtree` can be used. Availability: Unix, + Windows. .. function:: stat(path) @@ -1297,9 +1300,9 @@ .. function:: unlink(path) - Remove the file *path*. This is the same function as :func:`remove`; the - :func:`unlink` name is its traditional Unix name. Availability: Unix, - Windows. + Remove (delete) the file *path*. This is the same function as + :func:`remove`; the :func:`unlink` name is its traditional Unix + name. Availability: Unix, Windows. .. function:: utime(path, times) Modified: python/branches/release26-maint/Doc/library/readline.rst ============================================================================== --- python/branches/release26-maint/Doc/library/readline.rst (original) +++ python/branches/release26-maint/Doc/library/readline.rst Tue Oct 27 15:50:20 2009 @@ -1,4 +1,3 @@ - :mod:`readline` --- GNU readline interface ========================================== @@ -221,7 +220,7 @@ class HistoryConsole(code.InteractiveConsole): def __init__(self, locals=None, filename="", histfile=os.path.expanduser("~/.console-history")): - code.InteractiveConsole.__init__(self) + code.InteractiveConsole.__init__(self, locals, filename) self.init_history(histfile) def init_history(self, histfile): Modified: python/branches/release26-maint/Doc/library/signal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/signal.rst (original) +++ python/branches/release26-maint/Doc/library/signal.rst Tue Oct 27 15:50:20 2009 @@ -211,9 +211,9 @@ exception to be raised. The *handler* is called with two arguments: the signal number and the current - stack frame (``None`` or a frame object; for a description of frame objects, see - the reference manual section on the standard type hierarchy or see the attribute - descriptions in the :mod:`inspect` module). + stack frame (``None`` or a frame object; for a description of frame objects, + see the :ref:`description in the type hierarchy ` or see the + attribute descriptions in the :mod:`inspect` module). .. _signal-example: 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 Tue Oct 27 15:50:20 2009 @@ -465,7 +465,7 @@ import socket import sys - HOST, PORT = "localhost" + HOST, PORT = "localhost", 9999 data = " ".join(sys.argv[1:]) # SOCK_DGRAM is the socket type to use for UDP sockets Modified: python/branches/release26-maint/Doc/library/ssl.rst ============================================================================== --- python/branches/release26-maint/Doc/library/ssl.rst (original) +++ python/branches/release26-maint/Doc/library/ssl.rst Tue Oct 27 15:50:20 2009 @@ -1,6 +1,5 @@ - :mod:`ssl` --- SSL wrapper for socket objects -==================================================================== +============================================= .. module:: ssl :synopsis: SSL wrapper for socket objects @@ -16,32 +15,29 @@ .. index:: TLS, SSL, Transport Layer Security, Secure Sockets Layer -This module provides access to Transport Layer Security (often known -as "Secure Sockets Layer") encryption and peer authentication -facilities for network sockets, both client-side and server-side. -This module uses the OpenSSL library. It is available on all modern -Unix systems, Windows, Mac OS X, and probably additional -platforms, as long as OpenSSL is installed on that platform. +This module provides access to Transport Layer Security (often known as "Secure +Sockets Layer") encryption and peer authentication facilities for network +sockets, both client-side and server-side. This module uses the OpenSSL +library. It is available on all modern Unix systems, Windows, Mac OS X, and +probably additional platforms, as long as OpenSSL is installed on that platform. .. note:: - Some behavior may be platform dependent, since calls are made to the operating - system socket APIs. The installed version of OpenSSL may also cause - variations in behavior. - -This section documents the objects and functions in the ``ssl`` module; -for more general information about TLS, SSL, and certificates, the -reader is referred to the documents in the "See Also" section at -the bottom. - -This module provides a class, :class:`ssl.SSLSocket`, which is -derived from the :class:`socket.socket` type, and provides -a socket-like wrapper that also encrypts and decrypts the data -going over the socket with SSL. It supports additional -:meth:`read` and :meth:`write` methods, along with a method, :meth:`getpeercert`, -to retrieve the certificate of the other side of the connection, and -a method, :meth:`cipher`, to retrieve the cipher being used for the -secure connection. + Some behavior may be platform dependent, since calls are made to the + operating system socket APIs. The installed version of OpenSSL may also + cause variations in behavior. + +This section documents the objects and functions in the ``ssl`` module; for more +general information about TLS, SSL, and certificates, the reader is referred to +the documents in the "See Also" section at the bottom. + +This module provides a class, :class:`ssl.SSLSocket`, which is derived from the +:class:`socket.socket` type, and provides a socket-like wrapper that also +encrypts and decrypts the data going over the socket with SSL. It supports +additional :meth:`read` and :meth:`write` methods, along with a method, +:meth:`getpeercert`, to retrieve the certificate of the other side of the +connection, and a method, :meth:`cipher`, to retrieve the cipher being used for +the secure connection. Functions, Constants, and Exceptions ------------------------------------ @@ -49,31 +45,33 @@ .. exception:: SSLError Raised to signal an error from the underlying SSL implementation. This - signifies some problem in the higher-level - encryption and authentication layer that's superimposed on the underlying - network connection. This error is a subtype of :exc:`socket.error`, which - in turn is a subtype of :exc:`IOError`. + signifies some problem in the higher-level encryption and authentication + layer that's superimposed on the underlying network connection. This error + is a subtype of :exc:`socket.error`, which in turn is a subtype of + :exc:`IOError`. .. function:: wrap_socket (sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version={see docs}, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True) - Takes an instance ``sock`` of :class:`socket.socket`, and returns an instance of :class:`ssl.SSLSocket`, a subtype - of :class:`socket.socket`, which wraps the underlying socket in an SSL context. - For client-side sockets, the context construction is lazy; if the underlying socket isn't - connected yet, the context construction will be performed after :meth:`connect` is called - on the socket. For server-side sockets, if the socket has no remote peer, it is assumed - to be a listening socket, and the server-side SSL wrapping is automatically performed - on client connections accepted via the :meth:`accept` method. :func:`wrap_socket` may - raise :exc:`SSLError`. - - The ``keyfile`` and ``certfile`` parameters specify optional files which contain a certificate - to be used to identify the local side of the connection. See the discussion of :ref:`ssl-certificates` - for more information on how the certificate is stored in the ``certfile``. - - Often the private key is stored - in the same file as the certificate; in this case, only the ``certfile`` parameter need be - passed. If the private key is stored in a separate file, both parameters must be used. - If the private key is stored in the ``certfile``, it should come before the first certificate - in the certificate chain:: + Takes an instance ``sock`` of :class:`socket.socket`, and returns an instance + of :class:`ssl.SSLSocket`, a subtype of :class:`socket.socket`, which wraps + the underlying socket in an SSL context. For client-side sockets, the + context construction is lazy; if the underlying socket isn't connected yet, + the context construction will be performed after :meth:`connect` is called on + the socket. For server-side sockets, if the socket has no remote peer, it is + assumed to be a listening socket, and the server-side SSL wrapping is + automatically performed on client connections accepted via the :meth:`accept` + method. :func:`wrap_socket` may raise :exc:`SSLError`. + + The ``keyfile`` and ``certfile`` parameters specify optional files which + contain a certificate to be used to identify the local side of the + connection. See the discussion of :ref:`ssl-certificates` for more + information on how the certificate is stored in the ``certfile``. + + Often the private key is stored in the same file as the certificate; in this + case, only the ``certfile`` parameter need be passed. If the private key is + stored in a separate file, both parameters must be used. If the private key + is stored in the ``certfile``, it should come before the first certificate in + the certificate chain:: -----BEGIN RSA PRIVATE KEY----- ... (private key in base64 encoding) ... @@ -82,31 +80,33 @@ ... (certificate in base64 PEM encoding) ... -----END CERTIFICATE----- - The parameter ``server_side`` is a boolean which identifies whether server-side or client-side - behavior is desired from this socket. + The parameter ``server_side`` is a boolean which identifies whether + server-side or client-side behavior is desired from this socket. - The parameter ``cert_reqs`` specifies whether a certificate is - required from the other side of the connection, and whether it will - be validated if provided. It must be one of the three values - :const:`CERT_NONE` (certificates ignored), :const:`CERT_OPTIONAL` (not required, - but validated if provided), or :const:`CERT_REQUIRED` (required and - validated). If the value of this parameter is not :const:`CERT_NONE`, then - the ``ca_certs`` parameter must point to a file of CA certificates. - - The ``ca_certs`` file contains a set of concatenated "certification authority" certificates, - which are used to validate certificates passed from the other end of the connection. - See the discussion of :ref:`ssl-certificates` for more information about how to arrange - the certificates in this file. - - The parameter ``ssl_version`` specifies which version of the SSL protocol to use. - Typically, the server chooses a particular protocol version, and the client - must adapt to the server's choice. Most of the versions are not interoperable - with the other versions. If not specified, for client-side operation, the - default SSL version is SSLv3; for server-side operation, SSLv23. These - version selections provide the most compatibility with other versions. + The parameter ``cert_reqs`` specifies whether a certificate is required from + the other side of the connection, and whether it will be validated if + provided. It must be one of the three values :const:`CERT_NONE` + (certificates ignored), :const:`CERT_OPTIONAL` (not required, but validated + if provided), or :const:`CERT_REQUIRED` (required and validated). If the + value of this parameter is not :const:`CERT_NONE`, then the ``ca_certs`` + parameter must point to a file of CA certificates. + + The ``ca_certs`` file contains a set of concatenated "certification + authority" certificates, which are used to validate certificates passed from + the other end of the connection. See the discussion of + :ref:`ssl-certificates` for more information about how to arrange the + certificates in this file. + + The parameter ``ssl_version`` specifies which version of the SSL protocol to + use. Typically, the server chooses a particular protocol version, and the + client must adapt to the server's choice. Most of the versions are not + interoperable with the other versions. If not specified, for client-side + operation, the default SSL version is SSLv3; for server-side operation, + SSLv23. These version selections provide the most compatibility with other + versions. - Here's a table showing which versions in a client (down the side) - can connect to which versions in a server (along the top): + Here's a table showing which versions in a client (down the side) can connect + to which versions in a server (along the top): .. table:: @@ -119,51 +119,52 @@ *TLSv1* no no yes yes ======================== ========= ========= ========== ========= - In some older versions of OpenSSL (for instance, 0.9.7l on OS X 10.4), - an SSLv2 client could not connect to an SSLv23 server. + In some older versions of OpenSSL (for instance, 0.9.7l on OS X 10.4), an + SSLv2 client could not connect to an SSLv23 server. The parameter ``do_handshake_on_connect`` specifies whether to do the SSL handshake automatically after doing a :meth:`socket.connect`, or whether the - application program will call it explicitly, by invoking the :meth:`SSLSocket.do_handshake` - method. Calling :meth:`SSLSocket.do_handshake` explicitly gives the program control over - the blocking behavior of the socket I/O involved in the handshake. - - The parameter ``suppress_ragged_eofs`` specifies how the :meth:`SSLSocket.read` - method should signal unexpected EOF from the other end of the connection. If specified - as :const:`True` (the default), it returns a normal EOF in response to unexpected - EOF errors raised from the underlying socket; if :const:`False`, it will raise - the exceptions back to the caller. + application program will call it explicitly, by invoking the + :meth:`SSLSocket.do_handshake` method. Calling + :meth:`SSLSocket.do_handshake` explicitly gives the program control over the + blocking behavior of the socket I/O involved in the handshake. + + The parameter ``suppress_ragged_eofs`` specifies how the + :meth:`SSLSocket.read` method should signal unexpected EOF from the other end + of the connection. If specified as :const:`True` (the default), it returns a + normal EOF in response to unexpected EOF errors raised from the underlying + socket; if :const:`False`, it will raise the exceptions back to the caller. .. function:: RAND_status() - Returns True if the SSL pseudo-random number generator has been - seeded with 'enough' randomness, and False otherwise. You can use - :func:`ssl.RAND_egd` and :func:`ssl.RAND_add` to increase the randomness - of the pseudo-random number generator. + Returns True if the SSL pseudo-random number generator has been seeded with + 'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd` + and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random + number generator. .. function:: RAND_egd(path) If you are running an entropy-gathering daemon (EGD) somewhere, and ``path`` - is the pathname of a socket connection open to it, this will read - 256 bytes of randomness from the socket, and add it to the SSL pseudo-random number generator - to increase the security of generated secret keys. This is typically only - necessary on systems without better sources of randomness. + is the pathname of a socket connection open to it, this will read 256 bytes + of randomness from the socket, and add it to the SSL pseudo-random number + generator to increase the security of generated secret keys. This is + typically only necessary on systems without better sources of randomness. - See http://egd.sourceforge.net/ or http://prngd.sourceforge.net/ for - sources of entropy-gathering daemons. + See http://egd.sourceforge.net/ or http://prngd.sourceforge.net/ for sources + of entropy-gathering daemons. .. function:: RAND_add(bytes, entropy) - Mixes the given ``bytes`` into the SSL pseudo-random number generator. - The parameter ``entropy`` (a float) is a lower bound on the entropy - contained in string (so you can always use :const:`0.0`). - See :rfc:`1750` for more information on sources of entropy. + Mixes the given ``bytes`` into the SSL pseudo-random number generator. The + parameter ``entropy`` (a float) is a lower bound on the entropy contained in + string (so you can always use :const:`0.0`). See :rfc:`1750` for more + information on sources of entropy. .. function:: cert_time_to_seconds(timestring) - Returns a floating-point value containing a normal seconds-after-the-epoch time - value, given the time-string representing the "notBefore" or "notAfter" date - from a certificate. + Returns a floating-point value containing a normal seconds-after-the-epoch + time value, given the time-string representing the "notBefore" or "notAfter" + date from a certificate. Here's an example:: @@ -177,14 +178,13 @@ .. function:: get_server_certificate (addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None) - Given the address ``addr`` of an SSL-protected server, as a - (*hostname*, *port-number*) pair, fetches the server's certificate, - and returns it as a PEM-encoded string. If ``ssl_version`` is - specified, uses that version of the SSL protocol to attempt to - connect to the server. If ``ca_certs`` is specified, it should be - a file containing a list of root certificates, the same format as - used for the same parameter in :func:`wrap_socket`. The call will - attempt to validate the server certificate against that set of root + Given the address ``addr`` of an SSL-protected server, as a (*hostname*, + *port-number*) pair, fetches the server's certificate, and returns it as a + PEM-encoded string. If ``ssl_version`` is specified, uses that version of + the SSL protocol to attempt to connect to the server. If ``ca_certs`` is + specified, it should be a file containing a list of root certificates, the + same format as used for the same parameter in :func:`wrap_socket`. The call + will attempt to validate the server certificate against that set of root certificates, and will fail if the validation attempt fails. .. function:: DER_cert_to_PEM_cert (DER_cert_bytes) @@ -194,31 +194,29 @@ .. function:: PEM_cert_to_DER_cert (PEM_cert_string) - Given a certificate as an ASCII PEM string, returns a DER-encoded - sequence of bytes for that same certificate. + Given a certificate as an ASCII PEM string, returns a DER-encoded sequence of + bytes for that same certificate. .. data:: CERT_NONE - Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` - when no certificates will be required or validated from the other - side of the socket connection. + Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when no + certificates will be required or validated from the other side of the socket + connection. .. data:: CERT_OPTIONAL - Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` - when no certificates will be required from the other side of the - socket connection, but if they are provided, will be validated. - Note that use of this setting requires a valid certificate - validation file also be passed as a value of the ``ca_certs`` - parameter. + Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when no + certificates will be required from the other side of the socket connection, + but if they are provided, will be validated. Note that use of this setting + requires a valid certificate validation file also be passed as a value of the + ``ca_certs`` parameter. .. data:: CERT_REQUIRED - Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` - when certificates will be required from the other side of the - socket connection. Note that use of this setting requires a valid certificate - validation file also be passed as a value of the ``ca_certs`` - parameter. + Value to pass to the ``cert_reqs`` parameter to :func:`sslobject` when + certificates will be required from the other side of the socket connection. + Note that use of this setting requires a valid certificate validation file + also be passed as a value of the ``ca_certs`` parameter. .. data:: PROTOCOL_SSLv2 @@ -226,22 +224,21 @@ .. data:: PROTOCOL_SSLv23 - Selects SSL version 2 or 3 as the channel encryption protocol. - This is a setting to use with servers for maximum compatibility - with the other end of an SSL connection, but it may cause the - specific ciphers chosen for the encryption to be of fairly low - quality. + Selects SSL version 2 or 3 as the channel encryption protocol. This is a + setting to use with servers for maximum compatibility with the other end of + an SSL connection, but it may cause the specific ciphers chosen for the + encryption to be of fairly low quality. .. data:: PROTOCOL_SSLv3 - Selects SSL version 3 as the channel encryption protocol. - For clients, this is the maximally compatible SSL variant. + Selects SSL version 3 as the channel encryption protocol. For clients, this + is the maximally compatible SSL variant. .. data:: PROTOCOL_TLSv1 - Selects TLS version 1 as the channel encryption protocol. This is - the most modern version, and probably the best choice for maximum - protection, if both sides can speak it. + Selects TLS version 1 as the channel encryption protocol. This is the most + modern version, and probably the best choice for maximum protection, if both + sides can speak it. SSLSocket Objects @@ -253,30 +250,28 @@ .. method:: SSLSocket.write(data) - Writes the ``data`` to the other side of the connection, using the - SSL channel to encrypt. Returns the number of bytes written. + Writes the ``data`` to the other side of the connection, using the SSL + channel to encrypt. Returns the number of bytes written. .. method:: SSLSocket.getpeercert(binary_form=False) - If there is no certificate for the peer on the other end of the - connection, returns ``None``. + If there is no certificate for the peer on the other end of the connection, + returns ``None``. - If the parameter ``binary_form`` is :const:`False`, and a - certificate was received from the peer, this method returns a - :class:`dict` instance. If the certificate was not validated, the - dict is empty. If the certificate was validated, it returns a dict - with the keys ``subject`` (the principal for which the certificate - was issued), and ``notAfter`` (the time after which the certificate - should not be trusted). The certificate was already validated, so - the ``notBefore`` and ``issuer`` fields are not returned. If a - certificate contains an instance of the *Subject Alternative Name* - extension (see :rfc:`3280`), there will also be a - ``subjectAltName`` key in the dictionary. + If the parameter ``binary_form`` is :const:`False`, and a certificate was + received from the peer, this method returns a :class:`dict` instance. If the + certificate was not validated, the dict is empty. If the certificate was + validated, it returns a dict with the keys ``subject`` (the principal for + which the certificate was issued), and ``notAfter`` (the time after which the + certificate should not be trusted). The certificate was already validated, + so the ``notBefore`` and ``issuer`` fields are not returned. If a + certificate contains an instance of the *Subject Alternative Name* extension + (see :rfc:`3280`), there will also be a ``subjectAltName`` key in the + dictionary. The "subject" field is a tuple containing the sequence of relative - distinguished names (RDNs) given in the certificate's data - structure for the principal, and each RDN is a sequence of - name-value pairs:: + distinguished names (RDNs) given in the certificate's data structure for the + principal, and each RDN is a sequence of name-value pairs:: {'notAfter': 'Feb 16 16:54:50 2013 GMT', 'subject': ((('countryName', u'US'),), @@ -286,29 +281,27 @@ (('organizationalUnitName', u'SSL'),), (('commonName', u'somemachine.python.org'),))} - If the ``binary_form`` parameter is :const:`True`, and a - certificate was provided, this method returns the DER-encoded form - of the entire certificate as a sequence of bytes, or :const:`None` if the - peer did not provide a certificate. This return - value is independent of validation; if validation was required - (:const:`CERT_OPTIONAL` or :const:`CERT_REQUIRED`), it will have + If the ``binary_form`` parameter is :const:`True`, and a certificate was + provided, this method returns the DER-encoded form of the entire certificate + as a sequence of bytes, or :const:`None` if the peer did not provide a + certificate. This return value is independent of validation; if validation + was required (:const:`CERT_OPTIONAL` or :const:`CERT_REQUIRED`), it will have been validated, but if :const:`CERT_NONE` was used to establish the connection, the certificate, if present, will not have been validated. .. method:: SSLSocket.cipher() - Returns a three-value tuple containing the name of the cipher being - used, the version of the SSL protocol that defines its use, and the - number of secret bits being used. If no connection has been - established, returns ``None``. + Returns a three-value tuple containing the name of the cipher being used, the + version of the SSL protocol that defines its use, and the number of secret + bits being used. If no connection has been established, returns ``None``. .. method:: SSLSocket.do_handshake() - Perform a TLS/SSL handshake. If this is used with a non-blocking socket, - it may raise :exc:`SSLError` with an ``arg[0]`` of :const:`SSL_ERROR_WANT_READ` - or :const:`SSL_ERROR_WANT_WRITE`, in which case it must be called again until it - completes successfully. For example, to simulate the behavior of a blocking socket, - one might write:: + Perform a TLS/SSL handshake. If this is used with a non-blocking socket, it + may raise :exc:`SSLError` with an ``arg[0]`` of :const:`SSL_ERROR_WANT_READ` + or :const:`SSL_ERROR_WANT_WRITE`, in which case it must be called again until + it completes successfully. For example, to simulate the behavior of a + blocking socket, one might write:: while True: try: @@ -324,13 +317,12 @@ .. method:: SSLSocket.unwrap() - Performs the SSL shutdown handshake, which removes the TLS layer - from the underlying socket, and returns the underlying socket - object. This can be used to go from encrypted operation over a - connection to unencrypted. The socket instance returned should always be - used for further communication with the other side of the - connection, rather than the original socket instance (which may - not function properly after the unwrap). + Performs the SSL shutdown handshake, which removes the TLS layer from the + underlying socket, and returns the underlying socket object. This can be + used to go from encrypted operation over a connection to unencrypted. The + socket instance returned should always be used for further communication with + the other side of the connection, rather than the original socket instance + (which may not function properly after the unwrap). .. index:: single: certificates @@ -341,57 +333,54 @@ Certificates ------------ -Certificates in general are part of a public-key / private-key system. In this system, each *principal*, -(which may be a machine, or a person, or an organization) is assigned a unique two-part encryption key. -One part of the key is public, and is called the *public key*; the other part is kept secret, and is called -the *private key*. The two parts are related, in that if you encrypt a message with one of the parts, you can -decrypt it with the other part, and **only** with the other part. - -A certificate contains information about two principals. It contains -the name of a *subject*, and the subject's public key. It also -contains a statement by a second principal, the *issuer*, that the -subject is who he claims to be, and that this is indeed the subject's -public key. The issuer's statement is signed with the issuer's -private key, which only the issuer knows. However, anyone can verify -the issuer's statement by finding the issuer's public key, decrypting -the statement with it, and comparing it to the other information in -the certificate. The certificate also contains information about the -time period over which it is valid. This is expressed as two fields, -called "notBefore" and "notAfter". - -In the Python use of certificates, a client or server -can use a certificate to prove who they are. The other -side of a network connection can also be required to produce a certificate, -and that certificate can be validated to the satisfaction -of the client or server that requires such validation. -The connection attempt can be set to raise an exception if -the validation fails. Validation is done -automatically, by the underlying OpenSSL framework; the -application need not concern itself with its mechanics. -But the application does usually need to provide -sets of certificates to allow this process to take place. - -Python uses files to contain certificates. They should be formatted -as "PEM" (see :rfc:`1422`), which is a base-64 encoded form wrapped -with a header line and a footer line:: +Certificates in general are part of a public-key / private-key system. In this +system, each *principal*, (which may be a machine, or a person, or an +organization) is assigned a unique two-part encryption key. One part of the key +is public, and is called the *public key*; the other part is kept secret, and is +called the *private key*. The two parts are related, in that if you encrypt a +message with one of the parts, you can decrypt it with the other part, and +**only** with the other part. + +A certificate contains information about two principals. It contains the name +of a *subject*, and the subject's public key. It also contains a statement by a +second principal, the *issuer*, that the subject is who he claims to be, and +that this is indeed the subject's public key. The issuer's statement is signed +with the issuer's private key, which only the issuer knows. However, anyone can +verify the issuer's statement by finding the issuer's public key, decrypting the +statement with it, and comparing it to the other information in the certificate. +The certificate also contains information about the time period over which it is +valid. This is expressed as two fields, called "notBefore" and "notAfter". + +In the Python use of certificates, a client or server can use a certificate to +prove who they are. The other side of a network connection can also be required +to produce a certificate, and that certificate can be validated to the +satisfaction of the client or server that requires such validation. The +connection attempt can be set to raise an exception if the validation fails. +Validation is done automatically, by the underlying OpenSSL framework; the +application need not concern itself with its mechanics. But the application +does usually need to provide sets of certificates to allow this process to take +place. + +Python uses files to contain certificates. They should be formatted as "PEM" +(see :rfc:`1422`), which is a base-64 encoded form wrapped with a header line +and a footer line:: -----BEGIN CERTIFICATE----- ... (certificate in base64 PEM encoding) ... -----END CERTIFICATE----- -The Python files which contain certificates can contain a sequence -of certificates, sometimes called a *certificate chain*. This chain -should start with the specific certificate for the principal who "is" -the client or server, and then the certificate for the issuer of that -certificate, and then the certificate for the issuer of *that* certificate, -and so on up the chain till you get to a certificate which is *self-signed*, -that is, a certificate which has the same subject and issuer, -sometimes called a *root certificate*. The certificates should just -be concatenated together in the certificate file. For example, suppose -we had a three certificate chain, from our server certificate to the -certificate of the certification authority that signed our server certificate, -to the root certificate of the agency which issued the certification authority's -certificate:: +The Python files which contain certificates can contain a sequence of +certificates, sometimes called a *certificate chain*. This chain should start +with the specific certificate for the principal who "is" the client or server, +and then the certificate for the issuer of that certificate, and then the +certificate for the issuer of *that* certificate, and so on up the chain till +you get to a certificate which is *self-signed*, that is, a certificate which +has the same subject and issuer, sometimes called a *root certificate*. The +certificates should just be concatenated together in the certificate file. For +example, suppose we had a three certificate chain, from our server certificate +to the certificate of the certification authority that signed our server +certificate, to the root certificate of the agency which issued the +certification authority's certificate:: -----BEGIN CERTIFICATE----- ... (certificate for your server)... @@ -405,33 +394,30 @@ If you are going to require validation of the other side of the connection's certificate, you need to provide a "CA certs" file, filled with the certificate -chains for each issuer you are willing to trust. Again, this file just -contains these chains concatenated together. For validation, Python will -use the first chain it finds in the file which matches. +chains for each issuer you are willing to trust. Again, this file just contains +these chains concatenated together. For validation, Python will use the first +chain it finds in the file which matches. Some "standard" root certificates are available from various certification -authorities: -`CACert.org `_, -`Thawte `_, -`Verisign `_, -`Positive SSL `_ (used by python.org), -`Equifax and GeoTrust `_. - -In general, if you are using -SSL3 or TLS1, you don't need to put the full chain in your "CA certs" file; -you only need the root certificates, and the remote peer is supposed to -furnish the other certificates necessary to chain from its certificate to -a root certificate. -See :rfc:`4158` for more discussion of the way in which -certification chains can be built. - -If you are going to create a server that provides SSL-encrypted -connection services, you will need to acquire a certificate for that -service. There are many ways of acquiring appropriate certificates, -such as buying one from a certification authority. Another common -practice is to generate a self-signed certificate. The simplest -way to do this is with the OpenSSL package, using something like -the following:: +authorities: `CACert.org `_, `Thawte +`_, `Verisign +`_, `Positive SSL +`_ +(used by python.org), `Equifax and GeoTrust +`_. + +In general, if you are using SSL3 or TLS1, you don't need to put the full chain +in your "CA certs" file; you only need the root certificates, and the remote +peer is supposed to furnish the other certificates necessary to chain from its +certificate to a root certificate. See :rfc:`4158` for more discussion of the +way in which certification chains can be built. + +If you are going to create a server that provides SSL-encrypted connection +services, you will need to acquire a certificate for that service. There are +many ways of acquiring appropriate certificates, such as buying one from a +certification authority. Another common practice is to generate a self-signed +certificate. The simplest way to do this is with the OpenSSL package, using +something like the following:: % openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem Generating a 1024 bit RSA private key @@ -455,9 +441,9 @@ Email Address []:ops at myserver.mygroup.myorganization.com % -The disadvantage of a self-signed certificate is that it is its -own root certificate, and no one else will have it in their cache -of known (and trusted) root certificates. +The disadvantage of a self-signed certificate is that it is its own root +certificate, and no one else will have it in their cache of known (and trusted) +root certificates. Examples @@ -466,7 +452,8 @@ Testing for SSL support ^^^^^^^^^^^^^^^^^^^^^^^ -To test for the presence of SSL support in a Python installation, user code should use the following idiom:: +To test for the presence of SSL support in a Python installation, user code +should use the following idiom:: try: import ssl @@ -478,8 +465,8 @@ Client-side operation ^^^^^^^^^^^^^^^^^^^^^ -This example connects to an SSL server, prints the server's address and certificate, -sends some bytes, and reads part of the response:: +This example connects to an SSL server, prints the server's address and +certificate, sends some bytes, and reads part of the response:: import socket, ssl, pprint @@ -507,8 +494,8 @@ # note that closing the SSLSocket will also close the underlying socket ssl_sock.close() -As of September 6, 2007, the certificate printed by this program -looked like this:: +As of September 6, 2007, the certificate printed by this program looked like +this:: {'notAfter': 'May 8 23:59:59 2009 GMT', 'subject': ((('serialNumber', u'2497886'),), @@ -531,9 +518,9 @@ Server-side operation ^^^^^^^^^^^^^^^^^^^^^ -For server operation, typically you'd need to have a server certificate, and private key, each in a file. -You'd open a socket, bind it to a port, call :meth:`listen` on it, then start waiting for clients -to connect:: +For server operation, typically you'd need to have a server certificate, and +private key, each in a file. You'd open a socket, bind it to a port, call +:meth:`listen` on it, then start waiting for clients to connect:: import socket, ssl @@ -541,8 +528,9 @@ bindsocket.bind(('myaddr.mydomain.com', 10023)) bindsocket.listen(5) -When one did, you'd call :meth:`accept` on the socket to get the new socket from the other -end, and use :func:`wrap_socket` to create a server-side SSL context for it:: +When one did, you'd call :meth:`accept` on the socket to get the new socket from +the other end, and use :func:`wrap_socket` to create a server-side SSL context +for it:: while True: newsocket, fromaddr = bindsocket.accept() @@ -553,7 +541,8 @@ ssl_version=ssl.PROTOCOL_TLSv1) deal_with_client(connstream) -Then you'd read data from the ``connstream`` and do something with it till you are finished with the client (or the client is finished with you):: +Then you'd read data from the ``connstream`` and do something with it till you +are finished with the client (or the client is finished with you):: def deal_with_client(connstream): Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 15:50:20 2009 @@ -1754,7 +1754,7 @@ .. method:: update(other, ...) set |= other | ... - Update the set, adding elements from *other*. + Update the set, adding elements from all others. .. versionchanged:: 2.6 Accepts multiple input iterables. @@ -1762,7 +1762,7 @@ .. method:: intersection_update(other, ...) set &= other & ... - Update the set, keeping only elements found in it and *other*. + Update the set, keeping only elements found in it and all others. .. versionchanged:: 2.6 Accepts multiple input iterables. @@ -2050,7 +2050,7 @@ :func:`update` accepts either another dictionary object or an iterable of key/value pairs (as a tuple or other iterable of length two). If keyword - arguments are specified, the dictionary is then is updated with those + arguments are specified, the dictionary is then updated with those key/value pairs: ``d.update(red=1, blue=2)``. .. versionchanged:: 2.4 @@ -2440,9 +2440,9 @@ their implementation of the context management protocol. See the :mod:`contextlib` module for some examples. -Python's :term:`generator`\s and the ``contextlib.contextfactory`` :term:`decorator` +Python's :term:`generator`\s and the ``contextlib.contextmanager`` :term:`decorator` provide a convenient way to implement these protocols. If a generator function is -decorated with the ``contextlib.contextfactory`` decorator, it will return a +decorated with the ``contextlib.contextmanager`` decorator, it will return a context manager implementing the necessary :meth:`__enter__` and :meth:`__exit__` methods, rather than the iterator produced by an undecorated generator function. Modified: python/branches/release26-maint/Doc/library/string.rst ============================================================================== --- python/branches/release26-maint/Doc/library/string.rst (original) +++ python/branches/release26-maint/Doc/library/string.rst Tue Oct 27 15:50:20 2009 @@ -243,7 +243,6 @@ Some simple format string examples:: "First, thou shalt count to {0}" # References first positional argument - "Bring me a {}" # Implicitly references the first positional argument "My quest is {name}" # References keyword argument 'name' "Weight in tons {0.weight}" # 'weight' attribute of first positional arg "Units destroyed: {players[0]}" # First element of keyword argument 'players'. Modified: python/branches/release26-maint/Doc/library/sys.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sys.rst (original) +++ python/branches/release26-maint/Doc/library/sys.rst Tue Oct 27 15:50:20 2009 @@ -417,7 +417,8 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. + This function should be used for internal and specialized purposes only. It + is not guaranteed to exist in all implementations of Python. .. function:: getprofile() Modified: python/branches/release26-maint/Doc/library/thread.rst ============================================================================== --- python/branches/release26-maint/Doc/library/thread.rst (original) +++ python/branches/release26-maint/Doc/library/thread.rst Tue Oct 27 15:50:20 2009 @@ -156,7 +156,7 @@ module is available, interrupts always go to the main thread.) * Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is - equivalent to calling :func:`exit`. + equivalent to calling :func:`thread.exit`. * Not all built-in functions that may block waiting for I/O allow other threads to run. (The most popular ones (:func:`time.sleep`, :meth:`file.read`, Modified: python/branches/release26-maint/Doc/library/urllib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/urllib.rst (original) +++ python/branches/release26-maint/Doc/library/urllib.rst Tue Oct 27 15:50:20 2009 @@ -205,9 +205,10 @@ .. function:: quote(string[, safe]) Replace special characters in *string* using the ``%xx`` escape. Letters, - digits, and the characters ``'_.-'`` are never quoted. The optional *safe* - parameter specifies additional characters that should not be quoted --- its - default value is ``'/'``. + digits, and the characters ``'_.-'`` are never quoted. By default, this + function is intended for quoting the path section of the URL.The optional + *safe* parameter specifies additional characters that should not be quoted + --- its default value is ``'/'``. Example: ``quote('/~connolly/')`` yields ``'/%7econnolly/'``. Modified: python/branches/release26-maint/Doc/library/warnings.rst ============================================================================== --- python/branches/release26-maint/Doc/library/warnings.rst (original) +++ python/branches/release26-maint/Doc/library/warnings.rst Tue Oct 27 15:50:20 2009 @@ -1,4 +1,3 @@ - :mod:`warnings` --- Warning control =================================== @@ -129,16 +128,16 @@ +---------------+----------------------------------------------+ * *message* is a string containing a regular expression that the warning message - must match (the match is compiled to always be case-insensitive) + must match (the match is compiled to always be case-insensitive). * *category* is a class (a subclass of :exc:`Warning`) of which the warning - category must be a subclass in order to match + category must be a subclass in order to match. * *module* is a string containing a regular expression that the module name must - match (the match is compiled to be case-sensitive) + match (the match is compiled to be case-sensitive). * *lineno* is an integer that the line number where the warning occurred must - match, or ``0`` to match all line numbers + match, or ``0`` to match all line numbers. Since the :exc:`Warning` class is derived from the built-in :exc:`Exception` class, to turn a warning into an error we simply raise ``category(message)``. @@ -300,10 +299,11 @@ .. function:: formatwarning(message, category, filename, lineno[, line]) - Format a warning the standard way. This returns a string which may contain - embedded newlines and ends in a newline. *line* is - a line of source code to be included in the warning message; if *line* is not supplied, - :func:`formatwarning` will try to read the line specified by *filename* and *lineno*. + Format a warning the standard way. This returns a string which may contain + embedded newlines and ends in a newline. *line* is a line of source code to + be included in the warning message; if *line* is not supplied, + :func:`formatwarning` will try to read the line specified by *filename* and + *lineno*. .. versionchanged:: 2.6 Added the *line* argument. @@ -311,10 +311,11 @@ .. function:: filterwarnings(action[, message[, category[, module[, lineno[, append]]]]]) - Insert an entry into the list of warnings filters. The entry is inserted at the - front by default; if *append* is true, it is inserted at the end. This checks - the types of the arguments, compiles the message and module regular expressions, - and inserts them as a tuple in the list of warnings filters. Entries closer to + Insert an entry into the list of :ref:`warnings filter specifications + `. The entry is inserted at the front by default; if + *append* is true, it is inserted at the end. This checks the types of the + arguments, compiles the *message* and *module* regular expressions, and + inserts them as a tuple in the list of warnings filters. Entries closer to the front of the list override entries later in the list, if both match a particular warning. Omitted arguments default to a value that matches everything. @@ -322,10 +323,11 @@ .. function:: simplefilter(action[, category[, lineno[, append]]]) - Insert a simple entry into the list of warnings filters. The meaning of the - function parameters is as for :func:`filterwarnings`, but regular expressions - are not needed as the filter inserted always matches any message in any module - as long as the category and line number match. + Insert a simple entry into the list of :ref:`warnings filter specifications + `. The meaning of the function parameters is as for + :func:`filterwarnings`, but regular expressions are not needed as the filter + inserted always matches any message in any module as long as the category and + line number match. .. function:: resetwarnings() Modified: python/branches/release26-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release26-maint/Doc/reference/datamodel.rst Tue Oct 27 15:50:20 2009 @@ -959,6 +959,8 @@ If a code object represents a function, the first item in :attr:`co_consts` is the documentation string of the function, or ``None`` if undefined. + .. _frame-objects: + Frame objects .. index:: object: frame Modified: python/branches/release26-maint/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/simple_stmts.rst (original) +++ python/branches/release26-maint/Doc/reference/simple_stmts.rst Tue Oct 27 15:50:20 2009 @@ -151,11 +151,30 @@ * If the target is an attribute reference: The primary expression in the reference is evaluated. It should yield an object with assignable attributes; - if this is not the case, :exc:`TypeError` is raised. That object is then asked - to assign the assigned object to the given attribute; if it cannot perform the - assignment, it raises an exception (usually but not necessarily + if this is not the case, :exc:`TypeError` is raised. That object is then + asked to assign the assigned object to the given attribute; if it cannot + perform the assignment, it raises an exception (usually but not necessarily :exc:`AttributeError`). + .. _attr-target-note: + + Note: If the object is a class instance and the attribute reference occurs on + both sides of the assignment operator, the RHS expression, ``a.x`` can access + either an instance attribute or (if no instance attribute exists) a class + attribute. The LHS target ``a.x`` is always set as an instance attribute, + creating it if necessary. Thus, the two occurrences of ``a.x`` do not + necessarily refer to the same attribute: if the RHS expression refers to a + class attribute, the LHS creates a new instance attribute as the target of the + assignment:: + + class Cls: + x = 3 # class variable + inst = Cls() + inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3 + + This description does not necessarily apply to descriptor attributes, such as + properties created with :func:`property`. + .. index:: pair: subscription; assignment object: mutable @@ -253,16 +272,8 @@ *in-place* behavior, the binary operation performed by augmented assignment is the same as the normal binary operations. -For targets which are attribute references, the initial value is retrieved with -a :meth:`getattr` and the result is assigned with a :meth:`setattr`. Notice -that the two methods do not necessarily refer to the same variable. When -:meth:`getattr` refers to a class variable, :meth:`setattr` still writes to an -instance variable. For example:: - - class A: - x = 3 # class variable - a = A() - a.x += 1 # writes a.x as 4 leaving A.x as 3 +For targets which are attribute references, the same :ref:`caveat about class +and instance attributes ` applies as for regular assignments. .. _assert: Modified: python/branches/release26-maint/Doc/tutorial/classes.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/classes.rst (original) +++ python/branches/release26-maint/Doc/tutorial/classes.rst Tue Oct 27 15:50:20 2009 @@ -50,8 +50,8 @@ .. _tut-scopes: -Python Scopes and Name Spaces -============================= +Python Scopes and Namespaces +============================ Before introducing classes, I first have to tell you something about Python's scope rules. Class definitions play some neat tricks with namespaces, and you @@ -86,7 +86,7 @@ :keyword:`del` statement. For example, ``del modname.the_answer`` will remove the attribute :attr:`the_answer` from the object named by ``modname``. -Name spaces are created at different moments and have different lifetimes. The +Namespaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created when the Python interpreter starts up, and is never deleted. The global namespace for a module is created when the module definition is read in; normally, module namespaces also last @@ -331,9 +331,9 @@ attribute that is a function object, a method object is created by packing (pointers to) the instance object and the function object just found together in an abstract object: this is the method object. When the method object is called -with an argument list, it is unpacked again, a new argument list is constructed -from the instance object and the original argument list, and the function object -is called with this new argument list. +with an argument list, a new argument list is constructed from the instance +object and the argument list, and the function object is called with this new +argument list. .. _tut-remarks: Modified: python/branches/release26-maint/Doc/tutorial/errors.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/errors.rst (original) +++ python/branches/release26-maint/Doc/tutorial/errors.rst Tue Oct 27 15:50:20 2009 @@ -165,14 +165,11 @@ The except clause may specify a variable after the exception name (or tuple). The variable is bound to an exception instance with the arguments stored in ``instance.args``. For convenience, the exception instance defines -:meth:`__getitem__` and :meth:`__str__` so the arguments can be accessed or -printed directly without having to reference ``.args``. +:meth:`__str__` so the arguments can be printed directly without having to +reference ``.args``. -But use of ``.args`` is discouraged. Instead, the preferred use is to pass a -single argument to an exception (which can be a tuple if multiple arguments are -needed) and have it bound to the ``message`` attribute. One may also -instantiate an exception first before raising it and add any attributes to it as -desired. :: +One may also instantiate an exception first before raising it and add any +attributes to it as desired. :: >>> try: ... raise Exception('spam', 'eggs') @@ -248,9 +245,10 @@ User-defined Exceptions ======================= -Programs may name their own exceptions by creating a new exception class. -Exceptions should typically be derived from the :exc:`Exception` class, either -directly or indirectly. For example:: +Programs may name their own exceptions by creating a new exception class (see +:ref:`tut-classes` for more about Python classes). Exceptions should typically +be derived from the :exc:`Exception` class, either directly or indirectly. For +example:: >>> class MyError(Exception): ... def __init__(self, value): @@ -288,28 +286,28 @@ """Exception raised for errors in the input. Attributes: - expression -- input expression in which the error occurred - message -- explanation of the error + expr -- input expression in which the error occurred + msg -- explanation of the error """ - def __init__(self, expression, message): - self.expression = expression - self.message = message + def __init__(self, expr, msg): + self.expr = expr + self.msg = msg class TransitionError(Error): """Raised when an operation attempts a state transition that's not allowed. Attributes: - previous -- state at beginning of transition + prev -- state at beginning of transition next -- attempted new state - message -- explanation of why the specific transition is not allowed + msg -- explanation of why the specific transition is not allowed """ - def __init__(self, previous, next, message): - self.previous = previous + def __init__(self, prev, next, msg): + self.prev = prev self.next = next - self.message = message + self.msg = msg Most exceptions are defined with names that end in "Error," similar to the naming of the standard exceptions. Modified: python/branches/release26-maint/Doc/tutorial/inputoutput.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/inputoutput.rst (original) +++ python/branches/release26-maint/Doc/tutorial/inputoutput.rst Tue Oct 27 15:50:20 2009 @@ -123,11 +123,11 @@ Basic usage of the :meth:`str.format` method looks like this:: - >>> print 'We are the {0} who say "{1}!"'.format('knights', 'Ni') + >>> print 'We are the {} who say "{}!"'.format('knights', 'Ni') We are the knights who say "Ni!" The brackets and characters within them (called format fields) are replaced with -the objects passed into the :meth:`~str.format` method. The number in the +the objects passed into the :meth:`~str.format` method. A number in the brackets refers to the position of the object passed into the :meth:`~str.format` method. :: @@ -149,6 +149,15 @@ ... other='Georg') The story of Bill, Manfred, and Georg. +``'!s'`` (apply :func:`str`) and ``'!r'`` (apply :func:`repr`) can be used to +convert the value before it is formatted. :: + + >>> import math + >>> print 'The value of PI is approximately {}.'.format(math.pi) + The value of PI is approximately 3.14159265359. + >>> print 'The value of PI is approximately {!r}.'.format(math.pi) + The value of PI is approximately 3.141592653589793. + An optional ``':'`` and format specifier can follow the field name. This allows greater control over how the value is formatted. The following example truncates Pi to three places after the decimal. @@ -239,8 +248,8 @@ omitted. On Windows, ``'b'`` appended to the mode opens the file in binary mode, so there -are also modes like ``'rb'``, ``'wb'``, and ``'r+b'``. Windows makes a -distinction between text and binary files; the end-of-line characters in text +are also modes like ``'rb'``, ``'wb'``, and ``'r+b'``. Python on Windows makes +a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written. This behind-the-scenes modification to file data is fine for ASCII text files, but it'll corrupt binary data like that in :file:`JPEG` or :file:`EXE` files. Be Modified: python/branches/release26-maint/Doc/tutorial/introduction.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/introduction.rst (original) +++ python/branches/release26-maint/Doc/tutorial/introduction.rst Tue Oct 27 15:50:20 2009 @@ -138,7 +138,6 @@ 4.0 >>> abs(a) # sqrt(a.real**2 + a.imag**2) 5.0 - >>> In interactive mode, the last printed expression is assigned to the variable ``_``. This means that when you are using Python as a desk calculator, it is @@ -152,7 +151,6 @@ 113.0625 >>> round(_, 2) 113.06 - >>> This variable should be treated as read-only by the user. Don't explicitly assign a value to it --- you would create an independent local variable with the @@ -193,7 +191,9 @@ Note that newlines still need to be embedded in the string using ``\n``; the newline following the trailing backslash is discarded. This example would print -the following:: +the following: + +.. code-block:: text This is a rather long string containing several lines of text just as you would do in C. @@ -209,7 +209,9 @@ -H hostname Hostname to connect to """ -produces the following output:: +produces the following output: + +.. code-block:: text Usage: thingy [OPTIONS] -h Display this usage message @@ -224,7 +226,9 @@ print hello -would print:: +would print: + +.. code-block:: text This is a rather long string containing\n\ several lines of text much as you would do in C. Modified: python/branches/release26-maint/Doc/tutorial/modules.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/modules.rst (original) +++ python/branches/release26-maint/Doc/tutorial/modules.rst Tue Oct 27 15:50:20 2009 @@ -103,6 +103,10 @@ This imports all names except those beginning with an underscore (``_``). +Note that in general the practice of importing ``*`` from a module or package is +frowned upon, since it often causes poorly readable code. However, it is okay to +use it to save typing in interactive sessions. + .. note:: For efficiency reasons, each module is only imported once per interpreter @@ -443,14 +447,9 @@ Now what happens when the user writes ``from sound.effects import *``? Ideally, one would hope that this somehow goes out to the filesystem, finds which -submodules are present in the package, and imports them all. Unfortunately, -this operation does not work very well on Windows platforms, where the -filesystem does not always have accurate information about the case of a -filename. On these platforms, there is no guaranteed way to know whether a file -:file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or -:mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all -file names with a capitalized first letter.) The DOS 8+3 filename restriction -adds another interesting problem for long module names. +submodules are present in the package, and imports them all. This could take a +long time and importing sub-modules might have unwanted side-effects that should +only happen when the sub-module is explicitly imported. The only solution is for the package author to provide an explicit index of the package. The :keyword:`import` statement uses the following convention: if a package's @@ -485,10 +484,9 @@ when the ``from...import`` statement is executed. (This also works when ``__all__`` is defined.) -Note that in general the practice of importing ``*`` from a module or package is -frowned upon, since it often causes poorly readable code. However, it is okay to -use it to save typing in interactive sessions, and certain modules are designed -to export only names that follow certain patterns. +Although certain modules are designed to export only names that follow certain +patterns when you use ``import *``, it is still considered bad practise in +production code. Remember, there is nothing wrong with using ``from Package import specific_submodule``! In fact, this is the recommended notation unless the From python-checkins at python.org Tue Oct 27 15:56:32 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:56:32 -0000 Subject: [Python-checkins] r75789 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 15:56:32 2009 New Revision: 75789 Log: Blocked revisions 74000-74001,74006,74150,74152,74173,74365,74513,74524,74556,74625,74733-74734,74780,74783,74785-74786 via svnmerge ........ r74000 | amaury.forgeotdarc | 2009-07-13 22:01:11 +0200 (Mo, 13 Jul 2009) | 4 lines #1616979: Add the cp720 (Arabic DOS) encoding. Since there is no official mapping file from unicode.org, the codec file is generated on Windows with the new genwincodec.py script. ........ r74001 | amaury.forgeotdarc | 2009-07-13 22:03:21 +0200 (Mo, 13 Jul 2009) | 2 lines NEWS entry for r74000. ........ r74006 | amaury.forgeotdarc | 2009-07-14 01:11:54 +0200 (Di, 14 Jul 2009) | 2 lines Document the newly added codec ........ r74150 | benjamin.peterson | 2009-07-22 01:13:14 +0200 (Mi, 22 Jul 2009) | 1 line install unittest as a package ........ r74152 | benjamin.peterson | 2009-07-22 02:03:43 +0200 (Mi, 22 Jul 2009) | 1 line simplify ........ r74173 | benjamin.peterson | 2009-07-22 18:34:37 +0200 (Mi, 22 Jul 2009) | 1 line revert r74152 ........ r74365 | georg.brandl | 2009-08-13 09:48:05 +0200 (Do, 13 Aug 2009) | 1 line #6679: Remove mention that sub supports no flags. ........ r74513 | skip.montanaro | 2009-08-18 16:37:52 +0200 (Di, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74524 | gregory.p.smith | 2009-08-20 11:39:38 +0200 (Do, 20 Aug 2009) | 2 lines Add weakref support to the thread.lock type. ........ r74556 | kristjan.jonsson | 2009-08-28 00:20:21 +0200 (Fr, 28 Aug 2009) | 2 lines issue 6275 Add an "exc_value" attribute to the _AssertRaisesContext context manager in the unittest package. This allows further tests on the exception that was raised after the context manager exits. ........ r74625 | benjamin.peterson | 2009-09-02 00:27:57 +0200 (Mi, 02 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74733 | benjamin.peterson | 2009-09-09 13:40:54 +0200 (Mi, 09 Sep 2009) | 1 line tabbify ........ r74734 | benjamin.peterson | 2009-09-09 13:42:57 +0200 (Mi, 09 Sep 2009) | 1 line revert unintended changes ........ r74780 | michael.foord | 2009-09-13 18:40:02 +0200 (So, 13 Sep 2009) | 1 line Objects that compare equal automatically pass or fail assertAlmostEqual and assertNotAlmostEqual tests on unittest.TestCase. Issue 6567. ........ r74783 | michael.foord | 2009-09-13 19:28:35 +0200 (So, 13 Sep 2009) | 1 line unittest.TestLoader.loadTestsFromName honors the loader suiteClass attribute. Issue 6866. ........ r74785 | michael.foord | 2009-09-13 21:07:03 +0200 (So, 13 Sep 2009) | 1 line Test discovery in unittest will only attempt to import modules that are importable; i.e. their names are valid Python identifiers. If an import fails during discovery this will be recorded as an error and test discovery will continue. Issue 6568. ........ r74786 | michael.foord | 2009-09-13 21:08:18 +0200 (So, 13 Sep 2009) | 1 line Remove an extraneous space in unittest documentation. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 15:59:27 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 14:59:27 -0000 Subject: [Python-checkins] r75790 - in python/branches/release26-maint: Doc/c-api/unicode.rst Doc/documenting/markup.rst Doc/extending/extending.rst Doc/library/bdb.rst Doc/library/codecs.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/logging.rst Doc/library/pdb.rst Doc/library/shelve.rst Doc/library/string.rst Doc/library/termios.rst Doc/library/threading.rst Doc/tutorial/interpreter.rst Doc/whatsnew/2.6.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 15:59:26 2009 New Revision: 75790 Log: Merged revisions 74861-74863,74876,74896,74930,74933,74952-74953,75015,75019,75260-75263,75265-75266,75289 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74861 | benjamin.peterson | 2009-09-17 05:18:28 +0200 (Do, 17 Sep 2009) | 1 line pep 8 defaults ........ r74862 | brett.cannon | 2009-09-17 05:24:45 +0200 (Do, 17 Sep 2009) | 1 line Note in the intro to Extending... that ctypes can be a simpler, more portable solution than custom C code. ........ r74863 | benjamin.peterson | 2009-09-17 05:27:33 +0200 (Do, 17 Sep 2009) | 1 line rationalize a bit ........ r74876 | georg.brandl | 2009-09-17 18:15:53 +0200 (Do, 17 Sep 2009) | 1 line #6932: remove paragraph that advises relying on __del__ being called. ........ r74896 | georg.brandl | 2009-09-18 09:22:41 +0200 (Fr, 18 Sep 2009) | 1 line #6936: for interactive use, quit() is just fine. ........ r74930 | georg.brandl | 2009-09-18 23:21:41 +0200 (Fr, 18 Sep 2009) | 1 line #6925: rewrite docs for locals() and vars() a bit. ........ r74933 | georg.brandl | 2009-09-18 23:35:59 +0200 (Fr, 18 Sep 2009) | 1 line #6930: clarify description about byteorder handling in UTF decoder routines. ........ r74952 | georg.brandl | 2009-09-19 12:42:34 +0200 (Sa, 19 Sep 2009) | 1 line #6946: fix duplicate index entries for datetime classes. ........ r74953 | georg.brandl | 2009-09-19 14:04:16 +0200 (Sa, 19 Sep 2009) | 1 line Fix references to threading.enumerate(). ........ r75015 | georg.brandl | 2009-09-22 12:55:08 +0200 (Di, 22 Sep 2009) | 1 line Fix encoding name. ........ r75019 | vinay.sajip | 2009-09-22 19:23:41 +0200 (Di, 22 Sep 2009) | 1 line Fixed a typo, and added sections on optimization and using arbitrary objects as messages. ........ r75260 | andrew.kuchling | 2009-10-05 23:24:20 +0200 (Mo, 05 Okt 2009) | 1 line Wording fix ........ r75261 | andrew.kuchling | 2009-10-05 23:24:35 +0200 (Mo, 05 Okt 2009) | 1 line Fix narkup ........ r75262 | andrew.kuchling | 2009-10-05 23:25:03 +0200 (Mo, 05 Okt 2009) | 1 line Document 'skip' parameter to constructor ........ r75263 | andrew.kuchling | 2009-10-05 23:25:35 +0200 (Mo, 05 Okt 2009) | 1 line Note side benefit of socket.create_connection() ........ r75265 | andrew.kuchling | 2009-10-06 00:31:11 +0200 (Di, 06 Okt 2009) | 1 line Reword sentence ........ r75266 | andrew.kuchling | 2009-10-06 00:32:48 +0200 (Di, 06 Okt 2009) | 1 line Use standard comma punctuation; reword some sentences in the docs ........ r75289 | mark.dickinson | 2009-10-08 22:02:25 +0200 (Do, 08 Okt 2009) | 2 lines Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/c-api/unicode.rst python/branches/release26-maint/Doc/documenting/markup.rst python/branches/release26-maint/Doc/extending/extending.rst python/branches/release26-maint/Doc/library/bdb.rst python/branches/release26-maint/Doc/library/codecs.rst python/branches/release26-maint/Doc/library/datetime.rst python/branches/release26-maint/Doc/library/functions.rst python/branches/release26-maint/Doc/library/logging.rst python/branches/release26-maint/Doc/library/pdb.rst python/branches/release26-maint/Doc/library/shelve.rst python/branches/release26-maint/Doc/library/string.rst python/branches/release26-maint/Doc/library/termios.rst python/branches/release26-maint/Doc/library/threading.rst python/branches/release26-maint/Doc/tutorial/interpreter.rst python/branches/release26-maint/Doc/whatsnew/2.6.rst Modified: python/branches/release26-maint/Doc/c-api/unicode.rst ============================================================================== --- python/branches/release26-maint/Doc/c-api/unicode.rst (original) +++ python/branches/release26-maint/Doc/c-api/unicode.rst Tue Oct 27 15:59:26 2009 @@ -414,10 +414,13 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first four bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the end of input data. + If ``*byteorder`` is zero, and the first four bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output. + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. In a narrow build codepoints outside the BMP will be decoded as surrogate pairs. @@ -442,8 +445,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-32 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) @@ -487,10 +489,14 @@ *byteorder == 0: native order *byteorder == 1: big endian - and then switches if the first two bytes of the input data are a byte order mark - (BOM) and the specified byte order is native order. This BOM is not copied into - the resulting Unicode string. After completion, *\*byteorder* is set to the - current byte order at the. + If ``*byteorder`` is zero, and the first two bytes of the input data are a + byte order mark (BOM), the decoder switches to this byte order and the BOM is + not copied into the resulting Unicode string. If ``*byteorder`` is ``-1`` or + ``1``, any byte order mark is copied to the output (where it will result in + either a ``\ufeff`` or a ``\ufffe`` character). + + After completion, *\*byteorder* is set to the current byte order at the end + of input data. If *byteorder* is *NULL*, the codec starts in native order mode. @@ -520,8 +526,7 @@ .. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python string object holding the UTF-16 encoded value of the Unicode - data in *s*. If *byteorder* is not ``0``, output is written according to the - following byte order:: + data in *s*. Output is written according to the following byte order:: byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) Modified: python/branches/release26-maint/Doc/documenting/markup.rst ============================================================================== --- python/branches/release26-maint/Doc/documenting/markup.rst (original) +++ python/branches/release26-maint/Doc/documenting/markup.rst Tue Oct 27 15:59:26 2009 @@ -597,8 +597,10 @@ An important bit of information about an API that a user should be aware of when using whatever bit of API the warning pertains to. The content of the directive should be written in complete sentences and include all appropriate - punctuation. This should only be chosen over ``note`` for information - regarding the possibility of crashes, data loss, or security implications. + punctuation. In the interest of not scaring users away from pages filled + with warnings, this directive should only be chosen over ``note`` for + information regarding the possibility of crashes, data loss, or security + implications. .. describe:: versionadded Modified: python/branches/release26-maint/Doc/extending/extending.rst ============================================================================== --- python/branches/release26-maint/Doc/extending/extending.rst (original) +++ python/branches/release26-maint/Doc/extending/extending.rst Tue Oct 27 15:59:26 2009 @@ -20,6 +20,13 @@ The compilation of an extension module depends on its intended use as well as on your system setup; details are given in later chapters. +Do note that if your use case is calling C library functions or system calls, +you should consider using the :mod:`ctypes` module rather than writing custom +C code. Not only does :mod:`ctypes` let you write Python code to interface +with C code, but it is more portable between implementations of Python than +writing and compiling an extension module which typically ties you to CPython. + + .. _extending-simpleexample: Modified: python/branches/release26-maint/Doc/library/bdb.rst ============================================================================== --- python/branches/release26-maint/Doc/library/bdb.rst (original) +++ python/branches/release26-maint/Doc/library/bdb.rst Tue Oct 27 15:59:26 2009 @@ -62,14 +62,22 @@ * The breakpoint hit count. -.. class:: Bdb() +.. class:: Bdb(skip=None) - The :class:`Bdb` acts as a generic Python debugger base class. + The :class:`Bdb` class acts as a generic Python debugger base class. This class takes care of the details of the trace facility; a derived class should implement user interaction. The standard debugger class (:class:`pdb.Pdb`) is an example. + The *skip* argument, if given, must be an iterable of glob-style + module name patterns. The debugger will not step into frames that + originate in a module that matches one of these patterns. Whether a + frame is considered to originate in a certain module is determined + by the ``__name__`` in the frame globals. + + .. versionadded:: 2.7 + The *skip* argument. The following methods of :class:`Bdb` normally don't need to be overridden. Modified: python/branches/release26-maint/Doc/library/codecs.rst ============================================================================== --- python/branches/release26-maint/Doc/library/codecs.rst (original) +++ python/branches/release26-maint/Doc/library/codecs.rst Tue Oct 27 15:59:26 2009 @@ -958,7 +958,7 @@ +-----------------+--------------------------------+--------------------------------+ | cp1255 | windows-1255 | Hebrew | +-----------------+--------------------------------+--------------------------------+ -| cp1256 | windows1256 | Arabic | +| cp1256 | windows-1256 | Arabic | +-----------------+--------------------------------+--------------------------------+ | cp1257 | windows-1257 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ Modified: python/branches/release26-maint/Doc/library/datetime.rst ============================================================================== --- python/branches/release26-maint/Doc/library/datetime.rst (original) +++ python/branches/release26-maint/Doc/library/datetime.rst Tue Oct 27 15:59:26 2009 @@ -65,6 +65,7 @@ .. class:: date + :noindex: An idealized naive date, assuming the current Gregorian calendar always was, and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, and @@ -72,6 +73,7 @@ .. class:: time + :noindex: An idealized time, independent of any particular day, assuming that every day has exactly 24\*60\*60 seconds (there is no notion of "leap seconds" here). @@ -80,6 +82,7 @@ .. class:: datetime + :noindex: A combination of a date and a time. Attributes: :attr:`year`, :attr:`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:`microsecond`, @@ -87,6 +90,7 @@ .. class:: timedelta + :noindex: A duration expressing the difference between two :class:`date`, :class:`time`, or :class:`datetime` instances to microsecond resolution. Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Tue Oct 27 15:59:26 2009 @@ -637,15 +637,13 @@ .. function:: locals() Update and return a dictionary representing the current local symbol table. + Free variables are returned by :func:`locals` when it is called in function + blocks, but not in class blocks. .. note:: - The contents of this dictionary should not be modified; changes may not affect - the values of local variables used by the interpreter. - - Free variables are returned by :func:`locals` when it is called in a function block. - Modifications of free variables may not affect the values used by the - interpreter. Free variables are not returned in class blocks. + The contents of this dictionary should not be modified; changes may not + affect the values of local and free variables used by the interpreter. .. function:: long([x[, base]]) @@ -1357,10 +1355,10 @@ .. function:: vars([object]) - Without arguments, return a dictionary corresponding to the current local symbol - table. With a module, class or class instance object as argument (or anything - else that has a :attr:`__dict__` attribute), returns a dictionary corresponding - to the object's symbol table. + Without an argument, act like :func:`locals`. + + With a module, class or class instance object as argument (or anything else that + has a :attr:`__dict__` attribute), return that attribute. .. note:: 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 Tue Oct 27 15:59:26 2009 @@ -59,7 +59,7 @@ import logging LOG_FILENAME = '/tmp/logging_example.out' - logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('This message should go to the log file') @@ -1499,6 +1499,53 @@ 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly. +Using arbitrary objects as messages +----------------------------------- + +In the preceding sections and examples, it has been assumed that the message +passed when logging the event is a string. However, this is not the only +possibility. You can pass an arbitrary object as a message, and its +:meth:`__str__` method will be called when the logging system needs to convert +it to a string representation. In fact, if you want to, you can avoid +computing a string representation altogether - for example, the +:class:`SocketHandler` emits an event by pickling it and sending it over the +wire. + +Optimization +------------ + +Formatting of message arguments is deferred until it cannot be avoided. +However, computing the arguments passed to the logging method can also be +expensive, and you may want to avoid doing it if the logger will just throw +away your event. To decide what to do, you can call the :meth:`isEnabledFor` +method which takes a level argument and returns true if the event would be +created by the Logger for that level of call. You can write code like this:: + + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Message with %s, %s", expensive_func1(), + expensive_func2()) + +so that if the logger's threshold is set above ``DEBUG``, the calls to +:func:`expensive_func1` and :func:`expensive_func2` are never made. + +There are other optimizations which can be made for specific applications which +need more precise control over what logging information is collected. Here's a +list of things you can do to avoid processing during logging which you don't +need: + ++-----------------------------------------------+----------------------------------------+ +| What you don't want to collect | How to avoid collecting it | ++===============================================+========================================+ +| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. | ++-----------------------------------------------+----------------------------------------+ +| Threading information. | Set ``logging.logThreads`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ +| Process information. | Set ``logging.logProcesses`` to ``0``. | ++-----------------------------------------------+----------------------------------------+ + +Also note that the core logging module only includes the basic handlers. If +you don't import :mod:`logging.handlers` and :mod:`logging.config`, they won't +take up any memory. .. _handler: Modified: python/branches/release26-maint/Doc/library/pdb.rst ============================================================================== --- python/branches/release26-maint/Doc/library/pdb.rst (original) +++ python/branches/release26-maint/Doc/library/pdb.rst Tue Oct 27 15:59:26 2009 @@ -53,7 +53,16 @@ .. versionadded:: 2.4 Restarting post-mortem behavior added. -Typical usage to inspect a crashed program is:: +The typical usage to break into the debugger from a running program is to +insert :: + + import pdb; pdb.set_trace() + +at the location you want to break into the debugger. You can then step through +the code following this statement, and continue running without the debugger using +the ``c`` command. + +The typical usage to inspect a crashed program is:: >>> import pdb >>> import mymodule Modified: python/branches/release26-maint/Doc/library/shelve.rst ============================================================================== --- python/branches/release26-maint/Doc/library/shelve.rst (original) +++ python/branches/release26-maint/Doc/library/shelve.rst Tue Oct 27 15:59:26 2009 @@ -30,27 +30,39 @@ Because of Python semantics, a shelf cannot know when a mutable persistent-dictionary entry is modified. By default modified objects are - written only when assigned to the shelf (see :ref:`shelve-example`). If - the optional *writeback* parameter is set to *True*, all entries accessed - are cached in memory, and written back at close time; this can make it - handier to mutate mutable entries in the persistent dictionary, but, if - many entries are accessed, it can consume vast amounts of memory for the - cache, and it can make the close operation very slow since all accessed - entries are written back (there is no way to determine which accessed - entries are mutable, nor which ones were actually mutated). + written only when assigned to the shelf (see :ref:`shelve-example`). If the + optional *writeback* parameter is set to *True*, all entries accessed are + cached in memory, and written back on :meth:`sync` and :meth:`close`; this + can make it handier to mutate mutable entries in the persistent dictionary, + but, if many entries are accessed, it can consume vast amounts of memory for + the cache, and it can make the close operation very slow since all accessed + entries are written back (there is no way to determine which accessed entries + are mutable, nor which ones were actually mutated). + + .. note:: + + Do not rely on the shelf being closed automatically; always call + :meth:`close` explicitly when you don't need it any more, or use a + :keyword:`with` statement with :func:`contextlib.closing`. + Shelf objects support all methods supported by dictionaries. This eases the transition from dictionary based scripts to those requiring persistent storage. -One additional method is supported: - +Two additional methods are supported: .. method:: Shelf.sync() - Write back all entries in the cache if the shelf was opened with *writeback* set - to *True*. Also empty the cache and synchronize the persistent dictionary on - disk, if feasible. This is called automatically when the shelf is closed with - :meth:`close`. + Write back all entries in the cache if the shelf was opened with *writeback* + set to :const:`True`. Also empty the cache and synchronize the persistent + dictionary on disk, if feasible. This is called automatically when the shelf + is closed with :meth:`close`. + +.. method:: Shelf.close() + + Synchronize and close the persistent *dict* object. Operations on a closed + shelf will fail with a :exc:`ValueError`. + .. seealso:: @@ -75,11 +87,6 @@ database should be fairly small, and in rare cases key collisions may cause the database to refuse updates. -* Depending on the implementation, closing a persistent dictionary may or may - not be necessary to flush changes to disk. The :meth:`__del__` method of the - :class:`Shelf` class calls the :meth:`close` method, so the programmer generally - need not do this explicitly. - * The :mod:`shelve` module does not support *concurrent* read/write access to shelved objects. (Multiple simultaneous read accesses are safe.) When a program has a shelf open for writing, no other program should have it open for Modified: python/branches/release26-maint/Doc/library/string.rst ============================================================================== --- python/branches/release26-maint/Doc/library/string.rst (original) +++ python/branches/release26-maint/Doc/library/string.rst Tue Oct 27 15:59:26 2009 @@ -435,15 +435,33 @@ +---------+----------------------------------------------------------+ | ``'F'`` | Fixed point. Same as ``'f'``. | +---------+----------------------------------------------------------+ - | ``'g'`` | General format. This prints the number as a fixed-point | - | | number, unless the number is too large, in which case | - | | it switches to ``'e'`` exponent notation. Infinity and | - | | NaN values are formatted as ``inf``, ``-inf`` and | - | | ``nan``, respectively. | + | ``'g'`` | General format. For a given precision ``p >= 1``, | + | | this rounds the number to ``p`` significant digits and | + | | then formats the result in either fixed-point format | + | | or in scientific notation, depending on its magnitude. | + | | | + | | The precise rules are as follows: suppose that the | + | | result formatted with presentation type ``'e'`` and | + | | precision ``p-1`` would have exponent ``exp``. Then | + | | if ``-4 <= exp < p``, the number is formatted | + | | with presentation type ``'f'`` and precision | + | | ``p-1-exp``. Otherwise, the number is formatted | + | | with presentation type ``'e'`` and precision ``p-1``. | + | | In both cases insignificant trailing zeros are removed | + | | from the significand, and the decimal point is also | + | | removed if there are no remaining digits following it. | + | | | + | | Postive and negative infinity, positive and negative | + | | zero, and nans, are formatted as ``inf``, ``-inf``, | + | | ``0``, ``-0`` and ``nan`` respectively, regardless of | + | | the precision. | + | | | + | | A precision of ``0`` is treated as equivalent to a | + | | precision of ``1``. | +---------+----------------------------------------------------------+ | ``'G'`` | General format. Same as ``'g'`` except switches to | - | | ``'E'`` if the number gets to large. The representations | - | | of infinity and NaN are uppercased, too. | + | | ``'E'`` if the number gets too large. The | + | | representations of infinity and NaN are uppercased, too. | +---------+----------------------------------------------------------+ | ``'n'`` | Number. This is the same as ``'g'``, except that it uses | | | the current locale setting to insert the appropriate | Modified: python/branches/release26-maint/Doc/library/termios.rst ============================================================================== --- python/branches/release26-maint/Doc/library/termios.rst (original) +++ python/branches/release26-maint/Doc/library/termios.rst Tue Oct 27 15:59:26 2009 @@ -90,7 +90,7 @@ :keyword:`finally` statement to ensure that the old tty attributes are restored exactly no matter what happens:: - def getpass(prompt = "Password: "): + def getpass(prompt="Password: "): import termios, sys fd = sys.stdin.fileno() old = termios.tcgetattr(fd) Modified: python/branches/release26-maint/Doc/library/threading.rst ============================================================================== --- python/branches/release26-maint/Doc/library/threading.rst (original) +++ python/branches/release26-maint/Doc/library/threading.rst Tue Oct 27 15:59:26 2009 @@ -33,7 +33,7 @@ activeCount() Return the number of :class:`Thread` objects currently alive. The returned - count is equal to the length of the list returned by :func:`enumerate`. + count is equal to the length of the list returned by :func:`.enumerate`. .. function:: Condition() @@ -321,7 +321,7 @@ Roughly, a thread is alive from the moment the :meth:`start` method returns until its :meth:`run` method terminates. The module function - :func:`enumerate` returns a list of all alive threads. + :func:`.enumerate` returns a list of all alive threads. .. method:: isDaemon() setDaemon() Modified: python/branches/release26-maint/Doc/tutorial/interpreter.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/interpreter.rst (original) +++ python/branches/release26-maint/Doc/tutorial/interpreter.rst Tue Oct 27 15:59:26 2009 @@ -31,7 +31,7 @@ Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn't work, you can exit the interpreter by typing the -following commands: ``import sys; sys.exit()``. +following command: ``quit()``. The interpreter's line-editing features usually aren't very sophisticated. On Unix, whoever installed the interpreter may have enabled support for the GNU Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.6.rst Tue Oct 27 15:59:26 2009 @@ -2412,9 +2412,13 @@ environments. TIPC addresses are 4- or 5-tuples. (Contributed by Alberto Bertogli; :issue:`1646`.) - A new function, :func:`create_connection`, takes an address - and connects to it using an optional timeout value, returning - the connected socket object. + A new function, :func:`create_connection`, takes an address and + connects to it using an optional timeout value, returning the + connected socket object. This function also looks up the address's + type and connects to it using IPv4 or IPv6 as appropriate. Changing + your code to use :func:`create_connection` instead of + ``socket(socket.AF_INET, ...)`` may be all that's required to make + your code work with IPv6. * The base classes in the :mod:`SocketServer` module now support calling a :meth:`handle_timeout` method after a span of inactivity From python-checkins at python.org Tue Oct 27 16:00:49 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:00:49 -0000 Subject: [Python-checkins] r75791 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:00:48 2009 New Revision: 75791 Log: Blocked revisions 74929,75076,75098,75139,75180,75264,75267-75268,75272-75273,75310 via svnmerge ........ r74929 | benjamin.peterson | 2009-09-18 23:14:55 +0200 (Fr, 18 Sep 2009) | 1 line add keyword arguments support to str/unicode encode and decode #6300 ........ r75076 | vinay.sajip | 2009-09-26 16:53:32 +0200 (Sa, 26 Sep 2009) | 1 line Tidied up name of parameter in StreamHandler ........ r75098 | michael.foord | 2009-09-27 22:08:23 +0200 (So, 27 Sep 2009) | 1 line Documentation improvement for load_tests protocol in unittest. Issue 6515. ........ r75139 | raymond.hettinger | 2009-09-29 20:53:24 +0200 (Di, 29 Sep 2009) | 3 lines Issue 7008: Better document str.title and show how to work around the apostrophe problem. ........ r75180 | georg.brandl | 2009-10-01 22:59:31 +0200 (Do, 01 Okt 2009) | 1 line #7031: Add TestCase.assertIsInstance and negated method. ........ r75264 | andrew.kuchling | 2009-10-06 00:30:22 +0200 (Di, 06 Okt 2009) | 1 line Add various items ........ r75267 | andrew.kuchling | 2009-10-06 00:42:56 +0200 (Di, 06 Okt 2009) | 1 line Backport r73983: Document the thousands separator. ........ r75268 | andrew.kuchling | 2009-10-06 00:45:39 +0200 (Di, 06 Okt 2009) | 1 line Remove two notes ........ r75272 | amaury.forgeotdarc | 2009-10-06 21:56:32 +0200 (Di, 06 Okt 2009) | 5 lines #1571184: makeunicodedata.py now generates the functions _PyUnicode_ToNumeric, _PyUnicode_IsLinebreak and _PyUnicode_IsWhitespace. It now also parses the Unihan.txt for numeric values. ........ r75273 | amaury.forgeotdarc | 2009-10-06 22:02:09 +0200 (Di, 06 Okt 2009) | 2 lines Add Anders Chrigstrom to Misc/ACKS for his work on unicodedata. ........ r75310 | vinay.sajip | 2009-10-10 22:32:36 +0200 (Sa, 10 Okt 2009) | 1 line Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:08:28 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:08:28 -0000 Subject: [Python-checkins] r75792 - in python/branches/release26-maint: Doc/contents.rst Doc/documenting/markup.rst Doc/faq Doc/faq/extending.rst Doc/faq/gui.rst Doc/howto/unicode.rst Doc/howto/webservers.rst Doc/install/index.rst Doc/library/__builtin__.rst Doc/library/codecs.rst Doc/library/configparser.rst Doc/library/curses.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/inspect.rst Doc/library/io.rst Doc/library/mailbox.rst Doc/library/math.rst Doc/library/msilib.rst Doc/library/os.rst Doc/library/othergui.rst Doc/library/platform.rst Doc/library/pty.rst Doc/library/signal.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/types.rst Doc/library/weakref.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/tools/sphinxext/indexcontent.html Doc/tools/sphinxext/pyspecific.py Doc/tools/sphinxext/static/basic.css Doc/tutorial/index.rst Doc/using/cmdline.rst Doc/using/windows.rst Doc/whatsnew/2.0.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.6.rst Lib/ctypes/wintypes.py Objects/stringobject.c Objects/unicodeobject.c Python/codecs.c Message-ID: Author: georg.brandl Date: Tue Oct 27 16:08:27 2009 New Revision: 75792 Log: Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75363 | georg.brandl | 2009-10-11 20:31:23 +0200 (So, 11 Okt 2009) | 1 line Add the Python FAQ lists to the documentation. Copied from sandbox/faq. Many thanks to AMK for the preparation work. ........ r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. ........ r75376 | benjamin.peterson | 2009-10-12 03:26:07 +0200 (Mo, 12 Okt 2009) | 1 line platform we don't care about ........ r75392 | andrew.kuchling | 2009-10-13 18:11:49 +0200 (Di, 13 Okt 2009) | 1 line Various link, textual, and markup fixes ........ r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line Fix markup. ........ r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line #7126: os.environ changes *do* take effect in subprocesses started with os.system(). ........ r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line #7116: str.join() takes an iterable. ........ r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line Fix missing word. ........ r75572 | benjamin.peterson | 2009-10-20 23:55:17 +0200 (Di, 20 Okt 2009) | 1 line clarify buffer arg #7178 ........ r75580 | georg.brandl | 2009-10-21 09:15:59 +0200 (Mi, 21 Okt 2009) | 1 line #7170: fix explanation about non-weakrefable builtin types. ........ r75590 | benjamin.peterson | 2009-10-22 04:36:47 +0200 (Do, 22 Okt 2009) | 1 line rewrite to be nice to other implementations ........ r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line Fix punctuation. ........ r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line Fix markup. ........ r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line Fix duplicate target. ........ r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line Add a new directive marking up implementation details and start using it. ........ r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line Make it more robust. ........ r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line Document new directive. ........ r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line Allow short form with text as argument. ........ r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line Use "impl-detail" directive where applicable. ........ r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line #6324: membership test tries iteration via __iter__. ........ r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line #7088: document new functions in signal as Unix-only. ........ r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line Reorder __slots__ fine print and add a clarification. ........ r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line #7035: improve docs of the various _errors() functions, and give them docstrings. ........ r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line #7156: document curses as Unix-only. ........ r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line #6977: getopt does not support optional option arguments. ........ r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line Add proper references. ........ r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line Make printout margin important. ........ r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line #7188: fix optionxform() docs. ........ r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines add further note about what's passed to optionxform ........ r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line Fix markup. ........ Added: python/branches/release26-maint/Doc/faq/ - copied from r75365, /python/trunk/Doc/faq/ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/contents.rst python/branches/release26-maint/Doc/documenting/markup.rst python/branches/release26-maint/Doc/faq/extending.rst python/branches/release26-maint/Doc/faq/gui.rst python/branches/release26-maint/Doc/howto/unicode.rst python/branches/release26-maint/Doc/howto/webservers.rst python/branches/release26-maint/Doc/install/index.rst python/branches/release26-maint/Doc/library/__builtin__.rst python/branches/release26-maint/Doc/library/codecs.rst python/branches/release26-maint/Doc/library/configparser.rst python/branches/release26-maint/Doc/library/curses.rst python/branches/release26-maint/Doc/library/datetime.rst python/branches/release26-maint/Doc/library/functions.rst python/branches/release26-maint/Doc/library/getopt.rst python/branches/release26-maint/Doc/library/inspect.rst python/branches/release26-maint/Doc/library/io.rst python/branches/release26-maint/Doc/library/mailbox.rst python/branches/release26-maint/Doc/library/math.rst python/branches/release26-maint/Doc/library/msilib.rst python/branches/release26-maint/Doc/library/os.rst python/branches/release26-maint/Doc/library/othergui.rst python/branches/release26-maint/Doc/library/platform.rst python/branches/release26-maint/Doc/library/pty.rst python/branches/release26-maint/Doc/library/signal.rst python/branches/release26-maint/Doc/library/stdtypes.rst python/branches/release26-maint/Doc/library/sys.rst python/branches/release26-maint/Doc/library/types.rst python/branches/release26-maint/Doc/library/weakref.rst python/branches/release26-maint/Doc/reference/datamodel.rst python/branches/release26-maint/Doc/reference/executionmodel.rst python/branches/release26-maint/Doc/reference/expressions.rst python/branches/release26-maint/Doc/reference/simple_stmts.rst python/branches/release26-maint/Doc/tools/sphinxext/indexcontent.html python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css python/branches/release26-maint/Doc/tutorial/index.rst python/branches/release26-maint/Doc/using/cmdline.rst python/branches/release26-maint/Doc/using/windows.rst python/branches/release26-maint/Doc/whatsnew/2.0.rst python/branches/release26-maint/Doc/whatsnew/2.2.rst python/branches/release26-maint/Doc/whatsnew/2.3.rst python/branches/release26-maint/Doc/whatsnew/2.4.rst python/branches/release26-maint/Doc/whatsnew/2.6.rst python/branches/release26-maint/Lib/ctypes/wintypes.py python/branches/release26-maint/Objects/stringobject.c python/branches/release26-maint/Objects/unicodeobject.c python/branches/release26-maint/Python/codecs.c Modified: python/branches/release26-maint/Doc/contents.rst ============================================================================== --- python/branches/release26-maint/Doc/contents.rst (original) +++ python/branches/release26-maint/Doc/contents.rst Tue Oct 27 16:08:27 2009 @@ -15,6 +15,7 @@ install/index.rst documenting/index.rst howto/index.rst + faq/index.rst glossary.rst about.rst Modified: python/branches/release26-maint/Doc/documenting/markup.rst ============================================================================== --- python/branches/release26-maint/Doc/documenting/markup.rst (original) +++ python/branches/release26-maint/Doc/documenting/markup.rst Tue Oct 27 16:08:27 2009 @@ -626,6 +626,24 @@ -------------- +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + .. describe:: seealso Many sections include a list of references to module documentation or Modified: python/branches/release26-maint/Doc/faq/extending.rst ============================================================================== --- /python/trunk/Doc/faq/extending.rst (original) +++ python/branches/release26-maint/Doc/faq/extending.rst Tue Oct 27 16:08:27 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`__, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping Modified: python/branches/release26-maint/Doc/faq/gui.rst ============================================================================== --- /python/trunk/Doc/faq/gui.rst (original) +++ python/branches/release26-maint/Doc/faq/gui.rst Tue Oct 27 16:08:27 2009 @@ -25,27 +25,26 @@ page at http://www.tcl.tk. Tcl/Tk is fully portable to the MacOS, Windows, and Unix platforms. -wxWindows +wxWidgets ''''''''' -wxWindows is a portable GUI class library written in C++ that's a portable -interface to various platform-specific libraries; wxWidgets is a Python -interface to wxWindows. wxWindows supports Windows and MacOS; on Unix variants, -it supports both GTk+ and Motif toolkits. wxWindows preserves the look and feel -of the underlying graphics toolkit, and there is quite a rich widget set and -collection of GDI classes. See `the wxWindows page `_ -for more details. - -`wxWidgets `_ is an extension module that wraps many of -the wxWindows C++ classes, and is quickly gaining popularity amongst Python -developers. You can get wxWidgets as part of the source or CVS distribution of -wxWindows, or directly from its home page. +wxWidgets is a GUI class library written in C++ that's a portable +interface to various platform-specific libraries, and that has a +Python interface called `wxPython `__. + +wxWidgets preserves the look and feel of the +underlying graphics toolkit, and has a large set of widgets and +collection of GDI classes. See `the wxWidgets page +`_ for more details. + +wxWidgets supports Windows and MacOS; on Unix variants, +it supports both GTk+ and Motif toolkits. Qt ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If +`_) and for KDE (`PyKDE `__). If you're writing open source software, you don't need to pay for PyQt, but if you want to write proprietary applications, you must buy a PyQt license from `Riverbank Computing `_ and (up to Qt 4.4; @@ -56,7 +55,7 @@ '''' PyGtk bindings for the `Gtk+ toolkit `_ have been -implemented by by James Henstridge; see ftp://ftp.gtk.org/pub/gtk/python/. +implemented by James Henstridge; see . FLTK '''' @@ -85,14 +84,15 @@ `The Mac port `_ by Jack Jansen has a rich and ever-growing set of modules that support the native Mac toolbox calls. The port -includes support for MacOS9 and MacOS X's Carbon libraries. By installing the -`PyObjc Objective-C bridge `_, Python programs -can use MacOS X's Cocoa libraries. See the documentation that comes with the Mac -port. +supports MacOS X's Carbon libraries. + +By installing the `PyObjc Objective-C bridge +`_, Python programs can use MacOS X's +Cocoa libraries. See the documentation that comes with the Mac port. :ref:`Pythonwin ` by Mark Hammond includes an interface to the -Microsoft Foundation Classes and a Python programming environment using it -that's written mostly in Python. +Microsoft Foundation Classes and a Python programming environment +that's written mostly in Python using the MFC classes. Tkinter questions @@ -105,23 +105,26 @@ applications, the applications will not be truly stand-alone, as the application will still need the Tcl and Tk libraries. -One solution is to ship the application with the tcl and tk libraries, and point +One solution is to ship the application with the Tcl and Tk libraries, and point to them at run-time using the :envvar:`TCL_LIBRARY` and :envvar:`TK_LIBRARY` environment variables. To get truly stand-alone applications, the Tcl scripts that form the library have to be integrated into the application as well. One tool supporting that is SAM (stand-alone modules), which is part of the Tix distribution -(http://tix.mne.com). Build Tix with SAM enabled, perform the appropriate call -to Tclsam_init etc inside Python's Modules/tkappinit.c, and link with libtclsam -and libtksam (you might include the Tix libraries as well). +(http://tix.sourceforge.net/). + +Build Tix with SAM enabled, perform the appropriate call to +:cfunc:`Tclsam_init`, etc. inside Python's +:file:`Modules/tkappinit.c`, and link with libtclsam and libtksam (you +might include the Tix libraries as well). Can I have Tk events handled while waiting for I/O? --------------------------------------------------- Yes, and you don't even need threads! But you'll have to restructure your I/O -code a bit. Tk has the equivalent of Xt's XtAddInput() call, which allows you +code a bit. Tk has the equivalent of Xt's :cfunc:`XtAddInput()` call, which allows you to register a callback function which will be called from the Tk mainloop when I/O is possible on a file descriptor. Here's what you need:: 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 Tue Oct 27 16:08:27 2009 @@ -472,7 +472,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: python/branches/release26-maint/Doc/howto/webservers.rst ============================================================================== --- python/branches/release26-maint/Doc/howto/webservers.rst (original) +++ python/branches/release26-maint/Doc/howto/webservers.rst Tue Oct 27 16:08:27 2009 @@ -270,8 +270,7 @@ * lighttpd ships its own `FastCGI module `_ as well as an `SCGI module `_. -* nginx also supports `FastCGI - `_. +* nginx also supports `FastCGI `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -524,7 +523,7 @@ informations on a web server. Often relational database engines like `MySQL `_ or -`PostgreSQL `_ are used due to their good +`PostgreSQL `_ are used due to their good performance handling very large databases consisting of up to millions of entries. These are *queried* using a language called `SQL `_. Python programmers in general do not like @@ -628,7 +627,7 @@ It has a big, international community which has created many sites using Django. There are also quite a lot of add-on projects which extend Django's normal functionality. This is partly due to Django's well written `online -documentation `_ and the `Django book +documentation `_ and the `Django book `_. Modified: python/branches/release26-maint/Doc/install/index.rst ============================================================================== --- python/branches/release26-maint/Doc/install/index.rst (original) +++ python/branches/release26-maint/Doc/install/index.rst Tue Oct 27 16:08:27 2009 @@ -940,7 +940,8 @@ These compilers require some special libraries. This task is more complex than for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find -a good program for this task at http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html) +a good program for this task at +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) Modified: python/branches/release26-maint/Doc/library/__builtin__.rst ============================================================================== --- python/branches/release26-maint/Doc/library/__builtin__.rst (original) +++ python/branches/release26-maint/Doc/library/__builtin__.rst Tue Oct 27 16:08:27 2009 @@ -33,9 +33,10 @@ # ... -As an implementation detail, most modules have the name ``__builtins__`` (note -the ``'s'``) made available as part of their globals. The value of -``__builtins__`` is normally either this module or the value of this modules's -:attr:`__dict__` attribute. Since this is an implementation detail, it may not -be used by alternate implementations of Python. +.. impl-detail:: + Most modules have the name ``__builtins__`` (note the ``'s'``) made available + as part of their globals. The value of ``__builtins__`` is normally either + this module or the value of this modules's :attr:`__dict__` attribute. Since + this is an implementation detail, it may not be used by alternate + implementations of Python. Modified: python/branches/release26-maint/Doc/library/codecs.rst ============================================================================== --- python/branches/release26-maint/Doc/library/codecs.rst (original) +++ python/branches/release26-maint/Doc/library/codecs.rst Tue Oct 27 16:08:27 2009 @@ -54,7 +54,7 @@ *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: - ``factory(errors='strict')`` + ``factory(errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, @@ -63,20 +63,24 @@ *streamreader* and *streamwriter*: These have to be factory functions providing the following interface: - ``factory(stream, errors='strict')`` + ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. - Possible values for errors are ``'strict'`` (raise an exception in case of an - encoding error), ``'replace'`` (replace malformed data with a suitable - replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and - continue without further notice), ``'xmlcharrefreplace'`` (replace with the - appropriate XML character reference (for encoding only)) and - ``'backslashreplace'`` (replace with backslashed escape sequences (for encoding - only)) as well as any other error handling name defined via - :func:`register_error`. + Possible values for errors are + + * ``'strict'``: raise an exception in case of an encoding error + * ``'replace'``: replace malformed data with a suitable replacement marker, + such as ``'?'`` or ``'\ufffd'`` + * ``'ignore'``: ignore malformed data and continue without further notice + * ``'xmlcharrefreplace'``: replace with the appropriate XML character + reference (for encoding only) + * ``'backslashreplace'``: replace with backslashed escape sequences (for + encoding only + + as well as any other error handling name defined via :func:`register_error`. In case a search function cannot find a given encoding, it should return ``None``. @@ -177,27 +181,33 @@ .. function:: strict_errors(exception) - Implements the ``strict`` error handling. + Implements the ``strict`` error handling: each encoding or decoding error + raises a :exc:`UnicodeError`. .. function:: replace_errors(exception) - Implements the ``replace`` error handling. + Implements the ``replace`` error handling: malformed data is replaced with a + suitable replacement character such as ``'?'`` in bytestrings and + ``'\ufffd'`` in Unicode strings. .. function:: ignore_errors(exception) - Implements the ``ignore`` error handling. + Implements the ``ignore`` error handling: malformed data is ignored and + encoding or decoding is continued without further notice. .. function:: xmlcharrefreplace_errors(exception) - Implements the ``xmlcharrefreplace`` error handling. + Implements the ``xmlcharrefreplace`` error handling (for encoding only): the + unencodable character is replaced by an appropriate XML character reference. .. function:: backslashreplace_errors(exception) - Implements the ``backslashreplace`` error handling. + Implements the ``backslashreplace`` error handling (for encoding only): the + unencodable character is replaced by a backslashed escape sequence. To simplify working with encoded files or stream, the module also defines these utility functions: Modified: python/branches/release26-maint/Doc/library/configparser.rst ============================================================================== --- python/branches/release26-maint/Doc/library/configparser.rst (original) +++ python/branches/release26-maint/Doc/library/configparser.rst Tue Oct 27 16:08:27 2009 @@ -317,12 +317,23 @@ .. method:: RawConfigParser.optionxform(option) - Transforms the option name *option* as found in an input file or as passed in by - client code to the form that should be used in the internal structures. The - default implementation returns a lower-case version of *option*; subclasses may - override this or client code can set an attribute of this name on instances to - affect this behavior. Setting this to :func:`str`, for example, would make - option names case sensitive. + Transforms the option name *option* as found in an input file or as passed in + by client code to the form that should be used in the internal structures. + The default implementation returns a lower-case version of *option*; + subclasses may override this or client code can set an attribute of this name + on instances to affect this behavior. + + You don't necessarily need to subclass a ConfigParser to use this method, you + can also re-set it on an instance, to a function that takes a string + argument. Setting it to ``str``, for example, would make option names case + sensitive:: + + cfgparser = ConfigParser() + ... + cfgparser.optionxform = str + + Note that when reading configuration files, whitespace around the + option names are stripped before :meth:`optionxform` is called. .. _configparser-objects: Modified: python/branches/release26-maint/Doc/library/curses.rst ============================================================================== --- python/branches/release26-maint/Doc/library/curses.rst (original) +++ python/branches/release26-maint/Doc/library/curses.rst Tue Oct 27 16:08:27 2009 @@ -1,13 +1,13 @@ - :mod:`curses` --- Terminal handling for character-cell displays =============================================================== .. module:: curses - :synopsis: An interface to the curses library, providing portable terminal handling. + :synopsis: An interface to the curses library, providing portable terminal + handling. + :platform: Unix .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond - .. versionchanged:: 1.6 Added support for the ``ncurses`` library and converted to a package. Modified: python/branches/release26-maint/Doc/library/datetime.rst ============================================================================== --- python/branches/release26-maint/Doc/library/datetime.rst (original) +++ python/branches/release26-maint/Doc/library/datetime.rst Tue Oct 27 16:08:27 2009 @@ -235,7 +235,7 @@ | | (-*t1.days*, -*t1.seconds*, | | | -*t1.microseconds*), and to *t1*\* -1. (1)(4) | +--------------------------------+-----------------------------------------------+ -| ``abs(t)`` | equivalent to +*t* when ``t.days >= 0``, and | +| ``abs(t)`` | equivalent to +\ *t* when ``t.days >= 0``, and| | | to -*t* when ``t.days < 0``. (2) | +--------------------------------+-----------------------------------------------+ Modified: python/branches/release26-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release26-maint/Doc/library/functions.rst (original) +++ python/branches/release26-maint/Doc/library/functions.rst Tue Oct 27 16:08:27 2009 @@ -523,8 +523,10 @@ Return the "identity" of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. - Two objects with non-overlapping lifetimes may have the same :func:`id` value. - (Implementation note: this is the address of the object.) + Two objects with non-overlapping lifetimes may have the same :func:`id` + value. + + .. impl-detail:: This is the address of the object. .. function:: input([prompt]) @@ -1377,14 +1379,15 @@ elements are never used (such as when the loop is usually terminated with :keyword:`break`). - .. note:: + .. impl-detail:: - :func:`xrange` is intended to be simple and fast. Implementations may impose - restrictions to achieve this. The C implementation of Python restricts all - arguments to native C longs ("short" Python integers), and also requires that - the number of elements fit in a native C long. If a larger range is needed, - an alternate version can be crafted using the :mod:`itertools` module: - ``islice(count(start, step), (stop-start+step-1)//step)``. + :func:`xrange` is intended to be simple and fast. Implementations may + impose restrictions to achieve this. The C implementation of Python + restricts all arguments to native C longs ("short" Python integers), and + also requires that the number of elements fit in a native C long. If a + larger range is needed, an alternate version can be crafted using the + :mod:`itertools` module: ``islice(count(start, step), + (stop-start+step-1)//step)``. .. function:: zip([iterable, ...]) Modified: python/branches/release26-maint/Doc/library/getopt.rst ============================================================================== --- python/branches/release26-maint/Doc/library/getopt.rst (original) +++ python/branches/release26-maint/Doc/library/getopt.rst Tue Oct 27 16:08:27 2009 @@ -30,19 +30,20 @@ .. note:: - Unlike GNU :cfunc:`getopt`, after a non-option argument, all further arguments - are considered also non-options. This is similar to the way non-GNU Unix systems - work. + Unlike GNU :cfunc:`getopt`, after a non-option argument, all further + arguments are considered also non-options. This is similar to the way + non-GNU Unix systems work. *long_options*, if specified, must be a list of strings with the names of the - long options which should be supported. The leading ``'-``\ ``-'`` characters - should not be included in the option name. Long options which require an - argument should be followed by an equal sign (``'='``). To accept only long - options, *options* should be an empty string. Long options on the command line - can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *long_options* is - ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, - but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. + long options which should be supported. The leading ``'-``\ ``-'`` + characters should not be included in the option name. Long options which + require an argument should be followed by an equal sign (``'='``). Optional + arguments are not supported. To accept only long options, *options* should + be an empty string. Long options on the command line can be recognized so + long as they provide a prefix of the option name that matches exactly one of + the accepted options. For example, if *long_options* is ``['foo', 'frob']``, + the option :option:`--fo` will match as :option:`--foo`, but :option:`--f` + will not match uniquely, so :exc:`GetoptError` will be raised. The return value consists of two elements: the first is a list of ``(option, value)`` pairs; the second is the list of program arguments left after the Modified: python/branches/release26-maint/Doc/library/inspect.rst ============================================================================== --- python/branches/release26-maint/Doc/library/inspect.rst (original) +++ python/branches/release26-maint/Doc/library/inspect.rst Tue Oct 27 16:08:27 2009 @@ -353,9 +353,11 @@ Return true if the object is a getset descriptor. - getsets are attributes defined in extension modules via ``PyGetSetDef`` - structures. For Python implementations without such types, this method will - always return ``False``. + .. impl-detail:: + + getsets are attributes defined in extension modules via + :ctype:`PyGetSetDef` structures. For Python implementations without such + types, this method will always return ``False``. .. versionadded:: 2.5 @@ -364,9 +366,11 @@ Return true if the object is a member descriptor. - Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, - this method will always return ``False``. + .. impl-detail:: + + Member descriptors are attributes defined in extension modules via + :ctype:`PyMemberDef` structures. For Python implementations without such + types, this method will always return ``False``. .. versionadded:: 2.5 @@ -567,10 +571,12 @@ Return the frame object for the caller's stack frame. - This function relies on Python stack frame support in the interpreter, which - isn't guaranteed to exist in all implementations of Python. If running in - an implementation without Python stack frame support this function returns - ``None``. + .. impl-detail:: + + This function relies on Python stack frame support in the interpreter, + which isn't guaranteed to exist in all implementations of Python. If + running in an implementation without Python stack frame support this + function returns ``None``. .. function:: stack([context]) Modified: python/branches/release26-maint/Doc/library/io.rst ============================================================================== --- python/branches/release26-maint/Doc/library/io.rst (original) +++ python/branches/release26-maint/Doc/library/io.rst Tue Oct 27 16:08:27 2009 @@ -96,8 +96,8 @@ *buffering* is an optional integer used to set the buffering policy. By default full buffering is on. Pass 0 to switch buffering off (only allowed - in binary mode), 1 to set line buffering, and an integer > 1 for full - buffering. + in binary mode), 1 to set line buffering, and an integer > 1 to indicate the + size of the buffer. *encoding* is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform Modified: python/branches/release26-maint/Doc/library/mailbox.rst ============================================================================== --- python/branches/release26-maint/Doc/library/mailbox.rst (original) +++ python/branches/release26-maint/Doc/library/mailbox.rst Tue Oct 27 16:08:27 2009 @@ -602,7 +602,7 @@ `nmh - Message Handling System `_ Home page of :program:`nmh`, an updated version of the original :program:`mh`. - `MH & nmh: Email for Users & Programmers `_ + `MH & nmh: Email for Users & Programmers `_ A GPL-licensed book on :program:`mh` and :program:`nmh`, with some information on the mailbox format. Modified: python/branches/release26-maint/Doc/library/math.rst ============================================================================== --- python/branches/release26-maint/Doc/library/math.rst (original) +++ python/branches/release26-maint/Doc/library/math.rst Tue Oct 27 16:08:27 2009 @@ -321,7 +321,7 @@ The mathematical constant *e*. -.. note:: +.. impl-detail:: The :mod:`math` module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified Modified: python/branches/release26-maint/Doc/library/msilib.rst ============================================================================== --- python/branches/release26-maint/Doc/library/msilib.rst (original) +++ python/branches/release26-maint/Doc/library/msilib.rst Tue Oct 27 16:08:27 2009 @@ -396,10 +396,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -424,7 +424,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -518,13 +518,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: @@ -553,5 +553,3 @@ This module contains definitions for the UIText and ActionText tables, for the standard installer actions. - - Modified: python/branches/release26-maint/Doc/library/os.rst ============================================================================== --- python/branches/release26-maint/Doc/library/os.rst (original) +++ python/branches/release26-maint/Doc/library/os.rst Tue Oct 27 16:08:27 2009 @@ -1836,9 +1836,9 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :cfunc:`system`, and has the same limitations. Changes - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the - environment of the executed command. + the Standard C function :cfunc:`system`, and has the same limitations. + Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the + executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning Modified: python/branches/release26-maint/Doc/library/othergui.rst ============================================================================== --- python/branches/release26-maint/Doc/library/othergui.rst (original) +++ python/branches/release26-maint/Doc/library/othergui.rst Tue Oct 27 16:08:27 2009 @@ -43,7 +43,7 @@ `PythonCAD `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool Modified: python/branches/release26-maint/Doc/library/platform.rst ============================================================================== --- python/branches/release26-maint/Doc/library/platform.rst (original) +++ python/branches/release26-maint/Doc/library/platform.rst Tue Oct 27 16:08:27 2009 @@ -98,7 +98,7 @@ .. function:: python_implementation() Returns a string identifying the Python implementation. Possible return values - are: 'CPython', 'IronPython', 'Jython' + are: 'CPython', 'IronPython', 'Jython'. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/pty.rst ============================================================================== --- python/branches/release26-maint/Doc/library/pty.rst (original) +++ python/branches/release26-maint/Doc/library/pty.rst Tue Oct 27 16:08:27 2009 @@ -3,8 +3,8 @@ ======================================== .. module:: pty - :platform: IRIX, Linux - :synopsis: Pseudo-Terminal Handling for SGI and Linux. + :platform: Linux + :synopsis: Pseudo-Terminal Handling for Linux. .. moduleauthor:: Steen Lumholt .. sectionauthor:: Moshe Zadka @@ -14,8 +14,8 @@ controlling terminal programmatically. Because pseudo-terminal handling is highly platform dependent, there is code to -do it only for SGI and Linux. (The Linux code is supposed to work on other -platforms, but hasn't been tested yet.) +do it only for Linux. (The Linux code is supposed to work on other platforms, +but hasn't been tested yet.) The :mod:`pty` module defines the following functions: @@ -32,8 +32,8 @@ .. function:: openpty() Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or - emulation code for SGI and generic Unix systems. Return a pair of file - descriptors ``(master, slave)``, for the master and the slave end, respectively. + emulation code for generic Unix systems. Return a pair of file descriptors + ``(master, slave)``, for the master and the slave end, respectively. .. function:: spawn(argv[, master_read[, stdin_read]]) Modified: python/branches/release26-maint/Doc/library/signal.rst ============================================================================== --- python/branches/release26-maint/Doc/library/signal.rst (original) +++ python/branches/release26-maint/Doc/library/signal.rst Tue Oct 27 16:08:27 2009 @@ -157,8 +157,8 @@ The old values are returned as a tuple: (delay, interval). - Attempting to pass an invalid interval timer will cause a - :exc:`ItimerError`. + Attempting to pass an invalid interval timer will cause an + :exc:`ItimerError`. Availability: Unix. .. versionadded:: 2.6 @@ -166,6 +166,7 @@ .. function:: getitimer(which) Returns current value of a given interval timer specified by *which*. + Availability: Unix. .. versionadded:: 2.6 @@ -186,14 +187,14 @@ .. function:: siginterrupt(signalnum, flag) - Change system call restart behaviour: if *flag* is :const:`False`, system calls - will be restarted when interrupted by signal *signalnum*, otherwise system calls will - be interrupted. Returns nothing. Availability: Unix (see the man page - :manpage:`siginterrupt(3)` for further information). - - Note that installing a signal handler with :func:`signal` will reset the restart - behaviour to interruptible by implicitly calling :cfunc:`siginterrupt` with a true *flag* - value for the given signal. + Change system call restart behaviour: if *flag* is :const:`False`, system + calls will be restarted when interrupted by signal *signalnum*, otherwise + system calls will be interrupted. Returns nothing. Availability: Unix (see + the man page :manpage:`siginterrupt(3)` for further information). + + Note that installing a signal handler with :func:`signal` will reset the + restart behaviour to interruptible by implicitly calling + :cfunc:`siginterrupt` with a true *flag* value for the given signal. .. versionadded:: 2.6 Modified: python/branches/release26-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release26-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release26-maint/Doc/library/stdtypes.rst Tue Oct 27 16:08:27 2009 @@ -195,9 +195,11 @@ :meth:`__cmp__` method. Refer to :ref:`customization`) for information on the use of this method to effect object comparisons. -**Implementation note:** Objects of different types except numbers are ordered -by their type names; objects of the same types that don't support proper -comparison are ordered by their address. +.. impl-detail:: + + Objects of different types except numbers are ordered by their type names; + objects of the same types that don't support proper comparison are ordered by + their address. .. index:: operator: in @@ -765,13 +767,15 @@ If *k* is ``None``, it is treated like ``1``. (6) - If *s* and *t* are both strings, some Python implementations such as CPython can - usually perform an in-place optimization for assignments of the form ``s=s+t`` - or ``s+=t``. When applicable, this optimization makes quadratic run-time much - less likely. This optimization is both version and implementation dependent. - For performance sensitive code, it is preferable to use the :meth:`str.join` - method which assures consistent linear concatenation performance across versions - and implementations. + .. impl-detail:: + + If *s* and *t* are both strings, some Python implementations such as + CPython can usually perform an in-place optimization for assignments of + the form ``s = s + t`` or ``s += t``. When applicable, this optimization + makes quadratic run-time much less likely. This optimization is both + version and implementation dependent. For performance sensitive code, it + is preferable to use the :meth:`str.join` method which assures consistent + linear concatenation performance across versions and implementations. .. versionchanged:: 2.4 Formerly, string concatenation never occurred in-place. @@ -961,10 +965,11 @@ For 8-bit strings, this method is locale-dependent. -.. method:: str.join(seq) +.. method:: str.join(iterable) - Return a string which is the concatenation of the strings in the sequence *seq*. - The separator between elements is the string providing this method. + Return a string which is the concatenation of the strings in the + :term:`iterable` *iterable*. The separator between elements is the string + providing this method. .. method:: str.ljust(width[, fillchar]) @@ -1593,10 +1598,13 @@ example, sort by department, then by salary grade). (10) - While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation of Python 2.3 and newer - makes the list appear empty for the duration, and raises :exc:`ValueError` if it - can detect that the list has been mutated during a sort. + .. impl-detail:: + + While a list is being sorted, the effect of attempting to mutate, or even + inspect, the list is undefined. The C implementation of Python 2.3 and + newer makes the list appear empty for the duration, and raises + :exc:`ValueError` if it can detect that the list has been mutated during a + sort. .. _types-set: @@ -1970,20 +1978,21 @@ Return a copy of the dictionary's list of ``(key, value)`` pairs. - .. note:: + .. impl-detail:: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's - history of insertions and deletions. If :meth:`items`, :meth:`keys`, - :meth:`values`, :meth:`iteritems`, :meth:`iterkeys`, and - :meth:`itervalues` are called with no intervening modifications to the - dictionary, the lists will directly correspond. This allows the - creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = - zip(d.values(), d.keys())``. The same relationship holds for the - :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs = - zip(d.itervalues(), d.iterkeys())`` provides the same value for - ``pairs``. Another way to create the same list is ``pairs = [(v, k) for - (k, v) in d.iteritems()]``. + history of insertions and deletions. + + If :meth:`items`, :meth:`keys`, :meth:`values`, :meth:`iteritems`, + :meth:`iterkeys`, and :meth:`itervalues` are called with no intervening + modifications to the dictionary, the lists will directly correspond. This + allows the creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = + zip(d.values(), d.keys())``. The same relationship holds for the + :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs = + zip(d.itervalues(), d.iterkeys())`` provides the same value for + ``pairs``. Another way to create the same list is ``pairs = [(v, k) for + (k, v) in d.iteritems()]``. .. method:: iteritems() Modified: python/branches/release26-maint/Doc/library/sys.rst ============================================================================== --- python/branches/release26-maint/Doc/library/sys.rst (original) +++ python/branches/release26-maint/Doc/library/sys.rst Tue Oct 27 16:08:27 2009 @@ -417,8 +417,10 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. It - is not guaranteed to exist in all implementations of Python. + .. impl-detail:: + + This function should be used for internal and specialized purposes only. + It is not guaranteed to exist in all implementations of Python. .. function:: getprofile() @@ -440,12 +442,12 @@ Get the trace function as set by :func:`settrace`. - .. note:: + .. impl-detail:: The :func:`gettrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, - and thus may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. versionadded:: 2.6 @@ -809,12 +811,12 @@ For more information on code and frame objects, refer to :ref:`types`. - .. note:: + .. impl-detail:: The :func:`settrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, and thus - may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: settscdump(on_flag) Modified: python/branches/release26-maint/Doc/library/types.rst ============================================================================== --- python/branches/release26-maint/Doc/library/types.rst (original) +++ python/branches/release26-maint/Doc/library/types.rst Tue Oct 27 16:08:27 2009 @@ -241,8 +241,11 @@ as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the :class:`property` type, but for classes defined in extension modules. - In other implementations of Python, this type may be identical to - ``GetSetDescriptorType``. + + .. impl-detail:: + + In other implementations of Python, this type may be identical to + ``GetSetDescriptorType``. .. versionadded:: 2.5 Modified: python/branches/release26-maint/Doc/library/weakref.rst ============================================================================== --- python/branches/release26-maint/Doc/library/weakref.rst (original) +++ python/branches/release26-maint/Doc/library/weakref.rst Tue Oct 27 16:08:27 2009 @@ -1,4 +1,3 @@ - :mod:`weakref` --- Weak references ================================== @@ -73,6 +72,11 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable +.. impl-detail:: + + Other built-in types such as :class:`tuple` and :class:`long` do not support + weak references even when subclassed. + Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/branches/release26-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release26-maint/Doc/reference/datamodel.rst Tue Oct 27 16:08:27 2009 @@ -56,13 +56,16 @@ they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether --- it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that -are still reachable. (Implementation note: CPython currently uses a -reference-counting scheme with (optional) delayed detection of cyclically linked -garbage, which collects most objects as soon as they become unreachable, but is -not guaranteed to collect garbage containing circular references. See the -documentation of the :mod:`gc` module for information on controlling the -collection of cyclic garbage. Other implementations act differently and CPython -may change.) +are still reachable. + +.. impl-detail:: + + CPython currently uses a reference-counting scheme with (optional) delayed + detection of cyclically linked garbage, which collects most objects as soon + as they become unreachable, but is not guaranteed to collect garbage + containing circular references. See the documentation of the :mod:`gc` + module for information on controlling the collection of cyclic garbage. + Other implementations act differently and CPython may change. Note that the use of the implementation's tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching @@ -1672,15 +1675,15 @@ *__slots__*; otherwise, the class attribute would overwrite the descriptor assignment. +* The action of a *__slots__* declaration is limited to the class where it is + defined. As a result, subclasses will have a *__dict__* unless they also define + *__slots__* (which must only contain names of any *additional* slots). + * If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this. -* The action of a *__slots__* declaration is limited to the class where it is - defined. As a result, subclasses will have a *__dict__* unless they also define - *__slots__*. - * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`long`, :class:`str` and :class:`tuple`. @@ -1885,12 +1888,16 @@ supply the following special method with a more efficient implementation, which also does not require the object be a sequence. - .. method:: object.__contains__(self, item) - Called to implement membership test operators. Should return true if *item* is - in *self*, false otherwise. For mapping objects, this should consider the keys - of the mapping rather than the values or the key-item pairs. + Called to implement membership test operators. Should return true if *item* + is in *self*, false otherwise. For mapping objects, this should consider the + keys of the mapping rather than the values or the key-item pairs. + + For objects that don't define :meth:`__contains__`, the membership test first + tries iteration via :meth:`__iter__`, then the old sequence iteration + protocol via :meth:`__getitem__`, see :ref:`this section in the language + reference `. .. _sequence-methods: Modified: python/branches/release26-maint/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/executionmodel.rst (original) +++ python/branches/release26-maint/Doc/reference/executionmodel.rst Tue Oct 27 16:08:27 2009 @@ -128,7 +128,7 @@ itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. -.. note:: +.. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should Modified: python/branches/release26-maint/Doc/reference/expressions.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/expressions.rst (original) +++ python/branches/release26-maint/Doc/reference/expressions.rst Tue Oct 27 16:08:27 2009 @@ -663,13 +663,13 @@ raised. Otherwise, the list of filled slots is used as the argument list for the call. -.. note:: +.. impl-detail:: - An implementation may provide built-in functions whose positional parameters do - not have names, even if they are 'named' for the purpose of documentation, and - which therefore cannot be supplied by keyword. In CPython, this is the case for - functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their - arguments. + An implementation may provide built-in functions whose positional parameters + do not have names, even if they are 'named' for the purpose of documentation, + and which therefore cannot be supplied by keyword. In CPython, this is the + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to + parse their arguments. If there are more positional arguments than there are formal parameter slots, a :exc:`TypeError` exception is raised, unless a formal parameter using the syntax @@ -1068,6 +1068,8 @@ another one is made arbitrarily but consistently within one execution of a program. +.. _membership-test-details: + The operators :keyword:`in` and :keyword:`not in` test for collection membership. ``x in s`` evaluates to true if *x* is a member of the collection *s*, and false otherwise. ``x not in s`` returns the negation of ``x in s``. @@ -1092,7 +1094,12 @@ For user-defined classes which define the :meth:`__contains__` method, ``x in y`` is true if and only if ``y.__contains__(x)`` is true. -For user-defined classes which do not define :meth:`__contains__` and do define +For user-defined classes which do not define :meth:`__contains__` but do define +:meth:`__iter__`, ``x in y`` is true if some value ``z`` with ``x == z`` is +produced while iterating over ``y``. If an exception is raised during the +iteration, it is as if :keyword:`in` raised that exception. + +Lastly, the old-style iteration protocol is tried: if a class defines :meth:`__getitem__`, ``x in y`` is true if and only if there is a non-negative integer index *i* such that ``x == y[i]``, and all lower integer indices do not raise :exc:`IndexError` exception. (If any other exception is raised, it is as Modified: python/branches/release26-maint/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/release26-maint/Doc/reference/simple_stmts.rst (original) +++ python/branches/release26-maint/Doc/reference/simple_stmts.rst Tue Oct 27 16:08:27 2009 @@ -219,9 +219,11 @@ the length of the assigned sequence, thus changing the length of the target sequence, if the object allows it. -(In the current implementation, the syntax for targets is taken to be the same -as for expressions, and invalid syntax is rejected during the code generation -phase, causing less detailed error messages.) +.. impl-detail:: + + In the current implementation, the syntax for targets is taken to be the same + as for expressions, and invalid syntax is rejected during the code generation + phase, causing less detailed error messages. WARNING: Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are 'safe' (for example ``a, b = b, a`` @@ -950,9 +952,11 @@ parameters or in a :keyword:`for` loop control target, :keyword:`class` definition, function definition, or :keyword:`import` statement. -(The current implementation does not enforce the latter two restrictions, but -programs should not abuse this freedom, as future implementations may enforce -them or silently change the meaning of the program.) +.. impl-detail:: + + The current implementation does not enforce the latter two restrictions, but + programs should not abuse this freedom, as future implementations may enforce + them or silently change the meaning of the program. .. index:: statement: exec Modified: python/branches/release26-maint/Doc/tools/sphinxext/indexcontent.html ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/indexcontent.html (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/indexcontent.html Tue Oct 27 16:08:27 2009 @@ -26,6 +26,8 @@ sharing modules with others

            + Modified: python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 16:08:27 2009 @@ -21,6 +21,8 @@ Body.enum.converters['upperroman'] = lambda x: None +# Support for marking up and linking to bugs.python.org issues + def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): issue = utils.unescape(text) text = 'issue ' + issue @@ -28,6 +30,34 @@ return [refnode], [] +# Support for marking up implementation details + +from sphinx.util.compat import Directive + +class ImplementationDetail(Directive): + + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = True + + def run(self): + pnode = nodes.compound(classes=['impl-detail']) + content = self.content + add_text = nodes.strong('CPython implementation detail:', + 'CPython implementation detail:') + if self.arguments: + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.append(nodes.paragraph('', '', *(n + m))) + self.state.nested_parse(content, self.content_offset, pnode) + if pnode.children and isinstance(pnode[0], nodes.paragraph): + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) + else: + pnode.insert(0, nodes.paragraph('', '', add_text)) + return [pnode] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -105,10 +135,12 @@ finally: f.close() + # Support for checking for suspicious markup import suspicious + # Support for documenting Opcodes import re @@ -131,6 +163,7 @@ def setup(app): app.add_role('issue', issue_role) + app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', Modified: python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css Tue Oct 27 16:08:27 2009 @@ -348,6 +348,17 @@ background-color: #ffa } +.impl-detail { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; + border: 1px solid #ccc; +} + +.impl-detail p { + margin: 0; +} + /* -- code displays --------------------------------------------------------- */ pre { @@ -408,7 +419,7 @@ div.document, div.documentwrapper, div.bodywrapper { - margin: 0; + margin: 0 !important; width: 100%; } Modified: python/branches/release26-maint/Doc/tutorial/index.rst ============================================================================== --- python/branches/release26-maint/Doc/tutorial/index.rst (original) +++ python/branches/release26-maint/Doc/tutorial/index.rst Tue Oct 27 16:08:27 2009 @@ -28,18 +28,17 @@ interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. -For a description of standard objects and modules, see the Python Library -Reference document. The Python Reference Manual gives a more formal definition -of the language. To write extensions in C or C++, read Extending and Embedding -the Python Interpreter and Python/C API Reference. There are also several books -covering Python in depth. +For a description of standard objects and modules, see :ref:`library-index`. +:ref:`reference-index` gives a more formal definition of the language. To write +extensions in C or C++, read :ref:`extending-index` and +:ref:`c-api-index`. There are also several books covering Python in depth. This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the -various Python library modules described in the Python Library Reference. +various Python library modules described in :ref:`library-index`. The :ref:`glossary` is also worth going through. Modified: python/branches/release26-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release26-maint/Doc/using/cmdline.rst (original) +++ python/branches/release26-maint/Doc/using/cmdline.rst Tue Oct 27 16:08:27 2009 @@ -8,7 +8,7 @@ The CPython interpreter scans the command line and the environment for various settings. -.. note:: +.. impl-detail:: Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. Modified: python/branches/release26-maint/Doc/using/windows.rst ============================================================================== --- python/branches/release26-maint/Doc/using/windows.rst (original) +++ python/branches/release26-maint/Doc/using/windows.rst Tue Oct 27 16:08:27 2009 @@ -69,7 +69,7 @@ `ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Python Enthought Edition `_ +`Enthought Python Distribution `_ Popular modules (such as PyWin32) with their respective documentation, tool suite for building extensible python applications @@ -223,8 +223,7 @@ * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces `PythonWin `_ + `MingW -- Python extensions `_ by Trent Apted et al, 2007 Modified: python/branches/release26-maint/Doc/whatsnew/2.0.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.0.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.0.rst Tue Oct 27 16:08:27 2009 @@ -572,8 +572,7 @@ mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still ``'win32'`` on Win64 because it seems that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) PythonWin also supports Windows CE; see the -Python CE page at http://starship.python.net/crew/mhammond/ce/ for more -information. +Python CE page at http://pythonce.sourceforge.net/ for more information. Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify "configure --with-dyld --with-suffix=.x". @@ -1041,8 +1040,8 @@ to include SSL support, which adds an additional function to the :mod:`socket` module: :func:`socket.ssl(socket, keyfile, certfile)`, which takes a socket object and returns an SSL socket. The :mod:`httplib` and :mod:`urllib` modules -were also changed to support "https://" URLs, though no one has implemented FTP -or SMTP over SSL. +were also changed to support ``https://`` URLs, though no one has implemented +FTP or SMTP over SSL. The :mod:`httplib` module has been rewritten by Greg Stein to support HTTP/1.1. Backward compatibility with the 1.5 version of :mod:`httplib` is provided, Modified: python/branches/release26-maint/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.2.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.2.rst Tue Oct 27 16:08:27 2009 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso:: +.. seealso (now defunct) http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and @@ -49,14 +49,14 @@ complicated section of this article, I'll provide an overview of the changes and offer some comments. -A long time ago I wrote a Web page (http://www.amk.ca/python/writing/warts.html) -listing flaws in Python's design. One of the most significant flaws was that -it's impossible to subclass Python types implemented in C. In particular, it's -not possible to subclass built-in types, so you can't just subclass, say, lists -in order to add a single useful method to them. The :mod:`UserList` module -provides a class that supports all of the methods of lists and that can be -subclassed further, but there's lots of C code that expects a regular Python -list and won't accept a :class:`UserList` instance. +A long time ago I wrote a Web page listing flaws in Python's design. One of the +most significant flaws was that it's impossible to subclass Python types +implemented in C. In particular, it's not possible to subclass built-in types, +so you can't just subclass, say, lists in order to add a single useful method to +them. The :mod:`UserList` module provides a class that supports all of the +methods of lists and that can be subclassed further, but there's lots of C code +that expects a regular Python list and won't accept a :class:`UserList` +instance. Python 2.2 fixes this, and in the process adds some exciting new capabilities. A brief summary: Modified: python/branches/release26-maint/Doc/whatsnew/2.3.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.3.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.3.rst Tue Oct 27 16:08:27 2009 @@ -1855,10 +1855,10 @@ .. seealso:: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c - For the full details of the pymalloc implementation, see the comments at the top - of the file :file:`Objects/obmalloc.c` in the Python source code. The above - link points to the file within the SourceForge CVS browser. + http://svn.python.org/view/python/trunk/Objects/obmalloc.c + For the full details of the pymalloc implementation, see the comments at + the top of the file :file:`Objects/obmalloc.c` in the Python source code. + The above link points to the file within the python.org SVN browser. .. ====================================================================== Modified: python/branches/release26-maint/Doc/whatsnew/2.4.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.4.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.4.rst Tue Oct 27 16:08:27 2009 @@ -680,9 +680,6 @@ Written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. - http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html - A more detailed overview of the IEEE-754 representation. - http://www.lahey.com/float.htm The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. @@ -756,7 +753,7 @@ :ctype:`double` to an ASCII string. The code for these functions came from the GLib library -(http://developer.gnome.org/arch/gtk/glib.html), whose developers kindly +(http://library.gnome.org/devel/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release26-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release26-maint/Doc/whatsnew/2.6.rst Tue Oct 27 16:08:27 2009 @@ -1824,7 +1824,7 @@ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol available, instead of restricting itself to protocol 1. - (Contributed by W. Barnes; :issue:`1551443`.) + (Contributed by W. Barnes.) * The :mod:`cgi` module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions @@ -2977,7 +2977,7 @@ * The BerkeleyDB module now has a C API object, available as ``bsddb.db.api``. This object can be used by other C extensions that wish to use the :mod:`bsddb` module for their own purposes. - (Contributed by Duncan Grisby; :issue:`1551895`.) + (Contributed by Duncan Grisby.) * The new buffer interface, previously described in `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__, Modified: python/branches/release26-maint/Lib/ctypes/wintypes.py ============================================================================== --- python/branches/release26-maint/Lib/ctypes/wintypes.py (original) +++ python/branches/release26-maint/Lib/ctypes/wintypes.py Tue Oct 27 16:08:27 2009 @@ -179,7 +179,7 @@ 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT', - 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', + 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE'] Modified: python/branches/release26-maint/Objects/stringobject.c ============================================================================== --- python/branches/release26-maint/Objects/stringobject.c (original) +++ python/branches/release26-maint/Objects/stringobject.c Tue Oct 27 16:08:27 2009 @@ -1806,10 +1806,10 @@ PyDoc_STRVAR(join__doc__, -"S.join(sequence) -> string\n\ +"S.join(iterable) -> string\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject * string_join(PyStringObject *self, PyObject *orig) Modified: python/branches/release26-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release26-maint/Objects/unicodeobject.c (original) +++ python/branches/release26-maint/Objects/unicodeobject.c Tue Oct 27 16:08:27 2009 @@ -7036,10 +7036,10 @@ } PyDoc_STRVAR(join__doc__, - "S.join(sequence) -> unicode\n\ + "S.join(iterable) -> unicode\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject* unicode_join(PyObject *self, PyObject *data) Modified: python/branches/release26-maint/Python/codecs.c ============================================================================== --- python/branches/release26-maint/Python/codecs.c (original) +++ python/branches/release26-maint/Python/codecs.c Tue Oct 27 16:08:27 2009 @@ -774,7 +774,9 @@ { "strict_errors", strict_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'strict' error handling, which " + "raises a UnicodeError on coding errors.") } }, #ifdef Py_USING_UNICODE @@ -783,7 +785,9 @@ { "ignore_errors", ignore_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'ignore' error handling, which " + "ignores malformed data and continues.") } }, { @@ -791,7 +795,9 @@ { "replace_errors", replace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'replace' error handling, which " + "replaces malformed data with a replacement marker.") } }, { @@ -799,7 +805,10 @@ { "xmlcharrefreplace_errors", xmlcharrefreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'xmlcharrefreplace' error handling, " + "which replaces an unencodable character with the " + "appropriate XML character reference.") } }, { @@ -807,7 +816,10 @@ { "backslashreplace_errors", backslashreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'backslashreplace' error handling, " + "which replaces an unencodable character with a " + "backslashed escape sequence.") } } #endif From python-checkins at python.org Tue Oct 27 16:08:53 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:08:53 -0000 Subject: [Python-checkins] r75793 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:08:53 2009 New Revision: 75793 Log: Blocked revisions 75370-75372,75391,75551 via svnmerge ........ r75370 | georg.brandl | 2009-10-11 23:10:07 +0200 (So, 11 Okt 2009) | 1 line Move find_recursionlimit.py to Tools/scripts; it is out of place in Misc. ........ r75371 | georg.brandl | 2009-10-11 23:14:37 +0200 (So, 11 Okt 2009) | 1 line Add find_recursionlimit.py to README. ........ r75372 | georg.brandl | 2009-10-11 23:17:14 +0200 (So, 11 Okt 2009) | 1 line Update Misc/README. ........ r75391 | andrew.kuchling | 2009-10-13 17:49:33 +0200 (Di, 13 Okt 2009) | 1 line Link to PEP ........ r75551 | benjamin.peterson | 2009-10-20 05:14:10 +0200 (Di, 20 Okt 2009) | 1 line use property api ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:09:20 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:09:20 -0000 Subject: [Python-checkins] r75794 - in python/branches/release26-maint: Lib/ctypes/wintypes.py Message-ID: Author: georg.brandl Date: Tue Oct 27 16:09:20 2009 New Revision: 75794 Log: Merged revisions 75593 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line Revert unintended change. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/ctypes/wintypes.py Modified: python/branches/release26-maint/Lib/ctypes/wintypes.py ============================================================================== --- python/branches/release26-maint/Lib/ctypes/wintypes.py (original) +++ python/branches/release26-maint/Lib/ctypes/wintypes.py Tue Oct 27 16:09:20 2009 @@ -179,7 +179,7 @@ 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT', - 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', + 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE'] From python-checkins at python.org Tue Oct 27 16:10:22 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:10:22 -0000 Subject: [Python-checkins] r75795 - python/trunk/Doc/distutils/apiref.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 16:10:22 2009 New Revision: 75795 Log: Fix a strange mis-edit. Modified: python/trunk/Doc/distutils/apiref.rst Modified: python/trunk/Doc/distutils/apiref.rst ============================================================================== --- python/trunk/Doc/distutils/apiref.rst (original) +++ python/trunk/Doc/distutils/apiref.rst Tue Oct 27 16:10:22 2009 @@ -1958,9 +1958,9 @@ Subclasses of :class:`Command` must define the following methods. -.. method:: Command.initialize_options()(S) +.. method:: Command.initialize_options() - et default values for all the options that this command supports. Note that + Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, :meth:`initialize_options` From python-checkins at python.org Tue Oct 27 16:10:48 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:10:48 -0000 Subject: [Python-checkins] r75796 - in python/branches/release26-maint: Doc/distutils/apiref.rst Message-ID: Author: georg.brandl Date: Tue Oct 27 16:10:48 2009 New Revision: 75796 Log: Merged revisions 75795 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line Fix a strange mis-edit. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Doc/distutils/apiref.rst 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 Tue Oct 27 16:10:48 2009 @@ -1962,9 +1962,9 @@ Subclasses of :class:`Command` must define the following methods. -.. method:: Command.initialize_options()(S) +.. method:: Command.initialize_options() - et default values for all the options that this command supports. Note that + Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, :meth:`initialize_options` From python-checkins at python.org Tue Oct 27 16:28:26 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:28:26 -0000 Subject: [Python-checkins] r75797 - in python/branches/py3k: Demo/comparisons/sortingtest.py Doc/distutils/apiref.rst Doc/documenting/markup.rst Doc/faq/design.rst Doc/faq/extending.rst Doc/faq/general.rst Doc/faq/gui.rst Doc/faq/library.rst Doc/faq/programming.rst Doc/faq/windows.rst Doc/howto/unicode.rst Doc/howto/webservers.rst Doc/install/index.rst Doc/library/codecs.rst Doc/library/configparser.rst Doc/library/curses.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/inspect.rst Doc/library/mailbox.rst Doc/library/math.rst Doc/library/msilib.rst Doc/library/os.rst Doc/library/othergui.rst Doc/library/platform.rst Doc/library/signal.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/types.rst Doc/library/weakref.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/tools/sphinxext/pyspecific.py Doc/tools/sphinxext/static/basic.css Doc/tutorial/index.rst Doc/using/cmdline.rst Doc/using/windows.rst Doc/whatsnew/2.0.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.6.rst Lib/threading.py Lib/warnings.py Modules/_ctypes/_ctypes.c Objects/unicodeobject.c Python/codecs.c Message-ID: Author: georg.brandl Date: Tue Oct 27 16:28:25 2009 New Revision: 75797 Log: Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. ........ r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line Fix markup. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line #7126: os.environ changes *do* take effect in subprocesses started with os.system(). ........ r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line #7116: str.join() takes an iterable. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line Fix missing word. ........ r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line Fix punctuation. ........ r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line Revert unintended change. ........ r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line Fix markup. ........ r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line Fix duplicate target. ........ r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line Add a new directive marking up implementation details and start using it. ........ r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line Make it more robust. ........ r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line Document new directive. ........ r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line Allow short form with text as argument. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line Use "impl-detail" directive where applicable. ........ r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line #6324: membership test tries iteration via __iter__. ........ r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line #7088: document new functions in signal as Unix-only. ........ r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line Reorder __slots__ fine print and add a clarification. ........ r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line #7035: improve docs of the various _errors() functions, and give them docstrings. ........ r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line #7156: document curses as Unix-only. ........ r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line #6977: getopt does not support optional option arguments. ........ r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line Add proper references. ........ r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line Make printout margin important. ........ r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line #7188: fix optionxform() docs. ........ r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines add further note about what's passed to optionxform ........ r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines Improve some docstrings in the 'warnings' module. ........ r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line Fix markup. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........ r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line Fix a strange mis-edit. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Demo/comparisons/sortingtest.py python/branches/py3k/Doc/distutils/apiref.rst python/branches/py3k/Doc/documenting/markup.rst python/branches/py3k/Doc/faq/design.rst python/branches/py3k/Doc/faq/extending.rst python/branches/py3k/Doc/faq/general.rst python/branches/py3k/Doc/faq/gui.rst python/branches/py3k/Doc/faq/library.rst python/branches/py3k/Doc/faq/programming.rst python/branches/py3k/Doc/faq/windows.rst python/branches/py3k/Doc/howto/unicode.rst python/branches/py3k/Doc/howto/webservers.rst python/branches/py3k/Doc/install/index.rst python/branches/py3k/Doc/library/codecs.rst python/branches/py3k/Doc/library/configparser.rst python/branches/py3k/Doc/library/curses.rst python/branches/py3k/Doc/library/datetime.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/getopt.rst python/branches/py3k/Doc/library/inspect.rst python/branches/py3k/Doc/library/mailbox.rst python/branches/py3k/Doc/library/math.rst python/branches/py3k/Doc/library/msilib.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Doc/library/othergui.rst python/branches/py3k/Doc/library/platform.rst python/branches/py3k/Doc/library/signal.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Doc/library/types.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Doc/reference/executionmodel.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Doc/reference/simple_stmts.rst python/branches/py3k/Doc/tools/sphinxext/pyspecific.py python/branches/py3k/Doc/tools/sphinxext/static/basic.css python/branches/py3k/Doc/tutorial/index.rst python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Doc/using/windows.rst python/branches/py3k/Doc/whatsnew/2.0.rst python/branches/py3k/Doc/whatsnew/2.2.rst python/branches/py3k/Doc/whatsnew/2.3.rst python/branches/py3k/Doc/whatsnew/2.4.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/threading.py python/branches/py3k/Lib/warnings.py python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Objects/unicodeobject.c python/branches/py3k/Python/codecs.c Modified: python/branches/py3k/Demo/comparisons/sortingtest.py ============================================================================== --- python/branches/py3k/Demo/comparisons/sortingtest.py (original) +++ python/branches/py3k/Demo/comparisons/sortingtest.py Tue Oct 27 16:28:25 2009 @@ -24,7 +24,6 @@ # - Handles blank input lines correctly import re -import string import sys def main(): @@ -32,18 +31,13 @@ def makekey(item, prog=prog): match = prog.match(item) if match: - var, num = match.group(1, 2) - return string.atoi(num), var + var, num = match.groups() + return int(num), var else: # Bad input -- pretend it's a var with value 0 return 0, item - while 1: - line = sys.stdin.readline() - if not line: - break - items = line.split() - items = list(map(makekey, items)) - items.sort() + for line in sys.stdin: + items = sorted(makekey(item) for item in line.split()) for num, var in items: print("%s=%s" % (var, num), end=' ') print() Modified: python/branches/py3k/Doc/distutils/apiref.rst ============================================================================== --- python/branches/py3k/Doc/distutils/apiref.rst (original) +++ python/branches/py3k/Doc/distutils/apiref.rst Tue Oct 27 16:28:25 2009 @@ -1976,9 +1976,9 @@ Subclasses of :class:`Command` must define the following methods. -.. method:: Command.initialize_options()(S) +.. method:: Command.initialize_options() - et default values for all the options that this command supports. Note that + Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, :meth:`initialize_options` Modified: python/branches/py3k/Doc/documenting/markup.rst ============================================================================== --- python/branches/py3k/Doc/documenting/markup.rst (original) +++ python/branches/py3k/Doc/documenting/markup.rst Tue Oct 27 16:28:25 2009 @@ -626,6 +626,24 @@ -------------- +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + .. describe:: seealso Many sections include a list of references to module documentation or Modified: python/branches/py3k/Doc/faq/design.rst ============================================================================== --- python/branches/py3k/Doc/faq/design.rst (original) +++ python/branches/py3k/Doc/faq/design.rst Tue Oct 27 16:28:25 2009 @@ -396,12 +396,13 @@ ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this approach is feasible, -although the speedups reached so far are only modest (e.g. 2x). Jython uses the -same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated -that in combination with whole-program analysis, speedups of 1000x are feasible -for small demo programs. See the proceedings from the `1997 Python conference -`_ for more information.) +conferences `_ have shown that this +approach is feasible, although the speedups reached so far are only modest +(e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim +Hugunin has demonstrated that in combination with whole-program analysis, +speedups of 1000x are feasible for small demo programs. See the proceedings +from the `1997 Python conference +`_ for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual Modified: python/branches/py3k/Doc/faq/extending.rst ============================================================================== --- python/branches/py3k/Doc/faq/extending.rst (original) +++ python/branches/py3k/Doc/faq/extending.rst Tue Oct 27 16:28:25 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`__, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping Modified: python/branches/py3k/Doc/faq/general.rst ============================================================================== --- python/branches/py3k/Doc/faq/general.rst (original) +++ python/branches/py3k/Doc/faq/general.rst Tue Oct 27 16:28:25 2009 @@ -164,9 +164,10 @@ several useful pieces of freely distributable software. The source will compile and run out of the box on most UNIX platforms. -Consult the `Developer FAQ -`__ for more information -on getting the source code and compiling it. +.. XXX update link once the dev faq is relocated + +Consult the `Developer FAQ `__ for more +information on getting the source code and compiling it. How do I get documentation on Python? @@ -176,7 +177,7 @@ The standard documentation for the current stable version of Python is available at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are -also available at http://docs.python.org/download/. +also available at http://docs.python.org/download.html. The documentation is written in reStructuredText and processed by `the Sphinx documentation tool `__. The reStructuredText source @@ -220,8 +221,10 @@ newsgroups and on the Python home page at http://www.python.org/; an RSS feed of news is available. +.. XXX update link once the dev faq is relocated + You can also access the development version of Python through Subversion. See -http://www.python.org/dev/devfaq.html#subversion-svn for details. +http://www.python.org/dev/faq/ for details. How do I submit bug reports and patches for Python? Modified: python/branches/py3k/Doc/faq/gui.rst ============================================================================== --- python/branches/py3k/Doc/faq/gui.rst (original) +++ python/branches/py3k/Doc/faq/gui.rst Tue Oct 27 16:28:25 2009 @@ -45,11 +45,12 @@ ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If you're -writing open source software, you don't need to pay for PyQt, but if you want to -write proprietary applications, you must buy a PyQt license from `Riverbank -Computing `_ and a Qt license from -`Trolltech `_. +`_) and for KDE (PyKDE). If +you're writing open source software, you don't need to pay for PyQt, but if you +want to write proprietary applications, you must buy a PyQt license from +`Riverbank Computing `_ and (up to Qt 4.4; +Qt 4.5 upwards is licensed under the LGPL license) a Qt license from `Trolltech +`_. Gtk+ '''' Modified: python/branches/py3k/Doc/faq/library.rst ============================================================================== --- python/branches/py3k/Doc/faq/library.rst (original) +++ python/branches/py3k/Doc/faq/library.rst Tue Oct 27 16:28:25 2009 @@ -16,14 +16,10 @@ standard library module. (Eventually you'll learn what's in the standard library and will able to skip this step.) -Search the `Python Package Index `_. - -Next, check the `Vaults of Parnassus `_, an older -index of packages. - -Finally, try `Google `_ or other Web search engine. -Searching for "Python" plus a keyword or two for your topic of interest will -usually find something helpful. +For third-party packages, search the `Python Package Index +`_ or try `Google `_ or +another Web search engine. Searching for "Python" plus a keyword or two for +your topic of interest will usually find something helpful. Where is the math.py (socket.py, regex.py, etc.) source file? @@ -181,11 +177,10 @@ How do I create documentation from doc strings? ----------------------------------------------- -.. XXX mention Sphinx/epydoc - The :mod:`pydoc` module can create HTML from the doc strings in your Python -source code. An alternative is `pythondoc -`_. +source code. An alternative for creating API documentation purely from +docstrings is `epydoc `_. `Sphinx +`_ can also include docstring content. How do I get a single keypress at a time? @@ -237,7 +232,7 @@ low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see -http://starship.python.net/crew/aahz/OSCON2001/. +http://www.pythoncraft.com/OSCON2001/. None of my threads seem to run: why? @@ -397,6 +392,7 @@ ------------------------------------------------ .. XXX mention multiprocessing +.. XXX link to dbeazley's talk about GIL? The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded @@ -583,7 +579,7 @@ ("ptys") instead of pipes. Or you can use a Python interface to Don Libes' "expect" library. A Python extension that interfaces to expect is called "expy" and available from http://expectpy.sourceforge.net. A pure Python solution that -works like expect is ` pexpect `_. +works like expect is `pexpect `_. How do I access the serial (RS232) port? Modified: python/branches/py3k/Doc/faq/programming.rst ============================================================================== --- python/branches/py3k/Doc/faq/programming.rst (original) +++ python/branches/py3k/Doc/faq/programming.rst Tue Oct 27 16:28:25 2009 @@ -67,8 +67,8 @@ PyChecker performs, Pylint offers some additional features such as checking line length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://www.logilab.org/projects/pylint/documentation provides a full list of -Pylint's features. +http://www.logilab.org/card/pylint_manual provides a full list of Pylint's +features. How can I create a stand-alone binary from a Python script? @@ -1141,7 +1141,7 @@ A = [[None] * w for i in range(h)] Or, you can use an extension that provides a matrix datatype; `Numeric Python -`_ is the best known. +`_ is the best known. How do I apply a method to a sequence of objects? Modified: python/branches/py3k/Doc/faq/windows.rst ============================================================================== --- python/branches/py3k/Doc/faq/windows.rst (original) +++ python/branches/py3k/Doc/faq/windows.rst Tue Oct 27 16:28:25 2009 @@ -389,10 +389,10 @@ .py :REG_SZ: c:\\python.exe -u %s %s This line will allow you to call your script with a simple reference like: -http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" -directory for your server (which it usually is by default). The "-u" flag -specifies unbuffered and binary mode for stdin - needed when working with binary -data. +``http://yourserver/scripts/yourscript.py`` provided "scripts" is an +"executable" directory for your server (which it usually is by default). The +:option:`-u` flag specifies unbuffered and binary mode for stdin - needed when +working with binary data. In addition, it is recommended that using ".py" may not be a good idea for the file extensions when used in this context (you might want to reserve ``*.py`` @@ -517,7 +517,7 @@ There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will -find links to the knowledge base at: http://www.microsoft.com/kb. +find links to the knowledge base at: http://support.microsoft.com/. PyRun_SimpleFile() crashes on Windows but not on Unix; why? @@ -604,4 +604,4 @@ we can't fix it). David A Burton has written a little program to fix this. Go to -http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". +http://www.burtonsys.com/downloads.html and click on "ctl3dfix.zip". Modified: python/branches/py3k/Doc/howto/unicode.rst ============================================================================== --- python/branches/py3k/Doc/howto/unicode.rst (original) +++ python/branches/py3k/Doc/howto/unicode.rst Tue Oct 27 16:28:25 2009 @@ -403,7 +403,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: python/branches/py3k/Doc/howto/webservers.rst ============================================================================== --- python/branches/py3k/Doc/howto/webservers.rst (original) +++ python/branches/py3k/Doc/howto/webservers.rst Tue Oct 27 16:28:25 2009 @@ -270,8 +270,7 @@ * lighttpd ships its own `FastCGI module `_ as well as an `SCGI module `_. -* nginx also supports `FastCGI - `_. +* nginx also supports `FastCGI `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -525,7 +524,7 @@ informations on a web server. Often relational database engines like `MySQL `_ or -`PostgreSQL `_ are used due to their good +`PostgreSQL `_ are used due to their good performance handling very large databases consisting of up to millions of entries. These are *queried* using a language called `SQL `_. Python programmers in general do not like @@ -629,7 +628,7 @@ It has a big, international community which has created many sites using Django. There are also quite a lot of add-on projects which extend Django's normal functionality. This is partly due to Django's well written `online -documentation `_ and the `Django book +documentation `_ and the `Django book `_. Modified: python/branches/py3k/Doc/install/index.rst ============================================================================== --- python/branches/py3k/Doc/install/index.rst (original) +++ python/branches/py3k/Doc/install/index.rst Tue Oct 27 16:28:25 2009 @@ -937,7 +937,8 @@ These compilers require some special libraries. This task is more complex than for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find -a good program for this task at http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html) +a good program for this task at +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) Modified: python/branches/py3k/Doc/library/codecs.rst ============================================================================== --- python/branches/py3k/Doc/library/codecs.rst (original) +++ python/branches/py3k/Doc/library/codecs.rst Tue Oct 27 16:28:25 2009 @@ -53,7 +53,7 @@ *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: - ``factory(errors='strict')`` + ``factory(errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, @@ -62,21 +62,25 @@ *streamreader* and *streamwriter*: These have to be factory functions providing the following interface: - ``factory(stream, errors='strict')`` + ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. - Possible values for errors are ``'strict'`` (raise an exception in case of an - encoding error), ``'replace'`` (replace malformed data with a suitable - replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and - continue without further notice), ``'xmlcharrefreplace'`` (replace with the - appropriate XML character reference (for encoding only)), - ``'backslashreplace'`` (replace with backslashed escape sequences (for - encoding only)), ``'surrogateescape'`` (replace with surrogate U+DCxx, see - :pep:`383`) as well as any other error handling name defined via - :func:`register_error`. + Possible values for errors are + + * ``'strict'``: raise an exception in case of an encoding error + * ``'replace'``: replace malformed data with a suitable replacement marker, + such as ``'?'`` or ``'\ufffd'`` + * ``'ignore'``: ignore malformed data and continue without further notice + * ``'xmlcharrefreplace'``: replace with the appropriate XML character + reference (for encoding only) + * ``'backslashreplace'``: replace with backslashed escape sequences (for + encoding only + * ``'surrogateescape'``: replace with surrogate U+DCxx, see :pep:`383` + + as well as any other error handling name defined via :func:`register_error`. In case a search function cannot find a given encoding, it should return ``None``. @@ -173,27 +177,33 @@ .. function:: strict_errors(exception) - Implements the ``strict`` error handling. + Implements the ``strict`` error handling: each encoding or decoding error + raises a :exc:`UnicodeError`. .. function:: replace_errors(exception) - Implements the ``replace`` error handling. + Implements the ``replace`` error handling: malformed data is replaced with a + suitable replacement character such as ``'?'`` in bytestrings and + ``'\ufffd'`` in Unicode strings. .. function:: ignore_errors(exception) - Implements the ``ignore`` error handling. + Implements the ``ignore`` error handling: malformed data is ignored and + encoding or decoding is continued without further notice. .. function:: xmlcharrefreplace_errors(exception) - Implements the ``xmlcharrefreplace`` error handling. + Implements the ``xmlcharrefreplace`` error handling (for encoding only): the + unencodable character is replaced by an appropriate XML character reference. .. function:: backslashreplace_errors(exception) - Implements the ``backslashreplace`` error handling. + Implements the ``backslashreplace`` error handling (for encoding only): the + unencodable character is replaced by a backslashed escape sequence. To simplify working with encoded files or stream, the module also defines these utility functions: Modified: python/branches/py3k/Doc/library/configparser.rst ============================================================================== --- python/branches/py3k/Doc/library/configparser.rst (original) +++ python/branches/py3k/Doc/library/configparser.rst Tue Oct 27 16:28:25 2009 @@ -301,12 +301,23 @@ .. method:: RawConfigParser.optionxform(option) - Transforms the option name *option* as found in an input file or as passed in by - client code to the form that should be used in the internal structures. The - default implementation returns a lower-case version of *option*; subclasses may - override this or client code can set an attribute of this name on instances to - affect this behavior. Setting this to :func:`str`, for example, would make - option names case sensitive. + Transforms the option name *option* as found in an input file or as passed in + by client code to the form that should be used in the internal structures. + The default implementation returns a lower-case version of *option*; + subclasses may override this or client code can set an attribute of this name + on instances to affect this behavior. + + You don't necessarily need to subclass a ConfigParser to use this method, you + can also re-set it on an instance, to a function that takes a string + argument. Setting it to ``str``, for example, would make option names case + sensitive:: + + cfgparser = ConfigParser() + ... + cfgparser.optionxform = str + + Note that when reading configuration files, whitespace around the + option names are stripped before :meth:`optionxform` is called. .. _configparser-objects: Modified: python/branches/py3k/Doc/library/curses.rst ============================================================================== --- python/branches/py3k/Doc/library/curses.rst (original) +++ python/branches/py3k/Doc/library/curses.rst Tue Oct 27 16:28:25 2009 @@ -4,10 +4,10 @@ .. module:: curses :synopsis: An interface to the curses library, providing portable terminal handling. + :platform: Unix .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond - The :mod:`curses` module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling. Modified: python/branches/py3k/Doc/library/datetime.rst ============================================================================== --- python/branches/py3k/Doc/library/datetime.rst (original) +++ python/branches/py3k/Doc/library/datetime.rst Tue Oct 27 16:28:25 2009 @@ -233,7 +233,7 @@ | | (-*t1.days*, -*t1.seconds*, | | | -*t1.microseconds*), and to *t1*\* -1. (1)(4) | +--------------------------------+-----------------------------------------------+ -| ``abs(t)`` | equivalent to +*t* when ``t.days >= 0``, and | +| ``abs(t)`` | equivalent to +\ *t* when ``t.days >= 0``, and| | | to -*t* when ``t.days < 0``. (2) | +--------------------------------+-----------------------------------------------+ Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Tue Oct 27 16:28:25 2009 @@ -499,8 +499,10 @@ Return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. - Two objects with non-overlapping lifetimes may have the same :func:`id` value. - (Implementation note: this is the address of the object.) + Two objects with non-overlapping lifetimes may have the same :func:`id` + value. + + .. impl-detail:: This is the address of the object. .. function:: input([prompt]) Modified: python/branches/py3k/Doc/library/getopt.rst ============================================================================== --- python/branches/py3k/Doc/library/getopt.rst (original) +++ python/branches/py3k/Doc/library/getopt.rst Tue Oct 27 16:28:25 2009 @@ -36,12 +36,13 @@ *longopts*, if specified, must be a list of strings with the names of the long options which should be supported. The leading ``'--'`` characters should not be included in the option name. Long options which require an - argument should be followed by an equal sign (``'='``). To accept only long - options, *shortopts* should be an empty string. Long options on the command line - can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *longopts* is - ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, - but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. + argument should be followed by an equal sign (``'='``). Optional arguments + are not supported. To accept only long options, *shortopts* should be an + empty string. Long options on the command line can be recognized so long as + they provide a prefix of the option name that matches exactly one of the + accepted options. For example, if *longopts* is ``['foo', 'frob']``, the + option :option:`--fo` will match as :option:`--foo`, but :option:`--f` will + not match uniquely, so :exc:`GetoptError` will be raised. The return value consists of two elements: the first is a list of ``(option, value)`` pairs; the second is the list of program arguments left after the Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Tue Oct 27 16:28:25 2009 @@ -290,18 +290,22 @@ Return true if the object is a getset descriptor. - getsets are attributes defined in extension modules via ``PyGetSetDef`` - structures. For Python implementations without such types, this method will - always return ``False``. + .. impl-detail:: + + getsets are attributes defined in extension modules via + :ctype:`PyGetSetDef` structures. For Python implementations without such + types, this method will always return ``False``. .. function:: ismemberdescriptor(object) Return true if the object is a member descriptor. - Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, - this method will always return ``False``. + .. impl-detail:: + + Member descriptors are attributes defined in extension modules via + :ctype:`PyMemberDef` structures. For Python implementations without such + types, this method will always return ``False``. .. _inspect-source: @@ -508,10 +512,12 @@ Return the frame object for the caller's stack frame. - This function relies on Python stack frame support in the interpreter, which - isn't guaranteed to exist in all implementations of Python. If running in - an implementation without Python stack frame support this function returns - ``None``. + .. impl-detail:: + + This function relies on Python stack frame support in the interpreter, + which isn't guaranteed to exist in all implementations of Python. If + running in an implementation without Python stack frame support this + function returns ``None``. .. function:: stack(context=1) Modified: python/branches/py3k/Doc/library/mailbox.rst ============================================================================== --- python/branches/py3k/Doc/library/mailbox.rst (original) +++ python/branches/py3k/Doc/library/mailbox.rst Tue Oct 27 16:28:25 2009 @@ -595,7 +595,7 @@ `nmh - Message Handling System `_ Home page of :program:`nmh`, an updated version of the original :program:`mh`. - `MH & nmh: Email for Users & Programmers `_ + `MH & nmh: Email for Users & Programmers `_ A GPL-licensed book on :program:`mh` and :program:`nmh`, with some information on the mailbox format. Modified: python/branches/py3k/Doc/library/math.rst ============================================================================== --- python/branches/py3k/Doc/library/math.rst (original) +++ python/branches/py3k/Doc/library/math.rst Tue Oct 27 16:28:25 2009 @@ -301,7 +301,7 @@ The mathematical constant *e*. -.. note:: +.. impl-detail:: The :mod:`math` module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified Modified: python/branches/py3k/Doc/library/msilib.rst ============================================================================== --- python/branches/py3k/Doc/library/msilib.rst (original) +++ python/branches/py3k/Doc/library/msilib.rst Tue Oct 27 16:28:25 2009 @@ -394,10 +394,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -422,7 +422,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -516,13 +516,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: @@ -551,5 +551,3 @@ This module contains definitions for the UIText and ActionText tables, for the standard installer actions. - - Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Tue Oct 27 16:28:25 2009 @@ -1576,9 +1576,9 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :cfunc:`system`, and has the same limitations. Changes - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the - environment of the executed command. + the Standard C function :cfunc:`system`, and has the same limitations. + Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the + executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning Modified: python/branches/py3k/Doc/library/othergui.rst ============================================================================== --- python/branches/py3k/Doc/library/othergui.rst (original) +++ python/branches/py3k/Doc/library/othergui.rst Tue Oct 27 16:28:25 2009 @@ -43,7 +43,7 @@ `PythonCAD `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool Modified: python/branches/py3k/Doc/library/platform.rst ============================================================================== --- python/branches/py3k/Doc/library/platform.rst (original) +++ python/branches/py3k/Doc/library/platform.rst Tue Oct 27 16:28:25 2009 @@ -94,7 +94,7 @@ .. function:: python_implementation() Returns a string identifying the Python implementation. Possible return values - are: 'CPython', 'IronPython', 'Jython' + are: 'CPython', 'IronPython', 'Jython'. .. function:: python_revision() Modified: python/branches/py3k/Doc/library/signal.rst ============================================================================== --- python/branches/py3k/Doc/library/signal.rst (original) +++ python/branches/py3k/Doc/library/signal.rst Tue Oct 27 16:28:25 2009 @@ -157,13 +157,14 @@ The old values are returned as a tuple: (delay, interval). - Attempting to pass an invalid interval timer will cause a - :exc:`ItimerError`. + Attempting to pass an invalid interval timer will cause an + :exc:`ItimerError`. Availability: Unix. .. function:: getitimer(which) Returns current value of a given interval timer specified by *which*. + Availability: Unix. .. function:: set_wakeup_fd(fd) @@ -184,7 +185,7 @@ Change system call restart behaviour: if *flag* is :const:`False`, system calls will be restarted when interrupted by signal *signalnum*, otherwise - system calls will be interrupted. Returns nothing. Availability: Unix (see + system calls will be interrupted. Returns nothing. Availability: Unix (see the man page :manpage:`siginterrupt(3)` for further information). Note that installing a signal handler with :func:`signal` will reset the Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Tue Oct 27 16:28:25 2009 @@ -772,13 +772,15 @@ If *k* is ``None``, it is treated like ``1``. (6) - If *s* and *t* are both strings, some Python implementations such as CPython can - usually perform an in-place optimization for assignments of the form ``s=s+t`` - or ``s+=t``. When applicable, this optimization makes quadratic run-time much - less likely. This optimization is both version and implementation dependent. - For performance sensitive code, it is preferable to use the :meth:`str.join` - method which assures consistent linear concatenation performance across versions - and implementations. + .. impl-detail:: + + If *s* and *t* are both strings, some Python implementations such as + CPython can usually perform an in-place optimization for assignments of + the form ``s = s + t`` or ``s += t``. When applicable, this optimization + makes quadratic run-time much less likely. This optimization is both + version and implementation dependent. For performance sensitive code, it + is preferable to use the :meth:`str.join` method which assures consistent + linear concatenation performance across versions and implementations. .. _string-methods: @@ -951,12 +953,12 @@ least one cased character, false otherwise. -.. method:: str.join(seq) +.. method:: str.join(iterable) - Return a string which is the concatenation of the strings in the sequence - *seq*. A :exc:`TypeError` will be raised if there are any non-string values - in *seq*, including :class:`bytes` objects. The separator between elements - is the string providing this method. + Return a string which is the concatenation of the strings in the + :term:`iterable` *iterable*. A :exc:`TypeError` will be raised if there are + any non-string values in *seq*, including :class:`bytes` objects. The + separator between elements is the string providing this method. .. method:: str.ljust(width[, fillchar]) @@ -1510,14 +1512,17 @@ that compare equal --- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). - While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation - makes the list appear empty for the duration, and raises :exc:`ValueError` if it - can detect that the list has been mutated during a sort. + .. impl-detail:: + + While a list is being sorted, the effect of attempting to mutate, or even + inspect, the list is undefined. The C implementation of Python makes the + list appear empty for the duration, and raises :exc:`ValueError` if it can + detect that the list has been mutated during a sort. (8) :meth:`sort` is not supported by :class:`bytearray` objects. + .. _bytes-methods: Bytes and Byte Array Methods Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Tue Oct 27 16:28:25 2009 @@ -352,8 +352,10 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. It - is not guaranteed to exist in all implementations of Python. + .. impl-detail:: + + This function should be used for internal and specialized purposes only. + It is not guaranteed to exist in all implementations of Python. .. function:: getprofile() @@ -373,12 +375,12 @@ Get the trace function as set by :func:`settrace`. - .. note:: + .. impl-detail:: The :func:`gettrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, - and thus may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: getwindowsversion() @@ -750,12 +752,12 @@ For more information on code and frame objects, refer to :ref:`types`. - .. note:: + .. impl-detail:: The :func:`settrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, and thus - may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: settscdump(on_flag) Modified: python/branches/py3k/Doc/library/types.rst ============================================================================== --- python/branches/py3k/Doc/library/types.rst (original) +++ python/branches/py3k/Doc/library/types.rst Tue Oct 27 16:28:25 2009 @@ -77,5 +77,8 @@ as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the :class:`property` type, but for classes defined in extension modules. - In other implementations of Python, this type may be identical to - ``GetSetDescriptorType``. + + .. impl-detail:: + + In other implementations of Python, this type may be identical to + ``GetSetDescriptorType``. Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Tue Oct 27 16:28:25 2009 @@ -72,9 +72,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable -Other built-in types such as :class:`tuple` and :class:`int` do not support -weak references even when subclassed (those types implemented as a -:ctype:`PyVarObject`). +.. impl-detail:: + + Other built-in types such as :class:`tuple` and :class:`long` do not support + weak references even when subclassed. Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Tue Oct 27 16:28:25 2009 @@ -59,13 +59,16 @@ they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether --- it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that -are still reachable. (Implementation note: CPython currently uses a -reference-counting scheme with (optional) delayed detection of cyclically linked -garbage, which collects most objects as soon as they become unreachable, but is -not guaranteed to collect garbage containing circular references. See the -documentation of the :mod:`gc` module for information on controlling the -collection of cyclic garbage. Other implementations act differently and CPython -may change.) +are still reachable. + +.. impl-detail:: + + CPython currently uses a reference-counting scheme with (optional) delayed + detection of cyclically linked garbage, which collects most objects as soon + as they become unreachable, but is not guaranteed to collect garbage + containing circular references. See the documentation of the :mod:`gc` + module for information on controlling the collection of cyclic garbage. + Other implementations act differently and CPython may change. Note that the use of the implementation's tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching @@ -1469,15 +1472,15 @@ *__slots__*; otherwise, the class attribute would overwrite the descriptor assignment. +* The action of a *__slots__* declaration is limited to the class where it is + defined. As a result, subclasses will have a *__dict__* unless they also define + *__slots__* (which must only contain names of any *additional* slots). + * If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this. -* The action of a *__slots__* declaration is limited to the class where it is - defined. As a result, subclasses will have a *__dict__* unless they also define - *__slots__*. - * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`int`, :class:`str` and :class:`tuple`. @@ -1714,12 +1717,16 @@ supply the following special method with a more efficient implementation, which also does not require the object be a sequence. - .. method:: object.__contains__(self, item) - Called to implement membership test operators. Should return true if *item* is - in *self*, false otherwise. For mapping objects, this should consider the keys - of the mapping rather than the values or the key-item pairs. + Called to implement membership test operators. Should return true if *item* + is in *self*, false otherwise. For mapping objects, this should consider the + keys of the mapping rather than the values or the key-item pairs. + + For objects that don't define :meth:`__contains__`, the membership test first + tries iteration via :meth:`__iter__`, then the old sequence iteration + protocol via :meth:`__getitem__`, see :ref:`this section in the language + reference `. .. _numeric-types: Modified: python/branches/py3k/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/executionmodel.rst (original) +++ python/branches/py3k/Doc/reference/executionmodel.rst Tue Oct 27 16:28:25 2009 @@ -129,7 +129,7 @@ itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. -.. note:: +.. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Tue Oct 27 16:28:25 2009 @@ -639,13 +639,13 @@ raised. Otherwise, the list of filled slots is used as the argument list for the call. -.. note:: +.. impl-detail:: - An implementation may provide built-in functions whose positional parameters do - not have names, even if they are 'named' for the purpose of documentation, and - which therefore cannot be supplied by keyword. In CPython, this is the case for - functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their - arguments. + An implementation may provide built-in functions whose positional parameters + do not have names, even if they are 'named' for the purpose of documentation, + and which therefore cannot be supplied by keyword. In CPython, this is the + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to + parse their arguments. If there are more positional arguments than there are formal parameter slots, a :exc:`TypeError` exception is raised, unless a formal parameter using the syntax @@ -1053,6 +1053,8 @@ supported cross-type comparisons and unsupported comparisons. For example, ``Decimal(2) == 2`` and `2 == float(2)`` but ``Decimal(2) != float(2)``. +.. _membership-test-details: + The operators :keyword:`in` and :keyword:`not in` test for membership. ``x in s`` evaluates to true if *x* is a member of *s*, and false otherwise. ``x not in s`` returns the negation of ``x in s``. All built-in sequences and set types @@ -1069,7 +1071,12 @@ For user-defined classes which define the :meth:`__contains__` method, ``x in y`` is true if and only if ``y.__contains__(x)`` is true. -For user-defined classes which do not define :meth:`__contains__` and do define +For user-defined classes which do not define :meth:`__contains__` but do define +:meth:`__iter__`, ``x in y`` is true if some value ``z`` with ``x == z`` is +produced while iterating over ``y``. If an exception is raised during the +iteration, it is as if :keyword:`in` raised that exception. + +Lastly, the old-style iteration protocol is tried: if a class defines :meth:`__getitem__`, ``x in y`` is true if and only if there is a non-negative integer index *i* such that ``x == y[i]``, and all lower integer indices do not raise :exc:`IndexError` exception. (If any other exception is raised, it is as Modified: python/branches/py3k/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k/Doc/reference/simple_stmts.rst Tue Oct 27 16:28:25 2009 @@ -236,9 +236,11 @@ from the length of the assigned sequence, thus changing the length of the target sequence, if the object allows it. -(In the current implementation, the syntax for targets is taken to be the same -as for expressions, and invalid syntax is rejected during the code generation -phase, causing less detailed error messages.) +.. impl-detail:: + + In the current implementation, the syntax for targets is taken to be the same + as for expressions, and invalid syntax is rejected during the code generation + phase, causing less detailed error messages. WARNING: Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are 'safe' (for example ``a, b = b, a`` @@ -937,9 +939,11 @@ parameters or in a :keyword:`for` loop control target, :keyword:`class` definition, function definition, or :keyword:`import` statement. -(The current implementation does not enforce the latter two restrictions, but -programs should not abuse this freedom, as future implementations may enforce -them or silently change the meaning of the program.) +.. impl-detail:: + + The current implementation does not enforce the latter two restrictions, but + programs should not abuse this freedom, as future implementations may enforce + them or silently change the meaning of the program. .. index:: builtin: exec Modified: python/branches/py3k/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/py3k/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/py3k/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 16:28:25 2009 @@ -35,6 +35,8 @@ HTMLTranslator.visit_versionmodified = new_visit_versionmodified +# Support for marking up and linking to bugs.python.org issues + def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): issue = utils.unescape(text) text = 'issue ' + issue @@ -42,6 +44,34 @@ return [refnode], [] +# Support for marking up implementation details + +from sphinx.util.compat import Directive + +class ImplementationDetail(Directive): + + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = True + + def run(self): + pnode = nodes.compound(classes=['impl-detail']) + content = self.content + add_text = nodes.strong('CPython implementation detail:', + 'CPython implementation detail:') + if self.arguments: + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.append(nodes.paragraph('', '', *(n + m))) + self.state.nested_parse(content, self.content_offset, pnode) + if pnode.children and isinstance(pnode[0], nodes.paragraph): + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) + else: + pnode.insert(0, nodes.paragraph('', '', add_text)) + return [pnode] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -108,10 +138,12 @@ finally: f.close() + # Support for checking for suspicious markup import suspicious + # Support for documenting Opcodes import re @@ -134,6 +166,7 @@ def setup(app): app.add_role('issue', issue_role) + app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', Modified: python/branches/py3k/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/branches/py3k/Doc/tools/sphinxext/static/basic.css (original) +++ python/branches/py3k/Doc/tools/sphinxext/static/basic.css Tue Oct 27 16:28:25 2009 @@ -345,6 +345,21 @@ background-color: #ffa } +.impl-detail { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; + border: 1px solid #ccc; +} + +.impl-detail .compound-first { + margin-top: 0; +} + +.impl-detail .compound-last { + margin-bottom: 0; +} + /* -- code displays --------------------------------------------------------- */ pre { @@ -405,7 +420,7 @@ div.document, div.documentwrapper, div.bodywrapper { - margin: 0; + margin: 0 !important; width: 100%; } Modified: python/branches/py3k/Doc/tutorial/index.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/index.rst (original) +++ python/branches/py3k/Doc/tutorial/index.rst Tue Oct 27 16:28:25 2009 @@ -28,18 +28,17 @@ interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. -For a description of standard objects and modules, see the Python Library -Reference document. The Python Reference Manual gives a more formal definition -of the language. To write extensions in C or C++, read Extending and Embedding -the Python Interpreter and Python/C API Reference. There are also several books -covering Python in depth. +For a description of standard objects and modules, see :ref:`library-index`. +:ref:`reference-index` gives a more formal definition of the language. To write +extensions in C or C++, read :ref:`extending-index` and +:ref:`c-api-index`. There are also several books covering Python in depth. This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the -various Python library modules described in the Python Library Reference. +various Python library modules described in :ref:`library-index`. The :ref:`glossary` is also worth going through. Modified: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- python/branches/py3k/Doc/using/cmdline.rst (original) +++ python/branches/py3k/Doc/using/cmdline.rst Tue Oct 27 16:28:25 2009 @@ -8,7 +8,7 @@ The CPython interpreter scans the command line and the environment for various settings. -.. note:: +.. impl-detail:: Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. Modified: python/branches/py3k/Doc/using/windows.rst ============================================================================== --- python/branches/py3k/Doc/using/windows.rst (original) +++ python/branches/py3k/Doc/using/windows.rst Tue Oct 27 16:28:25 2009 @@ -67,7 +67,7 @@ `ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Python Enthought Edition `_ +`Enthought Python Distribution `_ Popular modules (such as PyWin32) with their respective documentation, tool suite for building extensible python applications @@ -221,8 +221,7 @@ * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces `PythonWin `_ + `MingW -- Python extensions `_ by Trent Apted et al, 2007 Modified: python/branches/py3k/Doc/whatsnew/2.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.0.rst Tue Oct 27 16:28:25 2009 @@ -572,8 +572,7 @@ mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still ``'win32'`` on Win64 because it seems that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) PythonWin also supports Windows CE; see the -Python CE page at http://starship.python.net/crew/mhammond/ce/ for more -information. +Python CE page at http://pythonce.sourceforge.net/ for more information. Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify "configure --with-dyld --with-suffix=.x". @@ -1041,8 +1040,8 @@ to include SSL support, which adds an additional function to the :mod:`socket` module: :func:`socket.ssl(socket, keyfile, certfile)`, which takes a socket object and returns an SSL socket. The :mod:`httplib` and :mod:`urllib` modules -were also changed to support "https://" URLs, though no one has implemented FTP -or SMTP over SSL. +were also changed to support ``https://`` URLs, though no one has implemented +FTP or SMTP over SSL. The :mod:`httplib` module has been rewritten by Greg Stein to support HTTP/1.1. Backward compatibility with the 1.5 version of :mod:`httplib` is provided, Modified: python/branches/py3k/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.2.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.2.rst Tue Oct 27 16:28:25 2009 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso:: +.. seealso (now defunct) http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and @@ -49,14 +49,14 @@ complicated section of this article, I'll provide an overview of the changes and offer some comments. -A long time ago I wrote a Web page (http://www.amk.ca/python/writing/warts.html) -listing flaws in Python's design. One of the most significant flaws was that -it's impossible to subclass Python types implemented in C. In particular, it's -not possible to subclass built-in types, so you can't just subclass, say, lists -in order to add a single useful method to them. The :mod:`UserList` module -provides a class that supports all of the methods of lists and that can be -subclassed further, but there's lots of C code that expects a regular Python -list and won't accept a :class:`UserList` instance. +A long time ago I wrote a Web page listing flaws in Python's design. One of the +most significant flaws was that it's impossible to subclass Python types +implemented in C. In particular, it's not possible to subclass built-in types, +so you can't just subclass, say, lists in order to add a single useful method to +them. The :mod:`UserList` module provides a class that supports all of the +methods of lists and that can be subclassed further, but there's lots of C code +that expects a regular Python list and won't accept a :class:`UserList` +instance. Python 2.2 fixes this, and in the process adds some exciting new capabilities. A brief summary: Modified: python/branches/py3k/Doc/whatsnew/2.3.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.3.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.3.rst Tue Oct 27 16:28:25 2009 @@ -1855,10 +1855,10 @@ .. seealso:: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c - For the full details of the pymalloc implementation, see the comments at the top - of the file :file:`Objects/obmalloc.c` in the Python source code. The above - link points to the file within the SourceForge CVS browser. + http://svn.python.org/view/python/trunk/Objects/obmalloc.c + For the full details of the pymalloc implementation, see the comments at + the top of the file :file:`Objects/obmalloc.c` in the Python source code. + The above link points to the file within the python.org SVN browser. .. ====================================================================== Modified: python/branches/py3k/Doc/whatsnew/2.4.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.4.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.4.rst Tue Oct 27 16:28:25 2009 @@ -680,9 +680,6 @@ Written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. - http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html - A more detailed overview of the IEEE-754 representation. - http://www.lahey.com/float.htm The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. @@ -756,7 +753,7 @@ :ctype:`double` to an ASCII string. The code for these functions came from the GLib library -(http://developer.gnome.org/arch/gtk/glib.html), whose developers kindly +(http://library.gnome.org/devel/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Tue Oct 27 16:28:25 2009 @@ -1828,7 +1828,7 @@ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol available, instead of restricting itself to protocol 1. - (Contributed by W. Barnes; :issue:`1551443`.) + (Contributed by W. Barnes.) * The :mod:`cgi` module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions @@ -2977,7 +2977,7 @@ * The BerkeleyDB module now has a C API object, available as ``bsddb.db.api``. This object can be used by other C extensions that wish to use the :mod:`bsddb` module for their own purposes. - (Contributed by Duncan Grisby; :issue:`1551895`.) + (Contributed by Duncan Grisby.) * The new buffer interface, previously described in `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__, Modified: python/branches/py3k/Lib/threading.py ============================================================================== --- python/branches/py3k/Lib/threading.py (original) +++ python/branches/py3k/Lib/threading.py Tue Oct 27 16:28:25 2009 @@ -119,7 +119,7 @@ def release(self): if self._owner is not current_thread(): - raise RuntimeError("cannot release un-aquired lock") + raise RuntimeError("cannot release un-acquired lock") self._count = count = self._count - 1 if not count: self._owner = None @@ -211,7 +211,7 @@ def wait(self, timeout=None): if not self._is_owned(): - raise RuntimeError("cannot wait on un-aquired lock") + raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() waiter.acquire() self._waiters.append(waiter) @@ -253,7 +253,7 @@ def notify(self, n=1): if not self._is_owned(): - raise RuntimeError("cannot notify on un-aquired lock") + raise RuntimeError("cannot notify on un-acquired lock") __waiters = self._waiters waiters = __waiters[:n] if not waiters: Modified: python/branches/py3k/Lib/warnings.py ============================================================================== --- python/branches/py3k/Lib/warnings.py (original) +++ python/branches/py3k/Lib/warnings.py Tue Oct 27 16:28:25 2009 @@ -32,7 +32,14 @@ append=False): """Insert an entry into the list of warnings filters (at the front). - Use assertions to check that all arguments have the right type.""" + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'message' -- a regex that the warning message must match + 'category' -- a class that the warning must be a subclass of + 'module' -- a regex that the module name must match + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters + """ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) @@ -53,6 +60,11 @@ """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'category' -- a class that the warning must be a subclass of + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters """ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Tue Oct 27 16:28:25 2009 @@ -1865,16 +1865,15 @@ } fmt = _ctypes_get_fielddesc(proto_str); if (fmt == NULL) { - Py_DECREF((PyObject *)result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", proto_str); - return NULL; + goto error; } stgdict = (StgDictObject *)PyObject_CallObject( (PyObject *)&PyCStgDict_Type, NULL); if (!stgdict) - return NULL; + goto error; stgdict->ffi_type_pointer = *fmt->pffi_type; stgdict->align = fmt->pffi_type->alignment; @@ -1889,6 +1888,7 @@ #endif if (stgdict->format == NULL) { Py_DECREF(result); + Py_DECREF(proto); Py_DECREF((PyObject *)stgdict); return NULL; } Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Tue Oct 27 16:28:25 2009 @@ -7710,10 +7710,10 @@ } PyDoc_STRVAR(join__doc__, - "S.join(sequence) -> str\n\ + "S.join(iterable) -> str\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject* unicode_join(PyObject *self, PyObject *data) Modified: python/branches/py3k/Python/codecs.c ============================================================================== --- python/branches/py3k/Python/codecs.c (original) +++ python/branches/py3k/Python/codecs.c Tue Oct 27 16:28:25 2009 @@ -957,7 +957,9 @@ { "strict_errors", strict_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'strict' error handling, which " + "raises a UnicodeError on coding errors.") } }, { @@ -965,7 +967,9 @@ { "ignore_errors", ignore_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'ignore' error handling, which " + "ignores malformed data and continues.") } }, { @@ -973,7 +977,9 @@ { "replace_errors", replace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'replace' error handling, which " + "replaces malformed data with a replacement marker.") } }, { @@ -981,7 +987,10 @@ { "xmlcharrefreplace_errors", xmlcharrefreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'xmlcharrefreplace' error handling, " + "which replaces an unencodable character with the " + "appropriate XML character reference.") } }, { @@ -989,7 +998,10 @@ { "backslashreplace_errors", backslashreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'backslashreplace' error handling, " + "which replaces an unencodable character with a " + "backslashed escape sequence.") } }, { From python-checkins at python.org Tue Oct 27 16:39:53 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:39:53 -0000 Subject: [Python-checkins] r75798 - in python/branches/release26-maint: Demo/comparisons/sortingtest.py Doc/tools/sphinxext/pyspecific.py Doc/tools/sphinxext/static/basic.css Lib/Cookie.py Lib/multiprocessing/queues.py Lib/pdb.py Lib/platform.py Lib/test/test_kqueue.py Lib/test/test_traceback.py Lib/threading.py Lib/traceback.py Lib/webbrowser.py Misc/gdbinit Modules/_ctypes/_ctypes.c Modules/selectmodule.c Python/peephole.c README Tools/scripts/pindent.py Message-ID: Author: georg.brandl Date: Tue Oct 27 16:39:53 2009 New Revision: 75798 Log: Merged revisions 73206,73232,73299,73683,74020,74185,74544,74643,74647,74817,74838-74839,74865,74946,75402,75459,75604,75696 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r73206 | georg.brandl | 2009-06-04 11:15:12 +0200 (Do, 04 Jun 2009) | 1 line #3584: ignore trailing newlines when placing the caret for a SyntaxError location. ........ r73232 | georg.brandl | 2009-06-04 20:59:58 +0200 (Do, 04 Jun 2009) | 1 line Add test for #3684. ........ r73299 | georg.brandl | 2009-06-08 20:41:36 +0200 (Mo, 08 Jun 2009) | 1 line Typo fix. ........ r73683 | georg.brandl | 2009-06-29 16:44:49 +0200 (Mo, 29 Jun 2009) | 1 line Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. ........ r74020 | georg.brandl | 2009-07-16 09:18:07 +0200 (Do, 16 Jul 2009) | 1 line #5910: fix kqueue for calls with more than one event. ........ r74185 | georg.brandl | 2009-07-23 11:17:09 +0200 (Do, 23 Jul 2009) | 1 line Fix the "pylocals" gdb command. ........ r74544 | georg.brandl | 2009-08-24 19:12:30 +0200 (Mo, 24 Aug 2009) | 1 line #6775: fix python.org URLs in README. ........ r74643 | georg.brandl | 2009-09-04 08:59:20 +0200 (Fr, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74647 | georg.brandl | 2009-09-04 10:17:04 +0200 (Fr, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line Make deprecation notices as visible as warnings are right now. ........ r74838 | georg.brandl | 2009-09-16 18:22:12 +0200 (Mi, 16 Sep 2009) | 1 line Remove some more boilerplate from the actual tests in test_pdb. ........ r74839 | georg.brandl | 2009-09-16 18:36:39 +0200 (Mi, 16 Sep 2009) | 1 line Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that. ........ r74865 | georg.brandl | 2009-09-17 09:49:37 +0200 (Do, 17 Sep 2009) | 1 line #6912: add "with" block support to pindent. ........ r74946 | georg.brandl | 2009-09-19 10:43:16 +0200 (Sa, 19 Sep 2009) | 1 line Update bug tracker reference. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Demo/comparisons/sortingtest.py python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css python/branches/release26-maint/Lib/Cookie.py python/branches/release26-maint/Lib/multiprocessing/queues.py python/branches/release26-maint/Lib/pdb.py python/branches/release26-maint/Lib/platform.py python/branches/release26-maint/Lib/test/test_kqueue.py python/branches/release26-maint/Lib/test/test_traceback.py python/branches/release26-maint/Lib/threading.py python/branches/release26-maint/Lib/traceback.py python/branches/release26-maint/Lib/webbrowser.py python/branches/release26-maint/Misc/gdbinit python/branches/release26-maint/Modules/_ctypes/_ctypes.c python/branches/release26-maint/Modules/selectmodule.c python/branches/release26-maint/Python/peephole.c python/branches/release26-maint/README python/branches/release26-maint/Tools/scripts/pindent.py Modified: python/branches/release26-maint/Demo/comparisons/sortingtest.py ============================================================================== --- python/branches/release26-maint/Demo/comparisons/sortingtest.py (original) +++ python/branches/release26-maint/Demo/comparisons/sortingtest.py Tue Oct 27 16:39:53 2009 @@ -24,7 +24,6 @@ # - Handles blank input lines correctly import re -import string import sys def main(): @@ -32,18 +31,13 @@ def makekey(item, prog=prog): match = prog.match(item) if match: - var, num = match.group(1, 2) - return string.atoi(num), var + var, num = match.groups() + return int(num), var else: # Bad input -- pretend it's a var with value 0 return 0, item - while 1: - line = sys.stdin.readline() - if not line: - break - items = line.split() - items = map(makekey, items) - items.sort() + for line in sys.stdin: + items = sorted(makekey(item) for item in line.split()) for num, var in items: print "%s=%s" % (var, num), print Modified: python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 16:39:53 2009 @@ -20,6 +20,20 @@ Body.enum.converters['lowerroman'] = \ Body.enum.converters['upperroman'] = lambda x: None +# monkey-patch HTML translator to give versionmodified paragraphs a class +from sphinx.writers.html import HTMLTranslator +from sphinx.locale import versionlabels +HTMLTranslator.visit_versionmodified = new_visit_versionmodified + +def new_visit_versionmodified(self, node): + self.body.append(self.starttag(node, 'p', CLASS=node['type'])) + text = versionlabels[node['type']] % node['version'] + if len(node): + text += ': ' + else: + text += '.' + self.body.append('%s' % text) + # Support for marking up and linking to bugs.python.org issues Modified: python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/static/basic.css Tue Oct 27 16:39:53 2009 @@ -5,15 +5,6 @@ /* -- main layout ----------------------------------------------------------- */ -div.documentwrapper { - float: left; - width: 100%; -} - -div.bodywrapper { - margin: 0 0 0 230px; -} - div.clearer { clear: both; } @@ -338,6 +329,12 @@ font-style: italic; } +p.deprecated { + background-color: #ffe4e4; + border: 1px solid #f66; + padding: 7px +} + .system-message { background-color: #fda; padding: 5px; @@ -355,8 +352,12 @@ border: 1px solid #ccc; } -.impl-detail p { - margin: 0; +.impl-detail .compound-first { + margin-top: 0; +} + +.impl-detail .compound-last { + margin-bottom: 0; } /* -- code displays --------------------------------------------------------- */ @@ -405,7 +406,7 @@ vertical-align: middle; } -div.math p { +div.body div.math p { text-align: center; } Modified: python/branches/release26-maint/Lib/Cookie.py ============================================================================== --- python/branches/release26-maint/Lib/Cookie.py (original) +++ python/branches/release26-maint/Lib/Cookie.py Tue Oct 27 16:39:53 2009 @@ -624,7 +624,9 @@ if type(rawdata) == type(""): self.__ParseString(rawdata) else: - self.update(rawdata) + # self.update() wouldn't call our custom __setitem__ + for k, v in rawdata.items(): + self[k] = v return # end load() Modified: python/branches/release26-maint/Lib/multiprocessing/queues.py ============================================================================== --- python/branches/release26-maint/Lib/multiprocessing/queues.py (original) +++ python/branches/release26-maint/Lib/multiprocessing/queues.py Tue Oct 27 16:39:53 2009 @@ -109,7 +109,7 @@ self._rlock.release() def qsize(self): - # Raises NotImplementError on Mac OSX because of broken sem_getvalue() + # Raises NotImplementedError on Mac OSX because of broken sem_getvalue() return self._maxsize - self._sem._semlock._get_value() def empty(self): Modified: python/branches/release26-maint/Lib/pdb.py ============================================================================== --- python/branches/release26-maint/Lib/pdb.py (original) +++ python/branches/release26-maint/Lib/pdb.py Tue Oct 27 16:39:53 2009 @@ -198,7 +198,9 @@ """Custom displayhook for the exec in default(), which prevents assignment of the _ variable in the builtins. """ - print repr(obj) + # reproduce the behavior of the standard displayhook, not printing None + if obj is not None: + print repr(obj) def default(self, line): if line[:1] == '!': line = line[1:] Modified: python/branches/release26-maint/Lib/platform.py ============================================================================== --- python/branches/release26-maint/Lib/platform.py (original) +++ python/branches/release26-maint/Lib/platform.py Tue Oct 27 16:39:53 2009 @@ -10,7 +10,7 @@ """ # This module is maintained by Marc-Andre Lemburg . # If you find problems, please submit bug reports/patches via the -# Python SourceForge Project Page and assign them to "lemburg". +# Python bug tracker (http://bugs.python.org) and assign them to "lemburg". # # Note: Please keep this module compatible to Python 1.5.2. # Modified: python/branches/release26-maint/Lib/test/test_kqueue.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_kqueue.py (original) +++ python/branches/release26-maint/Lib/test/test_kqueue.py Tue Oct 27 16:39:53 2009 @@ -162,6 +162,22 @@ server.close() serverSocket.close() + def testPair(self): + kq = select.kqueue() + a, b = socket.socketpair() + + a.send(b'foo') + event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) + event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE) + r = kq.control([event1, event2], 1, 1) + self.assertTrue(r) + self.assertFalse(r[0].flags & select.KQ_EV_ERROR) + self.assertEquals(b.recv(r[0].data), b'foo') + + a.close() + b.close() + kq.close() + def test_main(): test_support.run_unittest(TestKQueue) Modified: python/branches/release26-maint/Lib/test/test_traceback.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_traceback.py (original) +++ python/branches/release26-maint/Lib/test/test_traceback.py Tue Oct 27 16:39:53 2009 @@ -34,6 +34,9 @@ def syntax_error_with_caret(self): compile("def fact(x):\n\treturn x!\n", "?", "exec") + def syntax_error_with_caret_2(self): + compile("1 +\n", "?", "exec") + def syntax_error_without_caret(self): # XXX why doesn't compile raise the same traceback? import test.badsyntax_nocaret @@ -49,6 +52,12 @@ self.assert_("^" in err[2]) # third line has caret self.assert_(err[1].find("!") == err[2].find("^")) # in the right place + err = self.get_exception_format(self.syntax_error_with_caret_2, + SyntaxError) + self.assert_("^" in err[2]) # third line has caret + self.assert_(err[2].count('\n') == 1) # and no additional newline + self.assert_(err[1].find("+") == err[2].find("^")) # in the right place + def test_nocaret(self): if is_jython: # jython adds a caret in this case (why shouldn't it?) Modified: python/branches/release26-maint/Lib/threading.py ============================================================================== --- python/branches/release26-maint/Lib/threading.py (original) +++ python/branches/release26-maint/Lib/threading.py Tue Oct 27 16:39:53 2009 @@ -133,7 +133,7 @@ def release(self): if self.__owner is not current_thread(): - raise RuntimeError("cannot release un-aquired lock") + raise RuntimeError("cannot release un-acquired lock") self.__count = count = self.__count - 1 if not count: self.__owner = None @@ -227,7 +227,7 @@ def wait(self, timeout=None): if not self._is_owned(): - raise RuntimeError("cannot wait on un-aquired lock") + raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) @@ -269,7 +269,7 @@ def notify(self, n=1): if not self._is_owned(): - raise RuntimeError("cannot notify on un-aquired lock") + raise RuntimeError("cannot notify on un-acquired lock") __waiters = self.__waiters waiters = __waiters[:n] if not waiters: Modified: python/branches/release26-maint/Lib/traceback.py ============================================================================== --- python/branches/release26-maint/Lib/traceback.py (original) +++ python/branches/release26-maint/Lib/traceback.py Tue Oct 27 16:39:53 2009 @@ -190,7 +190,7 @@ if badline is not None: lines.append(' %s\n' % badline.strip()) if offset is not None: - caretspace = badline[:offset].lstrip() + caretspace = badline.rstrip('\n')[:offset].lstrip() # non-space whitespace (likes tabs) must be kept for alignment caretspace = ((c.isspace() and c or ' ') for c in caretspace) # only three spaces to account for offset1 == pos 0 Modified: python/branches/release26-maint/Lib/webbrowser.py ============================================================================== --- python/branches/release26-maint/Lib/webbrowser.py (original) +++ python/branches/release26-maint/Lib/webbrowser.py Tue Oct 27 16:39:53 2009 @@ -625,7 +625,9 @@ # and prepend to _tryorder for cmdline in _userchoices: if cmdline != '': - _synthesize(cmdline, -1) + cmd = _synthesize(cmdline, -1) + if cmd[1] is None: + register(cmdline, None, GenericBrowser(cmdline), -1) cmdline = None # to make del work if _userchoices was empty del cmdline del _userchoices Modified: python/branches/release26-maint/Misc/gdbinit ============================================================================== --- python/branches/release26-maint/Misc/gdbinit (original) +++ python/branches/release26-maint/Misc/gdbinit Tue Oct 27 16:39:53 2009 @@ -29,7 +29,7 @@ # print the local variables of the current frame define pylocals set $_i = 0 - while $_i < f->f_nlocals + while $_i < f->f_code->co_nlocals if f->f_localsplus + $_i != 0 set $_names = co->co_varnames set $_name = PyString_AsString(PyTuple_GetItem($_names, $_i)) Modified: python/branches/release26-maint/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/release26-maint/Modules/_ctypes/_ctypes.c (original) +++ python/branches/release26-maint/Modules/_ctypes/_ctypes.c Tue Oct 27 16:39:53 2009 @@ -1889,17 +1889,16 @@ } fmt = getentry(PyString_AS_STRING(proto)); if (fmt == NULL) { - Py_DECREF(result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", PyString_AS_STRING(proto)); - return NULL; + goto error; } stgdict = (StgDictObject *)PyObject_CallObject( (PyObject *)&StgDict_Type, NULL); if (!stgdict) - return NULL; + goto error; stgdict->ffi_type_pointer = *fmt->pffi_type; stgdict->align = fmt->pffi_type->alignment; @@ -1914,6 +1913,7 @@ #endif if (stgdict->format == NULL) { Py_DECREF(result); + Py_DECREF(proto); Py_DECREF((PyObject *)stgdict); return NULL; } Modified: python/branches/release26-maint/Modules/selectmodule.c ============================================================================== --- python/branches/release26-maint/Modules/selectmodule.c (original) +++ python/branches/release26-maint/Modules/selectmodule.c Tue Oct 27 16:39:53 2009 @@ -1487,7 +1487,7 @@ if (nevents < 0) { PyErr_Format(PyExc_ValueError, "Length of eventlist must be 0 or positive, got %d", - nchanges); + nevents); return NULL; } @@ -1545,6 +1545,7 @@ PyErr_NoMemory(); return NULL; } + i = 0; while ((ei = PyIter_Next(it)) != NULL) { if (!kqueue_event_Check(ei)) { Py_DECREF(ei); @@ -1553,7 +1554,7 @@ "select.kevent objects"); goto error; } else { - chl[i] = ((kqueue_event_Object *)ei)->e; + chl[i++] = ((kqueue_event_Object *)ei)->e; } Py_DECREF(ei); } @@ -1584,7 +1585,7 @@ goto error; } - for (i=0; i < gotevents; i++) { + for (i = 0; i < gotevents; i++) { kqueue_event_Object *ch; ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type); Modified: python/branches/release26-maint/Python/peephole.c ============================================================================== --- python/branches/release26-maint/Python/peephole.c (original) +++ python/branches/release26-maint/Python/peephole.c Tue Oct 27 16:39:53 2009 @@ -297,7 +297,7 @@ /* Bail out if an exception is set */ if (PyErr_Occurred()) - goto exitUnchanged; + goto exitError; /* Bypass optimization when the lineno table is too complex */ assert(PyString_Check(lineno_obj)); @@ -315,7 +315,7 @@ /* Make a modifiable copy of the code string */ codestr = (unsigned char *)PyMem_Malloc(codelen); if (codestr == NULL) - goto exitUnchanged; + goto exitError; codestr = (unsigned char *)memcpy(codestr, PyString_AS_STRING(code), codelen); @@ -330,11 +330,11 @@ /* Mapping to new jump targets after NOPs are removed */ addrmap = (int *)PyMem_Malloc(codelen * sizeof(int)); if (addrmap == NULL) - goto exitUnchanged; + goto exitError; blocks = markblocks(codestr, codelen); if (blocks == NULL) - goto exitUnchanged; + goto exitError; assert(PyList_Check(consts)); for (i=0 ; i Author: georg.brandl Date: Tue Oct 27 16:41:02 2009 New Revision: 75799 Log: Blocked revisions 72314,73190,73201,73212,73252,73275,73448,73471,73605,74028-74029,74542,74644,74650,74811,74908,74912,74954-74955,75175,75181,75313,75315,75318,75321-75322,75325,75327,75329,75337,75339,75342,75344,75346,75348,75350-75351,75354,75356,75358 via svnmerge ........ r72314 | georg.brandl | 2009-05-05 09:48:12 +0200 (Di, 05 Mai 2009) | 1 line #5932: fix error return in _convertPyInt_AsSsize_t() conversion function. ........ r73190 | georg.brandl | 2009-06-04 01:23:45 +0200 (Do, 04 Jun 2009) | 2 lines Avoid PendingDeprecationWarnings emitted by deprecated unittest methods. ........ r73201 | georg.brandl | 2009-06-04 10:58:32 +0200 (Do, 04 Jun 2009) | 1 line #5767: remove sgmlop support from xmlrpclib; the sgmlop parser does not do much validation and is no longer much faster than e.g. the cElementTree XMLParser. ........ r73212 | georg.brandl | 2009-06-04 12:10:41 +0200 (Do, 04 Jun 2009) | 1 line Better name for "Ctor". ........ r73252 | georg.brandl | 2009-06-06 07:54:34 +0200 (Sa, 06 Jun 2009) | 1 line #6206: fix test__locale. ........ r73275 | georg.brandl | 2009-06-07 22:37:52 +0200 (So, 07 Jun 2009) | 1 line Add Ezio. ........ r73448 | georg.brandl | 2009-06-16 19:43:44 +0200 (Di, 16 Jun 2009) | 1 line Remove unused macro. ........ r73471 | georg.brandl | 2009-06-19 00:24:26 +0200 (Fr, 19 Jun 2009) | 1 line #6276: Remove usage of nested() in favor of new with statement with multiple managers. ........ r73605 | georg.brandl | 2009-06-28 14:10:18 +0200 (So, 28 Jun 2009) | 1 line Remove stray pychecker directive. ........ r74028 | georg.brandl | 2009-07-16 21:24:48 +0200 (Do, 16 Jul 2009) | 1 line #6482: simplify "except: raise" to "finally:". ........ r74029 | georg.brandl | 2009-07-16 23:47:51 +0200 (Do, 16 Jul 2009) | 1 line Revert r74028. ........ r74542 | georg.brandl | 2009-08-23 23:28:56 +0200 (So, 23 Aug 2009) | 1 line Restore alphabetic order. ........ r74644 | georg.brandl | 2009-09-04 09:55:14 +0200 (Fr, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74650 | georg.brandl | 2009-09-04 13:19:34 +0200 (Fr, 04 Sep 2009) | 1 line #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups. ........ r74811 | georg.brandl | 2009-09-15 22:26:59 +0200 (Di, 15 Sep 2009) | 1 line Add Armin Ronacher. ........ r74908 | georg.brandl | 2009-09-18 15:57:11 +0200 (Fr, 18 Sep 2009) | 1 line Use str.format() to fix beginner's mistake with %-style string formatting. ........ r74912 | georg.brandl | 2009-09-18 18:19:56 +0200 (Fr, 18 Sep 2009) | 1 line Optimize optimization and fix method name in docstring. ........ r74954 | georg.brandl | 2009-09-19 15:13:56 +0200 (Sa, 19 Sep 2009) | 1 line Add Doug. ........ r74955 | georg.brandl | 2009-09-19 15:20:49 +0200 (Sa, 19 Sep 2009) | 1 line Add Mark Summerfield. ........ r75175 | georg.brandl | 2009-10-01 22:11:14 +0200 (Do, 01 Okt 2009) | 1 line Fix some weird whitespace and two other overlong lines. ........ r75181 | georg.brandl | 2009-10-01 23:02:39 +0200 (Do, 01 Okt 2009) | 1 line Add NEWS entry for r75180. ........ r75313 | georg.brandl | 2009-10-10 23:07:35 +0200 (Sa, 10 Okt 2009) | 1 line Bring old demo up-to-date. ........ r75315 | georg.brandl | 2009-10-10 23:10:05 +0200 (Sa, 10 Okt 2009) | 1 line Remove unneeded "L" suffixes. ........ r75318 | benjamin.peterson | 2009-10-10 23:15:58 +0200 (Sa, 10 Okt 2009) | 1 line remove script which uses long gone module ........ r75321 | georg.brandl | 2009-10-10 23:43:21 +0200 (Sa, 10 Okt 2009) | 1 line Remove outdated comment and fix a few style issues. ........ r75322 | georg.brandl | 2009-10-10 23:47:31 +0200 (Sa, 10 Okt 2009) | 1 line Show use of range() step argument nicely. ........ r75325 | georg.brandl | 2009-10-10 23:55:11 +0200 (Sa, 10 Okt 2009) | 1 line Modernize factorisation demo (mostly augassign.) ........ r75327 | georg.brandl | 2009-10-11 00:03:43 +0200 (So, 11 Okt 2009) | 1 line Style fixes. ........ r75329 | georg.brandl | 2009-10-11 00:26:45 +0200 (So, 11 Okt 2009) | 1 line Modernize all around (dont ask me how useful that script is nowadays...) ........ r75337 | georg.brandl | 2009-10-11 10:18:44 +0200 (So, 11 Okt 2009) | 1 line Update morse script, avoid globals, use iterators. ........ r75339 | georg.brandl | 2009-10-11 10:39:16 +0200 (So, 11 Okt 2009) | 1 line Update markov demo. ........ r75342 | georg.brandl | 2009-10-11 10:45:03 +0200 (So, 11 Okt 2009) | 1 line Remove useless script "mkrcs" and update README. ........ r75344 | georg.brandl | 2009-10-11 10:48:28 +0200 (So, 11 Okt 2009) | 1 line Update primes script. ........ r75346 | mark.dickinson | 2009-10-11 11:35:57 +0200 (So, 11 Okt 2009) | 1 line Fix 'primes 0 1' ........ r75348 | mark.dickinson | 2009-10-11 12:01:17 +0200 (So, 11 Okt 2009) | 1 line Set missing executable property on scripts ........ r75350 | georg.brandl | 2009-10-11 14:00:18 +0200 (So, 11 Okt 2009) | 1 line Use getopt in script.py demo. ........ r75351 | georg.brandl | 2009-10-11 14:03:01 +0200 (So, 11 Okt 2009) | 1 line Fix variable. ........ r75354 | georg.brandl | 2009-10-11 16:23:49 +0200 (So, 11 Okt 2009) | 1 line Update lpwatch script. ........ r75356 | georg.brandl | 2009-10-11 16:49:37 +0200 (So, 11 Okt 2009) | 1 line Remove ftpstats script, the daemon whose log files it reads is long gone. ........ r75358 | georg.brandl | 2009-10-11 17:06:44 +0200 (So, 11 Okt 2009) | 1 line Overhaul of Demo/xml. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:41:52 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:41:52 -0000 Subject: [Python-checkins] r75800 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:41:51 2009 New Revision: 75800 Log: Blocked revisions 72199,72210,72241,73109,73135 via svnmerge ........ r72199 | benjamin.peterson | 2009-05-02 19:33:01 +0200 (Sa, 02 Mai 2009) | 1 line remove py3k compat code ........ r72210 | gregory.p.smith | 2009-05-02 20:58:21 +0200 (Sa, 02 Mai 2009) | 2 lines Convert test method names to PEP8 style. ........ r72241 | gregory.p.smith | 2009-05-03 21:37:05 +0200 (So, 03 Mai 2009) | 3 lines Optimization: move RFC defined network constant construction out of the is_*() methods and into module private instances. ........ r73109 | gregory.p.smith | 2009-06-01 19:40:41 +0200 (Mo, 01 Jun 2009) | 6 lines Sync up __version__ number with the version of the ipaddr-py project this library came from that it matches. Remove the former apache license text now that its been contributed to PSF to avoid confusion. ........ r73135 | gregory.p.smith | 2009-06-02 07:25:34 +0200 (Di, 02 Jun 2009) | 3 lines Fixes issue6169: it was possible for two ipaddr network addresses to compare as both < and > than eachother. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:45:02 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:45:02 -0000 Subject: [Python-checkins] r75801 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:45:01 2009 New Revision: 75801 Log: Blocked revisions 70615,70618-70621,70624,70856,70864,71004,71043,71208,71721,72582-72583,72812,72923,73151,73247,73839,74007,74095,75095 via svnmerge ........ r70615 | benjamin.peterson | 2009-03-26 20:58:18 +0100 (Do, 26 M?r 2009) | 5 lines add some useful utilities for skipping tests with unittest's new skipping ability most significantly apply a modified portion of the patch from #4242 with patches for skipping implementation details ........ r70618 | benjamin.peterson | 2009-03-26 21:48:25 +0100 (Do, 26 M?r 2009) | 1 line remove test_support.TestSkipped and just use unittest.SkipTest ........ r70619 | benjamin.peterson | 2009-03-26 21:49:40 +0100 (Do, 26 M?r 2009) | 1 line fix naming ........ r70620 | benjamin.peterson | 2009-03-26 22:10:30 +0100 (Do, 26 M?r 2009) | 1 line fix incorrect auto-translation of TestSkipped -> unittest.SkipTest ........ r70621 | benjamin.peterson | 2009-03-26 22:11:16 +0100 (Do, 26 M?r 2009) | 1 line must pass argument to get expected behavior ;) ........ r70624 | benjamin.peterson | 2009-03-26 22:30:54 +0100 (Do, 26 M?r 2009) | 1 line ** is required here ........ r70856 | r.david.murray | 2009-03-31 20:32:17 +0200 (Di, 31 M?r 2009) | 7 lines A few more test skips via import_module, and change import_module to return the error message produced by importlib, so that if an import in the package whose import is being wrapped is what failed the skip message will contain the name of that module instead of the name of the wrapped module. Also fixed formatting of some previous comments. ........ r70864 | gregory.p.smith | 2009-03-31 21:03:28 +0200 (Di, 31 M?r 2009) | 10 lines Rename the actual method definitions to the official assertFoo names. Adds unittests to make sure the old fail* names continue to work now and adds a comment that they are pending deprecation. Also adds a test to confirm that the plural Equals method variants continue to exist even though we're unlikely to deprecate those. http://bugs.python.org/issue2578 ........ r71004 | benjamin.peterson | 2009-04-02 01:15:49 +0200 (Do, 02 Apr 2009) | 1 line remove double underscores ........ r71043 | michael.foord | 2009-04-02 07:51:54 +0200 (Do, 02 Apr 2009) | 7 lines Store the functions in the _type_equality_funcs as wrapped objects that are deep copyable. This allows for the deep copying of TestCase instances. Issue 5660 ........ r71208 | michael.foord | 2009-04-05 03:15:01 +0200 (So, 05 Apr 2009) | 4 lines Change the way unittest.TestSuite use their tests to always access them through iteration. Non behavior changing, this allows you to create custom subclasses that override __iter__. Issue #5693 ........ r71721 | benjamin.peterson | 2009-04-18 21:26:19 +0200 (Sa, 18 Apr 2009) | 1 line fix a few nits in unittest.py #5771 ........ r72582 | michael.foord | 2009-05-12 12:46:23 +0200 (Di, 12 Mai 2009) | 1 line Fix to restore command line behaviour for test modules using unittest.main(). Regression caused by issue 5995. Michael ........ r72583 | michael.foord | 2009-05-12 12:49:13 +0200 (Di, 12 Mai 2009) | 1 line Better fix for modules using unittest.main(). Fixes regression caused by commit for issue 5995. Michael Foord ........ r72812 | michael.foord | 2009-05-22 00:57:02 +0200 (Fr, 22 Mai 2009) | 1 line Rename TestCase._result to _resultForDoCleanups to avoid potential clashes in TestCase subclasses. Issue 6072. ........ r72923 | michael.foord | 2009-05-25 22:36:56 +0200 (Mo, 25 Mai 2009) | 1 line Make assertSequenceEqual error messages less cryptic, particularly for nested sequences. ........ r73151 | michael.foord | 2009-06-02 20:08:27 +0200 (Di, 02 Jun 2009) | 1 line Restore default testRunner argument in unittest.main to None. Issue 6177 ........ r73247 | michael.foord | 2009-06-05 16:14:34 +0200 (Fr, 05 Jun 2009) | 1 line Fix unittest discovery tests for Windows. Issue 6199 ........ r73839 | gregory.p.smith | 2009-07-04 10:42:10 +0200 (Sa, 04 Jul 2009) | 3 lines Merge r73838 from py3k branch. Use the nondeprecated unittest method names. ........ r74007 | michael.foord | 2009-07-14 19:58:12 +0200 (Di, 14 Jul 2009) | 1 line Move TestRunner initialisation into unittest.TestProgram.runTests. Fixes issue 6418. ........ r74095 | benjamin.peterson | 2009-07-19 22:18:21 +0200 (So, 19 Jul 2009) | 1 line split unittest.py into a package ........ r75095 | michael.foord | 2009-09-27 21:15:41 +0200 (So, 27 Sep 2009) | 1 line Test creation moved from TestProgram.parseArgs to TestProgram.createTests exclusively. Issue 6956. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:48:57 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:48:57 -0000 Subject: [Python-checkins] r75802 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:48:57 2009 New Revision: 75802 Log: Blocked revisions 68964,69014,69023,69070,69080,69085,69087,69227,69237,69242,69466,69525,69528,69530,69743,69748,69751,69770,69837-69838,69937,70016,70149,70293,70296,70623,74448 via svnmerge ........ r68964 | raymond.hettinger | 2009-01-26 17:52:22 +0100 (Mo, 26 Jan 2009) | 1 line Fix signed/unsigned mismatch. ........ r69014 | raymond.hettinger | 2009-01-27 11:03:04 +0100 (Di, 27 Jan 2009) | 1 line Issue 5021: doctest.testfile should set __name__ ........ r69023 | raymond.hettinger | 2009-01-27 14:26:35 +0100 (Di, 27 Jan 2009) | 1 line Add more tests for the powerset() recipe. ........ r69070 | raymond.hettinger | 2009-01-29 00:02:26 +0100 (Do, 29 Jan 2009) | 6 lines Issue 4920: Fixed next() vs __next__() issues in the ABCs for Iterator and MutableSet. Also added thorough test for required abstractmethods. ........ r69080 | brett.cannon | 2009-01-29 01:55:33 +0100 (Do, 29 Jan 2009) | 2 lines Ignore .pyc and .pyo files. ........ r69085 | raymond.hettinger | 2009-01-29 04:21:42 +0100 (Do, 29 Jan 2009) | 1 line Update itertools.__doc__ to include all tools. ........ r69087 | raymond.hettinger | 2009-01-29 04:43:44 +0100 (Do, 29 Jan 2009) | 1 line Fix typo. ........ r69227 | raymond.hettinger | 2009-02-02 22:50:13 +0100 (Mo, 02 Feb 2009) | 1 line Issue 1242657: list(obj) can swallow KeyboardInterrupt. ........ r69237 | raymond.hettinger | 2009-02-03 03:23:19 +0100 (Di, 03 Feb 2009) | 1 line Validate that __length_hint__ returns a usable result. ........ r69242 | raymond.hettinger | 2009-02-03 04:37:03 +0100 (Di, 03 Feb 2009) | 1 line Register decimals as numbers.Number ........ r69466 | raymond.hettinger | 2009-02-09 19:39:41 +0100 (Mo, 09 Feb 2009) | 3 lines Issue 5171: itertools.product docstring missing 'repeat' argument ........ r69525 | raymond.hettinger | 2009-02-12 11:16:19 +0100 (Do, 12 Feb 2009) | 1 line Fix spaces/tabs in example. ........ r69528 | raymond.hettinger | 2009-02-12 13:04:26 +0100 (Do, 12 Feb 2009) | 1 line Add an extra testcase. ........ r69530 | raymond.hettinger | 2009-02-12 13:43:01 +0100 (Do, 12 Feb 2009) | 1 line One more test. ........ r69743 | raymond.hettinger | 2009-02-19 00:10:19 +0100 (Do, 19 Feb 2009) | 1 line Py3k warnings now automatically include -Qwarn for division. ........ r69748 | raymond.hettinger | 2009-02-19 03:15:14 +0100 (Do, 19 Feb 2009) | 1 line Add keyword arg support to itertools.compress(). ........ r69751 | raymond.hettinger | 2009-02-19 03:38:25 +0100 (Do, 19 Feb 2009) | 1 line Add keyword arg support to itertools.repeat(). ........ r69770 | raymond.hettinger | 2009-02-19 10:50:24 +0100 (Do, 19 Feb 2009) | 1 line Inline coefficients in gamma(). Add reflection formula. Add comments. ........ r69837 | raymond.hettinger | 2009-02-21 08:17:22 +0100 (Sa, 21 Feb 2009) | 4 lines Fix keyword arguments for itertools.count(). Step arg without a start arg was ignored. ........ r69838 | raymond.hettinger | 2009-02-21 09:58:42 +0100 (Sa, 21 Feb 2009) | 1 line Speedup and simplify negative counter using count's new step argument. ........ r69937 | raymond.hettinger | 2009-02-24 13:23:23 +0100 (Di, 24 Feb 2009) | 3 lines Backport 69934: Register xrange() as a Sequence. ........ r70016 | raymond.hettinger | 2009-02-27 09:09:47 +0100 (Fr, 27 Feb 2009) | 1 line Give mapping views a usable repr. ........ r70149 | raymond.hettinger | 2009-03-03 23:59:25 +0100 (Di, 03 M?r 2009) | 5 lines Backport 70140, 70141, 70143, and 70144. Adds tests, switches from list to deque, fixes __reduce__ which was unnecessarily copying __keys. ........ r70293 | raymond.hettinger | 2009-03-10 05:49:21 +0100 (Di, 10 M?r 2009) | 1 line Add a version tag to the decimal module. ........ r70296 | raymond.hettinger | 2009-03-10 10:31:48 +0100 (Di, 10 M?r 2009) | 1 line Small optimization for corner case where maxlen==0. ........ r70623 | benjamin.peterson | 2009-03-26 22:30:10 +0100 (Do, 26 M?r 2009) | 1 line add missing import ........ r74448 | guilherme.polo | 2009-08-14 16:36:45 +0200 (Fr, 14 Aug 2009) | 3 lines Issue #1135: Add the XView and YView mix-ins to avoid duplicating the xview* and yview* methods. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 16:52:31 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 15:52:31 -0000 Subject: [Python-checkins] r75803 - python/branches/release26-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 16:52:31 2009 New Revision: 75803 Log: Blocked revisions 70466,70470,70472,70475,70477,70533,70538,70544,70601,70691,70844,70969,71073,71078,71127,71389,71392,72052,72774,73001,73006,73334-73335,73372,73382,73532,73536,73540,73697,74300 via svnmerge ........ r70466 | raymond.hettinger | 2009-03-18 23:13:20 +0100 (Mi, 18 M?r 2009) | 1 line Use mixin methods where possible. (2.7 only -- these don't all exist in 3.0) ........ r70470 | raymond.hettinger | 2009-03-19 16:21:10 +0100 (Do, 19 M?r 2009) | 6 lines Improve implementation with better underlying data structure for O(1) deletions. Big-Oh performance now the same as regular dictionaries. Uses a doubly-linked list instead of a list/seq to track insertion order. ........ r70472 | raymond.hettinger | 2009-03-19 20:24:43 +0100 (Do, 19 M?r 2009) | 1 line Silence a compiler warning. ........ r70475 | raymond.hettinger | 2009-03-20 00:12:41 +0100 (Fr, 20 M?r 2009) | 6 lines * Add implementation notes. * Re-order methods so that those touching the underlying data structure come first and the derived methods come last. ........ r70477 | raymond.hettinger | 2009-03-20 00:22:25 +0100 (Fr, 20 M?r 2009) | 1 line Fix typo ........ r70533 | raymond.hettinger | 2009-03-23 01:08:09 +0100 (Mo, 23 M?r 2009) | 6 lines Add more comments. Improve variable names. Make links clearer by using a Link object instead of a list. Use proxy links to avoid circular references. ........ r70538 | raymond.hettinger | 2009-03-23 05:42:18 +0100 (Mo, 23 M?r 2009) | 1 line Move initialization of root link to __init__. ........ r70544 | raymond.hettinger | 2009-03-23 19:26:59 +0100 (Mo, 23 M?r 2009) | 1 line Make imported name private and wrap long-line. ........ r70601 | raymond.hettinger | 2009-03-25 23:41:32 +0100 (Mi, 25 M?r 2009) | 1 line Separate initialization from clearing. ........ r70691 | raymond.hettinger | 2009-03-29 20:51:11 +0200 (So, 29 M?r 2009) | 1 line Make life easier for non-CPython implementations. ........ r70844 | raymond.hettinger | 2009-03-31 19:47:06 +0200 (Di, 31 M?r 2009) | 1 line Per the language summit, the optional fastpath imports should use from-import-star. ........ r70969 | raymond.hettinger | 2009-04-01 20:50:56 +0200 (Mi, 01 Apr 2009) | 1 line Issue #5647: MutableSet.__iand__() no longer mutates self during iteration. ........ r71073 | raymond.hettinger | 2009-04-03 00:25:40 +0200 (Fr, 03 Apr 2009) | 4 lines Have namedtuple's field renamer assign names that are consistent with the corresponding tuple index. ........ r71078 | raymond.hettinger | 2009-04-03 04:43:54 +0200 (Fr, 03 Apr 2009) | 4 lines Localize the function lookup in timeit. ........ r71127 | raymond.hettinger | 2009-04-04 10:46:58 +0200 (Sa, 04 Apr 2009) | 1 line Replace the localized min/max calls with normal if/else ........ r71389 | raymond.hettinger | 2009-04-08 07:39:38 +0200 (Mi, 08 Apr 2009) | 1 line Add docstrings. ........ r71392 | raymond.hettinger | 2009-04-08 10:26:55 +0200 (Mi, 08 Apr 2009) | 1 line Minor factoring. ........ r72052 | raymond.hettinger | 2009-04-27 23:12:27 +0200 (Mo, 27 Apr 2009) | 1 line Update spec version number. ........ r72774 | raymond.hettinger | 2009-05-18 17:51:59 +0200 (Mo, 18 Mai 2009) | 1 line Issue 6037: MutableSequence.__iadd__ should return self. ........ r73001 | raymond.hettinger | 2009-05-29 03:36:26 +0200 (Fr, 29 Mai 2009) | 1 line Issue 5150: Add rstrip() option to IDLE's format menu. ........ r73006 | raymond.hettinger | 2009-05-29 06:58:52 +0200 (Fr, 29 Mai 2009) | 1 line Issue 5982: Classmethod and staticmethod expose wrapped function with __func__. ........ r73334 | raymond.hettinger | 2009-06-10 18:15:02 +0200 (Mi, 10 Jun 2009) | 1 line Issue 6256: Fix stacklevel in warning message. ........ r73335 | raymond.hettinger | 2009-06-10 18:15:40 +0200 (Mi, 10 Jun 2009) | 1 line Fix signed/unsigned compiler warning. ........ r73372 | raymond.hettinger | 2009-06-12 00:08:10 +0200 (Fr, 12 Jun 2009) | 1 line Move comment to correct line. ........ r73382 | raymond.hettinger | 2009-06-12 01:14:53 +0200 (Fr, 12 Jun 2009) | 1 line Issue 6261: Clarify behavior of random.uniform(). ........ r73532 | raymond.hettinger | 2009-06-23 22:59:43 +0200 (Di, 23 Jun 2009) | 3 lines Issue 6329: Fix iteration for memoryviews. ........ r73536 | raymond.hettinger | 2009-06-23 23:32:28 +0200 (Di, 23 Jun 2009) | 1 line Issue 6305: Clarify error message for large arguments to itertools.islice(). ........ r73540 | raymond.hettinger | 2009-06-24 00:20:04 +0200 (Mi, 24 Jun 2009) | 1 line Add procedural note. ........ r73697 | raymond.hettinger | 2009-06-29 21:10:29 +0200 (Mo, 29 Jun 2009) | 1 line Issue 6370: Performance issue with collections.Counter(). ........ r74300 | raymond.hettinger | 2009-08-04 21:08:05 +0200 (Di, 04 Aug 2009) | 1 line Issue 6637: defaultdict.copy() failed with an empty factory. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 17:54:46 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 16:54:46 -0000 Subject: [Python-checkins] r75804 - in python/branches/release26-maint: Lib/decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Tue Oct 27 17:54:45 2009 New Revision: 75804 Log: Merged revisions 75275 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75275 | mark.dickinson | 2009-10-07 20:22:05 +0100 (Wed, 07 Oct 2009) | 6 lines Issue #7048: logb should round its result when that result doesn't fit into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.) ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/decimal.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/decimal.py ============================================================================== --- python/branches/release26-maint/Lib/decimal.py (original) +++ python/branches/release26-maint/Lib/decimal.py Tue Oct 27 17:54:45 2009 @@ -3083,7 +3083,8 @@ # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. - return Decimal(self.adjusted()) + ans = Decimal(self.adjusted()) + return ans._fix(context) def _islogical(self): """Return True if self is a logical operand. Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 17:54:45 2009 @@ -22,6 +22,9 @@ Library ------- +- Issue #7048: Force Decimal.logb to round its result when that result + is too large to fit in the current precision. + Tests ----- From python-checkins at python.org Tue Oct 27 18:00:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:00:04 -0000 Subject: [Python-checkins] r75805 - in python/branches/release26-maint: Lib/struct.py Misc/NEWS Modules/_struct.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:00:03 2009 New Revision: 75805 Log: Merged revisions 75283 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75283 | mark.dickinson | 2009-10-08 16:54:10 +0100 (Thu, 08 Oct 2009) | 4 lines Issue #7078: _struct.__doc__ was being ignored. Import it into struct. Also add description of '?' struct format character. Thanks Gabriel Genellina for the patch. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/struct.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Modules/_struct.c Modified: python/branches/release26-maint/Lib/struct.py ============================================================================== --- python/branches/release26-maint/Lib/struct.py (original) +++ python/branches/release26-maint/Lib/struct.py Tue Oct 27 18:00:03 2009 @@ -1,2 +1,3 @@ from _struct import * from _struct import _clearcache +from _struct import __doc__ Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 18:00:03 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Issue #7078: Set struct.__doc__ from _struct.__doc__. + - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. Modified: python/branches/release26-maint/Modules/_struct.c ============================================================================== --- python/branches/release26-maint/Modules/_struct.c (original) +++ python/branches/release26-maint/Modules/_struct.c Tue Oct 27 18:00:03 2009 @@ -2042,20 +2042,22 @@ /* Module initialization */ PyDoc_STRVAR(module_doc, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ +"Functions to convert between Python values and C structs represented\n\ +as Python strings. It uses format strings (explained below) as compact\n\ +descriptions of the lay-out of the C structs and the intended conversion\n\ +to/from Python values.\n\ \n\ The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ + @: native order, size & alignment (default)\n\ + =: native order, std. size & alignment\n\ + <: little-endian, std. size & alignment\n\ + >: big-endian, std. size & alignment\n\ + !: same as >\n\ \n\ The remaining chars indicate types of args and must match exactly;\n\ these can be preceded by a decimal repeat count:\n\ x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ + ?: _Bool (requires C99; if not available, char is used instead)\n\ h:short; H:unsigned short; i:int; I:unsigned int;\n\ l:long; L:unsigned long; f:float; d:double.\n\ Special cases (preceding decimal count indicates length):\n\ From python-checkins at python.org Tue Oct 27 18:02:48 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:02:48 -0000 Subject: [Python-checkins] r75806 - in python/branches/release26-maint: Lib/test/decimaltestdata/abs.decTest Lib/test/decimaltestdata/add.decTest Lib/test/decimaltestdata/and.decTest Lib/test/decimaltestdata/base.decTest Lib/test/decimaltestdata/clamp.decTest Lib/test/decimaltestdata/class.decTest Lib/test/decimaltestdata/compare.decTest Lib/test/decimaltestdata/comparetotal.decTest Lib/test/decimaltestdata/comparetotmag.decTest Lib/test/decimaltestdata/copy.decTest Lib/test/decimaltestdata/copyabs.decTest Lib/test/decimaltestdata/copynegate.decTest Lib/test/decimaltestdata/copysign.decTest Lib/test/decimaltestdata/ddAbs.decTest Lib/test/decimaltestdata/ddAdd.decTest Lib/test/decimaltestdata/ddAnd.decTest Lib/test/decimaltestdata/ddBase.decTest Lib/test/decimaltestdata/ddCanonical.decTest Lib/test/decimaltestdata/ddClass.decTest Lib/test/decimaltestdata/ddCompare.decTest Lib/test/decimaltestdata/ddCompareSig.decTest Lib/test/decimaltestdata/ddCompareTotal.decTest Lib/test/decimaltestdata/ddCompareTotalMag.decTest Lib/test/decimaltestdata/ddCopy.decTest Lib/test/decimaltestdata/ddCopyAbs.decTest Lib/test/decimaltestdata/ddCopyNegate.decTest Lib/test/decimaltestdata/ddCopySign.decTest Lib/test/decimaltestdata/ddDivide.decTest Lib/test/decimaltestdata/ddDivideInt.decTest Lib/test/decimaltestdata/ddEncode.decTest Lib/test/decimaltestdata/ddFMA.decTest Lib/test/decimaltestdata/ddInvert.decTest Lib/test/decimaltestdata/ddLogB.decTest Lib/test/decimaltestdata/ddMax.decTest Lib/test/decimaltestdata/ddMaxMag.decTest Lib/test/decimaltestdata/ddMin.decTest Lib/test/decimaltestdata/ddMinMag.decTest Lib/test/decimaltestdata/ddMinus.decTest Lib/test/decimaltestdata/ddMultiply.decTest Lib/test/decimaltestdata/ddNextMinus.decTest Lib/test/decimaltestdata/ddNextPlus.decTest Lib/test/decimaltestdata/ddNextToward.decTest Lib/test/decimaltestdata/ddOr.decTest Lib/test/decimaltestdata/ddPlus.decTest Lib/test/decimaltestdata/ddQuantize.decTest Lib/test/decimaltestdata/ddReduce.decTest Lib/test/decimaltestdata/ddRemainder.decTest Lib/test/decimaltestdata/ddRemainderNear.decTest Lib/test/decimaltestdata/ddRotate.decTest Lib/test/decimaltestdata/ddSameQuantum.decTest Lib/test/decimaltestdata/ddScaleB.decTest Lib/test/decimaltestdata/ddShift.decTest Lib/test/decimaltestdata/ddSubtract.decTest Lib/test/decimaltestdata/ddToIntegral.decTest Lib/test/decimaltestdata/ddXor.decTest Lib/test/decimaltestdata/decDouble.decTest Lib/test/decimaltestdata/decQuad.decTest Lib/test/decimaltestdata/decSingle.decTest Lib/test/decimaltestdata/divide.decTest Lib/test/decimaltestdata/divideint.decTest Lib/test/decimaltestdata/dqAbs.decTest Lib/test/decimaltestdata/dqAdd.decTest Lib/test/decimaltestdata/dqAnd.decTest Lib/test/decimaltestdata/dqBase.decTest Lib/test/decimaltestdata/dqCanonical.decTest Lib/test/decimaltestdata/dqClass.decTest Lib/test/decimaltestdata/dqCompare.decTest Lib/test/decimaltestdata/dqCompareSig.decTest Lib/test/decimaltestdata/dqCompareTotal.decTest Lib/test/decimaltestdata/dqCompareTotalMag.decTest Lib/test/decimaltestdata/dqCopy.decTest Lib/test/decimaltestdata/dqCopyAbs.decTest Lib/test/decimaltestdata/dqCopyNegate.decTest Lib/test/decimaltestdata/dqCopySign.decTest Lib/test/decimaltestdata/dqDivide.decTest Lib/test/decimaltestdata/dqDivideInt.decTest Lib/test/decimaltestdata/dqEncode.decTest Lib/test/decimaltestdata/dqFMA.decTest Lib/test/decimaltestdata/dqInvert.decTest Lib/test/decimaltestdata/dqLogB.decTest Lib/test/decimaltestdata/dqMax.decTest Lib/test/decimaltestdata/dqMaxMag.decTest Lib/test/decimaltestdata/dqMin.decTest Lib/test/decimaltestdata/dqMinMag.decTest Lib/test/decimaltestdata/dqMinus.decTest Lib/test/decimaltestdata/dqMultiply.decTest Lib/test/decimaltestdata/dqNextMinus.decTest Lib/test/decimaltestdata/dqNextPlus.decTest Lib/test/decimaltestdata/dqNextToward.decTest Lib/test/decimaltestdata/dqOr.decTest Lib/test/decimaltestdata/dqPlus.decTest Lib/test/decimaltestdata/dqQuantize.decTest Lib/test/decimaltestdata/dqReduce.decTest Lib/test/decimaltestdata/dqRemainder.decTest Lib/test/decimaltestdata/dqRemainderNear.decTest Lib/test/decimaltestdata/dqRotate.decTest Lib/test/decimaltestdata/dqSameQuantum.decTest Lib/test/decimaltestdata/dqScaleB.decTest Lib/test/decimaltestdata/dqShift.decTest Lib/test/decimaltestdata/dqSubtract.decTest Lib/test/decimaltestdata/dqToIntegral.decTest Lib/test/decimaltestdata/dqXor.decTest Lib/test/decimaltestdata/dsBase.decTest Lib/test/decimaltestdata/dsEncode.decTest Lib/test/decimaltestdata/exp.decTest Lib/test/decimaltestdata/fma.decTest Lib/test/decimaltestdata/inexact.decTest Lib/test/decimaltestdata/invert.decTest Lib/test/decimaltestdata/ln.decTest Lib/test/decimaltestdata/log10.decTest Lib/test/decimaltestdata/logb.decTest Lib/test/decimaltestdata/max.decTest Lib/test/decimaltestdata/maxmag.decTest Lib/test/decimaltestdata/min.decTest Lib/test/decimaltestdata/minmag.decTest Lib/test/decimaltestdata/minus.decTest Lib/test/decimaltestdata/multiply.decTest Lib/test/decimaltestdata/nextminus.decTest Lib/test/decimaltestdata/nextplus.decTest Lib/test/decimaltestdata/nexttoward.decTest Lib/test/decimaltestdata/or.decTest Lib/test/decimaltestdata/plus.decTest Lib/test/decimaltestdata/power.decTest Lib/test/decimaltestdata/powersqrt.decTest Lib/test/decimaltestdata/quantize.decTest Lib/test/decimaltestdata/randomBound32.decTest Lib/test/decimaltestdata/randoms.decTest Lib/test/decimaltestdata/reduce.decTest Lib/test/decimaltestdata/remainder.decTest Lib/test/decimaltestdata/remainderNear.decTest Lib/test/decimaltestdata/rescale.decTest Lib/test/decimaltestdata/rotate.decTest Lib/test/decimaltestdata/rounding.decTest Lib/test/decimaltestdata/samequantum.decTest Lib/test/decimaltestdata/scaleb.decTest Lib/test/decimaltestdata/shift.decTest Lib/test/decimaltestdata/squareroot.decTest Lib/test/decimaltestdata/subtract.decTest Lib/test/decimaltestdata/testall.decTest Lib/test/decimaltestdata/tointegral.decTest Lib/test/decimaltestdata/tointegralx.decTest Lib/test/decimaltestdata/xor.decTest Lib/test/test_decimal.py Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:02:46 2009 New Revision: 75806 Log: Merged revisions 75286 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75286 | mark.dickinson | 2009-10-08 17:28:39 +0100 (Thu, 08 Oct 2009) | 2 lines Update decimal test data to the most recent set from Mike Cowlishaw. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/decimaltestdata/abs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/add.decTest python/branches/release26-maint/Lib/test/decimaltestdata/and.decTest python/branches/release26-maint/Lib/test/decimaltestdata/base.decTest python/branches/release26-maint/Lib/test/decimaltestdata/clamp.decTest python/branches/release26-maint/Lib/test/decimaltestdata/class.decTest python/branches/release26-maint/Lib/test/decimaltestdata/compare.decTest python/branches/release26-maint/Lib/test/decimaltestdata/comparetotal.decTest python/branches/release26-maint/Lib/test/decimaltestdata/comparetotmag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/copy.decTest python/branches/release26-maint/Lib/test/decimaltestdata/copyabs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/copynegate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/copysign.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddAbs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddAdd.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddAnd.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddBase.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCanonical.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddClass.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCompare.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareSig.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCopy.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddCopySign.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddDivide.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddDivideInt.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddEncode.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddFMA.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddInvert.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddLogB.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMax.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMaxMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMin.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMinMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMinus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddMultiply.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddNextMinus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddNextPlus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddNextToward.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddOr.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddPlus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddQuantize.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddReduce.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainder.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddRotate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddScaleB.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddShift.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddSubtract.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddToIntegral.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ddXor.decTest python/branches/release26-maint/Lib/test/decimaltestdata/decDouble.decTest python/branches/release26-maint/Lib/test/decimaltestdata/decQuad.decTest python/branches/release26-maint/Lib/test/decimaltestdata/decSingle.decTest python/branches/release26-maint/Lib/test/decimaltestdata/divide.decTest python/branches/release26-maint/Lib/test/decimaltestdata/divideint.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqAbs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqAdd.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqAnd.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqBase.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCanonical.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqClass.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCompare.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareSig.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCopy.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqCopySign.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqDivide.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqDivideInt.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqEncode.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqFMA.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqInvert.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqLogB.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMax.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMaxMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMin.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMinMag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMinus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqMultiply.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqNextMinus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqNextPlus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqNextToward.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqOr.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqPlus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqQuantize.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqReduce.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainder.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqRotate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqScaleB.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqShift.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqSubtract.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqToIntegral.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dqXor.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dsBase.decTest python/branches/release26-maint/Lib/test/decimaltestdata/dsEncode.decTest python/branches/release26-maint/Lib/test/decimaltestdata/exp.decTest python/branches/release26-maint/Lib/test/decimaltestdata/fma.decTest python/branches/release26-maint/Lib/test/decimaltestdata/inexact.decTest python/branches/release26-maint/Lib/test/decimaltestdata/invert.decTest python/branches/release26-maint/Lib/test/decimaltestdata/ln.decTest python/branches/release26-maint/Lib/test/decimaltestdata/log10.decTest python/branches/release26-maint/Lib/test/decimaltestdata/logb.decTest python/branches/release26-maint/Lib/test/decimaltestdata/max.decTest python/branches/release26-maint/Lib/test/decimaltestdata/maxmag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/min.decTest python/branches/release26-maint/Lib/test/decimaltestdata/minmag.decTest python/branches/release26-maint/Lib/test/decimaltestdata/minus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/multiply.decTest python/branches/release26-maint/Lib/test/decimaltestdata/nextminus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/nextplus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/nexttoward.decTest python/branches/release26-maint/Lib/test/decimaltestdata/or.decTest python/branches/release26-maint/Lib/test/decimaltestdata/plus.decTest python/branches/release26-maint/Lib/test/decimaltestdata/power.decTest python/branches/release26-maint/Lib/test/decimaltestdata/powersqrt.decTest python/branches/release26-maint/Lib/test/decimaltestdata/quantize.decTest python/branches/release26-maint/Lib/test/decimaltestdata/randomBound32.decTest python/branches/release26-maint/Lib/test/decimaltestdata/randoms.decTest python/branches/release26-maint/Lib/test/decimaltestdata/reduce.decTest python/branches/release26-maint/Lib/test/decimaltestdata/remainder.decTest python/branches/release26-maint/Lib/test/decimaltestdata/remainderNear.decTest python/branches/release26-maint/Lib/test/decimaltestdata/rescale.decTest python/branches/release26-maint/Lib/test/decimaltestdata/rotate.decTest python/branches/release26-maint/Lib/test/decimaltestdata/rounding.decTest python/branches/release26-maint/Lib/test/decimaltestdata/samequantum.decTest python/branches/release26-maint/Lib/test/decimaltestdata/scaleb.decTest python/branches/release26-maint/Lib/test/decimaltestdata/shift.decTest python/branches/release26-maint/Lib/test/decimaltestdata/squareroot.decTest python/branches/release26-maint/Lib/test/decimaltestdata/subtract.decTest python/branches/release26-maint/Lib/test/decimaltestdata/testall.decTest python/branches/release26-maint/Lib/test/decimaltestdata/tointegral.decTest python/branches/release26-maint/Lib/test/decimaltestdata/tointegralx.decTest python/branches/release26-maint/Lib/test/decimaltestdata/xor.decTest python/branches/release26-maint/Lib/test/test_decimal.py Modified: python/branches/release26-maint/Lib/test/decimaltestdata/abs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/abs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/abs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Additon, subtraction, rounding, and more overflows are tested Modified: python/branches/release26-maint/Lib/test/decimaltestdata/add.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/add.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/add.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 9 rounding: half_up Modified: python/branches/release26-maint/Lib/test/decimaltestdata/and.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/and.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/and.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/base.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/base.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/base.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 -- This file tests base conversions from string to a decimal number Modified: python/branches/release26-maint/Lib/test/decimaltestdata/clamp.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/clamp.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/clamp.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests uses the same limits as the 8-byte concrete -- representation, but applies clamping without using format-specific Modified: python/branches/release26-maint/Lib/test/decimaltestdata/class.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/class.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/class.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/release26-maint/Lib/test/decimaltestdata/compare.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/compare.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/compare.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/comparetotal.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/comparetotal.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/comparetotal.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/comparetotmag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/comparetotmag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/comparetotmag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that it cannot be assumed that add/subtract tests cover paths -- for this operation adequately, here, because the code might be Modified: python/branches/release26-maint/Lib/test/decimaltestdata/copy.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/copy.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/copy.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/copyabs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/copyabs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/copyabs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/copynegate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/copynegate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/copynegate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/copysign.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/copysign.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/copysign.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddAbs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddAbs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddAbs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddAdd.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddAdd.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddAdd.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddAnd.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddAnd.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddAnd.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddBase.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddBase.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddBase.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCanonical.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCanonical.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCanonical.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddClass.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddClass.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddClass.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCompare.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCompare.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCompare.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareSig.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareSig.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareSig.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotal.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCompareTotalMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCopy.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCopy.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCopy.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyAbs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCopyNegate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddCopySign.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddCopySign.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddCopySign.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddDivide.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddDivide.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddDivide.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 @@ -160,7 +160,7 @@ dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded --- test some cases that are close to exponent overflow +-- test some cases that are close to exponent overflow, some with coefficient padding dddiv270 divide 1 1e384 -> 1E-384 Subnormal dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow @@ -168,7 +168,16 @@ dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped -dddiv277 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 +dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped +dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped +dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384 + +dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped +dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded +dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped +dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded +dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped + -- Divide into 0 tests dddiv301 divide 0 7 -> 0 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddDivideInt.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddDivideInt.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddDivideInt.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddEncode.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddEncode.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddEncode.decTest Tue Oct 27 18:02:46 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal64.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the eight-byte concrete representation. -- Its characteristics are: Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddFMA.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddFMA.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddFMA.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddInvert.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddInvert.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddInvert.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddLogB.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddLogB.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddLogB.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMax.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMax.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMax.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMaxMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMaxMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMaxMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMin.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMin.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMin.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMinMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMinMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMinMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMinus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMinus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMinus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddMultiply.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddMultiply.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddMultiply.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddNextMinus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddNextMinus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddNextMinus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddNextPlus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddNextPlus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddNextPlus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddNextToward.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddNextToward.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddNextToward.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddOr.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddOr.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddOr.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddPlus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddPlus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddPlus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddQuantize.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddQuantize.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddQuantize.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddReduce.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddReduce.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddReduce.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainder.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainder.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainder.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddRemainderNear.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddRotate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddRotate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddRotate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddSameQuantum.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decDoubles. precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddScaleB.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddScaleB.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddScaleB.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddShift.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddShift.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddShift.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddSubtract.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddSubtract.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddSubtract.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decDoubles only; all arguments are -- representable in a decDouble Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddToIntegral.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddToIntegral.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddToIntegral.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ddXor.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ddXor.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ddXor.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 precision: 16 maxExponent: 384 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/decDouble.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/decDouble.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/decDouble.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decDouble tests dectest: ddAbs Modified: python/branches/release26-maint/Lib/test/decimaltestdata/decQuad.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/decQuad.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/decQuad.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decQuad tests dectest: dqAbs Modified: python/branches/release26-maint/Lib/test/decimaltestdata/decSingle.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/decSingle.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/decSingle.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- decSingle tests dectest: dsBase Modified: python/branches/release26-maint/Lib/test/decimaltestdata/divide.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/divide.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/divide.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/divideint.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/divideint.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/divideint.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqAbs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqAbs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqAbs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqAdd.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqAdd.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqAdd.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad @@ -637,7 +637,7 @@ dqadd7732 add 0 0 -> 0 dqadd7733 add 0 -0 -> 0 dqadd7734 add -0 0 -> 0 -dqadd7735 add -0 -0 -> -0 -- IEEE 854 special case +dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case dqadd7736 add 1 -1 -> 0 dqadd7737 add -1 -1 -> -2 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqAnd.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqAnd.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqAnd.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqBase.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqBase.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqBase.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCanonical.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCanonical.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCanonical.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests that copy operations leave uncanonical operands -- unchanged, and vice versa Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqClass.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqClass.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqClass.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [New 2006.11.27] Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCompare.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCompare.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCompare.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareSig.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareSig.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareSig.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotal.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCompareTotalMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Note that we cannot assume add/subtract tests cover paths adequately, -- here, because the code might be quite different (comparison cannot Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCopy.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCopy.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCopy.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyAbs.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCopyNegate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqCopySign.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqCopySign.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqCopySign.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqDivide.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqDivide.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqDivide.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqDivideInt.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqDivideInt.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqDivideInt.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqEncode.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqEncode.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqEncode.decTest Tue Oct 27 18:02:46 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal128.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqFMA.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqFMA.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqFMA.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqInvert.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqInvert.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqInvert.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqLogB.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqLogB.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqLogB.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMax.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMax.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMax.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMaxMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMaxMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMaxMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMin.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMin.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMin.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMinMag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMinMag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMinMag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMinus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMinus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMinus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqMultiply.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqMultiply.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqMultiply.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqNextMinus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqNextMinus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqNextMinus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqNextPlus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqNextPlus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqNextPlus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqNextToward.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqNextToward.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqNextToward.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqOr.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqOr.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqOr.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqPlus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqPlus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqPlus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqQuantize.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqQuantize.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqQuantize.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. @@ -357,8 +357,6 @@ rounding: down dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation --- ? should that one instead have been: --- dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation rounding: half_up -- and a few more from e-mail discussions Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqReduce.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqReduce.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqReduce.decTest Tue Oct 27 18:02:46 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainder.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainder.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainder.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqRemainderNear.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqRotate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqRotate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqRotate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqSameQuantum.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- All operands and results are decQuads. extended: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqScaleB.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqScaleB.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqScaleB.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqShift.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqShift.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqShift.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqSubtract.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqSubtract.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqSubtract.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests are for decQuads only; all arguments are -- representable in a decQuad Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqToIntegral.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqToIntegral.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqToIntegral.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value-exact' operations (from IEEE 854, later modified in 754r). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dqXor.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dqXor.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dqXor.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 clamp: 1 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dsBase.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dsBase.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dsBase.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) Modified: python/branches/release26-maint/Lib/test/decimaltestdata/dsEncode.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/dsEncode.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/dsEncode.decTest Tue Oct 27 18:02:46 2009 @@ -18,7 +18,7 @@ -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -- [Previously called decimal32.decTest] -version: 2.58 +version: 2.59 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: Modified: python/branches/release26-maint/Lib/test/decimaltestdata/exp.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/exp.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/exp.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Tests of the exponential funtion. Currently all testcases here -- show results which are correctly rounded (within <= 0.5 ulp). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/fma.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/fma.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/fma.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/inexact.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/inexact.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/inexact.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/invert.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/invert.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/invert.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/ln.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/ln.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/ln.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 16 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/log10.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/log10.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/log10.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/logb.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/logb.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/logb.decTest Tue Oct 27 18:02:46 2009 @@ -1,6 +1,6 @@ ------------------------------------------------------------------------ -- logb.decTest -- return integral adjusted exponent as per 754r -- --- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. -- +-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This emphasises the testing of notable cases, as they will often -- have unusual paths (especially the 10**n results). @@ -143,7 +143,33 @@ logbx1419 logb 1000E2 -> 5 logbx1420 logb 10000E2 -> 6 +-- inexacts +precision: 2 +logbx1500 logb 10000E2 -> 6 +logbx1501 logb 1E+99 -> 99 +logbx1502 logb 1E-99 -> -99 +logbx1503 logb 1E+100 -> 1.0E+2 Rounded +logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded +logbx1505 logb 1E-100 -> -1.0E+2 Rounded +logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded +logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded +logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded +logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded +logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded +logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded +precision: 1 +logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded +logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded +logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded +precision: 8 +logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded +logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded +precision: 9 +logbx1523 logb 1E+999999999 -> 999999999 +logbx1524 logb 1E-999999999 -> -999999999 + -- special values +precision: 9 logbx820 logb Infinity -> Infinity logbx821 logb -Infinity -> Infinity logbx822 logb 0 -> -Infinity Division_by_zero Modified: python/branches/release26-maint/Lib/test/decimaltestdata/max.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/max.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/max.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/maxmag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/maxmag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/maxmag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/min.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/min.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/min.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/minmag.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/minmag.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/minmag.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- we assume that base comparison is tested in compare.decTest, so -- these mainly cover special cases and rounding Modified: python/branches/release26-maint/Lib/test/decimaltestdata/minus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/minus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/minus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Subtraction, rounding, and more overflows are tested elsewhere. Modified: python/branches/release26-maint/Lib/test/decimaltestdata/multiply.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/multiply.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/multiply.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/nextminus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/nextminus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/nextminus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/nextplus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/nextplus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/nextplus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/nexttoward.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/nexttoward.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/nexttoward.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/or.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/or.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/or.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/plus.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/plus.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/plus.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests primarily tests the existence of the operator. -- Addition and rounding, and most overflows, are tested elsewhere. Modified: python/branches/release26-maint/Lib/test/decimaltestdata/power.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/power.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/power.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- In addition to the power operator testcases here, see also the file -- powersqrt.decTest which includes all the tests from Modified: python/branches/release26-maint/Lib/test/decimaltestdata/powersqrt.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/powersqrt.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/powersqrt.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases are taken from squareroot.decTest but are -- evaluated using the power operator. The differences in results Modified: python/branches/release26-maint/Lib/test/decimaltestdata/quantize.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/quantize.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/quantize.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- Most of the tests here assume a "regular pattern", where the -- sign and coefficient are +1. Modified: python/branches/release26-maint/Lib/test/decimaltestdata/randomBound32.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/randomBound32.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/randomBound32.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These testcases test calculations at precisions 31, 32, and 33, to -- exercise the boundaries around 2**5 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/randoms.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/randoms.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/randoms.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 maxexponent: 999999999 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/reduce.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/reduce.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/reduce.decTest Tue Oct 27 18:02:46 2009 @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ -- [This used to be called normalize.] -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/remainder.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/remainder.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/remainder.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/remainderNear.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/remainderNear.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/remainderNear.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/rescale.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/rescale.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/rescale.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- [obsolete] Quantize.decTest has the improved version Modified: python/branches/release26-maint/Lib/test/decimaltestdata/rotate.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/rotate.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/rotate.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/rounding.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/rounding.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/rounding.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- These tests require that implementations take account of residues in -- order to get correct results for some rounding modes. Rather than Modified: python/branches/release26-maint/Lib/test/decimaltestdata/samequantum.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/samequantum.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/samequantum.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/scaleb.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/scaleb.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/scaleb.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -198,3 +198,12 @@ scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998 scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded + +-- Krah examples +precision: 34 +maxExponent: 999999999 +minExponent: -999999999 +-- integer overflow in 3.61 or earlier +scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation +-- out of range +scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation Modified: python/branches/release26-maint/Lib/test/decimaltestdata/shift.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/shift.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/shift.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/squareroot.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/squareroot.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/squareroot.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 @@ -3812,6 +3812,16 @@ clamp: 1 sqtx9045 squareroot 1 -> 1.00000 Clamped +-- other +maxexponent: 999 +minexponent: -999 +precision: 16 +sqtx9046 squareroot 10 -> 3.162277660168379 inexact rounded +sqtx9047 squareroot 10E-1 -> 1.0 +sqtx9048 squareroot 10E-2 -> 0.3162277660168379 inexact rounded +sqtx9049 squareroot 10E-3 -> 0.10 + + -- High-precision exact and inexact maxexponent: 999 minexponent: -999 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/subtract.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/subtract.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/subtract.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/decimaltestdata/testall.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/testall.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/testall.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- core tests (using Extended: 1) -------------------------------------- dectest: base Modified: python/branches/release26-maint/Lib/test/decimaltestdata/tointegral.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/tointegral.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/tointegral.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/tointegralx.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/tointegralx.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/tointegralx.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 -- This set of tests tests the extended specification 'round-to-integral -- value' operation (from IEEE 854, later modified in 754r). Modified: python/branches/release26-maint/Lib/test/decimaltestdata/xor.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/xor.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/xor.decTest Tue Oct 27 18:02:46 2009 @@ -17,7 +17,7 @@ -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc at uk.ibm.com -- ------------------------------------------------------------------------ -version: 2.58 +version: 2.59 extended: 1 precision: 9 Modified: python/branches/release26-maint/Lib/test/test_decimal.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_decimal.py (original) +++ python/branches/release26-maint/Lib/test/test_decimal.py Tue Oct 27 18:02:46 2009 @@ -64,6 +64,13 @@ skip_expected = not os.path.isdir(directory) +# list of individual .decTest test ids that correspond to tests that +# we're skipping for one reason or another. +skipped_test_ids = [ + 'scbx164', # skipping apparently implementation-specific scaleb + 'scbx165', # tests, pending clarification of scaleb rules. +] + # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. EXTENDEDERRORTEST = False @@ -263,6 +270,10 @@ val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val + + if id in skipped_test_ids: + return + fname = nameAdapter.get(funct, funct) if fname == 'rescale': return From python-checkins at python.org Tue Oct 27 18:15:36 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:15:36 -0000 Subject: [Python-checkins] r75807 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:15:35 2009 New Revision: 75807 Log: Blocked revisions 75345,75347 via svnmerge ................ r75345 | georg.brandl | 2009-10-11 09:49:57 +0100 (Sun, 11 Oct 2009) | 9 lines Merged revisions 75344 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75344 | georg.brandl | 2009-10-11 10:48:28 +0200 (So, 11 Okt 2009) | 1 line Update primes script. ........ ................ r75347 | mark.dickinson | 2009-10-11 10:40:17 +0100 (Sun, 11 Oct 2009) | 9 lines Merged revisions 75346 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75346 | mark.dickinson | 2009-10-11 10:35:57 +0100 (Sun, 11 Oct 2009) | 1 line Fix 'primes 0 1' ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:18:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:18:26 -0000 Subject: [Python-checkins] r75808 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:18:26 2009 New Revision: 75808 Log: Blocked revisions 75349 via svnmerge ................ r75349 | mark.dickinson | 2009-10-11 11:32:51 +0100 (Sun, 11 Oct 2009) | 9 lines Merged revisions 75348 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75348 | mark.dickinson | 2009-10-11 11:01:17 +0100 (Sun, 11 Oct 2009) | 1 line Set missing executable property on scripts ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:21:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:21:04 -0000 Subject: [Python-checkins] r75809 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:21:04 2009 New Revision: 75809 Log: Blocked revisions 75434 via svnmerge ........ r75434 | mark.dickinson | 2009-10-15 16:18:55 +0100 (Thu, 15 Oct 2009) | 1 line Fix missing semicolon ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:21:56 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:21:56 -0000 Subject: [Python-checkins] r75810 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:21:56 2009 New Revision: 75810 Log: Blocked revisions 75438 via svnmerge ........ r75438 | mark.dickinson | 2009-10-15 16:53:58 +0100 (Thu, 15 Oct 2009) | 1 line Issue #7142: Fix uses of unicode in memoryview objects ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:26:32 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:26:32 -0000 Subject: [Python-checkins] r75811 - in python/branches/release26-maint: Python/compile.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:26:31 2009 New Revision: 75811 Log: Merged revisions 75440 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75440 | mark.dickinson | 2009-10-15 18:45:39 +0100 (Thu, 15 Oct 2009) | 1 line Allow core Python build to succeed under WITHOUT_COMPLEX. The module build stage still fails. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Python/compile.c Modified: python/branches/release26-maint/Python/compile.c ============================================================================== --- python/branches/release26-maint/Python/compile.c (original) +++ python/branches/release26-maint/Python/compile.c Tue Oct 27 18:26:31 2009 @@ -922,10 +922,8 @@ { PyObject *t, *v; Py_ssize_t arg; - unsigned char *p, *q; - Py_complex z; + unsigned char *p; double d; - int real_part_zero, imag_part_zero; /* necessary to make sure types aren't coerced (e.g., int and long) */ /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ @@ -940,7 +938,11 @@ else t = PyTuple_Pack(2, o, o->ob_type); } +#ifndef WITHOUT_COMPLEX else if (PyComplex_Check(o)) { + Py_complex z; + int real_part_zero, imag_part_zero; + unsigned char *q; /* complex case is even messier: we need to make complex(x, 0.) different from complex(x, -0.) and complex(0., y) different from complex(-0., y), for any x and y. In @@ -970,6 +972,7 @@ t = PyTuple_Pack(2, o, o->ob_type); } } +#endif /* WITHOUT_COMPLEX */ else { t = PyTuple_Pack(2, o, o->ob_type); } From python-checkins at python.org Tue Oct 27 18:31:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:31:26 -0000 Subject: [Python-checkins] r75812 - in python/branches/release31-maint: Python/compile.c Python/formatter_unicode.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:31:26 2009 New Revision: 75812 Log: Merged revisions 75441 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75441 | mark.dickinson | 2009-10-15 20:55:18 +0100 (Thu, 15 Oct 2009) | 9 lines Merged revisions 75440 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75440 | mark.dickinson | 2009-10-15 18:45:39 +0100 (Thu, 15 Oct 2009) | 1 line Allow core Python build to succeed under WITHOUT_COMPLEX. The module build stage still fails. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Python/compile.c python/branches/release31-maint/Python/formatter_unicode.c Modified: python/branches/release31-maint/Python/compile.c ============================================================================== --- python/branches/release31-maint/Python/compile.c (original) +++ python/branches/release31-maint/Python/compile.c Tue Oct 27 18:31:26 2009 @@ -909,10 +909,8 @@ { PyObject *t, *v; Py_ssize_t arg; - unsigned char *p, *q; - Py_complex z; + unsigned char *p; double d; - int real_part_zero, imag_part_zero; /* necessary to make sure types aren't coerced (e.g., int and long) */ /* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */ @@ -927,7 +925,11 @@ else t = PyTuple_Pack(2, o, o->ob_type); } +#ifndef WITHOUT_COMPLEX else if (PyComplex_Check(o)) { + Py_complex z; + int real_part_zero, imag_part_zero; + unsigned char *q; /* complex case is even messier: we need to make complex(x, 0.) different from complex(x, -0.) and complex(0., y) different from complex(-0., y), for any x and y. In @@ -957,6 +959,7 @@ t = PyTuple_Pack(2, o, o->ob_type); } } +#endif /* WITHOUT_COMPLEX */ else { t = PyTuple_Pack(2, o, o->ob_type); } Modified: python/branches/release31-maint/Python/formatter_unicode.c ============================================================================== --- python/branches/release31-maint/Python/formatter_unicode.c (original) +++ python/branches/release31-maint/Python/formatter_unicode.c Tue Oct 27 18:31:26 2009 @@ -9,6 +9,8 @@ #define FORMAT_STRING _PyUnicode_FormatAdvanced #define FORMAT_LONG _PyLong_FormatAdvanced #define FORMAT_FLOAT _PyFloat_FormatAdvanced +#ifndef WITHOUT_COMPLEX #define FORMAT_COMPLEX _PyComplex_FormatAdvanced +#endif #include "../Objects/stringlib/formatter.h" From python-checkins at python.org Tue Oct 27 18:32:46 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:32:46 -0000 Subject: [Python-checkins] r75813 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:32:46 2009 New Revision: 75813 Log: Blocked revisions 75454 via svnmerge ........ r75454 | mark.dickinson | 2009-10-17 08:06:37 +0100 (Sat, 17 Oct 2009) | 1 line test_math ulp computation was wrong on big-endian systems ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:33:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:33:26 -0000 Subject: [Python-checkins] r75814 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:33:26 2009 New Revision: 75814 Log: Blocked revisions 75455 via svnmerge ................ r75455 | mark.dickinson | 2009-10-17 08:10:00 +0100 (Sat, 17 Oct 2009) | 9 lines Merged revisions 75454 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75454 | mark.dickinson | 2009-10-17 08:06:37 +0100 (Sat, 17 Oct 2009) | 1 line test_math ulp computation was wrong on big-endian systems ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:34:20 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:34:20 -0000 Subject: [Python-checkins] r75815 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:34:20 2009 New Revision: 75815 Log: Blocked revisions 75470 via svnmerge ........ r75470 | mark.dickinson | 2009-10-17 22:46:32 +0100 (Sat, 17 Oct 2009) | 1 line Protect against attempts to replace PyNumber_Add with PyNumber_InPlaceAdd in builtin sum ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:35:12 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:35:12 -0000 Subject: [Python-checkins] r75816 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:35:12 2009 New Revision: 75816 Log: Blocked revisions 75471 via svnmerge ................ r75471 | mark.dickinson | 2009-10-17 22:48:16 +0100 (Sat, 17 Oct 2009) | 9 lines Merged revisions 75470 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75470 | mark.dickinson | 2009-10-17 22:46:32 +0100 (Sat, 17 Oct 2009) | 1 line Protect against attempts to replace PyNumber_Add with PyNumber_InPlaceAdd in builtin sum ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:38:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 17:38:05 -0000 Subject: [Python-checkins] r75817 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 18:38:05 2009 New Revision: 75817 Log: Blocked revisions 75495-75496 via svnmerge ........ r75495 | skip.montanaro | 2009-10-18 15:25:35 +0100 (Sun, 18 Oct 2009) | 1 line Issue 7147 - remove ability to attempt to build Python without complex number support (was broken anyway) ........ r75496 | mark.dickinson | 2009-10-18 17:41:32 +0100 (Sun, 18 Oct 2009) | 1 line Remove the uses of WITHOUT_COMPLEX introduced in r75471 ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 18:41:59 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 17:41:59 -0000 Subject: [Python-checkins] r75818 - in python/trunk: Lib/test/test_bz2.py Misc/NEWS Modules/bz2module.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 18:41:58 2009 New Revision: 75818 Log: Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. Modified: python/trunk/Lib/test/test_bz2.py python/trunk/Misc/NEWS python/trunk/Modules/bz2module.c Modified: python/trunk/Lib/test/test_bz2.py ============================================================================== --- python/trunk/Lib/test/test_bz2.py (original) +++ python/trunk/Lib/test/test_bz2.py Tue Oct 27 18:41:58 2009 @@ -7,6 +7,7 @@ import os import subprocess import sys +import threading bz2 = import_module('bz2') from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor @@ -306,6 +307,23 @@ else: self.fail("1/0 didn't raise an exception") + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = "1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Oct 27 18:41:58 2009 @@ -427,6 +427,9 @@ Library ------- +- Issue #7205: Fix a possible deadlock when using a BZ2File object from + several threads at once. + - Issue #7071: byte-compilation in Distutils is now done with respect to sys.dont_write_bytecode. Modified: python/trunk/Modules/bz2module.c ============================================================================== --- python/trunk/Modules/bz2module.c (original) +++ python/trunk/Modules/bz2module.c Tue Oct 27 18:41:58 2009 @@ -78,7 +78,12 @@ #ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) +#define ACQUIRE_LOCK(obj) do { \ + if (!PyThread_acquire_lock(obj->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(obj->lock, 1); \ + Py_END_ALLOW_THREADS \ + } } while(0) #define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) #else #define ACQUIRE_LOCK(obj) From python-checkins at python.org Tue Oct 27 18:46:10 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 17:46:10 -0000 Subject: [Python-checkins] r75819 - in python/branches/release26-maint: Lib/test/test_bz2.py Misc/NEWS Modules/bz2module.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 18:46:09 2009 New Revision: 75819 Log: Merged revisions 75818 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_bz2.py python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Modules/bz2module.c Modified: python/branches/release26-maint/Lib/test/test_bz2.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_bz2.py (original) +++ python/branches/release26-maint/Lib/test/test_bz2.py Tue Oct 27 18:46:09 2009 @@ -7,6 +7,7 @@ import os import subprocess import sys +import threading import bz2 from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor @@ -284,6 +285,23 @@ bz2f.close() self.assertEqual(xlines, ['Test']) + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = "1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 18:46:09 2009 @@ -24,6 +24,9 @@ Library ------- +- Issue #7205: Fix a possible deadlock when using a BZ2File object from + several threads at once. + - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. Modified: python/branches/release26-maint/Modules/bz2module.c ============================================================================== --- python/branches/release26-maint/Modules/bz2module.c (original) +++ python/branches/release26-maint/Modules/bz2module.c Tue Oct 27 18:46:09 2009 @@ -78,7 +78,12 @@ #ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) +#define ACQUIRE_LOCK(obj) do { \ + if (!PyThread_acquire_lock(obj->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(obj->lock, 1); \ + Py_END_ALLOW_THREADS \ + } } while(0) #define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) #else #define ACQUIRE_LOCK(obj) From python-checkins at python.org Tue Oct 27 18:47:14 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 17:47:14 -0000 Subject: [Python-checkins] r75820 - in python/branches/py3k: Lib/test/test_bz2.py Misc/NEWS Modules/bz2module.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 18:47:14 2009 New Revision: 75820 Log: Merged revisions 75818 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_bz2.py python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/bz2module.c Modified: python/branches/py3k/Lib/test/test_bz2.py ============================================================================== --- python/branches/py3k/Lib/test/test_bz2.py (original) +++ python/branches/py3k/Lib/test/test_bz2.py Tue Oct 27 18:47:14 2009 @@ -7,6 +7,7 @@ import os import subprocess import sys +import threading # Skip tests if the bz2 module doesn't exist. bz2 = support.import_module('bz2') @@ -282,6 +283,23 @@ else: self.fail("1/0 didn't raise an exception") + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = b"1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Oct 27 18:47:14 2009 @@ -117,6 +117,9 @@ Library ------- +- Issue #7205: Fix a possible deadlock when using a BZ2File object from + several threads at once. + - Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. - Issue #7099: Decimal.is_normal now returns True for numbers with exponent Modified: python/branches/py3k/Modules/bz2module.c ============================================================================== --- python/branches/py3k/Modules/bz2module.c (original) +++ python/branches/py3k/Modules/bz2module.c Tue Oct 27 18:47:14 2009 @@ -78,7 +78,12 @@ #ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) +#define ACQUIRE_LOCK(obj) do { \ + if (!PyThread_acquire_lock(obj->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(obj->lock, 1); \ + Py_END_ALLOW_THREADS \ + } } while(0) #define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) #else #define ACQUIRE_LOCK(obj) From python-checkins at python.org Tue Oct 27 18:49:21 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 17:49:21 -0000 Subject: [Python-checkins] r75821 - in python/branches/release31-maint: Lib/test/test_bz2.py Misc/NEWS Modules/bz2module.c Message-ID: Author: antoine.pitrou Date: Tue Oct 27 18:49:21 2009 New Revision: 75821 Log: Merged revisions 75820 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75820 | antoine.pitrou | 2009-10-27 18:47:14 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75818 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_bz2.py python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Modules/bz2module.c Modified: python/branches/release31-maint/Lib/test/test_bz2.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_bz2.py (original) +++ python/branches/release31-maint/Lib/test/test_bz2.py Tue Oct 27 18:49:21 2009 @@ -7,6 +7,7 @@ import os import subprocess import sys +import threading # Skip tests if the bz2 module doesn't exist. bz2 = support.import_module('bz2') @@ -282,6 +283,23 @@ else: self.fail("1/0 didn't raise an exception") + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = b"1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Tue Oct 27 18:49:21 2009 @@ -34,6 +34,9 @@ Library ------- +- Issue #7205: Fix a possible deadlock when using a BZ2File object from + several threads at once. + - Issue #7071: byte-compilation in Distutils is now done with respect to sys.dont_write_bytecode. Modified: python/branches/release31-maint/Modules/bz2module.c ============================================================================== --- python/branches/release31-maint/Modules/bz2module.c (original) +++ python/branches/release31-maint/Modules/bz2module.c Tue Oct 27 18:49:21 2009 @@ -78,7 +78,12 @@ #ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) +#define ACQUIRE_LOCK(obj) do { \ + if (!PyThread_acquire_lock(obj->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(obj->lock, 1); \ + Py_END_ALLOW_THREADS \ + } } while(0) #define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) #else #define ACQUIRE_LOCK(obj) From python-checkins at python.org Tue Oct 27 19:27:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:27:54 -0000 Subject: [Python-checkins] r75822 - in python/branches/release26-maint: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Misc/NEWS Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:27:53 2009 New Revision: 75822 Log: Merged revisions 75561 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75561 | mark.dickinson | 2009-10-20 14:33:03 +0100 (Tue, 20 Oct 2009) | 3 lines Issue #7099: Decimal.is_normal should return True for all nonzero finite non-subnormal values, even those with exponent > Emax. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/decimal.py python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/decimal.py ============================================================================== --- python/branches/release26-maint/Lib/decimal.py (original) +++ python/branches/release26-maint/Lib/decimal.py Tue Oct 27 19:27:53 2009 @@ -2874,7 +2874,7 @@ return False if context is None: context = getcontext() - return context.Emin <= self.adjusted() <= context.Emax + return context.Emin <= self.adjusted() def is_qnan(self): """Return True if self is a quiet NaN; otherwise return False.""" Modified: python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest Tue Oct 27 19:27:53 2009 @@ -1128,10 +1128,10 @@ bool0933 isnormal -1E+998 -> 1 bool0934 isnormal 1E+999 -> 1 bool0935 isnormal -1E+999 -> 1 -bool0936 isnormal 1E+1000 -> 0 -bool0937 isnormal -1E+1000 -> 0 -bool0938 isnormal 1E+2000 -> 0 -bool0939 isnormal -1E+2000 -> 0 +bool0936 isnormal 1E+1000 -> 1 +bool0937 isnormal -1E+1000 -> 1 +bool0938 isnormal 1E+2000 -> 1 +bool0939 isnormal -1E+2000 -> 1 bool0940 isnormal 9E-2000 -> 0 bool0941 isnormal -9E-2000 -> 0 bool0942 isnormal 9E-1008 -> 0 @@ -1178,10 +1178,10 @@ bool0983 isnormal -9E+998 -> 1 bool0984 isnormal 9E+999 -> 1 bool0985 isnormal -9E+999 -> 1 -bool0986 isnormal 9E+1000 -> 0 -bool0987 isnormal -9E+1000 -> 0 -bool0988 isnormal 9E+2000 -> 0 -bool0989 isnormal -9E+2000 -> 0 +bool0986 isnormal 9E+1000 -> 1 +bool0987 isnormal -9E+1000 -> 1 +bool0988 isnormal 9E+2000 -> 1 +bool0989 isnormal -9E+2000 -> 1 bool0990 isnormal 9.99999999E-2000 -> 0 bool0991 isnormal -9.99999999E-2000 -> 0 bool0992 isnormal 9.99999999E-1008 -> 0 @@ -1228,10 +1228,10 @@ bool1033 isnormal -9.99999999E+998 -> 1 bool1034 isnormal 9.99999999E+999 -> 1 bool1035 isnormal -9.99999999E+999 -> 1 -bool1036 isnormal 9.99999999E+1000 -> 0 -bool1037 isnormal -9.99999999E+1000 -> 0 -bool1038 isnormal 9.99999999E+2000 -> 0 -bool1039 isnormal -9.99999999E+2000 -> 0 +bool1036 isnormal 9.99999999E+1000 -> 1 +bool1037 isnormal -9.99999999E+1000 -> 1 +bool1038 isnormal 9.99999999E+2000 -> 1 +bool1039 isnormal -9.99999999E+2000 -> 1 bool1040 isnormal Infinity -> 0 bool1041 isnormal -Infinity -> 0 bool1042 isnormal NaN -> 0 Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Tue Oct 27 19:27:53 2009 @@ -24,6 +24,9 @@ Library ------- +- Issue #7099: Decimal.is_normal now returns True for numbers with exponent + larger than emax. + - Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. From python-checkins at python.org Tue Oct 27 19:31:30 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:31:30 -0000 Subject: [Python-checkins] r75823 - in python/branches/release26-maint: Misc/ACKS Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:31:29 2009 New Revision: 75823 Log: Merged revisions 75648 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75648 | mark.dickinson | 2009-10-24 12:47:17 +0100 (Sat, 24 Oct 2009) | 1 line Acknowledge Ned Deily (extensive bug hunting and testing on OS X) ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Misc/ACKS Modified: python/branches/release26-maint/Misc/ACKS ============================================================================== --- python/branches/release26-maint/Misc/ACKS (original) +++ python/branches/release26-maint/Misc/ACKS Tue Oct 27 19:31:29 2009 @@ -162,6 +162,7 @@ Ben Darnell Jonathan Dasteel John DeGood +Ned Deily Vincent Delft Arnaud Delobelle Erik Demaine From python-checkins at python.org Tue Oct 27 19:33:14 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 18:33:14 -0000 Subject: [Python-checkins] r75824 - python/trunk/Python/ast.c Message-ID: Author: eric.smith Date: Tue Oct 27 19:33:14 2009 New Revision: 75824 Log: Removed PyOS_ascii_atof from ast.c, as mentioned in issue 7117. Modified: python/trunk/Python/ast.c Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Tue Oct 27 19:33:14 2009 @@ -3236,17 +3236,17 @@ #ifndef WITHOUT_COMPLEX if (imflag) { complex.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - complex.imag = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(complex) + complex.imag = PyOS_string_to_double(s, (char **)&end, NULL); + if (complex.imag == -1.0 && PyErr_Occurred()) + return NULL; return PyComplex_FromCComplex(complex); } else #endif { - PyFPE_START_PROTECT("atof", return 0) - dx = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(dx) + dx = PyOS_string_to_double(s, NULL, NULL); + if (dx == -1.0 && PyErr_Occurred()) + return NULL; return PyFloat_FromDouble(dx); } } From python-checkins at python.org Tue Oct 27 19:35:06 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:35:06 -0000 Subject: [Python-checkins] r75825 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:35:06 2009 New Revision: 75825 Log: Blocked revisions 75667 via svnmerge ........ r75667 | mark.dickinson | 2009-10-24 15:04:48 +0100 (Sat, 24 Oct 2009) | 1 line Add tests for sys.float_repr_style ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:36:47 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 18:36:47 -0000 Subject: [Python-checkins] r75826 - python/trunk/Lib/test/test_asyncore.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 19:36:47 2009 New Revision: 75826 Log: Suppress transient refleaks in test_asyncore Modified: python/trunk/Lib/test/test_asyncore.py Modified: python/trunk/Lib/test/test_asyncore.py ============================================================================== --- python/trunk/Lib/test/test_asyncore.py (original) +++ python/trunk/Lib/test/test_asyncore.py Tue Oct 27 19:36:47 2009 @@ -319,40 +319,44 @@ def tearDown(self): asyncore.close_all() + @test_support.reap_threads def test_send(self): - self.evt = threading.Event() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) + evt = threading.Event() + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(3) + port = test_support.bind_port(sock) cap = StringIO() - args = (self.evt, cap, self.sock) - threading.Thread(target=capture_server, args=args).start() - - # wait a little longer for the server to initialize (it sometimes - # refuses connections on slow machines without this wait) - time.sleep(0.2) - - data = "Suppose there isn't a 16-ton weight?" - d = dispatcherwithsend_noread() - d.create_socket(socket.AF_INET, socket.SOCK_STREAM) - d.connect((HOST, self.port)) - - # give time for socket to connect - time.sleep(0.1) - - d.send(data) - d.send(data) - d.send('\n') - - n = 1000 - while d.out_buffer and n > 0: - asyncore.poll() - n -= 1 - - self.evt.wait() - - self.assertEqual(cap.getvalue(), data*2) + args = (evt, cap, sock) + t = threading.Thread(target=capture_server, args=args) + t.start() + try: + # wait a little longer for the server to initialize (it sometimes + # refuses connections on slow machines without this wait) + time.sleep(0.2) + + data = "Suppose there isn't a 16-ton weight?" + d = dispatcherwithsend_noread() + d.create_socket(socket.AF_INET, socket.SOCK_STREAM) + d.connect((HOST, port)) + + # give time for socket to connect + time.sleep(0.1) + + d.send(data) + d.send(data) + d.send('\n') + + n = 1000 + while d.out_buffer and n > 0: + asyncore.poll() + n -= 1 + + evt.wait() + + self.assertEqual(cap.getvalue(), data*2) + finally: + t.join() class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): From python-checkins at python.org Tue Oct 27 19:37:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:37:21 -0000 Subject: [Python-checkins] r75827 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:37:21 2009 New Revision: 75827 Log: Blocked revisions 75709 via svnmerge ........ r75709 | mark.dickinson | 2009-10-26 07:58:04 +0000 (Mon, 26 Oct 2009) | 1 line Silence gcc warning about possibly uninitialized variable 'converted_items' ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:38:17 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:38:17 -0000 Subject: [Python-checkins] r75828 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:38:17 2009 New Revision: 75828 Log: Blocked revisions 75711 via svnmerge ........ r75711 | mark.dickinson | 2009-10-26 11:59:30 +0000 (Mon, 26 Oct 2009) | 1 line Skip readline tests if readline module is not available. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:39:14 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:39:14 -0000 Subject: [Python-checkins] r75829 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:39:14 2009 New Revision: 75829 Log: Blocked revisions 75714 via svnmerge ........ r75714 | mark.dickinson | 2009-10-26 14:18:44 +0000 (Mon, 26 Oct 2009) | 1 line Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:39:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:39:54 -0000 Subject: [Python-checkins] r75830 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:39:54 2009 New Revision: 75830 Log: Blocked revisions 75715 via svnmerge ................ r75715 | mark.dickinson | 2009-10-26 14:19:42 +0000 (Mon, 26 Oct 2009) | 9 lines Merged revisions 75714 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75714 | mark.dickinson | 2009-10-26 14:18:44 +0000 (Mon, 26 Oct 2009) | 1 line Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:40:15 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:40:15 -0000 Subject: [Python-checkins] r75831 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:40:14 2009 New Revision: 75831 Log: Blocked revisions 75716 via svnmerge ........ r75716 | mark.dickinson | 2009-10-26 14:36:29 +0000 (Mon, 26 Oct 2009) | 1 line Move some comments to more appropriate places ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:42:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:42:04 -0000 Subject: [Python-checkins] r75832 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:42:04 2009 New Revision: 75832 Log: Blocked revisions 75728 via svnmerge ........ r75728 | mark.dickinson | 2009-10-26 19:59:23 +0000 (Mon, 26 Oct 2009) | 3 lines Use correct conversion specifier and length modifier when printing an integer of type off_t. Also, don't assume that long long is available. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:43:44 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:43:44 -0000 Subject: [Python-checkins] r75833 - in python/branches/release31-maint: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:43:44 2009 New Revision: 75833 Log: Merged revisions 75729 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75729 | mark.dickinson | 2009-10-26 20:02:55 +0000 (Mon, 26 Oct 2009) | 10 lines Merged revisions 75728 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75728 | mark.dickinson | 2009-10-26 19:59:23 +0000 (Mon, 26 Oct 2009) | 3 lines Use correct conversion specifier and length modifier when printing an integer of type off_t. Also, don't assume that long long is available. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_io/_iomodule.h python/branches/release31-maint/Modules/_io/bufferedio.c Modified: python/branches/release31-maint/Modules/_io/_iomodule.h ============================================================================== --- python/branches/release31-maint/Modules/_io/_iomodule.h (original) +++ python/branches/release31-maint/Modules/_io/_iomodule.h Tue Oct 27 19:43:44 2009 @@ -78,26 +78,30 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN +# define PY_PRIdOFF "ld" +#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +# define PY_PRIdOFF "zd" #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/release31-maint/Modules/_io/bufferedio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/bufferedio.c (original) +++ python/branches/release31-maint/Modules/_io/bufferedio.c Tue Oct 27 19:43:44 2009 @@ -580,7 +580,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; @@ -612,7 +613,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + n); return -1; } self->abs_pos = n; From python-checkins at python.org Tue Oct 27 19:47:34 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 18:47:34 -0000 Subject: [Python-checkins] r75834 - python/branches/py3k Message-ID: Author: eric.smith Date: Tue Oct 27 19:47:34 2009 New Revision: 75834 Log: Blocked revisions 75824 via svnmerge ........ r75824 | eric.smith | 2009-10-27 14:33:14 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from ast.c, as mentioned in issue 7117. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Oct 27 19:47:55 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:47:55 -0000 Subject: [Python-checkins] r75835 - python/branches/release31-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:47:55 2009 New Revision: 75835 Log: Blocked revisions 75732,75737-75738,75741 via svnmerge ........ r75732 | mark.dickinson | 2009-10-26 21:12:50 +0000 (Mon, 26 Oct 2009) | 1 line Fix extra-long line; also makes py3k match trunk here. ........ r75737 | mark.dickinson | 2009-10-26 21:51:18 +0000 (Mon, 26 Oct 2009) | 1 line Remove length limitation on string arguments to complex() ........ r75738 | mark.dickinson | 2009-10-26 22:05:06 +0000 (Mon, 26 Oct 2009) | 1 line Make sure memory is freed on error in complex_subtype_from_string. ........ r75741 | mark.dickinson | 2009-10-26 22:48:32 +0000 (Mon, 26 Oct 2009) | 2 lines Issue #7207: Fix race condition in telnetlib test; should stop test failures on OS X 10.6. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:49:23 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 18:49:23 -0000 Subject: [Python-checkins] r75836 - in python/branches/py3k: Lib/test/test_asyncore.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 19:49:23 2009 New Revision: 75836 Log: Merged revisions 75826 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75826 | antoine.pitrou | 2009-10-27 19:36:47 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_asyncore ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_asyncore.py Modified: python/branches/py3k/Lib/test/test_asyncore.py ============================================================================== --- python/branches/py3k/Lib/test/test_asyncore.py (original) +++ python/branches/py3k/Lib/test/test_asyncore.py Tue Oct 27 19:49:23 2009 @@ -320,40 +320,44 @@ def tearDown(self): asyncore.close_all() + @support.reap_threads def test_send(self): - self.evt = threading.Event() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(3) - self.port = support.bind_port(self.sock) + evt = threading.Event() + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(3) + port = support.bind_port(sock) cap = BytesIO() - args = (self.evt, cap, self.sock) - threading.Thread(target=capture_server, args=args).start() - - # wait a little longer for the server to initialize (it sometimes - # refuses connections on slow machines without this wait) - time.sleep(0.2) - - data = b"Suppose there isn't a 16-ton weight?" - d = dispatcherwithsend_noread() - d.create_socket(socket.AF_INET, socket.SOCK_STREAM) - d.connect((HOST, self.port)) - - # give time for socket to connect - time.sleep(0.1) - - d.send(data) - d.send(data) - d.send(b'\n') - - n = 1000 - while d.out_buffer and n > 0: - asyncore.poll() - n -= 1 - - self.evt.wait() - - self.assertEqual(cap.getvalue(), data*2) + args = (evt, cap, sock) + t = threading.Thread(target=capture_server, args=args) + t.start() + try: + # wait a little longer for the server to initialize (it sometimes + # refuses connections on slow machines without this wait) + time.sleep(0.2) + + data = b"Suppose there isn't a 16-ton weight?" + d = dispatcherwithsend_noread() + d.create_socket(socket.AF_INET, socket.SOCK_STREAM) + d.connect((HOST, port)) + + # give time for socket to connect + time.sleep(0.1) + + d.send(data) + d.send(data) + d.send(b'\n') + + n = 1000 + while d.out_buffer and n > 0: + asyncore.poll() + n -= 1 + + evt.wait() + + self.assertEqual(cap.getvalue(), data*2) + finally: + t.join() class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): From python-checkins at python.org Tue Oct 27 19:50:50 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 18:50:50 -0000 Subject: [Python-checkins] r75837 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 19:50:50 2009 New Revision: 75837 Log: Blocked revisions 75651,75653,75658,75660,75664,75666,75672,75720,75730-75731,75739 via svnmerge ........ r75651 | mark.dickinson | 2009-10-24 13:13:30 +0100 (Sat, 24 Oct 2009) | 7 lines Issue #7117: Prepare for backport of py3k float repr. Add the Python/dtoa.c file containing the main algorithms; add corresponding include file and include in Python.h; include license information for Python/dtoa.c; add dtoa.c and dtoa.h to Makefile. ........ r75653 | mark.dickinson | 2009-10-24 13:17:24 +0100 (Sat, 24 Oct 2009) | 1 line Temporary define to avoid build failure ........ r75658 | mark.dickinson | 2009-10-24 14:28:38 +0100 (Sat, 24 Oct 2009) | 8 lines Issue #7117 (backport py3k float repr) continued: - add double endianness detection to configure script - add configure-time check to see whether we can use inline assembly to get and set x87 control word in configure script - add functions to get and set x87 control word in Python/pymath.c - add pyport.h logic to determine whether it's safe to use the short float repr or not ........ r75660 | mark.dickinson | 2009-10-24 14:31:41 +0100 (Sat, 24 Oct 2009) | 1 line Remove temporary define from r75653 ........ r75664 | mark.dickinson | 2009-10-24 14:44:16 +0100 (Sat, 24 Oct 2009) | 1 line Configure check for double rounding should take BASECFLAGS into account ........ r75666 | mark.dickinson | 2009-10-24 15:01:08 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117 (backport py3k float repr) continued: Add sys.float_repr_style attribute ('short' if short float repr is in used; 'legacy' otherwise). ........ r75672 | mark.dickinson | 2009-10-24 16:54:35 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117: temporarily disable the short float repr while the pieces are being assembled. To re-enable, define the preprocessor symbol PY_SHORT_FLOAT_REPR ........ r75720 | mark.dickinson | 2009-10-26 15:39:50 +0000 (Mon, 26 Oct 2009) | 3 lines Issue #7117 (backport py3k float repr) continued: Backport pystrtod.c from py3k. ........ r75730 | mark.dickinson | 2009-10-26 21:09:09 +0000 (Mon, 26 Oct 2009) | 2 lines Issue #7117: Backport missing pystrtod.h declarations from py3k. ........ r75731 | mark.dickinson | 2009-10-26 21:11:20 +0000 (Mon, 26 Oct 2009) | 4 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in floatobject.c. Also, remove limitation on length of unicode inputs to float(). ........ r75739 | mark.dickinson | 2009-10-26 22:28:14 +0000 (Mon, 26 Oct 2009) | 5 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in complexobject.c. Also remove length restriction on unicode inputs to the complex constructor. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 19:50:53 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 18:50:53 -0000 Subject: [Python-checkins] r75838 - python/trunk/Lib/test/test_httpservers.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 19:50:52 2009 New Revision: 75838 Log: (Hopefully) suppress transient refleaks in test_httpservers. Modified: python/trunk/Lib/test/test_httpservers.py Modified: python/trunk/Lib/test/test_httpservers.py ============================================================================== --- python/trunk/Lib/test/test_httpservers.py (original) +++ python/trunk/Lib/test/test_httpservers.py Tue Oct 27 19:50:52 2009 @@ -50,6 +50,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): + self._threads = test_support.threading_setup() os.environ = test_support.EnvironmentVarGuard() self.lock = threading.Lock() self.thread = TestServerThread(self, self.request_handler) @@ -60,6 +61,7 @@ self.lock.release() self.thread.stop() os.environ.__exit__() + test_support.threading_cleanup(*self._threads) def request(self, uri, method='GET', body=None, headers={}): self.connection = httplib.HTTPConnection('localhost', self.PORT) From python-checkins at python.org Tue Oct 27 19:52:30 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 18:52:30 -0000 Subject: [Python-checkins] r75839 - in python/branches/py3k: Lib/test/test_httpservers.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 19:52:30 2009 New Revision: 75839 Log: Merged revisions 75838 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75838 | antoine.pitrou | 2009-10-27 19:50:52 +0100 (mar., 27 oct. 2009) | 3 lines (Hopefully) suppress transient refleaks in test_httpservers. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_httpservers.py Modified: python/branches/py3k/Lib/test/test_httpservers.py ============================================================================== --- python/branches/py3k/Lib/test/test_httpservers.py (original) +++ python/branches/py3k/Lib/test/test_httpservers.py Tue Oct 27 19:52:30 2009 @@ -51,6 +51,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): + self._threads = support.threading_setup() os.environ = support.EnvironmentVarGuard() self.lock = threading.Lock() self.thread = TestServerThread(self, self.request_handler) @@ -61,6 +62,7 @@ self.lock.release() self.thread.stop() os.environ.__exit__() + support.threading_cleanup(*self._threads) def request(self, uri, method='GET', body=None, headers={}): self.connection = http.client.HTTPConnection('localhost', self.PORT) From python-checkins at python.org Tue Oct 27 20:08:31 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 19:08:31 -0000 Subject: [Python-checkins] r75840 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Tue Oct 27 20:08:30 2009 New Revision: 75840 Log: Blocked revisions 75824 via svnmerge ........ r75824 | eric.smith | 2009-10-27 14:33:14 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from ast.c, as mentioned in issue 7117. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 20:23:57 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:23:57 -0000 Subject: [Python-checkins] r75842 - python/trunk/Lib/test/test_sys.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:23:56 2009 New Revision: 75842 Log: Fix transient refleak in test_sys. Modified: python/trunk/Lib/test/test_sys.py Modified: python/trunk/Lib/test/test_sys.py ============================================================================== --- python/trunk/Lib/test/test_sys.py (original) +++ python/trunk/Lib/test/test_sys.py Tue Oct 27 20:23:56 2009 @@ -5,6 +5,9 @@ class SysModuleTest(unittest.TestCase): + def tearDown(self): + test.test_support.reap_children() + def test_original_displayhook(self): import __builtin__ savestdout = sys.stdout @@ -257,6 +260,7 @@ self.current_frames_without_threads() # Test sys._current_frames() in a WITH_THREADS build. + @test.test_support.reap_threads def current_frames_with_threads(self): import threading, thread import traceback @@ -401,13 +405,13 @@ env["PYTHONIOENCODING"] = "cp424" p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read().strip() + out = p.communicate()[0].strip() self.assertEqual(out, unichr(0xa2).encode("cp424")) env["PYTHONIOENCODING"] = "ascii:replace" p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read().strip() + out = p.communicate()[0].strip() self.assertEqual(out, '?') From python-checkins at python.org Tue Oct 27 20:25:58 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:25:58 -0000 Subject: [Python-checkins] r75843 - in python/branches/py3k: Lib/test/test_sys.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:25:57 2009 New Revision: 75843 Log: Merged revisions 75842 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75842 | antoine.pitrou | 2009-10-27 20:23:56 +0100 (mar., 27 oct. 2009) | 3 lines Fix transient refleak in test_sys. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_sys.py Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Tue Oct 27 20:25:57 2009 @@ -16,6 +16,7 @@ sys.stdout = self.orig_stdout sys.stderr = self.orig_stderr sys.displayhook = self.orig_displayhook + test.support.reap_children() def test_original_displayhook(self): import builtins @@ -261,6 +262,7 @@ self.current_frames_without_threads() # Test sys._current_frames() in a WITH_THREADS build. + @test.support.reap_threads def current_frames_with_threads(self): import threading, _thread import traceback @@ -424,13 +426,13 @@ env["PYTHONIOENCODING"] = "cp424" p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read() + out = p.communicate()[0].strip() self.assertEqual(out, "\xa2\n".encode("cp424")) env["PYTHONIOENCODING"] = "ascii:replace" p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read().strip() + out = p.communicate()[0].strip() self.assertEqual(out, b'?') From python-checkins at python.org Tue Oct 27 20:36:44 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:36:44 -0000 Subject: [Python-checkins] r75844 - python/trunk/Lib/test/test_file2k.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:36:44 2009 New Revision: 75844 Log: Suppress transient refleaks in test_file2k. Modified: python/trunk/Lib/test/test_file2k.py Modified: python/trunk/Lib/test/test_file2k.py ============================================================================== --- python/trunk/Lib/test/test_file2k.py (original) +++ python/trunk/Lib/test/test_file2k.py Tue Oct 27 20:36:44 2009 @@ -374,6 +374,7 @@ # See #815646, #595601 def setUp(self): + self._threads = test_support.threading_setup() self.f = None self.filename = TESTFN with open(self.filename, "w") as f: @@ -392,6 +393,7 @@ os.remove(self.filename) except EnvironmentError: pass + test_support.threading_cleanup(*self._threads) def _create_file(self): self.f = open(self.filename, "w+") From python-checkins at python.org Tue Oct 27 20:39:10 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:39:10 -0000 Subject: [Python-checkins] r75845 - python/branches/py3k Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:39:10 2009 New Revision: 75845 Log: Blocked revisions 75844 via svnmerge ........ r75844 | antoine.pitrou | 2009-10-27 20:36:44 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_file2k. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Oct 27 20:42:57 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 19:42:57 -0000 Subject: [Python-checkins] r75846 - python/trunk/Python/marshal.c Message-ID: Author: eric.smith Date: Tue Oct 27 20:42:57 2009 New Revision: 75846 Log: Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. Modified: python/trunk/Python/marshal.c Modified: python/trunk/Python/marshal.c ============================================================================== --- python/trunk/Python/marshal.c (original) +++ python/trunk/Python/marshal.c Tue Oct 27 20:42:57 2009 @@ -698,10 +698,9 @@ break; } buf[n] = '\0'; - retval = NULL; - PyFPE_START_PROTECT("atof", break) - dx = PyOS_ascii_atof(buf); - PyFPE_END_PROTECT(dx) + dx = PyOS_string_to_double(buf, NULL, NULL); + if (dx == -1.0 && PyErr_Occurred()) + break; retval = PyFloat_FromDouble(dx); break; } @@ -738,10 +737,9 @@ break; } buf[n] = '\0'; - retval = NULL; - PyFPE_START_PROTECT("atof", break;) - c.real = PyOS_ascii_atof(buf); - PyFPE_END_PROTECT(c) + c.real = PyOS_string_to_double(buf, NULL, NULL); + if (c.real == -1.0 && PyErr_Occurred()) + break; n = r_byte(p); if (n == EOF || r_string(buf, (int)n, p) != n) { PyErr_SetString(PyExc_EOFError, @@ -750,9 +748,9 @@ break; } buf[n] = '\0'; - PyFPE_START_PROTECT("atof", break) - c.imag = PyOS_ascii_atof(buf); - PyFPE_END_PROTECT(c) + c.imag = PyOS_string_to_double(buf, NULL, NULL); + if (c.imag == -1.0 && PyErr_Occurred()) + break; retval = PyComplex_FromCComplex(c); break; } From python-checkins at python.org Tue Oct 27 20:44:06 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 19:44:06 -0000 Subject: [Python-checkins] r75847 - python/branches/py3k Message-ID: Author: eric.smith Date: Tue Oct 27 20:44:06 2009 New Revision: 75847 Log: Blocked revisions 75846 via svnmerge ........ r75846 | eric.smith | 2009-10-27 15:42:57 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Tue Oct 27 20:44:40 2009 From: python-checkins at python.org (eric.smith) Date: Tue, 27 Oct 2009 19:44:40 -0000 Subject: [Python-checkins] r75848 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Tue Oct 27 20:44:40 2009 New Revision: 75848 Log: Blocked revisions 75846 via svnmerge ........ r75846 | eric.smith | 2009-10-27 15:42:57 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 20:47:30 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:47:30 -0000 Subject: [Python-checkins] r75849 - python/trunk/Lib/test/test_smtplib.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:47:30 2009 New Revision: 75849 Log: Suppress transient refleaks in test_smtplib. Modified: python/trunk/Lib/test/test_smtplib.py Modified: python/trunk/Lib/test/test_smtplib.py ============================================================================== --- python/trunk/Lib/test/test_smtplib.py (original) +++ python/trunk/Lib/test/test_smtplib.py Tue Oct 27 20:47:30 2009 @@ -39,17 +39,21 @@ class GeneralTests(TestCase): def setUp(self): + self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "220 Hola mundo\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + test_support.threading_cleanup(*self._threads) def testBasic1(self): # connects @@ -142,12 +146,14 @@ self.output = StringIO.StringIO() sys.stdout = self.output + self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = test_support.find_unused_port() self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -158,6 +164,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + test_support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout @@ -253,17 +261,21 @@ self.output = StringIO.StringIO() sys.stdout = self.output + self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "199 no hello for you!\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + test_support.threading_cleanup(*self._threads) sys.stdout = self.old_stdout def testFailingHELO(self): @@ -369,12 +381,14 @@ class SMTPSimTests(TestCase): def setUp(self): + self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = test_support.find_unused_port() self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -385,6 +399,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + test_support.threading_cleanup(*self._threads) def testBasic(self): # smoke test From python-checkins at python.org Tue Oct 27 20:49:46 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 19:49:46 -0000 Subject: [Python-checkins] r75850 - in python/branches/py3k: Lib/test/test_smtplib.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 20:49:45 2009 New Revision: 75850 Log: Merged revisions 75849 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75849 | antoine.pitrou | 2009-10-27 20:47:30 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_smtplib. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_smtplib.py Modified: python/branches/py3k/Lib/test/test_smtplib.py ============================================================================== --- python/branches/py3k/Lib/test/test_smtplib.py (original) +++ python/branches/py3k/Lib/test/test_smtplib.py Tue Oct 27 20:49:45 2009 @@ -47,17 +47,21 @@ class GeneralTests(TestCase): def setUp(self): + self._threads = support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = support.bind_port(self.sock) servargs = (self.evt, b"220 Hola mundo\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) def testBasic1(self): # connects @@ -150,12 +154,14 @@ self.output = io.StringIO() sys.stdout = self.output + self._threads = support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = support.find_unused_port() self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -166,6 +172,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout @@ -261,17 +269,21 @@ self.output = io.StringIO() sys.stdout = self.output + self._threads = support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = support.bind_port(self.sock) servargs = (self.evt, b"199 no hello for you!\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) sys.stdout = self.old_stdout def testFailingHELO(self): @@ -377,12 +389,14 @@ class SMTPSimTests(TestCase): def setUp(self): + self._threads = support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = support.find_unused_port() self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -393,6 +407,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) def testBasic(self): # smoke test From python-checkins at python.org Tue Oct 27 21:02:25 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:02:25 -0000 Subject: [Python-checkins] r75851 - python/trunk/Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:02:23 2009 New Revision: 75851 Log: Suppress transient refleaks in test_threading. Modified: python/trunk/Lib/test/test_threading.py Modified: python/trunk/Lib/test/test_threading.py ============================================================================== --- python/trunk/Lib/test/test_threading.py (original) +++ python/trunk/Lib/test/test_threading.py Tue Oct 27 21:02:23 2009 @@ -54,7 +54,16 @@ print '%s is finished. %d tasks are running' % ( self.name, self.nrunning.get()) -class ThreadTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test.test_support.threading_setup() + + def tearDown(self): + test.test_support.threading_cleanup(*self._threads) + test.test_support.reap_children() + + +class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. @@ -382,7 +391,7 @@ sys.getrefcount(weak_raising_cyclic_object()))) -class ThreadJoinOnShutdown(unittest.TestCase): +class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: @@ -465,7 +474,7 @@ self._run_and_join(script) -class ThreadingExceptionTests(unittest.TestCase): +class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): From python-checkins at python.org Tue Oct 27 21:05:26 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:05:26 -0000 Subject: [Python-checkins] r75852 - in python/branches/py3k: Lib/test/test_threading.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:05:26 2009 New Revision: 75852 Log: Merged revisions 75851 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75851 | antoine.pitrou | 2009-10-27 21:02:23 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_threading. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_threading.py Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Tue Oct 27 21:05:26 2009 @@ -56,7 +56,16 @@ (self.name, self.nrunning.get())) -class ThreadTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test.support.threading_setup() + + def tearDown(self): + test.support.threading_cleanup(*self._threads) + test.support.reap_children() + + +class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. @@ -389,7 +398,7 @@ threading.activeCount() -class ThreadJoinOnShutdown(unittest.TestCase): +class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: @@ -470,7 +479,7 @@ self._run_and_join(script) -class ThreadingExceptionTests(unittest.TestCase): +class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): From python-checkins at python.org Tue Oct 27 21:09:05 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:09:05 -0000 Subject: [Python-checkins] r75853 - python/branches/release31-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 21:09:05 2009 New Revision: 75853 Log: Blocked revisions 74461,74528,74577,74580,74703,74743,74826,74939,75086,75093,75118,75173,75198,75242,75244-75245,75306,75311,75369,75435,75439,75448,75508,75512,75622,75652,75656,75661,75665,75668,75673,75676,75719,75721,75723,75733,75740,75744,75746,75834,75845,75847 via svnmerge ................ r74461 | benjamin.peterson | 2009-08-15 16:08:53 +0200 (Sa, 15 Aug 2009) | 8 lines Blocked revisions 74445 via svnmerge ........ r74445 | vinay.sajip | 2009-08-14 06:33:54 -0500 (Fri, 14 Aug 2009) | 1 line Added versionchanged notices for optional 'delay' parameter to file handler classes. ........ ................ r74528 | tarek.ziade | 2009-08-20 23:25:41 +0200 (Do, 20 Aug 2009) | 8 lines Blocked revisions 74503 via svnmerge ........ r74503 | tarek.ziade | 2009-08-18 10:21:49 +0200 (Tue, 18 Aug 2009) | 1 line fixed typo ........ ................ r74577 | mark.dickinson | 2009-08-28 23:04:57 +0200 (Fr, 28 Aug 2009) | 8 lines Blocked revisions 74575 via svnmerge ........ r74575 | mark.dickinson | 2009-08-28 21:46:24 +0100 (Fri, 28 Aug 2009) | 1 line Silence gcc 'comparison always false' warning ........ ................ r74580 | benjamin.peterson | 2009-08-29 15:44:43 +0200 (Sa, 29 Aug 2009) | 53 lines Blocked revisions 72880,74098,74100,74463,74522,74537,74543,74569-74570 via svnmerge ........ r72880 | senthil.kumaran | 2009-05-24 04:14:50 -0500 (Sun, 24 May 2009) | 3 lines Fixed Issue1424152, urllib2 fails with HTTPS over Proxy. ........ r74098 | kristjan.jonsson | 2009-07-19 17:14:00 -0500 (Sun, 19 Jul 2009) | 2 lines http://bugs.python.org/issue6499 zlib/gzip may not be present for all builds. Make xmlrpclib gracefully not supporg gzip encoding in this case ........ r74100 | kristjan.jonsson | 2009-07-19 17:35:44 -0500 (Sun, 19 Jul 2009) | 2 lines http://bugs.python.org/issue6499 gzip.GzipFile may not exist as a parent class ........ r74463 | gregory.p.smith | 2009-08-15 17:39:03 -0500 (Sat, 15 Aug 2009) | 6 lines Force the http connection to close after any request returned when buffering=True as our buffered data is not known to the HTTPConnection and may contain data needed by a future request if the connection were left open. See http://bugs.python.org/issue2576 and http://bugs.python.org/issue4879. ........ r74522 | gregory.p.smith | 2009-08-19 00:33:48 -0500 (Wed, 19 Aug 2009) | 8 lines Revert the changes from r74463, they were causing test_xmlrpc to fail. We do not need to force a close when using socket buffering on a httplib.HTTPRequest as the library does not support streaming requests so there should never been extra data beyond the end of the current request to have left over in the requests socket buffer. see http://bugs.python.org/issue6724 ........ r74537 | tarek.ziade | 2009-08-21 09:28:38 -0500 (Fri, 21 Aug 2009) | 1 line fixed misplaced Issue line ........ r74543 | kristjan.jonsson | 2009-08-24 06:39:31 -0500 (Mon, 24 Aug 2009) | 2 lines issue 6769 fix a mistake in instantiatiating the HTTPSConnection class. ........ r74569 | benjamin.peterson | 2009-08-28 11:48:03 -0500 (Fri, 28 Aug 2009) | 1 line restricted environments are no more ........ r74570 | benjamin.peterson | 2009-08-28 11:49:56 -0500 (Fri, 28 Aug 2009) | 1 line remove more code for restricted execution ........ ................ r74703 | benjamin.peterson | 2009-09-07 15:03:49 +0200 (Mo, 07 Sep 2009) | 12 lines Blocked revisions 74699,74702 via svnmerge ........ r74699 | benjamin.peterson | 2009-09-06 17:43:39 -0500 (Sun, 06 Sep 2009) | 1 line PyObject_GetIter can set an error for its self just fine ........ r74702 | benjamin.peterson | 2009-09-07 08:02:15 -0500 (Mon, 07 Sep 2009) | 1 line revert r74699 since it loses useful error information ........ ................ r74743 | benjamin.peterson | 2009-09-11 23:24:36 +0200 (Fr, 11 Sep 2009) | 12 lines Blocked revisions 74733-74734 via svnmerge ........ r74733 | benjamin.peterson | 2009-09-09 06:40:54 -0500 (Wed, 09 Sep 2009) | 1 line tabbify ........ r74734 | benjamin.peterson | 2009-09-09 06:42:57 -0500 (Wed, 09 Sep 2009) | 1 line revert unintended changes ........ ................ r74826 | ezio.melotti | 2009-09-16 15:22:57 +0200 (Mi, 16 Sep 2009) | 8 lines Blocked revisions 74825 via svnmerge ........ r74825 | ezio.melotti | 2009-09-16 16:14:05 +0300 (Wed, 16 Sep 2009) | 1 line #6879 - fix misstatement about exceptions ........ ................ r74939 | benjamin.peterson | 2009-09-18 23:51:43 +0200 (Fr, 18 Sep 2009) | 12 lines Blocked revisions 74936-74937 via svnmerge ........ r74936 | benjamin.peterson | 2009-09-18 16:46:21 -0500 (Fri, 18 Sep 2009) | 1 line backport keyword argument support for bytearray.decode ........ r74937 | benjamin.peterson | 2009-09-18 16:47:27 -0500 (Fri, 18 Sep 2009) | 1 line typo ........ ................ r75086 | mark.dickinson | 2009-09-27 18:08:13 +0200 (So, 27 Sep 2009) | 9 lines Blocked revisions 75084 via svnmerge ........ r75084 | mark.dickinson | 2009-09-27 17:05:21 +0100 (Sun, 27 Sep 2009) | 3 lines Issue #6713: Improve decimal int -> string conversions. Thanks Gawain Bolton for the suggestion and original patches. ........ ................ r75093 | mark.dickinson | 2009-09-27 18:41:06 +0200 (So, 27 Sep 2009) | 8 lines Blocked revisions 75091 via svnmerge ........ r75091 | mark.dickinson | 2009-09-27 17:39:28 +0100 (Sun, 27 Sep 2009) | 1 line Eliminate unnecessary get_wrapped_(u)long defines in struct module. ........ ................ r75118 | r.david.murray | 2009-09-28 20:55:36 +0200 (Mo, 28 Sep 2009) | 8 lines Blocked revisions 75115 via svnmerge ........ r75115 | r.david.murray | 2009-09-28 14:29:28 -0400 (Mon, 28 Sep 2009) | 2 lines Applying patches backported from 3.1, by Gregor Lingl. ........ ................ r75173 | antoine.pitrou | 2009-10-01 19:09:15 +0200 (Do, 01 Okt 2009) | 9 lines Blocked revisions 75171 via svnmerge ........ r75171 | antoine.pitrou | 2009-10-01 19:08:03 +0200 (jeu., 01 oct. 2009) | 4 lines Sync the 2.x `io` docs with py3k, with a small note as to the distinction between bytes streams and text streams. ........ ................ r75198 | tarek.ziade | 2009-10-03 02:10:24 +0200 (Sa, 03 Okt 2009) | 8 lines Blocked revisions 75196 via svnmerge ........ r75196 | tarek.ziade | 2009-10-03 02:07:35 +0200 (Sat, 03 Oct 2009) | 1 line removing the last remaning apply() calls ........ ................ r75242 | benjamin.peterson | 2009-10-04 22:13:06 +0200 (So, 04 Okt 2009) | 10 lines Blocked revisions 74845 via svnmerge ........ r74845 | georg.brandl | 2009-09-16 15:30:09 -0500 (Wed, 16 Sep 2009) | 5 lines #6844: do not emit DeprecationWarnings on access if Exception.message has been set by the user. This works by always setting it in __dict__, except when it's implicitly set in __init__. ........ ................ r75244 | benjamin.peterson | 2009-10-04 22:23:37 +0200 (So, 04 Okt 2009) | 20 lines Blocked revisions 74849,75143,75181 via svnmerge ........ r74849 | thomas.wouters | 2009-09-16 15:36:34 -0500 (Wed, 16 Sep 2009) | 4 lines Add news entry for r74841. ........ r75143 | philip.jenvey | 2009-09-29 14:10:15 -0500 (Tue, 29 Sep 2009) | 5 lines #5329: fix os.popen* regression from 2.5: don't execute commands as a sequence through the shell. also document the correct subprocess replacement for this case patch from Jean-Paul Calderone and Jani Hakala ........ r75181 | georg.brandl | 2009-10-01 16:02:39 -0500 (Thu, 01 Oct 2009) | 1 line Add NEWS entry for r75180. ........ ................ r75245 | benjamin.peterson | 2009-10-04 22:28:48 +0200 (So, 04 Okt 2009) | 16 lines Blocked revisions 75164-75166 via svnmerge ........ r75164 | senthil.kumaran | 2009-09-30 20:07:03 -0500 (Wed, 30 Sep 2009) | 3 lines Fix for issue7026 test_urllib: unsetting missing 'env' variable. ........ r75165 | senthil.kumaran | 2009-09-30 20:19:18 -0500 (Wed, 30 Sep 2009) | 3 lines using dict.unset(k) instead of del dict[k]. consistent with release26-maint ........ r75166 | senthil.kumaran | 2009-09-30 20:50:13 -0500 (Wed, 30 Sep 2009) | 3 lines That's self.env.unset(k) and not env.unset(k) I was heading back to the problem. ........ ................ r75306 | benjamin.peterson | 2009-10-10 00:34:44 +0200 (Sa, 10 Okt 2009) | 12 lines Blocked revisions 75304-75305 via svnmerge ........ r75304 | benjamin.peterson | 2009-10-09 17:05:45 -0500 (Fri, 09 Oct 2009) | 1 line replace callable() ........ r75305 | benjamin.peterson | 2009-10-09 17:15:50 -0500 (Fri, 09 Oct 2009) | 1 line replace has_key with 'in' operator ........ ................ r75311 | benjamin.peterson | 2009-10-10 22:39:25 +0200 (Sa, 10 Okt 2009) | 8 lines Blocked revisions 75310 via svnmerge ........ r75310 | vinay.sajip | 2009-10-10 15:32:36 -0500 (Sat, 10 Oct 2009) | 1 line Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code. ........ ................ r75369 | antoine.pitrou | 2009-10-11 23:07:02 +0200 (So, 11 Okt 2009) | 9 lines Blocked revisions 75367 via svnmerge ........ r75367 | antoine.pitrou | 2009-10-11 23:03:26 +0200 (dim., 11 oct. 2009) | 4 lines Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. ........ ................ r75435 | mark.dickinson | 2009-10-15 17:22:09 +0200 (Do, 15 Okt 2009) | 8 lines Blocked revisions 75434 via svnmerge ........ r75434 | mark.dickinson | 2009-10-15 16:18:55 +0100 (Thu, 15 Oct 2009) | 1 line Fix missing semicolon ........ ................ r75439 | mark.dickinson | 2009-10-15 17:54:39 +0200 (Do, 15 Okt 2009) | 8 lines Blocked revisions 75438 via svnmerge ........ r75438 | mark.dickinson | 2009-10-15 16:53:58 +0100 (Thu, 15 Oct 2009) | 1 line Issue #7142: Fix uses of unicode in memoryview objects ........ ................ r75448 | eric.smith | 2009-10-16 16:33:35 +0200 (Fr, 16 Okt 2009) | 8 lines Blocked revisions 75446 via svnmerge ........ r75446 | eric.smith | 2009-10-16 10:26:36 -0400 (Fri, 16 Oct 2009) | 1 line Removed usage of unsafe PyFloat_AsString. ........ ................ r75508 | eric.smith | 2009-10-19 02:35:35 +0200 (Mo, 19 Okt 2009) | 14 lines Blocked revisions 75506 via svnmerge ........ r75506 | eric.smith | 2009-10-18 20:34:12 -0400 (Sun, 18 Oct 2009) | 7 lines Removed calls to PyFloat_AsReprString. This is in anticipation of possibly implementing issue 7117 (short float repr). This removes the last calls to PyFloat_AsString, PyFloat_AsReprString, and PyFloat_AsStringEx, which are unsafe. Also, switch to defines for error values to bring this code more in line with the py3k branch. ........ ................ r75512 | eric.smith | 2009-10-19 16:42:58 +0200 (Mo, 19 Okt 2009) | 8 lines Blocked revisions 75510 via svnmerge ........ r75510 | eric.smith | 2009-10-19 10:38:14 -0400 (Mon, 19 Oct 2009) | 1 line Issue #7169: Document PyFloat_AsString and PyFloat_AsReprString, and note that they are unsafe and deprecated. ........ ................ r75622 | eric.smith | 2009-10-22 22:48:54 +0200 (Do, 22 Okt 2009) | 8 lines Blocked revisions 75620 via svnmerge ........ r75620 | eric.smith | 2009-10-22 16:13:14 -0400 (Thu, 22 Oct 2009) | 1 line Per the discussion in issue6882, backport the try/finally work that was done to the py3k version (mostly in r59477, I think). ........ ................ r75652 | mark.dickinson | 2009-10-24 14:15:17 +0200 (Sa, 24 Okt 2009) | 12 lines Blocked revisions 75651 via svnmerge ........ r75651 | mark.dickinson | 2009-10-24 13:13:30 +0100 (Sat, 24 Oct 2009) | 7 lines Issue #7117: Prepare for backport of py3k float repr. Add the Python/dtoa.c file containing the main algorithms; add corresponding include file and include in Python.h; include license information for Python/dtoa.c; add dtoa.c and dtoa.h to Makefile. ........ ................ r75656 | antoine.pitrou | 2009-10-24 14:31:03 +0200 (Sa, 24 Okt 2009) | 16 lines Blocked revisions 75650,75654-75655 via svnmerge ........ r75650 | antoine.pitrou | 2009-10-24 13:59:41 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74155] Issue #6242: Fix deallocator of io.StringIO and io.BytesIO ........ r75654 | antoine.pitrou | 2009-10-24 14:23:18 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74158] Issue #6218: Make io.BytesIO and io.StringIO picklable. ........ r75655 | antoine.pitrou | 2009-10-24 14:28:22 +0200 (sam., 24 oct. 2009) | 3 lines Manual py3k backport: [svn r74316] Issue #5449: Fix io.BytesIO to not accept arbitrary keywords ........ ................ r75661 | mark.dickinson | 2009-10-24 15:32:56 +0200 (Sa, 24 Okt 2009) | 22 lines Blocked revisions 75653,75658,75660 via svnmerge ........ r75653 | mark.dickinson | 2009-10-24 13:17:24 +0100 (Sat, 24 Oct 2009) | 1 line Temporary define to avoid build failure ........ r75658 | mark.dickinson | 2009-10-24 14:28:38 +0100 (Sat, 24 Oct 2009) | 8 lines Issue #7117 (backport py3k float repr) continued: - add double endianness detection to configure script - add configure-time check to see whether we can use inline assembly to get and set x87 control word in configure script - add functions to get and set x87 control word in Python/pymath.c - add pyport.h logic to determine whether it's safe to use the short float repr or not ........ r75660 | mark.dickinson | 2009-10-24 14:31:41 +0100 (Sat, 24 Oct 2009) | 1 line Remove temporary define from r75653 ........ ................ r75665 | mark.dickinson | 2009-10-24 15:46:38 +0200 (Sa, 24 Okt 2009) | 8 lines Blocked revisions 75664 via svnmerge ........ r75664 | mark.dickinson | 2009-10-24 14:44:16 +0100 (Sat, 24 Oct 2009) | 1 line Configure check for double rounding should take BASECFLAGS into account ........ ................ r75668 | mark.dickinson | 2009-10-24 16:05:34 +0200 (Sa, 24 Okt 2009) | 10 lines Blocked revisions 75666 via svnmerge ........ r75666 | mark.dickinson | 2009-10-24 15:01:08 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117 (backport py3k float repr) continued: Add sys.float_repr_style attribute ('short' if short float repr is in used; 'legacy' otherwise). ........ ................ r75673 | mark.dickinson | 2009-10-24 17:56:07 +0200 (Sa, 24 Okt 2009) | 10 lines Blocked revisions 75672 via svnmerge ........ r75672 | mark.dickinson | 2009-10-24 16:54:35 +0100 (Sat, 24 Oct 2009) | 4 lines Issue #7117: temporarily disable the short float repr while the pieces are being assembled. To re-enable, define the preprocessor symbol PY_SHORT_FLOAT_REPR ........ ................ r75676 | eric.smith | 2009-10-24 21:52:23 +0200 (Sa, 24 Okt 2009) | 8 lines Blocked revisions 75675 via svnmerge ........ r75675 | eric.smith | 2009-10-24 15:50:44 -0400 (Sat, 24 Oct 2009) | 1 line Removed unused function PyFloat_AsStringEx. It is unused in floatobject.c, and it's not declared in any .h file. ........ ................ r75719 | eric.smith | 2009-10-26 16:10:57 +0100 (Mo, 26 Okt 2009) | 12 lines Blocked revisions 75717-75718 via svnmerge ........ r75717 | eric.smith | 2009-10-26 10:48:55 -0400 (Mon, 26 Oct 2009) | 1 line Start to remove _PyOS_double_to_string, as mentioned in issue 7117. ........ r75718 | eric.smith | 2009-10-26 11:06:39 -0400 (Mon, 26 Oct 2009) | 1 line Continue removing _PyOS_double_to_string, as mentioned in issue 7117. ........ ................ r75721 | mark.dickinson | 2009-10-26 16:40:42 +0100 (Mo, 26 Okt 2009) | 9 lines Blocked revisions 75720 via svnmerge ........ r75720 | mark.dickinson | 2009-10-26 15:39:50 +0000 (Mon, 26 Oct 2009) | 3 lines Issue #7117 (backport py3k float repr) continued: Backport pystrtod.c from py3k. ........ ................ r75723 | eric.smith | 2009-10-26 18:48:13 +0100 (Mo, 26 Okt 2009) | 8 lines Blocked revisions 75722 via svnmerge ........ r75722 | eric.smith | 2009-10-26 13:46:17 -0400 (Mon, 26 Oct 2009) | 1 line Finished removing _PyOS_double_to_string, as mentioned in issue 7117. ........ ................ r75733 | mark.dickinson | 2009-10-26 22:13:15 +0100 (Mo, 26 Okt 2009) | 14 lines Blocked revisions 75730-75731 via svnmerge ........ r75730 | mark.dickinson | 2009-10-26 21:09:09 +0000 (Mon, 26 Oct 2009) | 2 lines Issue #7117: Backport missing pystrtod.h declarations from py3k. ........ r75731 | mark.dickinson | 2009-10-26 21:11:20 +0000 (Mon, 26 Oct 2009) | 4 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in floatobject.c. Also, remove limitation on length of unicode inputs to float(). ........ ................ r75740 | mark.dickinson | 2009-10-26 23:29:02 +0100 (Mo, 26 Okt 2009) | 10 lines Blocked revisions 75739 via svnmerge ........ r75739 | mark.dickinson | 2009-10-26 22:28:14 +0000 (Mon, 26 Oct 2009) | 5 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in complexobject.c. Also remove length restriction on unicode inputs to the complex constructor. ........ ................ r75744 | eric.smith | 2009-10-27 12:36:44 +0100 (Di, 27 Okt 2009) | 8 lines Blocked revisions 75743 via svnmerge ........ r75743 | eric.smith | 2009-10-27 07:32:11 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in cPickle as part of short float repr. ........ ................ r75746 | eric.smith | 2009-10-27 13:13:06 +0100 (Di, 27 Okt 2009) | 8 lines Blocked revisions 75745 via svnmerge ........ r75745 | eric.smith | 2009-10-27 08:12:44 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr. ........ ................ r75834 | eric.smith | 2009-10-27 19:47:34 +0100 (Di, 27 Okt 2009) | 8 lines Blocked revisions 75824 via svnmerge ........ r75824 | eric.smith | 2009-10-27 14:33:14 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from ast.c, as mentioned in issue 7117. ........ ................ r75845 | antoine.pitrou | 2009-10-27 20:39:10 +0100 (Di, 27 Okt 2009) | 8 lines Blocked revisions 75844 via svnmerge ........ r75844 | antoine.pitrou | 2009-10-27 20:36:44 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_file2k. ........ ................ r75847 | eric.smith | 2009-10-27 20:44:06 +0100 (Di, 27 Okt 2009) | 8 lines Blocked revisions 75846 via svnmerge ........ r75846 | eric.smith | 2009-10-27 15:42:57 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 21:13:07 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:13:07 -0000 Subject: [Python-checkins] r75854 - python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Message-ID: Author: georg.brandl Date: Tue Oct 27 21:13:06 2009 New Revision: 75854 Log: Create the function before using it. Modified: python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Modified: python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/release26-maint/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 21:13:06 2009 @@ -21,10 +21,6 @@ Body.enum.converters['upperroman'] = lambda x: None # monkey-patch HTML translator to give versionmodified paragraphs a class -from sphinx.writers.html import HTMLTranslator -from sphinx.locale import versionlabels -HTMLTranslator.visit_versionmodified = new_visit_versionmodified - def new_visit_versionmodified(self, node): self.body.append(self.starttag(node, 'p', CLASS=node['type'])) text = versionlabels[node['type']] % node['version'] @@ -34,6 +30,9 @@ text += '.' self.body.append('%s' % text) +from sphinx.writers.html import HTMLTranslator +from sphinx.locale import versionlabels +HTMLTranslator.visit_versionmodified = new_visit_versionmodified # Support for marking up and linking to bugs.python.org issues From python-checkins at python.org Tue Oct 27 21:14:04 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:14:04 -0000 Subject: [Python-checkins] r75855 - python/trunk/Lib/test/test_urllib2_localnet.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:14:04 2009 New Revision: 75855 Log: Fix transient refleaks in test_urllib2_localnet. Modified: python/trunk/Lib/test/test_urllib2_localnet.py Modified: python/trunk/Lib/test/test_urllib2_localnet.py ============================================================================== --- python/trunk/Lib/test/test_urllib2_localnet.py (original) +++ python/trunk/Lib/test/test_urllib2_localnet.py Tue Oct 27 21:14:04 2009 @@ -220,7 +220,15 @@ # Test cases -class ProxyAuthTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test_support.threading_setup() + + def tearDown(self): + test_support.threading_cleanup(*self._threads) + + +class ProxyAuthTests(BaseTestCase): URL = "http://localhost" USER = "tester" @@ -327,7 +335,7 @@ return FakeHTTPRequestHandler -class TestUrlopen(unittest.TestCase): +class TestUrlopen(BaseTestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a From python-checkins at python.org Tue Oct 27 21:17:04 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:17:04 -0000 Subject: [Python-checkins] r75856 - in python/branches/py3k: Lib/test/test_urllib2_localnet.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:17:03 2009 New Revision: 75856 Log: Merged revisions 75855 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75855 | antoine.pitrou | 2009-10-27 21:14:04 +0100 (mar., 27 oct. 2009) | 3 lines Fix transient refleaks in test_urllib2_localnet. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_urllib2_localnet.py Modified: python/branches/py3k/Lib/test/test_urllib2_localnet.py ============================================================================== --- python/branches/py3k/Lib/test/test_urllib2_localnet.py (original) +++ python/branches/py3k/Lib/test/test_urllib2_localnet.py Tue Oct 27 21:17:03 2009 @@ -221,7 +221,15 @@ # Test cases -class ProxyAuthTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test_support.threading_setup() + + def tearDown(self): + test_support.threading_cleanup(*self._threads) + + +class ProxyAuthTests(BaseTestCase): URL = "http://localhost" USER = "tester" @@ -329,7 +337,7 @@ return FakeHTTPRequestHandler -class TestUrlopen(unittest.TestCase): +class TestUrlopen(BaseTestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a From python-checkins at python.org Tue Oct 27 21:19:04 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:19:04 -0000 Subject: [Python-checkins] r75857 - in python/branches/release31-maint: Demo/scripts/README Demo/scripts/beer.py Demo/scripts/fact.py Demo/scripts/find-uname.py Demo/scripts/ftpstats.py Demo/scripts/lpwatch.py Demo/scripts/markov.py Demo/scripts/mkrcs.py Demo/scripts/morse.py Demo/scripts/newslist.py Demo/scripts/pi.py Demo/scripts/pp.py Demo/scripts/queens.py Demo/scripts/script.py Demo/scripts/unbirthday.py Demo/xml/elem_count.py Demo/xml/roundtrip.py Demo/xml/rss2html.py Doc/library/configparser.rst Doc/library/copy.rst Doc/library/marshal.rst Doc/library/urllib.parse.rst Doc/reference/datamodel.rst Lib/pdb.py Lib/pydoc.py Lib/test/test_funcattrs.py Lib/test/test_pdb.py Message-ID: Author: georg.brandl Date: Tue Oct 27 21:19:02 2009 New Revision: 75857 Log: Merged revisions 74609,74627,74634,74645,74651,74738,74840,75016,75316-75317,75323-75324,75326,75328,75330,75338,75340-75341,75343,75352-75353,75355,75357,75359 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r74609 | senthil.kumaran | 2009-08-31 18:43:45 +0200 (Mo, 31 Aug 2009) | 3 lines Doc fix for issue2637. ................ r74627 | georg.brandl | 2009-09-02 22:31:26 +0200 (Mi, 02 Sep 2009) | 1 line #6819: fix typo. ................ r74634 | georg.brandl | 2009-09-03 14:34:10 +0200 (Do, 03 Sep 2009) | 9 lines Merged revisions 74633 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74633 | georg.brandl | 2009-09-03 14:31:39 +0200 (Do, 03 Sep 2009) | 1 line #6757: complete the list of types that marshal can serialize. ........ ................ r74645 | georg.brandl | 2009-09-04 10:07:32 +0200 (Fr, 04 Sep 2009) | 1 line #5221: fix related topics: SEQUENCEMETHODS[12] doesnt exist any more. ................ r74651 | georg.brandl | 2009-09-04 13:20:54 +0200 (Fr, 04 Sep 2009) | 9 lines Recorded merge of revisions 74650 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74650 | georg.brandl | 2009-09-04 13:19:34 +0200 (Fr, 04 Sep 2009) | 1 line #5101: add back tests to test_funcattrs that were lost during unittest conversion, and make some PEP8 cleanups. ........ ................ r74738 | georg.brandl | 2009-09-09 18:51:05 +0200 (Mi, 09 Sep 2009) | 9 lines Merged revisions 74737 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74737 | georg.brandl | 2009-09-09 18:49:13 +0200 (Mi, 09 Sep 2009) | 1 line Properly document copy and deepcopy as functions. ........ ................ r74840 | georg.brandl | 2009-09-16 18:40:45 +0200 (Mi, 16 Sep 2009) | 13 lines Merged revisions 74838-74839 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74838 | georg.brandl | 2009-09-16 18:22:12 +0200 (Mi, 16 Sep 2009) | 1 line Remove some more boilerplate from the actual tests in test_pdb. ........ r74839 | georg.brandl | 2009-09-16 18:36:39 +0200 (Mi, 16 Sep 2009) | 1 line Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that. ........ ................ r75016 | georg.brandl | 2009-09-22 15:53:14 +0200 (Di, 22 Sep 2009) | 1 line #6969: make it explicit that configparser writes/reads text files, and fix the example. ................ r75316 | georg.brandl | 2009-10-10 23:12:35 +0200 (Sa, 10 Okt 2009) | 9 lines Merged revisions 75313 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75313 | georg.brandl | 2009-10-10 23:07:35 +0200 (Sa, 10 Okt 2009) | 1 line Bring old demo up-to-date. ........ ................ r75317 | georg.brandl | 2009-10-10 23:13:21 +0200 (Sa, 10 Okt 2009) | 9 lines Merged revisions 75315 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75315 | georg.brandl | 2009-10-10 23:10:05 +0200 (Sa, 10 Okt 2009) | 1 line Remove unneeded "L" suffixes. ........ ................ r75323 | georg.brandl | 2009-10-10 23:48:05 +0200 (Sa, 10 Okt 2009) | 9 lines Recorded merge of revisions 75321 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75321 | georg.brandl | 2009-10-10 23:43:21 +0200 (Sa, 10 Okt 2009) | 1 line Remove outdated comment and fix a few style issues. ........ ................ r75324 | georg.brandl | 2009-10-10 23:49:24 +0200 (Sa, 10 Okt 2009) | 9 lines Merged revisions 75322 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75322 | georg.brandl | 2009-10-10 23:47:31 +0200 (Sa, 10 Okt 2009) | 1 line Show use of range() step argument nicely. ........ ................ r75326 | georg.brandl | 2009-10-10 23:57:03 +0200 (Sa, 10 Okt 2009) | 9 lines Merged revisions 75325 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75325 | georg.brandl | 2009-10-10 23:55:11 +0200 (Sa, 10 Okt 2009) | 1 line Modernize factorisation demo (mostly augassign.) ........ ................ r75328 | georg.brandl | 2009-10-11 00:05:26 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75327 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75327 | georg.brandl | 2009-10-11 00:03:43 +0200 (So, 11 Okt 2009) | 1 line Style fixes. ........ ................ r75330 | georg.brandl | 2009-10-11 00:32:28 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75329 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75329 | georg.brandl | 2009-10-11 00:26:45 +0200 (So, 11 Okt 2009) | 1 line Modernize all around (dont ask me how useful that script is nowadays...) ........ ................ r75338 | georg.brandl | 2009-10-11 10:31:41 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75337 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75337 | georg.brandl | 2009-10-11 10:18:44 +0200 (So, 11 Okt 2009) | 1 line Update morse script, avoid globals, use iterators. ........ ................ r75340 | georg.brandl | 2009-10-11 10:42:09 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75339 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75339 | georg.brandl | 2009-10-11 10:39:16 +0200 (So, 11 Okt 2009) | 1 line Update markov demo. ........ ................ r75341 | georg.brandl | 2009-10-11 10:43:08 +0200 (So, 11 Okt 2009) | 1 line Fix README description. ................ r75343 | georg.brandl | 2009-10-11 10:46:56 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75342 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75342 | georg.brandl | 2009-10-11 10:45:03 +0200 (So, 11 Okt 2009) | 1 line Remove useless script "mkrcs" and update README. ........ ................ r75352 | georg.brandl | 2009-10-11 14:04:10 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75350 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75350 | georg.brandl | 2009-10-11 14:00:18 +0200 (So, 11 Okt 2009) | 1 line Use getopt in script.py demo. ........ ................ r75353 | georg.brandl | 2009-10-11 14:04:40 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75351 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75351 | georg.brandl | 2009-10-11 14:03:01 +0200 (So, 11 Okt 2009) | 1 line Fix variable. ........ ................ r75355 | georg.brandl | 2009-10-11 16:27:51 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75354 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75354 | georg.brandl | 2009-10-11 16:23:49 +0200 (So, 11 Okt 2009) | 1 line Update lpwatch script. ........ ................ r75357 | georg.brandl | 2009-10-11 16:50:57 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75356 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75356 | georg.brandl | 2009-10-11 16:49:37 +0200 (So, 11 Okt 2009) | 1 line Remove ftpstats script, the daemon whose log files it reads is long gone. ........ ................ r75359 | georg.brandl | 2009-10-11 17:56:06 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75358 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75358 | georg.brandl | 2009-10-11 17:06:44 +0200 (So, 11 Okt 2009) | 1 line Overhaul of Demo/xml. ........ ................ Added: python/branches/release31-maint/Demo/scripts/morse.py - copied unchanged from r75343, /python/branches/py3k/Demo/scripts/morse.py Removed: python/branches/release31-maint/Demo/scripts/ftpstats.py python/branches/release31-maint/Demo/scripts/mkrcs.py Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Demo/scripts/README python/branches/release31-maint/Demo/scripts/beer.py python/branches/release31-maint/Demo/scripts/fact.py python/branches/release31-maint/Demo/scripts/find-uname.py python/branches/release31-maint/Demo/scripts/lpwatch.py python/branches/release31-maint/Demo/scripts/markov.py python/branches/release31-maint/Demo/scripts/newslist.py python/branches/release31-maint/Demo/scripts/pi.py python/branches/release31-maint/Demo/scripts/pp.py python/branches/release31-maint/Demo/scripts/queens.py python/branches/release31-maint/Demo/scripts/script.py python/branches/release31-maint/Demo/scripts/unbirthday.py python/branches/release31-maint/Demo/xml/elem_count.py python/branches/release31-maint/Demo/xml/roundtrip.py python/branches/release31-maint/Demo/xml/rss2html.py python/branches/release31-maint/Doc/library/configparser.rst python/branches/release31-maint/Doc/library/copy.rst python/branches/release31-maint/Doc/library/marshal.rst python/branches/release31-maint/Doc/library/urllib.parse.rst python/branches/release31-maint/Doc/reference/datamodel.rst python/branches/release31-maint/Lib/pdb.py python/branches/release31-maint/Lib/pydoc.py python/branches/release31-maint/Lib/test/test_funcattrs.py python/branches/release31-maint/Lib/test/test_pdb.py Modified: python/branches/release31-maint/Demo/scripts/README ============================================================================== --- python/branches/release31-maint/Demo/scripts/README (original) +++ python/branches/release31-maint/Demo/scripts/README Tue Oct 27 21:19:02 2009 @@ -5,15 +5,14 @@ beer.py Print the classic 'bottles of beer' list. eqfix.py Fix .py files to use the correct equality test operator fact.py Factorize numbers -find-uname.py Search for Unicode characters using regexps. +find-uname.py Search for Unicode characters using regexps from.py Summarize mailbox -ftpstats.py Summarize ftp daemon log file lpwatch.py Watch BSD line printer queues makedir.py Like mkdir -p markov.py Markov chain simulation of words or characters -mboxconvvert.py Convert MH or MMDF mailboxes to unix mailbox format -mkrcs.py Fix symlinks named RCS into parallel tree -morse.py Produce morse code (audible or on AIFF file) +mboxconvert.py Convert MH or MMDF mailboxes to unix mailbox format +morse.py Produce morse code (as an AIFF file) +newslist.py List all newsgroups on a NNTP server as HTML pages pi.py Print all digits of pi -- given enough time and memory pp.py Emulate some Perl command line options primes.py Print prime numbers Modified: python/branches/release31-maint/Demo/scripts/beer.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/beer.py (original) +++ python/branches/release31-maint/Demo/scripts/beer.py Tue Oct 27 21:19:02 2009 @@ -1,14 +1,20 @@ #! /usr/bin/env python + # By GvR, demystified after a version by Fredrik Lundh. + import sys + n = 100 -if sys.argv[1:]: n = int(sys.argv[1]) +if sys.argv[1:]: + n = int(sys.argv[1]) + def bottle(n): if n == 0: return "no more bottles of beer" if n == 1: return "one bottle of beer" return str(n) + " bottles of beer" -for i in range(n): - print(bottle(n-i), "on the wall,") - print(bottle(n-i) + ".") + +for i in range(n, 0, -1): + print(bottle(i), "on the wall,") + print(bottle(i) + ".") print("Take one down, pass it around,") - print(bottle(n-i-1), "on the wall.") + print(bottle(i-1), "on the wall.") Modified: python/branches/release31-maint/Demo/scripts/fact.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/fact.py (original) +++ python/branches/release31-maint/Demo/scripts/fact.py Tue Oct 27 21:19:02 2009 @@ -9,39 +9,41 @@ from math import sqrt def fact(n): - if n < 1: raise ValueError # fact() argument should be >= 1 - if n == 1: return [] # special case + if n < 1: + raise ValueError('fact() argument should be >= 1') + if n == 1: + return [] # special case res = [] - # Treat even factors special, so we can use i = i+2 later - while n%2 == 0: + # Treat even factors special, so we can use i += 2 later + while n % 2 == 0: res.append(2) - n = n//2 + n //= 2 # Try odd numbers up to sqrt(n) - limit = sqrt(float(n+1)) + limit = sqrt(n+1) i = 3 while i <= limit: - if n%i == 0: + if n % i == 0: res.append(i) - n = n//i + n //= i limit = sqrt(n+1) else: - i = i+2 + i += 2 if n != 1: res.append(n) return res def main(): if len(sys.argv) > 1: - for arg in sys.argv[1:]: - n = eval(arg) - print(n, fact(n)) + source = sys.argv[1:] else: + source = iter(input, '') + for arg in source: try: - while 1: - n = eval(input()) - print(n, fact(n)) - except EOFError: - pass + n = int(arg) + except ValueError: + print(arg, 'is not an integer') + else: + print(n, fact(n)) if __name__ == "__main__": main() Modified: python/branches/release31-maint/Demo/scripts/find-uname.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/find-uname.py (original) +++ python/branches/release31-maint/Demo/scripts/find-uname.py Tue Oct 27 21:19:02 2009 @@ -21,20 +21,20 @@ import re def main(args): - unicode_names= [] + unicode_names = [] for ix in range(sys.maxunicode+1): try: - unicode_names.append( (ix, unicodedata.name(chr(ix))) ) + unicode_names.append((ix, unicodedata.name(chr(ix)))) except ValueError: # no name for the character pass for arg in args: pat = re.compile(arg, re.I) - matches = [(x,y) for (x,y) in unicode_names - if pat.search(y) is not None] + matches = [(y,x) for (x,y) in unicode_names + if pat.search(y) is not None] if matches: print("***", arg, "matches", "***") - for (x,y) in matches: - print("%s (%d)" % (y,x)) + for match in matches: + print("%s (%d)" % match) if __name__ == "__main__": main(sys.argv[1:]) Deleted: python/branches/release31-maint/Demo/scripts/ftpstats.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/ftpstats.py Tue Oct 27 21:19:02 2009 +++ (empty file) @@ -1,142 +0,0 @@ -#! /usr/bin/env python - -# Extract statistics from ftp daemon log. - -# Usage: -# ftpstats [-m maxitems] [-s search] [file] -# -m maxitems: restrict number of items in "top-N" lists, default 25. -# -s string: restrict statistics to lines containing this string. -# Default file is /usr/adm/ftpd; a "-" means read standard input. - -# The script must be run on the host where the ftp daemon runs. -# (At CWI this is currently buizerd.) - -import os -import sys -import re -import string -import getopt - -pat = '^([a-zA-Z0-9 :]*)!(.*)!(.*)!([<>].*)!([0-9]+)!([0-9]+)$' -prog = re.compile(pat) - -def main(): - maxitems = 25 - search = None - try: - opts, args = getopt.getopt(sys.argv[1:], 'm:s:') - except getopt.error as msg: - print(msg) - print('usage: ftpstats [-m maxitems] [file]') - sys.exit(2) - for o, a in opts: - if o == '-m': - maxitems = string.atoi(a) - if o == '-s': - search = a - file = '/usr/adm/ftpd' - if args: file = args[0] - if file == '-': - f = sys.stdin - else: - try: - f = open(file, 'r') - except IOError as msg: - print(file, ':', msg) - sys.exit(1) - bydate = {} - bytime = {} - byfile = {} - bydir = {} - byhost = {} - byuser = {} - bytype = {} - lineno = 0 - try: - while 1: - line = f.readline() - if not line: break - lineno = lineno + 1 - if search and string.find(line, search) < 0: - continue - if prog.match(line) < 0: - print('Bad line', lineno, ':', repr(line)) - continue - items = prog.group(1, 2, 3, 4, 5, 6) - (logtime, loguser, loghost, logfile, logbytes, - logxxx2) = items -## print logtime -## print '-->', loguser -## print '--> -->', loghost -## print '--> --> -->', logfile -## print '--> --> --> -->', logbytes -## print '--> --> --> --> -->', logxxx2 -## for i in logtime, loghost, logbytes, logxxx2: -## if '!' in i: print '???', i - add(bydate, logtime[-4:] + ' ' + logtime[:6], items) - add(bytime, logtime[7:9] + ':00-59', items) - direction, logfile = logfile[0], logfile[1:] - # The real path probably starts at the last //... - while 1: - i = string.find(logfile, '//') - if i < 0: break - logfile = logfile[i+1:] - add(byfile, logfile + ' ' + direction, items) - logdir = os.path.dirname(logfile) -## logdir = os.path.normpath(logdir) + '/.' - while 1: - add(bydir, logdir + ' ' + direction, items) - dirhead = os.path.dirname(logdir) - if dirhead == logdir: break - logdir = dirhead - add(byhost, loghost, items) - add(byuser, loguser, items) - add(bytype, direction, items) - except KeyboardInterrupt: - print('Interrupted at line', lineno) - show(bytype, 'by transfer direction', maxitems) - show(bydir, 'by directory', maxitems) - show(byfile, 'by file', maxitems) - show(byhost, 'by host', maxitems) - show(byuser, 'by user', maxitems) - showbar(bydate, 'by date') - showbar(bytime, 'by time of day') - -def showbar(dict, title): - n = len(title) - print('='*((70-n)//2), title, '='*((71-n)//2)) - list = [] - for key in sorted(dict.keys()): - n = len(str(key)) - list.append((len(dict[key]), key)) - maxkeylength = 0 - maxcount = 0 - for count, key in list: - maxkeylength = max(maxkeylength, len(key)) - maxcount = max(maxcount, count) - maxbarlength = 72 - maxkeylength - 7 - for count, key in list: - barlength = int(round(maxbarlength*float(count)/maxcount)) - bar = '*'*barlength - print('%5d %-*s %s' % (count, maxkeylength, key, bar)) - -def show(dict, title, maxitems): - if len(dict) > maxitems: - title = title + ' (first %d)'%maxitems - n = len(title) - print('='*((70-n)//2), title, '='*((71-n)//2)) - list = [] - for key in dict.keys(): - list.append((-len(dict[key]), key)) - list.sort() - for count, key in list[:maxitems]: - print('%5d %s' % (-count, key)) - -def add(dict, key, item): - if key in dict: - dict[key].append(item) - else: - dict[key] = [item] - -if __name__ == "__main__": - main() Modified: python/branches/release31-maint/Demo/scripts/lpwatch.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/lpwatch.py (original) +++ python/branches/release31-maint/Demo/scripts/lpwatch.py Tue Oct 27 21:19:02 2009 @@ -3,10 +3,9 @@ # Watch line printer queue(s). # Intended for BSD 4.3 lpq. -import posix +import os import sys import time -import string DEF_PRINTER = 'psc' DEF_DELAY = 10 @@ -14,94 +13,87 @@ def main(): delay = DEF_DELAY # XXX Use getopt() later try: - thisuser = posix.environ['LOGNAME'] + thisuser = os.environ['LOGNAME'] except: - thisuser = posix.environ['USER'] + thisuser = os.environ['USER'] printers = sys.argv[1:] if printers: # Strip '-P' from printer names just in case # the user specified it... - for i in range(len(printers)): - if printers[i][:2] == '-P': - printers[i] = printers[i][2:] + for i, name in enumerate(printers): + if name[:2] == '-P': + printers[i] = name[2:] else: - if 'PRINTER' in posix.environ: - printers = [posix.environ['PRINTER']] + if 'PRINTER' in os.environ: + printers = [os.environ['PRINTER']] else: printers = [DEF_PRINTER] - # - clearhome = posix.popen('clear', 'r').read() - # - while 1: + + clearhome = os.popen('clear', 'r').read() + + while True: text = clearhome for name in printers: - text = text + makestatus(name, thisuser) + '\n' + text += makestatus(name, thisuser) + '\n' print(text) time.sleep(delay) def makestatus(name, thisuser): - pipe = posix.popen('lpq -P' + name + ' 2>&1', 'r') + pipe = os.popen('lpq -P' + name + ' 2>&1', 'r') lines = [] users = {} aheadbytes = 0 aheadjobs = 0 - userseen = 0 + userseen = False totalbytes = 0 totaljobs = 0 - while 1: - line = pipe.readline() - if not line: break - fields = string.split(line) + for line in pipe: + fields = line.split() n = len(fields) if len(fields) >= 6 and fields[n-1] == 'bytes': - rank = fields[0] - user = fields[1] - job = fields[2] + rank, user, job = fields[0:3] files = fields[3:-2] - bytes = eval(fields[n-2]) + bytes = int(fields[n-2]) if user == thisuser: - userseen = 1 + userseen = True elif not userseen: - aheadbytes = aheadbytes + bytes - aheadjobs = aheadjobs + 1 - totalbytes = totalbytes + bytes - totaljobs = totaljobs + 1 - if user in users: - ujobs, ubytes = users[user] - else: - ujobs, ubytes = 0, 0 - ujobs = ujobs + 1 - ubytes = ubytes + bytes + aheadbytes += bytes + aheadjobs += 1 + totalbytes += bytes + totaljobs += 1 + ujobs, ubytes = users.get(user, (0, 0)) + ujobs += 1 + ubytes += bytes users[user] = ujobs, ubytes else: if fields and fields[0] != 'Rank': - line = string.strip(line) + line = line.strip() if line == 'no entries': line = name + ': idle' elif line[-22:] == ' is ready and printing': line = name lines.append(line) - # + if totaljobs: - line = '%d K' % ((totalbytes+1023)//1024) + line = '%d K' % ((totalbytes+1023) // 1024) if totaljobs != len(users): - line = line + ' (%d jobs)' % totaljobs + line += ' (%d jobs)' % totaljobs if len(users) == 1: - line = line + ' for %s' % (list(users.keys())[0],) + line += ' for %s' % next(iter(users)) else: - line = line + ' for %d users' % len(users) + line += ' for %d users' % len(users) if userseen: if aheadjobs == 0: - line = line + ' (%s first)' % thisuser + line += ' (%s first)' % thisuser else: - line = line + ' (%d K before %s)' % ( - (aheadbytes+1023)//1024, thisuser) + line += ' (%d K before %s)' % ( + (aheadbytes+1023) // 1024, thisuser) lines.append(line) - # + sts = pipe.close() if sts: lines.append('lpq exit status %r' % (sts,)) - return string.joinfields(lines, ': ') + return ': '.join(lines) if __name__ == "__main__": try: Modified: python/branches/release31-maint/Demo/scripts/markov.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/markov.py (original) +++ python/branches/release31-maint/Demo/scripts/markov.py Tue Oct 27 21:19:02 2009 @@ -5,11 +5,10 @@ self.histsize = histsize self.choice = choice self.trans = {} + def add(self, state, next): - if state not in self.trans: - self.trans[state] = [next] - else: - self.trans[state].append(next) + self.trans.setdefault(state, []).append(next) + def put(self, seq): n = self.histsize add = self.add @@ -17,26 +16,29 @@ for i in range(len(seq)): add(seq[max(0, i-n):i], seq[i:i+1]) add(seq[len(seq)-n:], None) + def get(self): choice = self.choice trans = self.trans n = self.histsize seq = choice(trans[None]) - while 1: + while True: subseq = seq[max(0, len(seq)-n):] options = trans[subseq] next = choice(options) - if not next: break - seq = seq + next + if not next: + break + seq += next return seq + def test(): - import sys, string, random, getopt + import sys, random, getopt args = sys.argv[1:] try: - opts, args = getopt.getopt(args, '0123456789cdw') + opts, args = getopt.getopt(args, '0123456789cdwq') except getopt.error: - print('Usage: markov [-#] [-cddqw] [file] ...') + print('Usage: %s [-#] [-cddqw] [file] ...' % sys.argv[0]) print('Options:') print('-#: 1-digit history size (default 2)') print('-c: characters (default)') @@ -49,16 +51,19 @@ print('exactly one space separating words.') print('Output consists of paragraphs separated by blank') print('lines, where lines are no longer than 72 characters.') + sys.exit(2) histsize = 2 - do_words = 0 + do_words = False debug = 1 for o, a in opts: - if '-0' <= o <= '-9': histsize = eval(o[1:]) - if o == '-c': do_words = 0 - if o == '-d': debug = debug + 1 + if '-0' <= o <= '-9': histsize = int(o[1:]) + if o == '-c': do_words = False + if o == '-d': debug += 1 if o == '-q': debug = 0 - if o == '-w': do_words = 1 - if not args: args = ['-'] + if o == '-w': do_words = True + if not args: + args = ['-'] + m = Markov(histsize, random.choice) try: for filename in args: @@ -72,13 +77,15 @@ if debug: print('processing', filename, '...') text = f.read() f.close() - paralist = string.splitfields(text, '\n\n') + paralist = text.split('\n\n') for para in paralist: if debug > 1: print('feeding ...') - words = string.split(para) + words = para.split() if words: - if do_words: data = tuple(words) - else: data = string.joinfields(words, ' ') + if do_words: + data = tuple(words) + else: + data = ' '.join(words) m.put(data) except KeyboardInterrupt: print('Interrupted -- continue with data read so far') @@ -86,16 +93,19 @@ print('No valid input files') return if debug: print('done.') + if debug > 1: for key in m.trans.keys(): if key is None or len(key) < histsize: print(repr(key), m.trans[key]) if histsize == 0: print(repr(''), m.trans['']) print() - while 1: + while True: data = m.get() - if do_words: words = data - else: words = string.split(data) + if do_words: + words = data + else: + words = data.split() n = 0 limit = 72 for w in words: @@ -103,15 +113,9 @@ print() n = 0 print(w, end=' ') - n = n + len(w) + 1 + n += len(w) + 1 print() print() -def tuple(list): - if len(list) == 0: return () - if len(list) == 1: return (list[0],) - i = len(list)//2 - return tuple(list[:i]) + tuple(list[i:]) - if __name__ == "__main__": test() Deleted: python/branches/release31-maint/Demo/scripts/mkrcs.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/mkrcs.py Tue Oct 27 21:19:02 2009 +++ (empty file) @@ -1,61 +0,0 @@ -#! /usr/bin/env python - -# A rather specialized script to make sure that a symbolic link named -# RCS exists pointing to a real RCS directory in a parallel tree -# referenced as RCStree in an ancestor directory. -# (I use this because I like my RCS files to reside on a physically -# different machine). - -import os - -def main(): - rcstree = 'RCStree' - rcs = 'RCS' - if os.path.islink(rcs): - print('%r is a symlink to %r' % (rcs, os.readlink(rcs))) - return - if os.path.isdir(rcs): - print('%r is an ordinary directory' % (rcs,)) - return - if os.path.exists(rcs): - print('%r is a file?!?!' % (rcs,)) - return - # - p = os.getcwd() - up = '' - down = '' - # Invariants: - # (1) join(p, down) is the current directory - # (2) up is the same directory as p - # Ergo: - # (3) join(up, down) is the current directory - #print 'p =', repr(p) - while not os.path.isdir(os.path.join(p, rcstree)): - head, tail = os.path.split(p) - #print 'head = %r; tail = %r' % (head, tail) - if not tail: - print('Sorry, no ancestor dir contains %r' % (rcstree,)) - return - p = head - up = os.path.join(os.pardir, up) - down = os.path.join(tail, down) - #print 'p = %r; up = %r; down = %r' % (p, up, down) - there = os.path.join(up, rcstree) - there = os.path.join(there, down) - there = os.path.join(there, rcs) - if os.path.isdir(there): - print('%r already exists' % (there, )) - else: - print('making %r' % (there,)) - makedirs(there) - print('making symlink %r -> %r' % (rcs, there)) - os.symlink(there, rcs) - -def makedirs(p): - if not os.path.isdir(p): - head, tail = os.path.split(p) - makedirs(head) - os.mkdir(p, 0o777) - -if __name__ == "__main__": - main() Modified: python/branches/release31-maint/Demo/scripts/newslist.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/newslist.py (original) +++ python/branches/release31-maint/Demo/scripts/newslist.py Tue Oct 27 21:19:02 2009 @@ -32,22 +32,22 @@ # fraser at europarc.xerox.com qs101 at cl.cam.ac.uk # # ####################################################################### -import sys,nntplib, string, marshal, time, os, posix, string +import sys, nntplib, marshal, time, os ####################################################################### # Check these variables before running! # # Top directory. # Filenames which don't start with / are taken as being relative to this. -topdir='/anfs/qsbigdisc/web/html/newspage' +topdir = os.path.expanduser('~/newspage') # The name of your NNTP host # eg. # newshost = 'nntp-serv.cl.cam.ac.uk' # or use following to get the name from the NNTPSERVER environment # variable: -# newshost = posix.environ['NNTPSERVER'] -newshost = 'nntp-serv.cl.cam.ac.uk' +# newshost = os.environ['NNTPSERVER'] +newshost = 'news.example.com' # The filename for a local cache of the newsgroup list treefile = 'grouptree' @@ -81,7 +81,7 @@ # pagelinkicon can contain html to put an icon after links to # further pages. This helps to make important links stand out. # Set to '' if not wanted, or '...' is quite a good one. -pagelinkicon='... ' +pagelinkicon = '... ' # --------------------------------------------------------------------- # Less important personal preferences: @@ -106,7 +106,7 @@ from stat import * rcsrev = '$Revision$' -rcsrev = string.join([s for s in string.split(rcsrev) if '$' not in s]) +rcsrev = ' '.join([s for s in rcsrev.split() if '$' not in s]) desc = {} # Make (possibly) relative filenames into absolute ones @@ -120,7 +120,7 @@ def addtotree(tree, groups): print('Updating tree...') for i in groups: - parts = string.splitfields(i,'.') + parts = i.split('.') makeleaf(tree, parts) # Makeleaf makes a leaf and the branch leading to it if necessary @@ -141,34 +141,38 @@ # to those groups beginning with . def createpage(root, tree, p): - filename = os.path.join(pagedir,root+'.html') + filename = os.path.join(pagedir, root+'.html') if root == rootpage: detail = '' else: detail = ' under ' + root - f = open(filename,'w') - # f.write('Content-Type: text/html\n') - f.write('Newsgroups available' + detail + '\n') - f.write('

            Newsgroups available' + detail +'

            \n') - f.write('Back to top level

            \n') - printtree(f,tree,0,p) - f.write('This page automatically created by \'newslist\' v. '+rcsrev+'.') - f.write(time.ctime(time.time()) + '

            ') - f.close() + with open(filename, 'w') as f: + # f.write('Content-Type: text/html\n') + f.write('\n\n') + f.write('Newsgroups available%s\n' % detail) + f.write('\n\n') + f.write('

            Newsgroups available%s

            \n' % detail) + f.write('Back to top level

            \n' % + (httppref, rootpage)) + printtree(f, tree, 0, p) + f.write('\n

            ') + f.write("This page automatically created by 'newslist' v. %s." % + rcsrev) + f.write(time.ctime(time.time()) + '\n') + f.write('\n\n') # Printtree prints the groups as a bulleted list. Groups with # more than subgroups will be put on a separate page. # Other sets of subgroups are just indented. def printtree(f, tree, indent, p): - global desc l = len(tree) - if l > sublistsize and indent>0: + if l > sublistsize and indent > 0: # Create a new page and a link to it - f.write('

          • ') - f.write(p[1:]+'.*') - f.write(''+pagelinkicon+'\n') + f.write('
          • ' % (httppref, p[1:])) + f.write(p[1:] + '.*') + f.write('%s\n' % pagelinkicon) createpage(p[1:], tree, p) return @@ -177,67 +181,64 @@ if l > 1: if indent > 0: # Create a sub-list - f.write('
          • '+p[1:]+'\n
              ') + f.write('
            • %s\n
                ' % p[1:]) else: # Create a main list - f.write('
                  ') + f.write('
                    ') indent = indent + 1 for i in kl: if i == '.': # Output a newsgroup - f.write('
                  • '+ p[1:] + ' ') + f.write('
                  • %s ' % (p[1:], p[1:])) if p[1:] in desc: - f.write(' '+desc[p[1:]]+'\n') + f.write(' %s\n' % desc[p[1:]]) else: f.write('\n') else: # Output a hierarchy - printtree(f,tree[i], indent, p+'.'+i) + printtree(f, tree[i], indent, p+'.'+i) if l > 1: - f.write('\n
                  ') + f.write('\n
                ') # Reading descriptions file --------------------------------------- -# This returns an array mapping group name to its description +# This returns a dict mapping group name to its description def readdesc(descfile): global desc - desc = {} if descfile == '': return try: - d = open(descfile, 'r') - print('Reading descriptions...') - except (IOError): + with open(descfile, 'r') as d: + print('Reading descriptions...') + for l in d: + bits = l.split() + try: + grp = bits[0] + dsc = ' '.join(bits[1:]) + if len(dsc) > 1: + desc[grp] = dsc + except IndexError: + pass + except IOError: print('Failed to open description file ' + descfile) return - l = d.readline() - while l != '': - bits = string.split(l) - try: - grp = bits[0] - dsc = string.join(bits[1:]) - if len(dsc)>1: - desc[grp] = dsc - except (IndexError): - pass - l = d.readline() # Check that ouput directory exists, ------------------------------ # and offer to create it if not def checkopdir(pagedir): if not os.path.isdir(pagedir): - print('Directory '+pagedir+' does not exist.') + print('Directory %s does not exist.' % pagedir) print('Shall I create it for you? (y/n)') if sys.stdin.readline()[0] == 'y': try: - os.mkdir(pagedir,0o777) + os.mkdir(pagedir, 0o777) except: print('Sorry - failed!') sys.exit(1) @@ -257,23 +258,21 @@ print('If this is the first time you have run newslist, then') print('use the -a option to create it.') sys.exit(1) - treedate = '%02d%02d%02d' % (treetime[0] % 100 ,treetime[1], treetime[2]) + treedate = '%02d%02d%02d' % (treetime[0] % 100, treetime[1], treetime[2]) try: - dump = open(treefile,'r') - tree = marshal.load(dump) - dump.close() - except (IOError): + with open(treefile, 'rb') as dump: + tree = marshal.load(dump) + except IOError: print('Cannot open local group list ' + treefile) return (tree, treedate) def writelocallist(treefile, tree): try: - dump = open(treefile,'w') - groups = marshal.dump(tree,dump) - dump.close() - print('Saved list to '+treefile+'\n') + with open(treefile, 'wb') as dump: + groups = marshal.dump(tree, dump) + print('Saved list to %s\n' % treefile) except: - print('Sorry - failed to write to local group cache '+treefile) + print('Sorry - failed to write to local group cache', treefile) print('Does it (or its directory) have the correct permissions?') sys.exit(1) @@ -281,18 +280,18 @@ def getallgroups(server): print('Getting list of all groups...') - treedate='010101' + treedate = '010101' info = server.list()[1] groups = [] print('Processing...') if skipempty: print('\nIgnoring following empty groups:') for i in info: - grpname = string.split(i[0])[0] - if skipempty and string.atoi(i[1]) < string.atoi(i[2]): - print(grpname+' ', end=' ') + grpname = i[0].split()[0] + if skipempty and int(i[1]) < int(i[2]): + print(grpname.decode() + ' ', end=' ') else: - groups.append(grpname) + groups.append(grpname.decode()) print('\n') if skipempty: print('(End of empty groups)') @@ -301,42 +300,39 @@ # Return list of new groups on server ----------------------------- def getnewgroups(server, treedate): - print('Getting list of new groups since start of '+treedate+'...', end=' ') - info = server.newgroups(treedate,'000001')[1] + print('Getting list of new groups since start of %s...' % treedate, end=' ') + info = server.newgroups(treedate, '000001')[1] print('got %d.' % len(info)) print('Processing...', end=' ') groups = [] for i in info: - grpname = string.split(i)[0] - groups.append(grpname) + grpname = i.split()[0] + groups.append(grpname.decode()) print('Done') return groups # Now the main program -------------------------------------------- def main(): - global desc - - tree={} + tree = {} # Check that the output directory exists checkopdir(pagedir) try: - print('Connecting to '+newshost+'...') + print('Connecting to %s...' % newshost) if sys.version[0] == '0': s = NNTP.init(newshost) else: s = NNTP(newshost) - connected = 1 + connected = True except (nntplib.error_temp, nntplib.error_perm) as x: print('Error connecting to host:', x) print('I\'ll try to use just the local list.') - connected = 0 + connected = False # If -a is specified, read the full list of groups from server if connected and len(sys.argv) > 1 and sys.argv[1] == '-a': - groups = getallgroups(s) # Otherwise just read the local file and then add Modified: python/branches/release31-maint/Demo/scripts/pi.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/pi.py (original) +++ python/branches/release31-maint/Demo/scripts/pi.py Tue Oct 27 21:19:02 2009 @@ -12,7 +12,7 @@ def main(): k, a, b, a1, b1 = 2, 4, 1, 12, 4 - while 1: + while True: # Next approximation p, q, k = k*k, 2*k+1, k+1 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 @@ -25,7 +25,6 @@ def output(d): # Use write() to avoid spaces between the digits - # Use str() to avoid the 'L' sys.stdout.write(str(d)) # Flush so the output is seen immediately sys.stdout.flush() Modified: python/branches/release31-maint/Demo/scripts/pp.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/pp.py (original) +++ python/branches/release31-maint/Demo/scripts/pp.py Tue Oct 27 21:19:02 2009 @@ -22,7 +22,6 @@ # - except for -n/-p, run directly from the file if at all possible import sys -import string import getopt FS = '' @@ -36,7 +35,7 @@ try: optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np') except getopt.error as msg: - sys.stderr.write(sys.argv[0] + ': ' + msg + '\n') + sys.stderr.write('%s: %s\n' % (sys.argv[0], msg)) sys.exit(2) for option, optarg in optlist: @@ -47,7 +46,7 @@ elif option == '-d': DFLAG = 1 elif option == '-e': - for line in string.splitfields(optarg, '\n'): + for line in optarg.split('\n'): SCRIPT.append(line) elif option == '-F': FS = optarg @@ -81,31 +80,31 @@ elif NFLAG: # Note that it is on purpose that AFLAG and PFLAG are # tested dynamically each time through the loop - prologue = [ \ - 'LINECOUNT = 0', \ - 'for FILE in ARGS:', \ - ' \tif FILE == \'-\':', \ - ' \t \tFP = sys.stdin', \ - ' \telse:', \ - ' \t \tFP = open(FILE, \'r\')', \ - ' \tLINENO = 0', \ - ' \twhile 1:', \ - ' \t \tLINE = FP.readline()', \ - ' \t \tif not LINE: break', \ - ' \t \tLINENO = LINENO + 1', \ - ' \t \tLINECOUNT = LINECOUNT + 1', \ - ' \t \tL = LINE[:-1]', \ - ' \t \taflag = AFLAG', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: F = string.splitfields(L, FS)', \ - ' \t \t \telse: F = string.split(L)' \ + prologue = [ + 'LINECOUNT = 0', + 'for FILE in ARGS:', + ' \tif FILE == \'-\':', + ' \t \tFP = sys.stdin', + ' \telse:', + ' \t \tFP = open(FILE, \'r\')', + ' \tLINENO = 0', + ' \twhile 1:', + ' \t \tLINE = FP.readline()', + ' \t \tif not LINE: break', + ' \t \tLINENO = LINENO + 1', + ' \t \tLINECOUNT = LINECOUNT + 1', + ' \t \tL = LINE[:-1]', + ' \t \taflag = AFLAG', + ' \t \tif aflag:', + ' \t \t \tif FS: F = L.split(FS)', + ' \t \t \telse: F = L.split()' ] - epilogue = [ \ - ' \t \tif not PFLAG: continue', \ - ' \t \tif aflag:', \ - ' \t \t \tif FS: print string.joinfields(F, FS)', \ - ' \t \t \telse: print string.join(F)', \ - ' \t \telse: print L', \ + epilogue = [ + ' \t \tif not PFLAG: continue', + ' \t \tif aflag:', + ' \t \t \tif FS: print(FS.join(F))', + ' \t \t \telse: print(\' \'.join(F))', + ' \t \telse: print(L)', ] else: prologue = ['if 1:'] @@ -114,18 +113,13 @@ # Note that we indent using tabs only, so that any indentation style # used in 'command' will come out right after re-indentation. -program = string.joinfields(prologue, '\n') + '\n' +program = '\n'.join(prologue) + '\n' for line in SCRIPT: - program = program + (' \t \t' + line + '\n') -program = program + (string.joinfields(epilogue, '\n') + '\n') + program += ' \t \t' + line + '\n' +program += '\n'.join(epilogue) + '\n' -import tempfile -fp = tempfile.NamedTemporaryFile() -fp.write(program) -fp.flush() -script = open(tfn).read() if DFLAG: import pdb - pdb.run(script) + pdb.run(program) else: - exec(script) + exec(program) Modified: python/branches/release31-maint/Demo/scripts/queens.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/queens.py (original) +++ python/branches/release31-maint/Demo/scripts/queens.py Tue Oct 27 21:19:02 2009 @@ -19,8 +19,8 @@ def reset(self): n = self.n - self.y = [None]*n # Where is the queen in column x - self.row = [0]*n # Is row[y] safe? + self.y = [None] * n # Where is the queen in column x + self.row = [0] * n # Is row[y] safe? self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe? self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe? self.nfound = 0 # Instrumentation @@ -50,7 +50,7 @@ self.up[x-y] = 0 self.down[x+y] = 0 - silent = 0 # If set, count solutions only + silent = 0 # If true, count solutions only def display(self): self.nfound = self.nfound + 1 Modified: python/branches/release31-maint/Demo/scripts/script.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/script.py (original) +++ python/branches/release31-maint/Demo/scripts/script.py Tue Oct 27 21:19:02 2009 @@ -1,4 +1,5 @@ #! /usr/bin/env python + # script.py -- Make typescript of terminal session. # Usage: # -a Append to typescript. @@ -6,28 +7,36 @@ # Author: Steen Lumholt. -import os, time, sys +import os, time, sys, getopt import pty def read(fd): data = os.read(fd, 1024) - file.write(data) + script.write(data) return data shell = 'sh' filename = 'typescript' -mode = 'w' +mode = 'wb' if 'SHELL' in os.environ: shell = os.environ['SHELL'] -if '-a' in sys.argv: - mode = 'a' -if '-p' in sys.argv: - shell = 'python' -file = open(filename, mode) +try: + opts, args = getopt.getopt(sys.argv[1:], 'ap') +except getopt.error as msg: + print('%s: %s' % (sys.argv[0], msg)) + sys.exit(2) + +for o, a in opts: + if o == '-a': + mode = 'ab' + elif o == '-p': + shell = 'python' + +script = open(filename, mode) sys.stdout.write('Script started, file is %s\n' % filename) -file.write('Script started on %s\n' % time.ctime(time.time())) +script.write(('Script started on %s\n' % time.ctime(time.time())).encode()) pty.spawn(shell, read) -file.write('Script done on %s\n' % time.ctime(time.time())) +script.write(('Script done on %s\n' % time.ctime(time.time())).encode()) sys.stdout.write('Script done, file is %s\n' % filename) Modified: python/branches/release31-maint/Demo/scripts/unbirthday.py ============================================================================== --- python/branches/release31-maint/Demo/scripts/unbirthday.py (original) +++ python/branches/release31-maint/Demo/scripts/unbirthday.py Tue Oct 27 21:19:02 2009 @@ -9,35 +9,27 @@ import time import calendar -def raw_input(prompt): - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - def main(): - # Note that the range checks below also check for bad types, - # e.g. 3.14 or (). However syntactically invalid replies - # will raise an exception. if sys.argv[1:]: year = int(sys.argv[1]) else: year = int(input('In which year were you born? ')) - if 0<=year<100: + if 0 <= year < 100: print("I'll assume that by", year, end=' ') year = year + 1900 print('you mean', year, 'and not the early Christian era') - elif not (1850<=year<=2002): + elif not (1850 <= year <= time.localtime()[0]): print("It's hard to believe you were born in", year) return - # + if sys.argv[2:]: month = int(sys.argv[2]) else: month = int(input('And in which month? (1-12) ')) - if not (1<=month<=12): + if not (1 <= month <= 12): print('There is no month numbered', month) return - # + if sys.argv[3:]: day = int(sys.argv[3]) else: @@ -46,36 +38,36 @@ maxday = 29 else: maxday = calendar.mdays[month] - if not (1<=day<=maxday): + if not (1 <= day <= maxday): print('There are no', day, 'days in that month!') return - # + bdaytuple = (year, month, day) bdaydate = mkdate(bdaytuple) print('You were born on', format(bdaytuple)) - # + todaytuple = time.localtime()[:3] todaydate = mkdate(todaytuple) print('Today is', format(todaytuple)) - # + if bdaytuple > todaytuple: print('You are a time traveler. Go back to the future!') return - # + if bdaytuple == todaytuple: print('You were born today. Have a nice life!') return - # + days = todaydate - bdaydate print('You have lived', days, 'days') - # + age = 0 for y in range(year, todaytuple[0] + 1): if bdaytuple < (y, month, day) <= todaytuple: age = age + 1 - # + print('You are', age, 'years old') - # + if todaytuple[1:] == bdaytuple[1:]: print('Congratulations! Today is your', nth(age), 'birthday') print('Yesterday was your', end=' ') @@ -83,8 +75,8 @@ print('Today is your', end=' ') print(nth(days - age), 'unbirthday') -def format(xxx_todo_changeme): - (year, month, day) = xxx_todo_changeme +def format(date): + (year, month, day) = date return '%d %s %d' % (day, calendar.month_name[month], year) def nth(n): @@ -93,12 +85,12 @@ if n == 3: return '3rd' return '%dth' % n -def mkdate(xxx_todo_changeme1): - # Januari 1st, in 0 A.D. is arbitrarily defined to be day 1, +def mkdate(date): + # January 1st, in 0 A.D. is arbitrarily defined to be day 1, # even though that day never actually existed and the calendar # was different then... - (year, month, day) = xxx_todo_changeme1 - days = year*365 # years, roughly + (year, month, day) = date + days = year*365 # years, roughly days = days + (year+3)//4 # plus leap years, roughly days = days - (year+99)//100 # minus non-leap years every century days = days + (year+399)//400 # plus leap years every 4 centirues Modified: python/branches/release31-maint/Demo/xml/elem_count.py ============================================================================== --- python/branches/release31-maint/Demo/xml/elem_count.py (original) +++ python/branches/release31-maint/Demo/xml/elem_count.py Tue Oct 27 21:19:02 2009 @@ -1,4 +1,10 @@ +""" +A simple demo that reads in an XML document and displays the number of +elements and attributes as well as a tally of elements and attributes by name. +""" + import sys +from collections import defaultdict from xml.sax import make_parser, handler @@ -7,16 +13,16 @@ def __init__(self): self._elems = 0 self._attrs = 0 - self._elem_types = {} - self._attr_types = {} + self._elem_types = defaultdict(int) + self._attr_types = defaultdict(int) def startElement(self, name, attrs): - self._elems = self._elems + 1 - self._attrs = self._attrs + len(attrs) - self._elem_types[name] = self._elem_types.get(name, 0) + 1 + self._elems += 1 + self._attrs += len(attrs) + self._elem_types[name] += 1 for name in attrs.keys(): - self._attr_types[name] = self._attr_types.get(name, 0) + 1 + self._attr_types[name] += 1 def endDocument(self): print("There were", self._elems, "elements.") @@ -30,7 +36,7 @@ for pair in self._attr_types.items(): print("%20s %d" % pair) - -parser = make_parser() -parser.setContentHandler(FancyCounter()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(FancyCounter()) + parser.parse(sys.argv[1]) Modified: python/branches/release31-maint/Demo/xml/roundtrip.py ============================================================================== --- python/branches/release31-maint/Demo/xml/roundtrip.py (original) +++ python/branches/release31-maint/Demo/xml/roundtrip.py Tue Oct 27 21:19:02 2009 @@ -3,7 +3,7 @@ but not necessarily identical, document. """ -import sys, string +import sys from xml.sax import saxutils, handler, make_parser @@ -11,7 +11,7 @@ class ContentGenerator(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out @@ -40,6 +40,7 @@ # --- The main program -parser = make_parser() -parser.setContentHandler(ContentGenerator()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(ContentGenerator()) + parser.parse(sys.argv[1]) Modified: python/branches/release31-maint/Demo/xml/rss2html.py ============================================================================== --- python/branches/release31-maint/Demo/xml/rss2html.py (original) +++ python/branches/release31-maint/Demo/xml/rss2html.py Tue Oct 27 21:19:02 2009 @@ -1,45 +1,50 @@ +""" +A demo that reads in an RSS XML document and emits an HTML file containing +a list of the individual items in the feed. +""" + import sys +import codecs from xml.sax import make_parser, handler # --- Templates -top = \ -""" +top = """\ - - - %s - + + + %s + + - -

                %s

                + +

                %s

                """ -bottom = \ -""" +bottom = """
              -
              -
              -Converted to HTML by sax_rss2html.py. -
              +
              +
              +Converted to HTML by rss2html.py. +
              - - + + """ # --- The ContentHandler class RSSHandler(handler.ContentHandler): - def __init__(self, out = sys.stdout): + def __init__(self, out=sys.stdout): handler.ContentHandler.__init__(self) self._out = out self._text = "" self._parent = None - self._list_started = 0 + self._list_started = False self._title = None self._link = None self._descr = "" @@ -69,7 +74,7 @@ elif name == "item": if not self._list_started: self._out.write("
                \n") - self._list_started = 1 + self._list_started = True self._out.write('
              • %s %s\n' % (self._link, self._title, self._descr)) @@ -86,6 +91,7 @@ # --- Main program -parser = make_parser() -parser.setContentHandler(RSSHandler()) -parser.parse(sys.argv[1]) +if __name__ == '__main__': + parser = make_parser() + parser.setContentHandler(RSSHandler()) + parser.parse(sys.argv[1]) Modified: python/branches/release31-maint/Doc/library/configparser.rst ============================================================================== --- python/branches/release31-maint/Doc/library/configparser.rst (original) +++ python/branches/release31-maint/Doc/library/configparser.rst Tue Oct 27 21:19:02 2009 @@ -231,9 +231,11 @@ .. method:: RawConfigParser.readfp(fp, filename=None) Read and parse configuration data from the file or file-like object in *fp* - (only the :meth:`readline` method is used). If *filename* is omitted and *fp* - has a :attr:`name` attribute, that is used for *filename*; the default is - ````. + (only the :meth:`readline` method is used). The file-like object must + operate in text mode, i.e. return strings from :meth:`readline`. + + If *filename* is omitted and *fp* has a :attr:`name` attribute, that is used + for *filename*; the default is ````. .. method:: RawConfigParser.get(section, option) @@ -279,8 +281,9 @@ .. method:: RawConfigParser.write(fileobject) - Write a representation of the configuration to the specified file object. This - representation can be parsed by a future :meth:`read` call. + Write a representation of the configuration to the specified file object, + which must be opened in text mode (accepting strings). This representation + can be parsed by a future :meth:`read` call. .. method:: RawConfigParser.remove_option(section, option) @@ -370,7 +373,7 @@ config.set('Section1', 'foo', '%(bar)s is %(baz)s!') # Writing our configuration file to 'example.cfg' - with open('example.cfg', 'wb') as configfile: + with open('example.cfg', 'w') as configfile: config.write(configfile) An example of reading the configuration file again:: Modified: python/branches/release31-maint/Doc/library/copy.rst ============================================================================== --- python/branches/release31-maint/Doc/library/copy.rst (original) +++ python/branches/release31-maint/Doc/library/copy.rst Tue Oct 27 21:19:02 2009 @@ -4,21 +4,25 @@ .. module:: copy :synopsis: Shallow and deep copy operations. +This module provides generic (shallow and deep) copying operations. -.. index:: - single: copy() (in copy) - single: deepcopy() (in copy) -This module provides generic (shallow and deep) copying operations. +Interface summary: + +.. function:: copy(x) + + Return a shallow copy of *x*. + + +.. function:: deepcopy(x) + + Return a deep copy of *x*. -Interface summary:: - import copy +.. exception:: error - x = copy.copy(y) # make a shallow copy of y - x = copy.deepcopy(y) # make a deep copy of y + Raised for module specific errors. -For module specific errors, :exc:`copy.error` is raised. The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): Modified: python/branches/release31-maint/Doc/library/marshal.rst ============================================================================== --- python/branches/release31-maint/Doc/library/marshal.rst (original) +++ python/branches/release31-maint/Doc/library/marshal.rst Tue Oct 27 21:19:02 2009 @@ -36,12 +36,14 @@ Not all Python object types are supported; in general, only objects whose value is independent from a particular invocation of Python can be written and read by -this module. The following types are supported: ``None``, integers, -floating point numbers, strings, bytes, bytearrays, tuples, lists, sets, -dictionaries, and code objects, where it should be understood that tuples, lists -and dictionaries are only supported as long as the values contained therein are -themselves supported; and recursive lists and dictionaries should not be written -(they will cause infinite loops). +this module. The following types are supported: booleans, integers, floating +point numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets, +frozensets, dictionaries, and code objects, where it should be understood that +tuples, lists, sets, frozensets and dictionaries are only supported as long as +the values contained therein are themselves supported; and recursive lists, sets +and dictionaries should not be written (they will cause infinite loops). The +singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration` can also be +marshalled and unmarshalled. There are functions that read/write files as well as functions operating on strings. Modified: python/branches/release31-maint/Doc/library/urllib.parse.rst ============================================================================== --- python/branches/release31-maint/Doc/library/urllib.parse.rst (original) +++ python/branches/release31-maint/Doc/library/urllib.parse.rst Tue Oct 27 21:19:02 2009 @@ -227,7 +227,8 @@ .. function:: quote(string, safe='/', encoding=None, errors=None) Replace special characters in *string* using the ``%xx`` escape. Letters, - digits, and the characters ``'_.-'`` are never quoted. The optional *safe* + digits, and the characters ``'_.-'`` are never quoted. By default, this + function is intended for quoting the path section of URL. The optional *safe* parameter specifies additional ASCII characters that should not be quoted --- its default value is ``'/'``. Modified: python/branches/release31-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release31-maint/Doc/reference/datamodel.rst Tue Oct 27 21:19:02 2009 @@ -666,7 +666,7 @@ of the shared library file. Custom classes - Custon class types are typically created by class definitions (see section + Custom class types are typically created by class definitions (see section :ref:`class`). A class has a namespace implemented by a dictionary object. Class attribute references are translated to lookups in this dictionary, e.g., ``C.x`` is translated to ``C.__dict__["x"]`` (although there are a number of Modified: python/branches/release31-maint/Lib/pdb.py ============================================================================== --- python/branches/release31-maint/Lib/pdb.py (original) +++ python/branches/release31-maint/Lib/pdb.py Tue Oct 27 21:19:02 2009 @@ -208,7 +208,9 @@ """Custom displayhook for the exec in default(), which prevents assignment of the _ variable in the builtins. """ - print(repr(obj)) + # reproduce the behavior of the standard displayhook, not printing None + if obj is not None: + print(repr(obj)) def default(self, line): if line[:1] == '!': line = line[1:] Modified: python/branches/release31-maint/Lib/pydoc.py ============================================================================== --- python/branches/release31-maint/Lib/pydoc.py (original) +++ python/branches/release31-maint/Lib/pydoc.py Tue Oct 27 21:19:02 2009 @@ -1557,7 +1557,7 @@ 'global': ('global', 'NAMESPACES'), 'if': ('if', 'TRUTHVALUE'), 'import': ('import', 'MODULES'), - 'in': ('in', 'SEQUENCEMETHODS2'), + 'in': ('in', 'SEQUENCEMETHODS'), 'is': 'COMPARISON', 'lambda': ('lambda', 'FUNCTIONS'), 'not': 'BOOLEAN', @@ -1643,12 +1643,12 @@ 'PRECEDENCE': 'EXPRESSIONS', 'OBJECTS': ('objects', 'TYPES'), 'SPECIALMETHODS': ('specialnames', 'BASICMETHODS ATTRIBUTEMETHODS ' - 'CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS ' - 'SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'), + 'CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS ' + 'NUMBERMETHODS CLASSES'), 'BASICMETHODS': ('customization', 'hash repr str SPECIALMETHODS'), 'ATTRIBUTEMETHODS': ('attribute-access', 'ATTRIBUTES SPECIALMETHODS'), 'CALLABLEMETHODS': ('callable-types', 'CALLS SPECIALMETHODS'), - 'SEQUENCEMETHODS': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS2 ' + 'SEQUENCEMETHODS': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS ' 'SPECIALMETHODS'), 'MAPPINGMETHODS': ('sequence-types', 'MAPPINGS SPECIALMETHODS'), 'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT ' @@ -1672,8 +1672,8 @@ 'DICTIONARIES': ('typesmapping', 'DICTIONARYLITERALS'), 'DICTIONARYLITERALS': ('dict', 'DICTIONARIES LITERALS'), 'ATTRIBUTES': ('attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'), - 'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS1'), - 'SLICINGS': ('slicings', 'SEQUENCEMETHODS2'), + 'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS'), + 'SLICINGS': ('slicings', 'SEQUENCEMETHODS'), 'CALLS': ('calls', 'EXPRESSIONS'), 'POWER': ('power', 'EXPRESSIONS'), 'UNARY': ('unary', 'EXPRESSIONS'), Modified: python/branches/release31-maint/Lib/test/test_funcattrs.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_funcattrs.py (original) +++ python/branches/release31-maint/Lib/test/test_funcattrs.py Tue Oct 27 21:19:02 2009 @@ -56,8 +56,29 @@ self.assertEqual(test(), 3) # self.b always returns 3, arbitrarily def test___globals__(self): - self.assertEqual(self.b.__globals__, globals()) - self.cannot_set_attr(self.b, '__globals__', 2, (AttributeError, TypeError)) + self.assertIs(self.b.__globals__, globals()) + self.cannot_set_attr(self.b, '__globals__', 2, + (AttributeError, TypeError)) + + def test___closure__(self): + a = 12 + def f(): print(a) + c = f.__closure__ + self.assertTrue(isinstance(c, tuple)) + self.assertEqual(len(c), 1) + # don't have a type object handy + self.assertEqual(c[0].__class__.__name__, "cell") + self.cannot_set_attr(f, "__closure__", c, AttributeError) + + def test_empty_cell(self): + def f(): print(a) + try: + f.__closure__[0].cell_contents + except ValueError: + pass + else: + self.fail("shouldn't be able to read an empty cell") + a = 12 def test___name__(self): self.assertEqual(self.b.__name__, 'b') @@ -90,16 +111,20 @@ self.assertEqual(c.__code__, d.__code__) self.assertEqual(c(), 7) # self.assertEqual(d(), 7) - try: b.__code__ = c.__code__ - except ValueError: pass - else: self.fail( - "__code__ with different numbers of free vars should not be " - "possible") - try: e.__code__ = d.__code__ - except ValueError: pass - else: self.fail( - "__code__ with different numbers of free vars should not be " - "possible") + try: + b.__code__ = c.__code__ + except ValueError: + pass + else: + self.fail("__code__ with different numbers of free vars should " + "not be possible") + try: + e.__code__ = d.__code__ + except ValueError: + pass + else: + self.fail("__code__ with different numbers of free vars should " + "not be possible") def test_blank_func_defaults(self): self.assertEqual(self.b.__defaults__, None) @@ -120,13 +145,16 @@ self.assertEqual(first_func(3, 5), 8) del second_func.__defaults__ self.assertEqual(second_func.__defaults__, None) - try: second_func() - except TypeError: pass - else: self.fail( - "func_defaults does not update; deleting it does not remove " - "requirement") + try: + second_func() + except TypeError: + pass + else: + self.fail("__defaults__ does not update; deleting it does not " + "remove requirement") -class ImplicitReferencesTest(FuncAttrsTest): + +class InstancemethodAttrTest(FuncAttrsTest): def test___class__(self): self.assertEqual(self.fi.a.__self__.__class__, self.F) @@ -146,31 +174,45 @@ self.fi.id = types.MethodType(id, self.fi) self.assertEqual(self.fi.id(), id(self.fi)) # Test usage - try: self.fi.id.unknown_attr - except AttributeError: pass - else: self.fail("using unknown attributes should raise AttributeError") + try: + self.fi.id.unknown_attr + except AttributeError: + pass + else: + self.fail("using unknown attributes should raise AttributeError") # Test assignment and deletion self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError) + class ArbitraryFunctionAttrTest(FuncAttrsTest): def test_set_attr(self): self.b.known_attr = 7 self.assertEqual(self.b.known_attr, 7) - try: self.fi.a.known_attr = 7 - except AttributeError: pass - else: self.fail("setting attributes on methods should raise error") + try: + self.fi.a.known_attr = 7 + except AttributeError: + pass + else: + self.fail("setting attributes on methods should raise error") def test_delete_unknown_attr(self): - try: del self.b.unknown_attr - except AttributeError: pass - else: self.fail("deleting unknown attribute should raise TypeError") + try: + del self.b.unknown_attr + except AttributeError: + pass + else: + self.fail("deleting unknown attribute should raise TypeError") def test_unset_attr(self): for func in [self.b, self.fi.a]: - try: func.non_existent_attr - except AttributeError: pass - else: self.fail("using unknown attributes should raise " - "AttributeError") + try: + func.non_existent_attr + except AttributeError: + pass + else: + self.fail("using unknown attributes should raise " + "AttributeError") + class FunctionDictsTest(FuncAttrsTest): def test_setting_dict_to_invalid(self): @@ -183,11 +225,11 @@ d = {'known_attr': 7} self.b.__dict__ = d # Test assignment - self.assertEqual(d, self.b.__dict__) + self.assertIs(d, self.b.__dict__) # ... and on all the different ways of referencing the method's func self.F.a.__dict__ = d - self.assertEqual(d, self.fi.a.__func__.__dict__) - self.assertEqual(d, self.fi.a.__dict__) + self.assertIs(d, self.fi.a.__func__.__dict__) + self.assertIs(d, self.fi.a.__dict__) # Test value self.assertEqual(self.b.known_attr, 7) self.assertEqual(self.b.__dict__['known_attr'], 7) @@ -196,9 +238,12 @@ self.assertEqual(self.fi.a.known_attr, 7) def test_delete___dict__(self): - try: del self.b.__dict__ - except TypeError: pass - else: self.fail("deleting function dictionary should raise TypeError") + try: + del self.b.__dict__ + except TypeError: + pass + else: + self.fail("deleting function dictionary should raise TypeError") def test_unassigned_dict(self): self.assertEqual(self.b.__dict__, {}) @@ -209,6 +254,7 @@ d[self.b] = value self.assertEqual(d[self.b], value) + class FunctionDocstringTest(FuncAttrsTest): def test_set_docstring_attr(self): self.assertEqual(self.b.__doc__, None) @@ -224,6 +270,7 @@ del self.b.__doc__ self.assertEqual(self.b.__doc__, None) + def cell(value): """Create a cell containing the given value.""" def f(): @@ -242,6 +289,7 @@ a = 1729 return f.__closure__[0] + class CellTest(unittest.TestCase): def test_comparison(self): # These tests are here simply to exercise the comparison code; @@ -254,6 +302,7 @@ self.assertTrue(cell(-36) == cell(-36.0)) self.assertTrue(cell(True) > empty_cell()) + class StaticMethodAttrsTest(unittest.TestCase): def test_func_attribute(self): def f(): @@ -267,7 +316,7 @@ def test_main(): - support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest, + support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest, ArbitraryFunctionAttrTest, FunctionDictsTest, FunctionDocstringTest, CellTest, StaticMethodAttrsTest) Modified: python/branches/release31-maint/Lib/test/test_pdb.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_pdb.py (original) +++ python/branches/release31-maint/Lib/test/test_pdb.py Tue Oct 27 21:19:02 2009 @@ -12,6 +12,49 @@ from test.test_doctest import _FakeInput +class PdbTestInput(object): + """Context manager that makes testing Pdb in doctests easier.""" + + def __init__(self, input): + self.input = input + + def __enter__(self): + self.real_stdin = sys.stdin + sys.stdin = _FakeInput(self.input) + + def __exit__(self, *exc): + sys.stdin = self.real_stdin + + +def test_pdb_displayhook(): + """This tests the custom displayhook for pdb. + + >>> def test_function(foo, bar): + ... import pdb; pdb.Pdb().set_trace() + ... pass + + >>> with PdbTestInput([ + ... 'foo', + ... 'bar', + ... 'for i in range(5): print(i)', + ... 'continue', + ... ]): + ... test_function(1, None) + > (3)test_function() + -> pass + (Pdb) foo + 1 + (Pdb) bar + (Pdb) for i in range(5): print(i) + 0 + 1 + 2 + 3 + 4 + (Pdb) continue + """ + + def test_pdb_skip_modules(): """This illustrates the simple case of module skipping. @@ -19,16 +62,12 @@ ... import string ... import pdb; pdb.Pdb(skip=['stri*']).set_trace() ... string.capwords('FOO') - >>> real_stdin = sys.stdin - >>> sys.stdin = _FakeInput([ - ... 'step', - ... 'continue', - ... ]) - >>> try: + >>> with PdbTestInput([ + ... 'step', + ... 'continue', + ... ]): ... skip_module() - ... finally: - ... sys.stdin = real_stdin > (4)skip_module() -> string.capwords('FOO') (Pdb) step @@ -36,7 +75,7 @@ > (4)skip_module()->None -> string.capwords('FOO') (Pdb) continue -""" + """ # Module for testing skipping of module that makes a callback @@ -50,22 +89,19 @@ >>> def skip_module(): ... def callback(): ... return None - ... import pdb;pdb.Pdb(skip=['module_to_skip*']).set_trace() + ... import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace() ... mod.foo_pony(callback) - >>> real_stdin = sys.stdin - >>> sys.stdin = _FakeInput([ - ... 'step', - ... 'step', - ... 'step', - ... 'step', - ... 'step', - ... 'continue', - ... ]) - >>> try: + >>> with PdbTestInput([ + ... 'step', + ... 'step', + ... 'step', + ... 'step', + ... 'step', + ... 'continue', + ... ]): ... skip_module() - ... finally: - ... sys.stdin = real_stdin + ... pass # provides something to "step" to > (5)skip_module() -> mod.foo_pony(callback) (Pdb) step @@ -84,10 +120,10 @@ > (5)skip_module()->None -> mod.foo_pony(callback) (Pdb) step - > (4)() - -> sys.stdin = real_stdin + > (10)() + -> pass # provides something to "step" to (Pdb) continue -""" + """ def test_main(): From python-checkins at python.org Tue Oct 27 21:19:58 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:19:58 -0000 Subject: [Python-checkins] r75858 - in python/branches/release31-maint: Misc/HISTORY Misc/README Misc/find_recursionlimit.py Tools/scripts/README Tools/scripts/find_recursionlimit.py Message-ID: Author: georg.brandl Date: Tue Oct 27 21:19:55 2009 New Revision: 75858 Log: Merged revisions 75373 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r75373 | georg.brandl | 2009-10-11 23:24:34 +0200 (So, 11 Okt 2009) | 17 lines Merged revisions 75370-75372 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75370 | georg.brandl | 2009-10-11 23:10:07 +0200 (So, 11 Okt 2009) | 1 line Move find_recursionlimit.py to Tools/scripts; it is out of place in Misc. ........ r75371 | georg.brandl | 2009-10-11 23:14:37 +0200 (So, 11 Okt 2009) | 1 line Add find_recursionlimit.py to README. ........ r75372 | georg.brandl | 2009-10-11 23:17:14 +0200 (So, 11 Okt 2009) | 1 line Update Misc/README. ........ ................ Added: python/branches/release31-maint/Tools/scripts/find_recursionlimit.py - copied unchanged from r75373, /python/branches/py3k/Tools/scripts/find_recursionlimit.py Removed: python/branches/release31-maint/Misc/find_recursionlimit.py Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/HISTORY python/branches/release31-maint/Misc/README python/branches/release31-maint/Tools/scripts/README Modified: python/branches/release31-maint/Misc/HISTORY ============================================================================== --- python/branches/release31-maint/Misc/HISTORY (original) +++ python/branches/release31-maint/Misc/HISTORY Tue Oct 27 21:19:55 2009 @@ -10435,7 +10435,7 @@ Python code. The limit exists to prevent infinite recursion from overflowing the C stack and causing a core dump. The default value is 1000. The maximum safe value for a particular platform can be found -by running Misc/find_recursionlimit.py. +by running Tools/scripts/find_recursionlimit.py. New Modules and Packages ------------------------ Modified: python/branches/release31-maint/Misc/README ============================================================================== --- python/branches/release31-maint/Misc/README (original) +++ python/branches/release31-maint/Misc/README Tue Oct 27 21:19:55 2009 @@ -9,24 +9,32 @@ ACKS Acknowledgements AIX-NOTES Notes for building Python on AIX +build.sh Script to build and test latest Python from the repository cheatsheet Quick summary of Python by Ken Manheimer -find_recursionlimit.py Script to find a value for sys.maxrecursionlimit +developers.txt A history of who got developer permissions, and why gdbinit Handy stuff to put in your .gdbinit file, if you use gdb HISTORY News from previous releases -- oldest last -HPUX-NOTES Notes about dynamic loading under HP-UX indent.pro GNU indent profile approximating my C style +maintainers.txt A list of maintainers for library modules NEWS News for this release (for some meaning of "this") +NEWS.help How to edit NEWS Porting Mini-FAQ on porting to new platforms PURIFY.README Information for Purify users pymemcompat.h Memory interface compatibility file. python.man UNIX man page for the python interpreter python-mode.el Emacs mode for editing Python programs +python.pc.in Package configuration info template for pkg-config python-wing.wpr Wing IDE project file README The file you're reading now +README.coverity Information about running Coverity's Prevent on Python +README.klocwork Information about running Klocwork's K7 on Python +README.OpenBSD Help for building problems on OpenBSD README.valgrind Information for Valgrind users, see valgrind-python.supp RFD Request For Discussion about a Python newsgroup RPM (Old) tools to build RPMs -SpecialBuilds.txt Describes extra symbols you can set for debug builds setuid-prog.c C helper program for set-uid Python scripts +SpecialBuilds.txt Describes extra symbols you can set for debug builds +TextMate A TextMate bundle for Python development +valgrind-python.supp Valgrind suppression file, see README.valgrind vgrindefs Python configuration for vgrind (a generic pretty printer) -valgrind-python.supp Valgrind suppression file, see README.valgrind +Vim Python development utilities for the Vim editor \ No newline at end of file Deleted: python/branches/release31-maint/Misc/find_recursionlimit.py ============================================================================== --- python/branches/release31-maint/Misc/find_recursionlimit.py Tue Oct 27 21:19:55 2009 +++ (empty file) @@ -1,118 +0,0 @@ -#! /usr/bin/env python -"""Find the maximum recursion limit that prevents interpreter termination. - -This script finds the maximum safe recursion limit on a particular -platform. If you need to change the recursion limit on your system, -this script will tell you a safe upper bound. To use the new limit, -call sys.setrecursionlimit(). - -This module implements several ways to create infinite recursion in -Python. Different implementations end up pushing different numbers of -C stack frames, depending on how many calls through Python's abstract -C API occur. - -After each round of tests, it prints a message: -"Limit of NNNN is fine". - -The highest printed value of "NNNN" is therefore the highest potentially -safe limit for your system (which depends on the OS, architecture, but also -the compilation flags). Please note that it is practically impossible to -test all possible recursion paths in the interpreter, so the results of -this test should not be trusted blindly -- although they give a good hint -of which values are reasonable. - -NOTE: When the C stack space allocated by your system is exceeded due -to excessive recursion, exact behaviour depends on the platform, although -the interpreter will always fail in a likely brutal way: either a -segmentation fault, a MemoryError, or just a silent abort. - -NB: A program that does not use __methods__ can set a higher limit. -""" - -import sys -import itertools - -class RecursiveBlowup1: - def __init__(self): - self.__init__() - -def test_init(): - return RecursiveBlowup1() - -class RecursiveBlowup2: - def __repr__(self): - return repr(self) - -def test_repr(): - return repr(RecursiveBlowup2()) - -class RecursiveBlowup4: - def __add__(self, x): - return x + self - -def test_add(): - return RecursiveBlowup4() + RecursiveBlowup4() - -class RecursiveBlowup5: - def __getattr__(self, attr): - return getattr(self, attr) - -def test_getattr(): - return RecursiveBlowup5().attr - -class RecursiveBlowup6: - def __getitem__(self, item): - return self[item - 2] + self[item - 1] - -def test_getitem(): - return RecursiveBlowup6()[5] - -def test_recurse(): - return test_recurse() - -def test_cpickle(_cache={}): - import io - try: - import _pickle - except ImportError: - print("cannot import _pickle, skipped!") - return - l = None - for n in itertools.count(): - try: - l = _cache[n] - continue # Already tried and it works, let's save some time - except KeyError: - for i in range(100): - l = [l] - _pickle.Pickler(io.BytesIO(), protocol=-1).dump(l) - _cache[n] = l - -def check_limit(n, test_func_name): - sys.setrecursionlimit(n) - if test_func_name.startswith("test_"): - print(test_func_name[5:]) - else: - print(test_func_name) - test_func = globals()[test_func_name] - try: - test_func() - # AttributeError can be raised because of the way e.g. PyDict_GetItem() - # silences all exceptions and returns NULL, which is usually interpreted - # as "missing attribute". - except (RuntimeError, AttributeError): - pass - else: - print("Yikes!") - -limit = 1000 -while 1: - check_limit(limit, "test_recurse") - check_limit(limit, "test_add") - check_limit(limit, "test_repr") - check_limit(limit, "test_init") - check_limit(limit, "test_getattr") - check_limit(limit, "test_getitem") - check_limit(limit, "test_cpickle") - print("Limit of %d is fine" % limit) - limit = limit + 100 Modified: python/branches/release31-maint/Tools/scripts/README ============================================================================== --- python/branches/release31-maint/Tools/scripts/README (original) +++ python/branches/release31-maint/Tools/scripts/README Tue Oct 27 21:19:55 2009 @@ -19,7 +19,8 @@ diff.py Print file diffs in context, unified, or ndiff formats dutree.py Format du(1) output as a tree sorted by size eptags.py Create Emacs TAGS file for Python modules -finddiv.py A grep-like tool that looks for division operators. +find_recursionlimit.py Find the maximum recursion limit on this machine +finddiv.py A grep-like tool that looks for division operators findlinksto.py Recursively find symbolic links to a given path prefix findnocoding.py Find source files which need an encoding declaration fixcid.py Massive identifier substitution on C source files @@ -28,8 +29,8 @@ fixnotice.py Fix the copyright notice in source files fixps.py Fix Python scripts' first line (if #!) ftpmirror.py FTP mirror script -google.py Open a webbrowser with Google. -gprof2html.py Transform gprof(1) output into useful HTML. +google.py Open a webbrowser with Google +gprof2html.py Transform gprof(1) output into useful HTML h2py.py Translate #define's into Python assignments idle Main program to start IDLE ifdef.py Remove #if(n)def groups from C sources @@ -55,9 +56,9 @@ redemo.py Basic regular expression demonstration facility reindent.py Change .py files to use 4-space indents. rgrep.py Reverse grep through a file (useful for big logfiles) -setup.py Install all scripts listed here. +setup.py Install all scripts listed here suff.py Sort a list of files by suffix -svneol.py Sets svn:eol-style on all files in directory. +svneol.py Sets svn:eol-style on all files in directory texcheck.py Validate Python LaTeX formatting (Raymond Hettinger) texi2html.py Convert GNU texinfo files into HTML treesync.py Synchronize source trees (very ideosyncratic) From python-checkins at python.org Tue Oct 27 21:20:38 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:20:38 -0000 Subject: [Python-checkins] r75859 - in python/branches/release31-maint: Doc/contents.rst Doc/faq Doc/tools/sphinxext/indexcontent.html Message-ID: Author: georg.brandl Date: Tue Oct 27 21:20:38 2009 New Revision: 75859 Log: Merged revisions 75374 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r75374 | georg.brandl | 2009-10-11 23:25:26 +0200 (So, 11 Okt 2009) | 9 lines Merged revisions 75363 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75363 | georg.brandl | 2009-10-11 20:31:23 +0200 (So, 11 Okt 2009) | 1 line Add the Python FAQ lists to the documentation. Copied from sandbox/faq. Many thanks to AMK for the preparation work. ........ ................ Added: python/branches/release31-maint/Doc/faq/ - copied from r75374, /python/branches/py3k/Doc/faq/ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/contents.rst python/branches/release31-maint/Doc/tools/sphinxext/indexcontent.html Modified: python/branches/release31-maint/Doc/contents.rst ============================================================================== --- python/branches/release31-maint/Doc/contents.rst (original) +++ python/branches/release31-maint/Doc/contents.rst Tue Oct 27 21:20:38 2009 @@ -15,6 +15,7 @@ install/index.rst documenting/index.rst howto/index.rst + faq/index.rst glossary.rst about.rst Modified: python/branches/release31-maint/Doc/tools/sphinxext/indexcontent.html ============================================================================== --- python/branches/release31-maint/Doc/tools/sphinxext/indexcontent.html (original) +++ python/branches/release31-maint/Doc/tools/sphinxext/indexcontent.html Tue Oct 27 21:20:38 2009 @@ -26,6 +26,8 @@ sharing modules with others

                + From python-checkins at python.org Tue Oct 27 21:20:41 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:20:41 -0000 Subject: [Python-checkins] r75860 - python/trunk/Lib/test/test_distutils.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:20:41 2009 New Revision: 75860 Log: Try to fix transient refleaks in test_distutils. Modified: python/trunk/Lib/test/test_distutils.py Modified: python/trunk/Lib/test/test_distutils.py ============================================================================== --- python/trunk/Lib/test/test_distutils.py (original) +++ python/trunk/Lib/test/test_distutils.py Tue Oct 27 21:20:41 2009 @@ -11,6 +11,7 @@ def test_main(): test.test_support.run_unittest(distutils.tests.test_suite()) + test.test_support.reap_children() if __name__ == "__main__": From python-checkins at python.org Tue Oct 27 21:21:45 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 20:21:45 -0000 Subject: [Python-checkins] r75861 - in python/branches/py3k: Lib/test/test_distutils.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 21:21:45 2009 New Revision: 75861 Log: Merged revisions 75860 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75860 | antoine.pitrou | 2009-10-27 21:20:41 +0100 (mar., 27 oct. 2009) | 3 lines Try to fix transient refleaks in test_distutils. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_distutils.py Modified: python/branches/py3k/Lib/test/test_distutils.py ============================================================================== --- python/branches/py3k/Lib/test/test_distutils.py (original) +++ python/branches/py3k/Lib/test/test_distutils.py Tue Oct 27 21:21:45 2009 @@ -11,6 +11,7 @@ def test_main(): test.support.run_unittest(distutils.tests.test_suite()) + test.support.reap_children() if __name__ == "__main__": From python-checkins at python.org Tue Oct 27 21:23:21 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:23:21 -0000 Subject: [Python-checkins] r75862 - in python/branches/release31-maint: Doc/faq/library.rst Doc/faq/programming.rst Doc/library/socket.rst Doc/library/weakref.rst Doc/reference/compound_stmts.rst Doc/reference/datamodel.rst Lib/turtle.py Message-ID: Author: georg.brandl Date: Tue Oct 27 21:23:20 2009 New Revision: 75862 Log: Merged revisions 75393,75416,75581,75609,75615 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r75393 | georg.brandl | 2009-10-13 18:55:12 +0200 (Di, 13 Okt 2009) | 1 line Update module names in references in the FAQ. ................ r75416 | georg.brandl | 2009-10-14 20:46:15 +0200 (Mi, 14 Okt 2009) | 1 line #7129: add missing function. ................ r75581 | georg.brandl | 2009-10-21 09:17:48 +0200 (Mi, 21 Okt 2009) | 9 lines Merged revisions 75580 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75580 | georg.brandl | 2009-10-21 09:15:59 +0200 (Mi, 21 Okt 2009) | 1 line #7170: fix explanation about non-weakrefable builtin types. ........ ................ r75609 | georg.brandl | 2009-10-22 17:16:26 +0200 (Do, 22 Okt 2009) | 1 line #7137: fix makefile() documentation to match the new parameters. ................ r75615 | georg.brandl | 2009-10-22 18:08:10 +0200 (Do, 22 Okt 2009) | 1 line #6927: fix wrong word. ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/faq/library.rst python/branches/release31-maint/Doc/faq/programming.rst python/branches/release31-maint/Doc/library/socket.rst python/branches/release31-maint/Doc/library/weakref.rst python/branches/release31-maint/Doc/reference/compound_stmts.rst python/branches/release31-maint/Doc/reference/datamodel.rst python/branches/release31-maint/Lib/turtle.py Modified: python/branches/release31-maint/Doc/faq/library.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/library.rst (original) +++ python/branches/release31-maint/Doc/faq/library.rst Tue Oct 27 21:23:20 2009 @@ -232,11 +232,9 @@ How do I program using threads? ------------------------------- -.. XXX it's _thread in py3k - -Be sure to use the :mod:`threading` module and not the :mod:`thread` module. +Be sure to use the :mod:`threading` module and not the :mod:`_thread` module. The :mod:`threading` module builds convenient abstractions on top of the -low-level primitives provided by the :mod:`thread` module. +low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see http://starship.python.net/crew/aahz/OSCON2001/. @@ -280,7 +278,7 @@ Instead of trying to guess how long a :func:`time.sleep` delay will be enough, it's better to use some kind of semaphore mechanism. One idea is to use the -:mod:`Queue` module to create a queue object, let each thread append a token to +:mod:`queue` module to create a queue object, let each thread append a token to the queue when it finishes, and let the main thread read as many tokens from the queue as there are threads. @@ -288,8 +286,8 @@ How do I parcel out work among a bunch of worker threads? --------------------------------------------------------- -Use the :mod:`Queue` module to create a queue containing a list of jobs. The -:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +Use the :mod:`queue` module to create a queue containing a list of jobs. The +:class:`~queue.Queue` class maintains a list of objects with ``.put(obj)`` to add an item to the queue and ``.get()`` to return an item. The class will take care of the locking necessary to ensure that each job is handed out exactly once. @@ -777,11 +775,10 @@ Yes. -.. XXX remove bsddb in py3k, fix other module names - -Python 2.3 includes the :mod:`bsddb` package which provides an interface to the -BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM ` -and :mod:`GDBM ` are also included with standard Python. +Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM +` are also included with standard Python. There is also the +:mod:`sqlite3` module, which provides a lightweight disk-based relational +database. Support for most relational databases is available. See the `DatabaseProgramming wiki page @@ -794,8 +791,7 @@ The :mod:`pickle` library module solves this in a very general way (though you still can't store things like open files, sockets or windows), and the :mod:`shelve` library module uses pickle and (g)dbm to create persistent -mappings containing arbitrary Python objects. For better performance, you can -use the :mod:`cPickle` module. +mappings containing arbitrary Python objects. A more awkward way of doing things is to use pickle's little sister, marshal. The :mod:`marshal` module provides very fast ways to store noncircular basic Modified: python/branches/release31-maint/Doc/faq/programming.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/programming.rst (original) +++ python/branches/release31-maint/Doc/faq/programming.rst Tue Oct 27 21:23:20 2009 @@ -364,7 +364,7 @@ In general, don't use ``from modulename import *``. Doing so clutters the importer's namespace. Some people avoid this idiom even with the few modules that were designed to be imported in this manner. Modules designed in this -manner include :mod:`Tkinter`, and :mod:`threading`. +manner include :mod:`tkinter`, and :mod:`threading`. Import modules at the top of a file. Doing so makes it clear what other modules your code requires and avoids questions of whether the module name is in scope. Modified: python/branches/release31-maint/Doc/library/socket.rst ============================================================================== --- python/branches/release31-maint/Doc/library/socket.rst (original) +++ python/branches/release31-maint/Doc/library/socket.rst Tue Oct 27 21:23:20 2009 @@ -565,17 +565,17 @@ is system-dependent (usually 5). -.. method:: socket.makefile([mode[, bufsize]]) +.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, newline=None) .. index:: single: I/O control; buffering Return a :dfn:`file object` associated with the socket. (File objects are - described in :ref:`bltin-file-objects`.) The file object - references a :cfunc:`dup`\ ped version of the socket file descriptor, so the - file object and socket object may be closed or garbage-collected independently. - The socket must be in blocking mode (it can not have a timeout). The optional - *mode* and *bufsize* arguments are interpreted the same way as by the built-in - :func:`file` function. + described in :ref:`bltin-file-objects`.) The file object references a + :cfunc:`dup`\ ped version of the socket file descriptor, so the file object + and socket object may be closed or garbage-collected independently. The + socket must be in blocking mode (it can not have a timeout). The optional + arguments are interpreted the same way as by the built-in :func:`open` + function. .. method:: socket.recv(bufsize[, flags]) Modified: python/branches/release31-maint/Doc/library/weakref.rst ============================================================================== --- python/branches/release31-maint/Doc/library/weakref.rst (original) +++ python/branches/release31-maint/Doc/library/weakref.rst Tue Oct 27 21:23:20 2009 @@ -69,6 +69,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable +Other built-in types such as :class:`tuple` and :class:`int` do not support +weak references even when subclassed (those types implemented as a +:ctype:`PyVarObject`). + Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/branches/release31-maint/Doc/reference/compound_stmts.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/compound_stmts.rst (original) +++ python/branches/release31-maint/Doc/reference/compound_stmts.rst Tue Oct 27 21:23:20 2009 @@ -608,9 +608,9 @@ .. [#] The exception is propagated to the invocation stack only if there is no :keyword:`finally` clause that negates the exception. -.. [#] Currently, control "flows off the end" except in the case of an exception or the - execution of a :keyword:`return`, :keyword:`continue`, or :keyword:`break` - statement. +.. [#] Currently, control "flows off the end" except in the case of an exception + or the execution of a :keyword:`return`, :keyword:`continue`, or + :keyword:`break` statement. .. [#] A string literal appearing as the first statement in the function body is transformed into the function's ``__doc__`` attribute and therefore the Modified: python/branches/release31-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release31-maint/Doc/reference/datamodel.rst Tue Oct 27 21:23:20 2009 @@ -1532,7 +1532,7 @@ The appropriate metaclass is determined by the following precedence rules: -* If the ``metaclass`` keyword argument is based with the bases, it is used. +* If the ``metaclass`` keyword argument is passed with the bases, it is used. * Otherwise, if there is at least one base class, its metaclass is used. Modified: python/branches/release31-maint/Lib/turtle.py ============================================================================== --- python/branches/release31-maint/Lib/turtle.py (original) +++ python/branches/release31-maint/Lib/turtle.py Tue Oct 27 21:23:20 2009 @@ -126,7 +126,7 @@ _tg_turtle_functions = ['back', 'backward', 'begin_fill', 'begin_poly', 'bk', 'circle', 'clear', 'clearstamp', 'clearstamps', 'clone', 'color', 'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd', - 'fillcolor', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', + 'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', 'getturtle', 'goto', 'heading', 'hideturtle', 'home', 'ht', 'isdown', 'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease', 'pd', 'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position', From python-checkins at python.org Tue Oct 27 21:24:46 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:24:46 -0000 Subject: [Python-checkins] r75863 - in python/branches/release31-maint: Demo/comparisons/sortingtest.py Doc/distutils/apiref.rst Doc/documenting/markup.rst Doc/faq/design.rst Doc/faq/extending.rst Doc/faq/general.rst Doc/faq/gui.rst Doc/faq/library.rst Doc/faq/programming.rst Doc/faq/windows.rst Doc/howto/unicode.rst Doc/howto/webservers.rst Doc/install/index.rst Doc/library/codecs.rst Doc/library/configparser.rst Doc/library/curses.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/inspect.rst Doc/library/mailbox.rst Doc/library/math.rst Doc/library/msilib.rst Doc/library/os.rst Doc/library/othergui.rst Doc/library/platform.rst Doc/library/signal.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/types.rst Doc/library/weakref.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/tools/sphinxext/pyspecific.py Doc/tools/sphinxext/static/basic.css Doc/tutorial/index.rst Doc/using/cmdline.rst Doc/using/windows.rst Doc/whatsnew/2.0.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.6.rst Lib/threading.py Lib/warnings.py Modules/_ctypes/_ctypes.c Objects/unicodeobject.c Python/codecs.c Message-ID: Author: georg.brandl Date: Tue Oct 27 21:24:45 2009 New Revision: 75863 Log: Merged revisions 75797 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r75797 | georg.brandl | 2009-10-27 16:28:25 +0100 (Di, 27 Okt 2009) | 129 lines Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. ........ r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line Fix markup. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line #7126: os.environ changes *do* take effect in subprocesses started with os.system(). ........ r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line #7116: str.join() takes an iterable. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line Fix missing word. ........ r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line Fix punctuation. ........ r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line Revert unintended change. ........ r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line Fix markup. ........ r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line Fix duplicate target. ........ r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line Add a new directive marking up implementation details and start using it. ........ r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line Make it more robust. ........ r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line Document new directive. ........ r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line Allow short form with text as argument. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line Use "impl-detail" directive where applicable. ........ r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line #6324: membership test tries iteration via __iter__. ........ r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line #7088: document new functions in signal as Unix-only. ........ r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line Reorder __slots__ fine print and add a clarification. ........ r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line #7035: improve docs of the various _errors() functions, and give them docstrings. ........ r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line #7156: document curses as Unix-only. ........ r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line #6977: getopt does not support optional option arguments. ........ r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line Add proper references. ........ r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line Make printout margin important. ........ r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line #7188: fix optionxform() docs. ........ r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines add further note about what's passed to optionxform ........ r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines Improve some docstrings in the 'warnings' module. ........ r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line Fix markup. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........ r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line Fix a strange mis-edit. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Demo/comparisons/sortingtest.py python/branches/release31-maint/Doc/distutils/apiref.rst python/branches/release31-maint/Doc/documenting/markup.rst python/branches/release31-maint/Doc/faq/design.rst python/branches/release31-maint/Doc/faq/extending.rst python/branches/release31-maint/Doc/faq/general.rst python/branches/release31-maint/Doc/faq/gui.rst python/branches/release31-maint/Doc/faq/library.rst python/branches/release31-maint/Doc/faq/programming.rst python/branches/release31-maint/Doc/faq/windows.rst python/branches/release31-maint/Doc/howto/unicode.rst python/branches/release31-maint/Doc/howto/webservers.rst python/branches/release31-maint/Doc/install/index.rst python/branches/release31-maint/Doc/library/codecs.rst python/branches/release31-maint/Doc/library/configparser.rst python/branches/release31-maint/Doc/library/curses.rst python/branches/release31-maint/Doc/library/datetime.rst python/branches/release31-maint/Doc/library/functions.rst python/branches/release31-maint/Doc/library/getopt.rst python/branches/release31-maint/Doc/library/inspect.rst python/branches/release31-maint/Doc/library/mailbox.rst python/branches/release31-maint/Doc/library/math.rst python/branches/release31-maint/Doc/library/msilib.rst python/branches/release31-maint/Doc/library/os.rst python/branches/release31-maint/Doc/library/othergui.rst python/branches/release31-maint/Doc/library/platform.rst python/branches/release31-maint/Doc/library/signal.rst python/branches/release31-maint/Doc/library/stdtypes.rst python/branches/release31-maint/Doc/library/sys.rst python/branches/release31-maint/Doc/library/types.rst python/branches/release31-maint/Doc/library/weakref.rst python/branches/release31-maint/Doc/reference/datamodel.rst python/branches/release31-maint/Doc/reference/executionmodel.rst python/branches/release31-maint/Doc/reference/expressions.rst python/branches/release31-maint/Doc/reference/simple_stmts.rst python/branches/release31-maint/Doc/tools/sphinxext/pyspecific.py python/branches/release31-maint/Doc/tools/sphinxext/static/basic.css python/branches/release31-maint/Doc/tutorial/index.rst python/branches/release31-maint/Doc/using/cmdline.rst python/branches/release31-maint/Doc/using/windows.rst python/branches/release31-maint/Doc/whatsnew/2.0.rst python/branches/release31-maint/Doc/whatsnew/2.2.rst python/branches/release31-maint/Doc/whatsnew/2.3.rst python/branches/release31-maint/Doc/whatsnew/2.4.rst python/branches/release31-maint/Doc/whatsnew/2.6.rst python/branches/release31-maint/Lib/threading.py python/branches/release31-maint/Lib/warnings.py python/branches/release31-maint/Modules/_ctypes/_ctypes.c python/branches/release31-maint/Objects/unicodeobject.c python/branches/release31-maint/Python/codecs.c Modified: python/branches/release31-maint/Demo/comparisons/sortingtest.py ============================================================================== --- python/branches/release31-maint/Demo/comparisons/sortingtest.py (original) +++ python/branches/release31-maint/Demo/comparisons/sortingtest.py Tue Oct 27 21:24:45 2009 @@ -24,7 +24,6 @@ # - Handles blank input lines correctly import re -import string import sys def main(): @@ -32,18 +31,13 @@ def makekey(item, prog=prog): match = prog.match(item) if match: - var, num = match.group(1, 2) - return string.atoi(num), var + var, num = match.groups() + return int(num), var else: # Bad input -- pretend it's a var with value 0 return 0, item - while 1: - line = sys.stdin.readline() - if not line: - break - items = line.split() - items = list(map(makekey, items)) - items.sort() + for line in sys.stdin: + items = sorted(makekey(item) for item in line.split()) for num, var in items: print("%s=%s" % (var, num), end=' ') print() Modified: python/branches/release31-maint/Doc/distutils/apiref.rst ============================================================================== --- python/branches/release31-maint/Doc/distutils/apiref.rst (original) +++ python/branches/release31-maint/Doc/distutils/apiref.rst Tue Oct 27 21:24:45 2009 @@ -1976,9 +1976,9 @@ Subclasses of :class:`Command` must define the following methods. -.. method:: Command.initialize_options()(S) +.. method:: Command.initialize_options() - et default values for all the options that this command supports. Note that + Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, :meth:`initialize_options` Modified: python/branches/release31-maint/Doc/documenting/markup.rst ============================================================================== --- python/branches/release31-maint/Doc/documenting/markup.rst (original) +++ python/branches/release31-maint/Doc/documenting/markup.rst Tue Oct 27 21:24:45 2009 @@ -626,6 +626,24 @@ -------------- +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + .. describe:: seealso Many sections include a list of references to module documentation or Modified: python/branches/release31-maint/Doc/faq/design.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/design.rst (original) +++ python/branches/release31-maint/Doc/faq/design.rst Tue Oct 27 21:24:45 2009 @@ -396,12 +396,13 @@ ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this approach is feasible, -although the speedups reached so far are only modest (e.g. 2x). Jython uses the -same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated -that in combination with whole-program analysis, speedups of 1000x are feasible -for small demo programs. See the proceedings from the `1997 Python conference -`_ for more information.) +conferences `_ have shown that this +approach is feasible, although the speedups reached so far are only modest +(e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim +Hugunin has demonstrated that in combination with whole-program analysis, +speedups of 1000x are feasible for small demo programs. See the proceedings +from the `1997 Python conference +`_ for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual Modified: python/branches/release31-maint/Doc/faq/extending.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/extending.rst (original) +++ python/branches/release31-maint/Doc/faq/extending.rst Tue Oct 27 21:24:45 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`__, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping Modified: python/branches/release31-maint/Doc/faq/general.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/general.rst (original) +++ python/branches/release31-maint/Doc/faq/general.rst Tue Oct 27 21:24:45 2009 @@ -164,9 +164,10 @@ several useful pieces of freely distributable software. The source will compile and run out of the box on most UNIX platforms. -Consult the `Developer FAQ -`__ for more information -on getting the source code and compiling it. +.. XXX update link once the dev faq is relocated + +Consult the `Developer FAQ `__ for more +information on getting the source code and compiling it. How do I get documentation on Python? @@ -176,7 +177,7 @@ The standard documentation for the current stable version of Python is available at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are -also available at http://docs.python.org/download/. +also available at http://docs.python.org/download.html. The documentation is written in reStructuredText and processed by `the Sphinx documentation tool `__. The reStructuredText source @@ -220,8 +221,10 @@ newsgroups and on the Python home page at http://www.python.org/; an RSS feed of news is available. +.. XXX update link once the dev faq is relocated + You can also access the development version of Python through Subversion. See -http://www.python.org/dev/devfaq.html#subversion-svn for details. +http://www.python.org/dev/faq/ for details. How do I submit bug reports and patches for Python? Modified: python/branches/release31-maint/Doc/faq/gui.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/gui.rst (original) +++ python/branches/release31-maint/Doc/faq/gui.rst Tue Oct 27 21:24:45 2009 @@ -45,11 +45,12 @@ ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If you're -writing open source software, you don't need to pay for PyQt, but if you want to -write proprietary applications, you must buy a PyQt license from `Riverbank -Computing `_ and a Qt license from -`Trolltech `_. +`_) and for KDE (PyKDE). If +you're writing open source software, you don't need to pay for PyQt, but if you +want to write proprietary applications, you must buy a PyQt license from +`Riverbank Computing `_ and (up to Qt 4.4; +Qt 4.5 upwards is licensed under the LGPL license) a Qt license from `Trolltech +`_. Gtk+ '''' Modified: python/branches/release31-maint/Doc/faq/library.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/library.rst (original) +++ python/branches/release31-maint/Doc/faq/library.rst Tue Oct 27 21:24:45 2009 @@ -16,14 +16,10 @@ standard library module. (Eventually you'll learn what's in the standard library and will able to skip this step.) -Search the `Python Package Index `_. - -Next, check the `Vaults of Parnassus `_, an older -index of packages. - -Finally, try `Google `_ or other Web search engine. -Searching for "Python" plus a keyword or two for your topic of interest will -usually find something helpful. +For third-party packages, search the `Python Package Index +`_ or try `Google `_ or +another Web search engine. Searching for "Python" plus a keyword or two for +your topic of interest will usually find something helpful. Where is the math.py (socket.py, regex.py, etc.) source file? @@ -181,11 +177,10 @@ How do I create documentation from doc strings? ----------------------------------------------- -.. XXX mention Sphinx/epydoc - The :mod:`pydoc` module can create HTML from the doc strings in your Python -source code. An alternative is `pythondoc -`_. +source code. An alternative for creating API documentation purely from +docstrings is `epydoc `_. `Sphinx +`_ can also include docstring content. How do I get a single keypress at a time? @@ -237,7 +232,7 @@ low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see -http://starship.python.net/crew/aahz/OSCON2001/. +http://www.pythoncraft.com/OSCON2001/. None of my threads seem to run: why? @@ -397,6 +392,7 @@ ------------------------------------------------ .. XXX mention multiprocessing +.. XXX link to dbeazley's talk about GIL? The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded @@ -583,7 +579,7 @@ ("ptys") instead of pipes. Or you can use a Python interface to Don Libes' "expect" library. A Python extension that interfaces to expect is called "expy" and available from http://expectpy.sourceforge.net. A pure Python solution that -works like expect is ` pexpect `_. +works like expect is `pexpect `_. How do I access the serial (RS232) port? Modified: python/branches/release31-maint/Doc/faq/programming.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/programming.rst (original) +++ python/branches/release31-maint/Doc/faq/programming.rst Tue Oct 27 21:24:45 2009 @@ -67,8 +67,8 @@ PyChecker performs, Pylint offers some additional features such as checking line length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://www.logilab.org/projects/pylint/documentation provides a full list of -Pylint's features. +http://www.logilab.org/card/pylint_manual provides a full list of Pylint's +features. How can I create a stand-alone binary from a Python script? @@ -1141,7 +1141,7 @@ A = [[None] * w for i in range(h)] Or, you can use an extension that provides a matrix datatype; `Numeric Python -`_ is the best known. +`_ is the best known. How do I apply a method to a sequence of objects? Modified: python/branches/release31-maint/Doc/faq/windows.rst ============================================================================== --- python/branches/release31-maint/Doc/faq/windows.rst (original) +++ python/branches/release31-maint/Doc/faq/windows.rst Tue Oct 27 21:24:45 2009 @@ -389,10 +389,10 @@ .py :REG_SZ: c:\\python.exe -u %s %s This line will allow you to call your script with a simple reference like: -http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" -directory for your server (which it usually is by default). The "-u" flag -specifies unbuffered and binary mode for stdin - needed when working with binary -data. +``http://yourserver/scripts/yourscript.py`` provided "scripts" is an +"executable" directory for your server (which it usually is by default). The +:option:`-u` flag specifies unbuffered and binary mode for stdin - needed when +working with binary data. In addition, it is recommended that using ".py" may not be a good idea for the file extensions when used in this context (you might want to reserve ``*.py`` @@ -517,7 +517,7 @@ There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will -find links to the knowledge base at: http://www.microsoft.com/kb. +find links to the knowledge base at: http://support.microsoft.com/. PyRun_SimpleFile() crashes on Windows but not on Unix; why? @@ -604,4 +604,4 @@ we can't fix it). David A Burton has written a little program to fix this. Go to -http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". +http://www.burtonsys.com/downloads.html and click on "ctl3dfix.zip". Modified: python/branches/release31-maint/Doc/howto/unicode.rst ============================================================================== --- python/branches/release31-maint/Doc/howto/unicode.rst (original) +++ python/branches/release31-maint/Doc/howto/unicode.rst Tue Oct 27 21:24:45 2009 @@ -403,7 +403,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: python/branches/release31-maint/Doc/howto/webservers.rst ============================================================================== --- python/branches/release31-maint/Doc/howto/webservers.rst (original) +++ python/branches/release31-maint/Doc/howto/webservers.rst Tue Oct 27 21:24:45 2009 @@ -270,8 +270,7 @@ * lighttpd ships its own `FastCGI module `_ as well as an `SCGI module `_. -* nginx also supports `FastCGI - `_. +* nginx also supports `FastCGI `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -525,7 +524,7 @@ informations on a web server. Often relational database engines like `MySQL `_ or -`PostgreSQL `_ are used due to their good +`PostgreSQL `_ are used due to their good performance handling very large databases consisting of up to millions of entries. These are *queried* using a language called `SQL `_. Python programmers in general do not like @@ -629,7 +628,7 @@ It has a big, international community which has created many sites using Django. There are also quite a lot of add-on projects which extend Django's normal functionality. This is partly due to Django's well written `online -documentation `_ and the `Django book +documentation `_ and the `Django book `_. Modified: python/branches/release31-maint/Doc/install/index.rst ============================================================================== --- python/branches/release31-maint/Doc/install/index.rst (original) +++ python/branches/release31-maint/Doc/install/index.rst Tue Oct 27 21:24:45 2009 @@ -937,7 +937,8 @@ These compilers require some special libraries. This task is more complex than for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find -a good program for this task at http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html) +a good program for this task at +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) Modified: python/branches/release31-maint/Doc/library/codecs.rst ============================================================================== --- python/branches/release31-maint/Doc/library/codecs.rst (original) +++ python/branches/release31-maint/Doc/library/codecs.rst Tue Oct 27 21:24:45 2009 @@ -53,7 +53,7 @@ *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: - ``factory(errors='strict')`` + ``factory(errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, @@ -62,21 +62,25 @@ *streamreader* and *streamwriter*: These have to be factory functions providing the following interface: - ``factory(stream, errors='strict')`` + ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. - Possible values for errors are ``'strict'`` (raise an exception in case of an - encoding error), ``'replace'`` (replace malformed data with a suitable - replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and - continue without further notice), ``'xmlcharrefreplace'`` (replace with the - appropriate XML character reference (for encoding only)), - ``'backslashreplace'`` (replace with backslashed escape sequences (for - encoding only)), ``'surrogateescape'`` (replace with surrogate U+DCxx, see - :pep:`383`) as well as any other error handling name defined via - :func:`register_error`. + Possible values for errors are + + * ``'strict'``: raise an exception in case of an encoding error + * ``'replace'``: replace malformed data with a suitable replacement marker, + such as ``'?'`` or ``'\ufffd'`` + * ``'ignore'``: ignore malformed data and continue without further notice + * ``'xmlcharrefreplace'``: replace with the appropriate XML character + reference (for encoding only) + * ``'backslashreplace'``: replace with backslashed escape sequences (for + encoding only + * ``'surrogateescape'``: replace with surrogate U+DCxx, see :pep:`383` + + as well as any other error handling name defined via :func:`register_error`. In case a search function cannot find a given encoding, it should return ``None``. @@ -173,27 +177,33 @@ .. function:: strict_errors(exception) - Implements the ``strict`` error handling. + Implements the ``strict`` error handling: each encoding or decoding error + raises a :exc:`UnicodeError`. .. function:: replace_errors(exception) - Implements the ``replace`` error handling. + Implements the ``replace`` error handling: malformed data is replaced with a + suitable replacement character such as ``'?'`` in bytestrings and + ``'\ufffd'`` in Unicode strings. .. function:: ignore_errors(exception) - Implements the ``ignore`` error handling. + Implements the ``ignore`` error handling: malformed data is ignored and + encoding or decoding is continued without further notice. .. function:: xmlcharrefreplace_errors(exception) - Implements the ``xmlcharrefreplace`` error handling. + Implements the ``xmlcharrefreplace`` error handling (for encoding only): the + unencodable character is replaced by an appropriate XML character reference. .. function:: backslashreplace_errors(exception) - Implements the ``backslashreplace`` error handling. + Implements the ``backslashreplace`` error handling (for encoding only): the + unencodable character is replaced by a backslashed escape sequence. To simplify working with encoded files or stream, the module also defines these utility functions: Modified: python/branches/release31-maint/Doc/library/configparser.rst ============================================================================== --- python/branches/release31-maint/Doc/library/configparser.rst (original) +++ python/branches/release31-maint/Doc/library/configparser.rst Tue Oct 27 21:24:45 2009 @@ -301,12 +301,23 @@ .. method:: RawConfigParser.optionxform(option) - Transforms the option name *option* as found in an input file or as passed in by - client code to the form that should be used in the internal structures. The - default implementation returns a lower-case version of *option*; subclasses may - override this or client code can set an attribute of this name on instances to - affect this behavior. Setting this to :func:`str`, for example, would make - option names case sensitive. + Transforms the option name *option* as found in an input file or as passed in + by client code to the form that should be used in the internal structures. + The default implementation returns a lower-case version of *option*; + subclasses may override this or client code can set an attribute of this name + on instances to affect this behavior. + + You don't necessarily need to subclass a ConfigParser to use this method, you + can also re-set it on an instance, to a function that takes a string + argument. Setting it to ``str``, for example, would make option names case + sensitive:: + + cfgparser = ConfigParser() + ... + cfgparser.optionxform = str + + Note that when reading configuration files, whitespace around the + option names are stripped before :meth:`optionxform` is called. .. _configparser-objects: Modified: python/branches/release31-maint/Doc/library/curses.rst ============================================================================== --- python/branches/release31-maint/Doc/library/curses.rst (original) +++ python/branches/release31-maint/Doc/library/curses.rst Tue Oct 27 21:24:45 2009 @@ -4,10 +4,10 @@ .. module:: curses :synopsis: An interface to the curses library, providing portable terminal handling. + :platform: Unix .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond - The :mod:`curses` module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling. Modified: python/branches/release31-maint/Doc/library/datetime.rst ============================================================================== --- python/branches/release31-maint/Doc/library/datetime.rst (original) +++ python/branches/release31-maint/Doc/library/datetime.rst Tue Oct 27 21:24:45 2009 @@ -233,7 +233,7 @@ | | (-*t1.days*, -*t1.seconds*, | | | -*t1.microseconds*), and to *t1*\* -1. (1)(4) | +--------------------------------+-----------------------------------------------+ -| ``abs(t)`` | equivalent to +*t* when ``t.days >= 0``, and | +| ``abs(t)`` | equivalent to +\ *t* when ``t.days >= 0``, and| | | to -*t* when ``t.days < 0``. (2) | +--------------------------------+-----------------------------------------------+ Modified: python/branches/release31-maint/Doc/library/functions.rst ============================================================================== --- python/branches/release31-maint/Doc/library/functions.rst (original) +++ python/branches/release31-maint/Doc/library/functions.rst Tue Oct 27 21:24:45 2009 @@ -499,8 +499,10 @@ Return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. - Two objects with non-overlapping lifetimes may have the same :func:`id` value. - (Implementation note: this is the address of the object.) + Two objects with non-overlapping lifetimes may have the same :func:`id` + value. + + .. impl-detail:: This is the address of the object. .. function:: input([prompt]) Modified: python/branches/release31-maint/Doc/library/getopt.rst ============================================================================== --- python/branches/release31-maint/Doc/library/getopt.rst (original) +++ python/branches/release31-maint/Doc/library/getopt.rst Tue Oct 27 21:24:45 2009 @@ -36,12 +36,13 @@ *longopts*, if specified, must be a list of strings with the names of the long options which should be supported. The leading ``'--'`` characters should not be included in the option name. Long options which require an - argument should be followed by an equal sign (``'='``). To accept only long - options, *shortopts* should be an empty string. Long options on the command line - can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *longopts* is - ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, - but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. + argument should be followed by an equal sign (``'='``). Optional arguments + are not supported. To accept only long options, *shortopts* should be an + empty string. Long options on the command line can be recognized so long as + they provide a prefix of the option name that matches exactly one of the + accepted options. For example, if *longopts* is ``['foo', 'frob']``, the + option :option:`--fo` will match as :option:`--foo`, but :option:`--f` will + not match uniquely, so :exc:`GetoptError` will be raised. The return value consists of two elements: the first is a list of ``(option, value)`` pairs; the second is the list of program arguments left after the Modified: python/branches/release31-maint/Doc/library/inspect.rst ============================================================================== --- python/branches/release31-maint/Doc/library/inspect.rst (original) +++ python/branches/release31-maint/Doc/library/inspect.rst Tue Oct 27 21:24:45 2009 @@ -290,18 +290,22 @@ Return true if the object is a getset descriptor. - getsets are attributes defined in extension modules via ``PyGetSetDef`` - structures. For Python implementations without such types, this method will - always return ``False``. + .. impl-detail:: + + getsets are attributes defined in extension modules via + :ctype:`PyGetSetDef` structures. For Python implementations without such + types, this method will always return ``False``. .. function:: ismemberdescriptor(object) Return true if the object is a member descriptor. - Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, - this method will always return ``False``. + .. impl-detail:: + + Member descriptors are attributes defined in extension modules via + :ctype:`PyMemberDef` structures. For Python implementations without such + types, this method will always return ``False``. .. _inspect-source: @@ -508,10 +512,12 @@ Return the frame object for the caller's stack frame. - This function relies on Python stack frame support in the interpreter, which - isn't guaranteed to exist in all implementations of Python. If running in - an implementation without Python stack frame support this function returns - ``None``. + .. impl-detail:: + + This function relies on Python stack frame support in the interpreter, + which isn't guaranteed to exist in all implementations of Python. If + running in an implementation without Python stack frame support this + function returns ``None``. .. function:: stack(context=1) Modified: python/branches/release31-maint/Doc/library/mailbox.rst ============================================================================== --- python/branches/release31-maint/Doc/library/mailbox.rst (original) +++ python/branches/release31-maint/Doc/library/mailbox.rst Tue Oct 27 21:24:45 2009 @@ -595,7 +595,7 @@ `nmh - Message Handling System `_ Home page of :program:`nmh`, an updated version of the original :program:`mh`. - `MH & nmh: Email for Users & Programmers `_ + `MH & nmh: Email for Users & Programmers `_ A GPL-licensed book on :program:`mh` and :program:`nmh`, with some information on the mailbox format. Modified: python/branches/release31-maint/Doc/library/math.rst ============================================================================== --- python/branches/release31-maint/Doc/library/math.rst (original) +++ python/branches/release31-maint/Doc/library/math.rst Tue Oct 27 21:24:45 2009 @@ -291,7 +291,7 @@ The mathematical constant *e*. -.. note:: +.. impl-detail:: The :mod:`math` module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified Modified: python/branches/release31-maint/Doc/library/msilib.rst ============================================================================== --- python/branches/release31-maint/Doc/library/msilib.rst (original) +++ python/branches/release31-maint/Doc/library/msilib.rst Tue Oct 27 21:24:45 2009 @@ -394,10 +394,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -422,7 +422,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -516,13 +516,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: @@ -551,5 +551,3 @@ This module contains definitions for the UIText and ActionText tables, for the standard installer actions. - - Modified: python/branches/release31-maint/Doc/library/os.rst ============================================================================== --- python/branches/release31-maint/Doc/library/os.rst (original) +++ python/branches/release31-maint/Doc/library/os.rst Tue Oct 27 21:24:45 2009 @@ -1578,9 +1578,9 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :cfunc:`system`, and has the same limitations. Changes - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the - environment of the executed command. + the Standard C function :cfunc:`system`, and has the same limitations. + Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the + executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning Modified: python/branches/release31-maint/Doc/library/othergui.rst ============================================================================== --- python/branches/release31-maint/Doc/library/othergui.rst (original) +++ python/branches/release31-maint/Doc/library/othergui.rst Tue Oct 27 21:24:45 2009 @@ -43,7 +43,7 @@ `PythonCAD `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool Modified: python/branches/release31-maint/Doc/library/platform.rst ============================================================================== --- python/branches/release31-maint/Doc/library/platform.rst (original) +++ python/branches/release31-maint/Doc/library/platform.rst Tue Oct 27 21:24:45 2009 @@ -94,7 +94,7 @@ .. function:: python_implementation() Returns a string identifying the Python implementation. Possible return values - are: 'CPython', 'IronPython', 'Jython' + are: 'CPython', 'IronPython', 'Jython'. .. function:: python_revision() Modified: python/branches/release31-maint/Doc/library/signal.rst ============================================================================== --- python/branches/release31-maint/Doc/library/signal.rst (original) +++ python/branches/release31-maint/Doc/library/signal.rst Tue Oct 27 21:24:45 2009 @@ -157,13 +157,14 @@ The old values are returned as a tuple: (delay, interval). - Attempting to pass an invalid interval timer will cause a - :exc:`ItimerError`. + Attempting to pass an invalid interval timer will cause an + :exc:`ItimerError`. Availability: Unix. .. function:: getitimer(which) Returns current value of a given interval timer specified by *which*. + Availability: Unix. .. function:: set_wakeup_fd(fd) @@ -182,14 +183,14 @@ .. function:: siginterrupt(signalnum, flag) - Change system call restart behaviour: if *flag* is :const:`False`, system calls - will be restarted when interrupted by signal *signalnum*, otherwise system calls will - be interrupted. Returns nothing. Availability: Unix (see the man page - :manpage:`siginterrupt(3)` for further information). - - Note that installing a signal handler with :func:`signal` will reset the restart - behaviour to interruptible by implicitly calling :cfunc:`siginterrupt` with a true *flag* - value for the given signal. + Change system call restart behaviour: if *flag* is :const:`False`, system + calls will be restarted when interrupted by signal *signalnum*, otherwise + system calls will be interrupted. Returns nothing. Availability: Unix (see + the man page :manpage:`siginterrupt(3)` for further information). + + Note that installing a signal handler with :func:`signal` will reset the + restart behaviour to interruptible by implicitly calling + :cfunc:`siginterrupt` with a true *flag* value for the given signal. .. function:: signal(signalnum, handler) Modified: python/branches/release31-maint/Doc/library/stdtypes.rst ============================================================================== --- python/branches/release31-maint/Doc/library/stdtypes.rst (original) +++ python/branches/release31-maint/Doc/library/stdtypes.rst Tue Oct 27 21:24:45 2009 @@ -772,13 +772,15 @@ If *k* is ``None``, it is treated like ``1``. (6) - If *s* and *t* are both strings, some Python implementations such as CPython can - usually perform an in-place optimization for assignments of the form ``s=s+t`` - or ``s+=t``. When applicable, this optimization makes quadratic run-time much - less likely. This optimization is both version and implementation dependent. - For performance sensitive code, it is preferable to use the :meth:`str.join` - method which assures consistent linear concatenation performance across versions - and implementations. + .. impl-detail:: + + If *s* and *t* are both strings, some Python implementations such as + CPython can usually perform an in-place optimization for assignments of + the form ``s = s + t`` or ``s += t``. When applicable, this optimization + makes quadratic run-time much less likely. This optimization is both + version and implementation dependent. For performance sensitive code, it + is preferable to use the :meth:`str.join` method which assures consistent + linear concatenation performance across versions and implementations. .. _string-methods: @@ -950,12 +952,12 @@ least one cased character, false otherwise. -.. method:: str.join(seq) +.. method:: str.join(iterable) - Return a string which is the concatenation of the strings in the sequence - *seq*. A :exc:`TypeError` will be raised if there are any non-string values - in *seq*, including :class:`bytes` objects. The separator between elements - is the string providing this method. + Return a string which is the concatenation of the strings in the + :term:`iterable` *iterable*. A :exc:`TypeError` will be raised if there are + any non-string values in *seq*, including :class:`bytes` objects. The + separator between elements is the string providing this method. .. method:: str.ljust(width[, fillchar]) @@ -1509,14 +1511,17 @@ that compare equal --- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). - While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation - makes the list appear empty for the duration, and raises :exc:`ValueError` if it - can detect that the list has been mutated during a sort. + .. impl-detail:: + + While a list is being sorted, the effect of attempting to mutate, or even + inspect, the list is undefined. The C implementation of Python makes the + list appear empty for the duration, and raises :exc:`ValueError` if it can + detect that the list has been mutated during a sort. (8) :meth:`sort` is not supported by :class:`bytearray` objects. + .. _bytes-methods: Bytes and Byte Array Methods Modified: python/branches/release31-maint/Doc/library/sys.rst ============================================================================== --- python/branches/release31-maint/Doc/library/sys.rst (original) +++ python/branches/release31-maint/Doc/library/sys.rst Tue Oct 27 21:24:45 2009 @@ -352,8 +352,10 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. It - is not guaranteed to exist in all implementations of Python. + .. impl-detail:: + + This function should be used for internal and specialized purposes only. + It is not guaranteed to exist in all implementations of Python. .. function:: getprofile() @@ -373,12 +375,12 @@ Get the trace function as set by :func:`settrace`. - .. note:: + .. impl-detail:: The :func:`gettrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, - and thus may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: getwindowsversion() @@ -749,12 +751,12 @@ For more information on code and frame objects, refer to :ref:`types`. - .. note:: + .. impl-detail:: The :func:`settrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, and thus - may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: settscdump(on_flag) Modified: python/branches/release31-maint/Doc/library/types.rst ============================================================================== --- python/branches/release31-maint/Doc/library/types.rst (original) +++ python/branches/release31-maint/Doc/library/types.rst Tue Oct 27 21:24:45 2009 @@ -77,5 +77,8 @@ as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the :class:`property` type, but for classes defined in extension modules. - In other implementations of Python, this type may be identical to - ``GetSetDescriptorType``. + + .. impl-detail:: + + In other implementations of Python, this type may be identical to + ``GetSetDescriptorType``. Modified: python/branches/release31-maint/Doc/library/weakref.rst ============================================================================== --- python/branches/release31-maint/Doc/library/weakref.rst (original) +++ python/branches/release31-maint/Doc/library/weakref.rst Tue Oct 27 21:24:45 2009 @@ -69,9 +69,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable -Other built-in types such as :class:`tuple` and :class:`int` do not support -weak references even when subclassed (those types implemented as a -:ctype:`PyVarObject`). +.. impl-detail:: + + Other built-in types such as :class:`tuple` and :class:`long` do not support + weak references even when subclassed. Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: python/branches/release31-maint/Doc/reference/datamodel.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/datamodel.rst (original) +++ python/branches/release31-maint/Doc/reference/datamodel.rst Tue Oct 27 21:24:45 2009 @@ -59,13 +59,16 @@ they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether --- it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that -are still reachable. (Implementation note: CPython currently uses a -reference-counting scheme with (optional) delayed detection of cyclically linked -garbage, which collects most objects as soon as they become unreachable, but is -not guaranteed to collect garbage containing circular references. See the -documentation of the :mod:`gc` module for information on controlling the -collection of cyclic garbage. Other implementations act differently and CPython -may change.) +are still reachable. + +.. impl-detail:: + + CPython currently uses a reference-counting scheme with (optional) delayed + detection of cyclically linked garbage, which collects most objects as soon + as they become unreachable, but is not guaranteed to collect garbage + containing circular references. See the documentation of the :mod:`gc` + module for information on controlling the collection of cyclic garbage. + Other implementations act differently and CPython may change. Note that the use of the implementation's tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching @@ -1469,15 +1472,15 @@ *__slots__*; otherwise, the class attribute would overwrite the descriptor assignment. +* The action of a *__slots__* declaration is limited to the class where it is + defined. As a result, subclasses will have a *__dict__* unless they also define + *__slots__* (which must only contain names of any *additional* slots). + * If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this. -* The action of a *__slots__* declaration is limited to the class where it is - defined. As a result, subclasses will have a *__dict__* unless they also define - *__slots__*. - * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`int`, :class:`str` and :class:`tuple`. @@ -1714,12 +1717,16 @@ supply the following special method with a more efficient implementation, which also does not require the object be a sequence. - .. method:: object.__contains__(self, item) - Called to implement membership test operators. Should return true if *item* is - in *self*, false otherwise. For mapping objects, this should consider the keys - of the mapping rather than the values or the key-item pairs. + Called to implement membership test operators. Should return true if *item* + is in *self*, false otherwise. For mapping objects, this should consider the + keys of the mapping rather than the values or the key-item pairs. + + For objects that don't define :meth:`__contains__`, the membership test first + tries iteration via :meth:`__iter__`, then the old sequence iteration + protocol via :meth:`__getitem__`, see :ref:`this section in the language + reference `. .. _numeric-types: Modified: python/branches/release31-maint/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/executionmodel.rst (original) +++ python/branches/release31-maint/Doc/reference/executionmodel.rst Tue Oct 27 21:24:45 2009 @@ -129,7 +129,7 @@ itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. -.. note:: +.. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should Modified: python/branches/release31-maint/Doc/reference/expressions.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/expressions.rst (original) +++ python/branches/release31-maint/Doc/reference/expressions.rst Tue Oct 27 21:24:45 2009 @@ -639,13 +639,13 @@ raised. Otherwise, the list of filled slots is used as the argument list for the call. -.. note:: +.. impl-detail:: - An implementation may provide built-in functions whose positional parameters do - not have names, even if they are 'named' for the purpose of documentation, and - which therefore cannot be supplied by keyword. In CPython, this is the case for - functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their - arguments. + An implementation may provide built-in functions whose positional parameters + do not have names, even if they are 'named' for the purpose of documentation, + and which therefore cannot be supplied by keyword. In CPython, this is the + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to + parse their arguments. If there are more positional arguments than there are formal parameter slots, a :exc:`TypeError` exception is raised, unless a formal parameter using the syntax @@ -1053,6 +1053,8 @@ supported cross-type comparisons and unsupported comparisons. For example, ``Decimal(2) == 2`` and `2 == float(2)`` but ``Decimal(2) != float(2)``. +.. _membership-test-details: + The operators :keyword:`in` and :keyword:`not in` test for membership. ``x in s`` evaluates to true if *x* is a member of *s*, and false otherwise. ``x not in s`` returns the negation of ``x in s``. All built-in sequences and set types @@ -1069,7 +1071,12 @@ For user-defined classes which define the :meth:`__contains__` method, ``x in y`` is true if and only if ``y.__contains__(x)`` is true. -For user-defined classes which do not define :meth:`__contains__` and do define +For user-defined classes which do not define :meth:`__contains__` but do define +:meth:`__iter__`, ``x in y`` is true if some value ``z`` with ``x == z`` is +produced while iterating over ``y``. If an exception is raised during the +iteration, it is as if :keyword:`in` raised that exception. + +Lastly, the old-style iteration protocol is tried: if a class defines :meth:`__getitem__`, ``x in y`` is true if and only if there is a non-negative integer index *i* such that ``x == y[i]``, and all lower integer indices do not raise :exc:`IndexError` exception. (If any other exception is raised, it is as Modified: python/branches/release31-maint/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/release31-maint/Doc/reference/simple_stmts.rst (original) +++ python/branches/release31-maint/Doc/reference/simple_stmts.rst Tue Oct 27 21:24:45 2009 @@ -236,9 +236,11 @@ from the length of the assigned sequence, thus changing the length of the target sequence, if the object allows it. -(In the current implementation, the syntax for targets is taken to be the same -as for expressions, and invalid syntax is rejected during the code generation -phase, causing less detailed error messages.) +.. impl-detail:: + + In the current implementation, the syntax for targets is taken to be the same + as for expressions, and invalid syntax is rejected during the code generation + phase, causing less detailed error messages. WARNING: Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are 'safe' (for example ``a, b = b, a`` @@ -935,9 +937,11 @@ parameters or in a :keyword:`for` loop control target, :keyword:`class` definition, function definition, or :keyword:`import` statement. -(The current implementation does not enforce the latter two restrictions, but -programs should not abuse this freedom, as future implementations may enforce -them or silently change the meaning of the program.) +.. impl-detail:: + + The current implementation does not enforce the latter two restrictions, but + programs should not abuse this freedom, as future implementations may enforce + them or silently change the meaning of the program. .. index:: builtin: exec Modified: python/branches/release31-maint/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- python/branches/release31-maint/Doc/tools/sphinxext/pyspecific.py (original) +++ python/branches/release31-maint/Doc/tools/sphinxext/pyspecific.py Tue Oct 27 21:24:45 2009 @@ -35,6 +35,8 @@ HTMLTranslator.visit_versionmodified = new_visit_versionmodified +# Support for marking up and linking to bugs.python.org issues + def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): issue = utils.unescape(text) text = 'issue ' + issue @@ -42,6 +44,34 @@ return [refnode], [] +# Support for marking up implementation details + +from sphinx.util.compat import Directive + +class ImplementationDetail(Directive): + + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = True + + def run(self): + pnode = nodes.compound(classes=['impl-detail']) + content = self.content + add_text = nodes.strong('CPython implementation detail:', + 'CPython implementation detail:') + if self.arguments: + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.append(nodes.paragraph('', '', *(n + m))) + self.state.nested_parse(content, self.content_offset, pnode) + if pnode.children and isinstance(pnode[0], nodes.paragraph): + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) + else: + pnode.insert(0, nodes.paragraph('', '', add_text)) + return [pnode] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -108,10 +138,12 @@ finally: f.close() + # Support for checking for suspicious markup import suspicious + # Support for documenting Opcodes import re @@ -134,6 +166,7 @@ def setup(app): app.add_role('issue', issue_role) + app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', Modified: python/branches/release31-maint/Doc/tools/sphinxext/static/basic.css ============================================================================== --- python/branches/release31-maint/Doc/tools/sphinxext/static/basic.css (original) +++ python/branches/release31-maint/Doc/tools/sphinxext/static/basic.css Tue Oct 27 21:24:45 2009 @@ -345,6 +345,21 @@ background-color: #ffa } +.impl-detail { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; + border: 1px solid #ccc; +} + +.impl-detail .compound-first { + margin-top: 0; +} + +.impl-detail .compound-last { + margin-bottom: 0; +} + /* -- code displays --------------------------------------------------------- */ pre { @@ -405,7 +420,7 @@ div.document, div.documentwrapper, div.bodywrapper { - margin: 0; + margin: 0 !important; width: 100%; } Modified: python/branches/release31-maint/Doc/tutorial/index.rst ============================================================================== --- python/branches/release31-maint/Doc/tutorial/index.rst (original) +++ python/branches/release31-maint/Doc/tutorial/index.rst Tue Oct 27 21:24:45 2009 @@ -28,18 +28,17 @@ interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. -For a description of standard objects and modules, see the Python Library -Reference document. The Python Reference Manual gives a more formal definition -of the language. To write extensions in C or C++, read Extending and Embedding -the Python Interpreter and Python/C API Reference. There are also several books -covering Python in depth. +For a description of standard objects and modules, see :ref:`library-index`. +:ref:`reference-index` gives a more formal definition of the language. To write +extensions in C or C++, read :ref:`extending-index` and +:ref:`c-api-index`. There are also several books covering Python in depth. This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the -various Python library modules described in the Python Library Reference. +various Python library modules described in :ref:`library-index`. The :ref:`glossary` is also worth going through. Modified: python/branches/release31-maint/Doc/using/cmdline.rst ============================================================================== --- python/branches/release31-maint/Doc/using/cmdline.rst (original) +++ python/branches/release31-maint/Doc/using/cmdline.rst Tue Oct 27 21:24:45 2009 @@ -8,7 +8,7 @@ The CPython interpreter scans the command line and the environment for various settings. -.. note:: +.. impl-detail:: Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. Modified: python/branches/release31-maint/Doc/using/windows.rst ============================================================================== --- python/branches/release31-maint/Doc/using/windows.rst (original) +++ python/branches/release31-maint/Doc/using/windows.rst Tue Oct 27 21:24:45 2009 @@ -67,7 +67,7 @@ `ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Python Enthought Edition `_ +`Enthought Python Distribution `_ Popular modules (such as PyWin32) with their respective documentation, tool suite for building extensible python applications @@ -221,8 +221,7 @@ * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces `PythonWin `_ + `MingW -- Python extensions `_ by Trent Apted et al, 2007 Modified: python/branches/release31-maint/Doc/whatsnew/2.0.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.0.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.0.rst Tue Oct 27 21:24:45 2009 @@ -572,8 +572,7 @@ mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still ``'win32'`` on Win64 because it seems that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) PythonWin also supports Windows CE; see the -Python CE page at http://starship.python.net/crew/mhammond/ce/ for more -information. +Python CE page at http://pythonce.sourceforge.net/ for more information. Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify "configure --with-dyld --with-suffix=.x". @@ -1041,8 +1040,8 @@ to include SSL support, which adds an additional function to the :mod:`socket` module: :func:`socket.ssl(socket, keyfile, certfile)`, which takes a socket object and returns an SSL socket. The :mod:`httplib` and :mod:`urllib` modules -were also changed to support "https://" URLs, though no one has implemented FTP -or SMTP over SSL. +were also changed to support ``https://`` URLs, though no one has implemented +FTP or SMTP over SSL. The :mod:`httplib` module has been rewritten by Greg Stein to support HTTP/1.1. Backward compatibility with the 1.5 version of :mod:`httplib` is provided, Modified: python/branches/release31-maint/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.2.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.2.rst Tue Oct 27 21:24:45 2009 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso:: +.. seealso (now defunct) http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and @@ -49,14 +49,14 @@ complicated section of this article, I'll provide an overview of the changes and offer some comments. -A long time ago I wrote a Web page (http://www.amk.ca/python/writing/warts.html) -listing flaws in Python's design. One of the most significant flaws was that -it's impossible to subclass Python types implemented in C. In particular, it's -not possible to subclass built-in types, so you can't just subclass, say, lists -in order to add a single useful method to them. The :mod:`UserList` module -provides a class that supports all of the methods of lists and that can be -subclassed further, but there's lots of C code that expects a regular Python -list and won't accept a :class:`UserList` instance. +A long time ago I wrote a Web page listing flaws in Python's design. One of the +most significant flaws was that it's impossible to subclass Python types +implemented in C. In particular, it's not possible to subclass built-in types, +so you can't just subclass, say, lists in order to add a single useful method to +them. The :mod:`UserList` module provides a class that supports all of the +methods of lists and that can be subclassed further, but there's lots of C code +that expects a regular Python list and won't accept a :class:`UserList` +instance. Python 2.2 fixes this, and in the process adds some exciting new capabilities. A brief summary: Modified: python/branches/release31-maint/Doc/whatsnew/2.3.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.3.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.3.rst Tue Oct 27 21:24:45 2009 @@ -1855,10 +1855,10 @@ .. seealso:: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c - For the full details of the pymalloc implementation, see the comments at the top - of the file :file:`Objects/obmalloc.c` in the Python source code. The above - link points to the file within the SourceForge CVS browser. + http://svn.python.org/view/python/trunk/Objects/obmalloc.c + For the full details of the pymalloc implementation, see the comments at + the top of the file :file:`Objects/obmalloc.c` in the Python source code. + The above link points to the file within the python.org SVN browser. .. ====================================================================== Modified: python/branches/release31-maint/Doc/whatsnew/2.4.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.4.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.4.rst Tue Oct 27 21:24:45 2009 @@ -680,9 +680,6 @@ Written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. - http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html - A more detailed overview of the IEEE-754 representation. - http://www.lahey.com/float.htm The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. @@ -756,7 +753,7 @@ :ctype:`double` to an ASCII string. The code for these functions came from the GLib library -(http://developer.gnome.org/arch/gtk/glib.html), whose developers kindly +(http://library.gnome.org/devel/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. Modified: python/branches/release31-maint/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/release31-maint/Doc/whatsnew/2.6.rst (original) +++ python/branches/release31-maint/Doc/whatsnew/2.6.rst Tue Oct 27 21:24:45 2009 @@ -1828,7 +1828,7 @@ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol available, instead of restricting itself to protocol 1. - (Contributed by W. Barnes; :issue:`1551443`.) + (Contributed by W. Barnes.) * The :mod:`cgi` module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions @@ -2977,7 +2977,7 @@ * The BerkeleyDB module now has a C API object, available as ``bsddb.db.api``. This object can be used by other C extensions that wish to use the :mod:`bsddb` module for their own purposes. - (Contributed by Duncan Grisby; :issue:`1551895`.) + (Contributed by Duncan Grisby.) * The new buffer interface, previously described in `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__, Modified: python/branches/release31-maint/Lib/threading.py ============================================================================== --- python/branches/release31-maint/Lib/threading.py (original) +++ python/branches/release31-maint/Lib/threading.py Tue Oct 27 21:24:45 2009 @@ -119,7 +119,7 @@ def release(self): if self._owner is not current_thread(): - raise RuntimeError("cannot release un-aquired lock") + raise RuntimeError("cannot release un-acquired lock") self._count = count = self._count - 1 if not count: self._owner = None @@ -211,7 +211,7 @@ def wait(self, timeout=None): if not self._is_owned(): - raise RuntimeError("cannot wait on un-aquired lock") + raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() waiter.acquire() self._waiters.append(waiter) @@ -253,7 +253,7 @@ def notify(self, n=1): if not self._is_owned(): - raise RuntimeError("cannot notify on un-aquired lock") + raise RuntimeError("cannot notify on un-acquired lock") __waiters = self._waiters waiters = __waiters[:n] if not waiters: Modified: python/branches/release31-maint/Lib/warnings.py ============================================================================== --- python/branches/release31-maint/Lib/warnings.py (original) +++ python/branches/release31-maint/Lib/warnings.py Tue Oct 27 21:24:45 2009 @@ -32,7 +32,14 @@ append=False): """Insert an entry into the list of warnings filters (at the front). - Use assertions to check that all arguments have the right type.""" + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'message' -- a regex that the warning message must match + 'category' -- a class that the warning must be a subclass of + 'module' -- a regex that the module name must match + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters + """ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) @@ -53,6 +60,11 @@ """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'category' -- a class that the warning must be a subclass of + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters """ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) Modified: python/branches/release31-maint/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/release31-maint/Modules/_ctypes/_ctypes.c (original) +++ python/branches/release31-maint/Modules/_ctypes/_ctypes.c Tue Oct 27 21:24:45 2009 @@ -1865,16 +1865,15 @@ } fmt = _ctypes_get_fielddesc(proto_str); if (fmt == NULL) { - Py_DECREF((PyObject *)result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", proto_str); - return NULL; + goto error; } stgdict = (StgDictObject *)PyObject_CallObject( (PyObject *)&PyCStgDict_Type, NULL); if (!stgdict) - return NULL; + goto error; stgdict->ffi_type_pointer = *fmt->pffi_type; stgdict->align = fmt->pffi_type->alignment; @@ -1889,6 +1888,7 @@ #endif if (stgdict->format == NULL) { Py_DECREF(result); + Py_DECREF(proto); Py_DECREF((PyObject *)stgdict); return NULL; } Modified: python/branches/release31-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release31-maint/Objects/unicodeobject.c (original) +++ python/branches/release31-maint/Objects/unicodeobject.c Tue Oct 27 21:24:45 2009 @@ -7708,10 +7708,10 @@ } PyDoc_STRVAR(join__doc__, - "S.join(sequence) -> str\n\ + "S.join(iterable) -> str\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject* unicode_join(PyObject *self, PyObject *data) Modified: python/branches/release31-maint/Python/codecs.c ============================================================================== --- python/branches/release31-maint/Python/codecs.c (original) +++ python/branches/release31-maint/Python/codecs.c Tue Oct 27 21:24:45 2009 @@ -957,7 +957,9 @@ { "strict_errors", strict_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'strict' error handling, which " + "raises a UnicodeError on coding errors.") } }, { @@ -965,7 +967,9 @@ { "ignore_errors", ignore_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'ignore' error handling, which " + "ignores malformed data and continues.") } }, { @@ -973,7 +977,9 @@ { "replace_errors", replace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'replace' error handling, which " + "replaces malformed data with a replacement marker.") } }, { @@ -981,7 +987,10 @@ { "xmlcharrefreplace_errors", xmlcharrefreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'xmlcharrefreplace' error handling, " + "which replaces an unencodable character with the " + "appropriate XML character reference.") } }, { @@ -989,7 +998,10 @@ { "backslashreplace_errors", backslashreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'backslashreplace' error handling, " + "which replaces an unencodable character with a " + "backslashed escape sequence.") } }, { From python-checkins at python.org Tue Oct 27 21:25:20 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:25:20 -0000 Subject: [Python-checkins] r75864 - python/branches/release31-maint Message-ID: Author: georg.brandl Date: Tue Oct 27 21:25:19 2009 New Revision: 75864 Log: Blocked revisions 74611,74623,74659,75243 via svnmerge ................ r74611 | georg.brandl | 2009-08-31 22:06:09 +0200 (Mo, 31 Aug 2009) | 9 lines Recorded merge of revisions 74608 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74608 | senthil.kumaran | 2009-08-31 18:40:27 +0200 (Mo, 31 Aug 2009) | 3 lines Doc fix for the issue2637. ........ ................ r74623 | georg.brandl | 2009-09-01 10:12:13 +0200 (Di, 01 Sep 2009) | 1 line Remove old news entry that got merged. ................ r74659 | georg.brandl | 2009-09-04 19:13:13 +0200 (Fr, 04 Sep 2009) | 13 lines Recorded merge of revisions 74655-74656 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74655 | chris.withers | 2009-09-04 18:12:32 +0200 (Fr, 04 Sep 2009) | 2 lines Fixes issue #6838: use a list to accumulate the value instead of repeatedly concatenating strings. ........ r74656 | chris.withers | 2009-09-04 18:32:22 +0200 (Fr, 04 Sep 2009) | 1 line news entry matching r74655 ........ ................ r75243 | benjamin.peterson | 2009-10-04 22:19:21 +0200 (So, 04 Okt 2009) | 17 lines Merged revisions 74865,75175,75180 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r74865 | georg.brandl | 2009-09-17 02:49:37 -0500 (Thu, 17 Sep 2009) | 1 line #6912: add "with" block support to pindent. ........ r75175 | georg.brandl | 2009-10-01 15:11:14 -0500 (Thu, 01 Oct 2009) | 1 line Fix some weird whitespace and two other overlong lines. ........ r75180 | georg.brandl | 2009-10-01 15:59:31 -0500 (Thu, 01 Oct 2009) | 1 line #7031: Add TestCase.assertIsInstance and negated method. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 21:49:00 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 27 Oct 2009 20:49:00 -0000 Subject: [Python-checkins] r75865 - sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Message-ID: Author: benjamin.peterson Date: Tue Oct 27 21:49:00 2009 New Revision: 75865 Log: explain reason for warning Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_map.py ============================================================================== --- sandbox/trunk/2to3/lib2to3/fixes/fix_map.py (original) +++ sandbox/trunk/2to3/lib2to3/fixes/fix_map.py Tue Oct 27 21:49:00 2009 @@ -78,7 +78,8 @@ args.children[0].type == token.NAME and \ args.children[0].value == "None": self.warning(node, "cannot convert map(None, ...) " - "with multiple arguments") + "with multiple arguments because map() " + "now truncates to the shortest sequence") return if in_special_context(node): return None From python-checkins at python.org Tue Oct 27 21:52:02 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:52:02 -0000 Subject: [Python-checkins] r75866 - in python/trunk: Lib/test/regrtest.py Makefile.pre.in Message-ID: Author: georg.brandl Date: Tue Oct 27 21:52:02 2009 New Revision: 75866 Log: Add a regrtest option to re-run in verbose mode immediately after a test fails, and use that option on the buildbots. Modified: python/trunk/Lib/test/regrtest.py python/trunk/Makefile.pre.in Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Tue Oct 27 21:52:02 2009 @@ -10,6 +10,7 @@ -v: verbose -- run tests in verbose mode with output to stdout -w: verbose2 -- re-run failed tests in verbose mode +-W: verbose3 -- re-run failed tests in verbose mode immediately -q: quiet -- don't print anything except if a test fails -x: exclude -- arguments are tests to *exclude* -s: single -- run only a single test (see below) @@ -195,7 +196,7 @@ exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, - random_seed=None, use_mp=None): + random_seed=None, use_mp=None, verbose3=False): """Execute a test suite. This also parses command-line options and modifies its behavior @@ -220,14 +221,12 @@ test_support.record_original_stdout(sys.stdout) try: - opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:j:', - ['help', 'verbose', 'quiet', 'exclude', - 'single', 'slow', 'random', 'fromfile', - 'findleaks', 'use=', 'threshold=', 'trace', - 'coverdir=', 'nocoverdir', 'runleaks', - 'huntrleaks=', 'verbose2', 'memlimit=', - 'randseed=', 'multiprocess=', 'slaveargs=', - ]) + opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wWM:j:', + ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', + 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', + 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', + 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', + 'multiprocess=', 'slaveargs=']) except getopt.error, msg: usage(2, msg) @@ -243,6 +242,8 @@ verbose += 1 elif o in ('-w', '--verbose2'): verbose2 = True + elif o in ('-W', '--verbose3'): + verbose3 = True elif o in ('-q', '--quiet'): quiet = True; verbose = 0 @@ -396,14 +397,17 @@ test_times.append((test_time, test)) if ok > 0: good.append(test) + return 'good' elif -2 < ok <= 0: bad.append(test) if ok == -1: environment_changed.append(test) + return 'bad' else: skipped.append(test) if ok == -3: resource_denieds.append(test) + return 'skipped' if use_mp: from threading import Thread @@ -479,7 +483,10 @@ try: result = runtest(test, verbose, quiet, testdir, huntrleaks) - accumulate_result(test, result) + which = accumulate_result(test, result) + if verbose3 and which == 'bad': + print "Re-running test %r in verbose mode" % test + runtest(test, True, quiet, testdir, huntrleaks) except KeyboardInterrupt: # print a newline separate from the ^C print Modified: python/trunk/Makefile.pre.in ============================================================================== --- python/trunk/Makefile.pre.in (original) +++ python/trunk/Makefile.pre.in Tue Oct 27 21:52:02 2009 @@ -716,7 +716,7 @@ - at if which pybuildbot.identify >/dev/null 2>&1; then \ pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \ fi - $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw + $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rwW QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \ test_multibytecodec test_urllib2_localnet test_itertools \ From python-checkins at python.org Tue Oct 27 21:55:45 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 20:55:45 -0000 Subject: [Python-checkins] r75867 - python/trunk/Lib/test/regrtest.py Message-ID: Author: georg.brandl Date: Tue Oct 27 21:55:44 2009 New Revision: 75867 Log: Reformat the regrtest command-line option help and group the options into sections. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Tue Oct 27 21:55:44 2009 @@ -8,26 +8,41 @@ Command line options: --v: verbose -- run tests in verbose mode with output to stdout --w: verbose2 -- re-run failed tests in verbose mode --W: verbose3 -- re-run failed tests in verbose mode immediately --q: quiet -- don't print anything except if a test fails --x: exclude -- arguments are tests to *exclude* --s: single -- run only a single test (see below) --S: slow -- print the slowest 10 tests --r: random -- randomize test execution order --f: fromfile -- read names of tests to run from a file (see below) --l: findleaks -- if GC is available detect tests that leak memory --u: use -- specify which special resource intensive tests to run --h: help -- print this text and exit --t: threshold -- call gc.set_threshold(N) --T: coverage -- turn on code coverage using the trace module --D: coverdir -- Directory where coverage files are put --N: nocoverdir -- Put coverage files alongside modules --L: runleaks -- run the leaks(1) command just before exit --R: huntrleaks -- search for reference leaks (needs debug build, v. slow) --M: memlimit -- run very large memory-consuming tests --j: multiprocess -- run several processes at once +-h/--help -- print this text and exit + +Verbosity + +-v/--verbose -- run tests in verbose mode with output to stdout +-w/--verbose2 -- re-run failed tests in verbose mode +-W/--verbose3 -- re-run failed tests in verbose mode immediately +-q/--quiet -- don't print anything except if a test fails +-S/--slow -- print the slowest 10 tests + +Selecting tests + +-r/--random -- randomize test execution order +-f/--fromfile -- read names of tests to run from a file (see below) +-x/--exclude -- arguments are tests to *exclude* +-s/--single -- run only a single test (see below) +-u/--use RES1,RES2,... + -- specify which special resource intensive tests to run +-M/--memlimit LIMIT + -- run very large memory-consuming tests + +Special runs + +-l/--findleaks -- if GC is available detect tests that leak memory +-L/--runleaks -- run the leaks(1) command just before exit +-R/--huntrleaks RUNCOUNTS + -- search for reference leaks (needs debug build, v. slow) +-j/--multiprocess PROCESSES + -- run PROCESSES processes at once +-T/--coverage -- turn on code coverage using the trace module +-D/--coverdir DIRECTORY + -- Directory where coverage files are put +-N/--nocoverdir -- Put coverage files alongside modules +-t/--threshold THRESHOLD + -- call gc.set_threshold(THRESHOLD) If non-option arguments are present, they are names for tests to run, unless -x is given, in which case they are names for tests not to run. From python-checkins at python.org Tue Oct 27 21:59:18 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 27 Oct 2009 20:59:18 -0000 Subject: [Python-checkins] r75868 - python/trunk/Lib/test/test_ast.py Message-ID: Author: benjamin.peterson Date: Tue Oct 27 21:59:18 2009 New Revision: 75868 Log: test expect base classes Modified: python/trunk/Lib/test/test_ast.py Modified: python/trunk/Lib/test/test_ast.py ============================================================================== --- python/trunk/Lib/test/test_ast.py (original) +++ python/trunk/Lib/test/test_ast.py Tue Oct 27 21:59:18 2009 @@ -161,6 +161,14 @@ im = ast.parse("from . import y").body[0] self.assertIsNone(im.module) + def test_base_classes(self): + self.assertTrue(issubclass(ast.For, ast.stmt)) + self.assertTrue(issubclass(ast.Name, ast.expr)) + self.assertTrue(issubclass(ast.stmt, ast.AST)) + self.assertTrue(issubclass(ast.expr, ast.AST)) + self.assertTrue(issubclass(ast.comprehension, ast.AST)) + self.assertTrue(issubclass(ast.Gt, ast.AST)) + def test_nodeclasses(self): x = ast.BinOp(1, 2, 3, lineno=0) self.assertEquals(x.left, 1) From python-checkins at python.org Tue Oct 27 22:02:11 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 21:02:11 -0000 Subject: [Python-checkins] r75869 - in python/branches/py3k: Lib/test/regrtest.py Makefile.pre.in Message-ID: Author: georg.brandl Date: Tue Oct 27 22:02:11 2009 New Revision: 75869 Log: Merged revisions 75866-75867 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75866 | georg.brandl | 2009-10-27 21:52:02 +0100 (Di, 27 Okt 2009) | 1 line Add a regrtest option to re-run in verbose mode immediately after a test fails, and use that option on the buildbots. ........ r75867 | georg.brandl | 2009-10-27 21:55:44 +0100 (Di, 27 Okt 2009) | 1 line Reformat the regrtest command-line option help and group the options into sections. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Makefile.pre.in Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Tue Oct 27 22:02:11 2009 @@ -8,27 +8,43 @@ Command line options: --v: verbose -- run tests in verbose mode with output to stdout --w: verbose2 -- re-run failed tests in verbose mode --d: debug -- print traceback for failed tests --q: quiet -- don't print anything except if a test fails --x: exclude -- arguments are tests to *exclude* --s: single -- run only a single test (see below) --S: slow -- print the slowest 10 tests --r: random -- randomize test execution order --f: fromfile -- read names of tests to run from a file (see below) --l: findleaks -- if GC is available detect tests that leak memory --u: use -- specify which special resource intensive tests to run --h: help -- print this text and exit --t: threshold -- call gc.set_threshold(N) --T: coverage -- turn on code coverage using the trace module --D: coverdir -- Directory where coverage files are put --N: nocoverdir -- Put coverage files alongside modules --L: runleaks -- run the leaks(1) command just before exit --R: huntrleaks -- search for reference leaks (needs debug build, v. slow) --M: memlimit -- run very large memory-consuming tests --n: nowindows -- suppress error message boxes on Windows --j: multiprocess -- run several processes at once +-h/--help -- print this text and exit + +Verbosity + +-v/--verbose -- run tests in verbose mode with output to stdout +-w/--verbose2 -- re-run failed tests in verbose mode +-W/--verbose3 -- re-run failed tests in verbose mode immediately +-d/--debug -- print traceback for failed tests +-q/--quiet -- don't print anything except if a test fails +-S/--slow -- print the slowest 10 tests + +Selecting tests + +-r/--random -- randomize test execution order +-f/--fromfile -- read names of tests to run from a file (see below) +-x/--exclude -- arguments are tests to *exclude* +-s/--single -- run only a single test (see below) +-u/--use RES1,RES2,... + -- specify which special resource intensive tests to run +-M/--memlimit LIMIT + -- run very large memory-consuming tests + +Special runs + +-l/--findleaks -- if GC is available detect tests that leak memory +-L/--runleaks -- run the leaks(1) command just before exit +-R/--huntrleaks RUNCOUNTS + -- search for reference leaks (needs debug build, v. slow) +-j/--multiprocess PROCESSES + -- run PROCESSES processes at once +-T/--coverage -- turn on code coverage using the trace module +-D/--coverdir DIRECTORY + -- Directory where coverage files are put +-N/--nocoverdir -- Put coverage files alongside modules +-t/--threshold THRESHOLD + -- call gc.set_threshold(THRESHOLD) +-n/--nowindows -- suppress error message boxes on Windows If non-option arguments are present, they are names for tests to run, unless -x is given, in which case they are names for tests not to run. @@ -193,7 +209,7 @@ exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, - random_seed=None, use_mp=None): + random_seed=None, use_mp=None, verbose3=False): """Execute a test suite. This also parses command-line options and modifies its behavior @@ -219,15 +235,12 @@ support.record_original_stdout(sys.stdout) try: - opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:wM:nj:', - ['help', 'verbose', 'quiet', 'exclude', - 'single', 'slow', 'random', 'fromfile', - 'findleaks', 'use=', 'threshold=', 'trace', - 'coverdir=', 'nocoverdir', 'runleaks', - 'huntrleaks=', 'verbose2', 'memlimit=', - 'debug', 'start=', 'nowindows', - 'randseed=', 'multiprocess=', 'slaveargs=', - ]) + opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:wWM:nj:', + ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', + 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', + 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', + 'runleaks', 'huntrleaks=', 'memlimit=', 'debug', 'start=', + 'nowindows', 'randseed=', 'multiprocess=', 'slaveargs=']) except getopt.error as msg: usage(msg) @@ -248,6 +261,8 @@ verbose2 = True elif o in ('-d', '--debug'): debug = True + elif o in ('-W', '--verbose3'): + verbose3 = True elif o in ('-q', '--quiet'): quiet = True; verbose = 0 @@ -430,14 +445,17 @@ test_times.append((test_time, test)) if ok > 0: good.append(test) + return 'good' elif -2 < ok <= 0: bad.append(test) if ok == -1: environment_changed.append(test) + return 'bad' else: skipped.append(test) if ok == -3: resource_denieds.append(test) + return 'skipped' if use_mp: from threading import Thread @@ -514,7 +532,10 @@ try: result = runtest(test, verbose, quiet, testdir, huntrleaks, debug) - accumulate_result(test, result) + which = accumulate_result(test, result) + if verbose3 and which == 'bad': + print("Re-running test {} in verbose mode".format(test)) + runtest(test, True, quiet, testdir, huntrleaks, debug) except KeyboardInterrupt: # print a newline separate from the ^C print() Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Tue Oct 27 22:02:11 2009 @@ -735,7 +735,7 @@ - at if which pybuildbot.identify >/dev/null 2>&1; then \ pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \ fi - $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw + $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rwW QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \ test_multibytecodec test_urllib2_localnet test_itertools \ From python-checkins at python.org Tue Oct 27 22:14:51 2009 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 27 Oct 2009 21:14:51 -0000 Subject: [Python-checkins] r75870 - python/branches/py3k/Modules/_testcapimodule.c Message-ID: Author: benjamin.peterson Date: Tue Oct 27 22:14:50 2009 New Revision: 75870 Log: remove shadowing declartion Modified: python/branches/py3k/Modules/_testcapimodule.c Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Tue Oct 27 22:14:50 2009 @@ -627,7 +627,6 @@ PyObject *tuple, *obj; Py_UNICODE *value; Py_ssize_t len; - int x; /* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */ /* Just use the macro and check that it compiles */ From python-checkins at python.org Tue Oct 27 22:20:27 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 21:20:27 -0000 Subject: [Python-checkins] r75871 - in python/trunk: Lib/test/test_site.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Tue Oct 27 22:20:27 2009 New Revision: 75871 Log: Issue #7218: Fix test_site for win32 Modified: python/trunk/Lib/test/test_site.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_site.py ============================================================================== --- python/trunk/Lib/test/test_site.py (original) +++ python/trunk/Lib/test/test_site.py Tue Oct 27 22:20:27 2009 @@ -169,7 +169,7 @@ else: self.assertTrue(len(dirs), 2) self.assertEquals(dirs[0], 'xoxo') - wanted = os.path.join('xoxo', 'Lib', 'site-packages') + wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEquals(dirs[1], wanted) # let's try the specific Apple location Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Oct 27 22:20:27 2009 @@ -427,6 +427,9 @@ Library ------- +- Issue #7218: Fix test_site for win32, the directory comparison was done with + an uppercase. + - Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. From python-checkins at python.org Tue Oct 27 22:22:06 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 21:22:06 -0000 Subject: [Python-checkins] r75872 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Tue Oct 27 22:22:06 2009 New Revision: 75872 Log: Blocked revisions 75871 via svnmerge ........ r75871 | tarek.ziade | 2009-10-27 22:20:27 +0100 (Tue, 27 Oct 2009) | 1 line Issue #7218: Fix test_site for win32 ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 22:24:21 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 21:24:21 -0000 Subject: [Python-checkins] r75873 - in python/branches/py3k: Lib/test/test_site.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Tue Oct 27 22:24:21 2009 New Revision: 75873 Log: Merged revisions 75871 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75871 | tarek.ziade | 2009-10-27 22:20:27 +0100 (Tue, 27 Oct 2009) | 1 line Issue #7218: Fix test_site for win32 ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_site.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/test/test_site.py ============================================================================== --- python/branches/py3k/Lib/test/test_site.py (original) +++ python/branches/py3k/Lib/test/test_site.py Tue Oct 27 22:24:21 2009 @@ -168,7 +168,7 @@ else: self.assertTrue(len(dirs), 2) self.assertEquals(dirs[0], 'xoxo') - wanted = os.path.join('xoxo', 'Lib', 'site-packages') + wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEquals(dirs[1], wanted) # let's try the specific Apple location Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Oct 27 22:24:21 2009 @@ -117,6 +117,9 @@ Library ------- +- Issue #7218: Fix test_site for win32, the directory comparison was done with + an uppercase. + - Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. From python-checkins at python.org Tue Oct 27 22:27:24 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 21:27:24 -0000 Subject: [Python-checkins] r75874 - python/trunk/Lib/test/test_socketserver.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 22:27:24 2009 New Revision: 75874 Log: Reduce the probability of refleaks in test_socketserver. Not completely suppressed though, see issue #7222. Modified: python/trunk/Lib/test/test_socketserver.py Modified: python/trunk/Lib/test/test_socketserver.py ============================================================================== --- python/trunk/Lib/test/test_socketserver.py (original) +++ python/trunk/Lib/test/test_socketserver.py Tue Oct 27 22:27:24 2009 @@ -16,7 +16,7 @@ import SocketServer import test.test_support -from test.test_support import reap_children, verbose +from test.test_support import reap_children, reap_threads, verbose from test.test_support import TESTFN as TEST_FILE test.test_support.requires("network") @@ -122,6 +122,7 @@ self.assertEquals(server.server_address, server.socket.getsockname()) return server + @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) From python-checkins at python.org Tue Oct 27 22:29:35 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 21:29:35 -0000 Subject: [Python-checkins] r75875 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Tue Oct 27 22:29:35 2009 New Revision: 75875 Log: Blocked revisions 75873 via svnmerge ................ r75873 | tarek.ziade | 2009-10-27 22:24:21 +0100 (Tue, 27 Oct 2009) | 9 lines Merged revisions 75871 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75871 | tarek.ziade | 2009-10-27 22:20:27 +0100 (Tue, 27 Oct 2009) | 1 line Issue #7218: Fix test_site for win32 ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Tue Oct 27 22:32:38 2009 From: python-checkins at python.org (antoine.pitrou) Date: Tue, 27 Oct 2009 21:32:38 -0000 Subject: [Python-checkins] r75876 - in python/branches/py3k: Lib/test/test_socketserver.py Message-ID: Author: antoine.pitrou Date: Tue Oct 27 22:32:38 2009 New Revision: 75876 Log: Merged revisions 75874 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75874 | antoine.pitrou | 2009-10-27 22:27:24 +0100 (mar., 27 oct. 2009) | 4 lines Reduce the probability of refleaks in test_socketserver. Not completely suppressed though, see issue #7222. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_socketserver.py Modified: python/branches/py3k/Lib/test/test_socketserver.py ============================================================================== --- python/branches/py3k/Lib/test/test_socketserver.py (original) +++ python/branches/py3k/Lib/test/test_socketserver.py Tue Oct 27 22:32:38 2009 @@ -16,7 +16,7 @@ import socketserver import test.support -from test.support import reap_children, verbose +from test.support import reap_children, reap_threads, verbose from test.support import TESTFN as TEST_FILE test.support.requires("network") @@ -122,6 +122,7 @@ self.assertEquals(server.server_address, server.socket.getsockname()) return server + @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) From python-checkins at python.org Tue Oct 27 22:37:48 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 21:37:48 -0000 Subject: [Python-checkins] r75877 - python/branches/py3k/Modules/_localemodule.c Message-ID: Author: georg.brandl Date: Tue Oct 27 22:37:48 2009 New Revision: 75877 Log: Only declare variable when it's used. Modified: python/branches/py3k/Modules/_localemodule.c Modified: python/branches/py3k/Modules/_localemodule.c ============================================================================== --- python/branches/py3k/Modules/_localemodule.c (original) +++ python/branches/py3k/Modules/_localemodule.c Tue Oct 27 22:37:48 2009 @@ -281,7 +281,9 @@ wchar_t *s, *buf = NULL; size_t n1, n2; PyObject *result = NULL; +#ifndef HAVE_USABLE_WCHAR_T Py_ssize_t i; +#endif if (!PyArg_ParseTuple(args, "u#:strxfrm", &s0, &n0)) return NULL; From python-checkins at python.org Tue Oct 27 22:39:08 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 21:39:08 -0000 Subject: [Python-checkins] r75878 - in python/branches/release31-maint: Modules/_localemodule.c Message-ID: Author: georg.brandl Date: Tue Oct 27 22:39:08 2009 New Revision: 75878 Log: Merged revisions 75877 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ........ r75877 | georg.brandl | 2009-10-27 22:37:48 +0100 (Di, 27 Okt 2009) | 1 line Only declare variable when it's used. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_localemodule.c Modified: python/branches/release31-maint/Modules/_localemodule.c ============================================================================== --- python/branches/release31-maint/Modules/_localemodule.c (original) +++ python/branches/release31-maint/Modules/_localemodule.c Tue Oct 27 22:39:08 2009 @@ -281,7 +281,9 @@ wchar_t *s, *buf = NULL; size_t n1, n2; PyObject *result = NULL; +#ifndef HAVE_USABLE_WCHAR_T Py_ssize_t i; +#endif if (!PyArg_ParseTuple(args, "u#:strxfrm", &s0, &n0)) return NULL; From python-checkins at python.org Tue Oct 27 22:48:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 21:48:21 -0000 Subject: [Python-checkins] r75879 - in python/trunk/Modules/_io: _iomodule.h bufferedio.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 22:48:20 2009 New Revision: 75879 Log: Silence gcc warnings when trying to print an off_t using "lld", on platforms where off_t has type long (e.g., 64-bit Linux). Modified: python/trunk/Modules/_io/_iomodule.h python/trunk/Modules/_io/bufferedio.c Modified: python/trunk/Modules/_io/_iomodule.h ============================================================================== --- python/trunk/Modules/_io/_iomodule.h (original) +++ python/trunk/Modules/_io/_iomodule.h Tue Oct 27 22:48:20 2009 @@ -75,6 +75,14 @@ * Offset type for positioning. */ +/* Printing a variable of type off_t correctly and without producing + compiler warnings is surprisingly painful. We identify an integer + type whose size matches off_t and then: (1) cast the off_t to that + integer type and (2) use the appropriate conversion specification + for printf. The cast is necessary: gcc complains about formatting + a long with "%lld" even when both long and long long have the same + precision. */ + #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -84,7 +92,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ - +# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ #else /* Other platforms use off_t */ @@ -95,18 +103,21 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" +# define PY_OFF_T_COMPAT long long #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN # define PY_PRIdOFF "ld" +# define PY_OFF_T_COMPAT long #elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) # define PyLong_AsOff_t PyLong_AsSsize_t # define PyLong_FromOff_t PyLong_FromSsize_t # define PY_OFF_T_MAX PY_SSIZE_T_MAX # define PY_OFF_T_MIN PY_SSIZE_T_MIN # define PY_PRIdOFF "zd" +# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/trunk/Modules/_io/bufferedio.c ============================================================================== --- python/trunk/Modules/_io/bufferedio.c (original) +++ python/trunk/Modules/_io/bufferedio.c Tue Oct 27 22:48:20 2009 @@ -581,7 +581,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; @@ -614,7 +614,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; From python-checkins at python.org Tue Oct 27 22:48:54 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 21:48:54 -0000 Subject: [Python-checkins] r75880 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 22:48:54 2009 New Revision: 75880 Log: Blocked revisions 75879 via svnmerge ........ r75879 | mark.dickinson | 2009-10-27 21:48:20 +0000 (Tue, 27 Oct 2009) | 3 lines Silence gcc warnings when trying to print an off_t using "lld", on platforms where off_t has type long (e.g., 64-bit Linux). ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 22:49:48 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 21:49:48 -0000 Subject: [Python-checkins] r75881 - in python/branches/py3k: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 22:49:48 2009 New Revision: 75881 Log: Merged revisions 75879 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75879 | mark.dickinson | 2009-10-27 21:48:20 +0000 (Tue, 27 Oct 2009) | 3 lines Silence gcc warnings when trying to print an off_t using "lld", on platforms where off_t has type long (e.g., 64-bit Linux). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/_iomodule.h python/branches/py3k/Modules/_io/bufferedio.c Modified: python/branches/py3k/Modules/_io/_iomodule.h ============================================================================== --- python/branches/py3k/Modules/_io/_iomodule.h (original) +++ python/branches/py3k/Modules/_io/_iomodule.h Tue Oct 27 22:49:48 2009 @@ -70,6 +70,14 @@ * Offset type for positioning. */ +/* Printing a variable of type off_t correctly and without producing + compiler warnings is surprisingly painful. We identify an integer + type whose size matches off_t and then: (1) cast the off_t to that + integer type and (2) use the appropriate conversion specification + for printf. The cast is necessary: gcc complains about formatting + a long with "%lld" even when both long and long long have the same + precision. */ + #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -79,7 +87,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ - +# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ #else /* Other platforms use off_t */ @@ -90,18 +98,21 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" +# define PY_OFF_T_COMPAT long long #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN # define PY_PRIdOFF "ld" +# define PY_OFF_T_COMPAT long #elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) # define PyLong_AsOff_t PyLong_AsSsize_t # define PyLong_FromOff_t PyLong_FromSsize_t # define PY_OFF_T_MAX PY_SSIZE_T_MAX # define PY_OFF_T_MIN PY_SSIZE_T_MIN # define PY_PRIdOFF "zd" +# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/py3k/Modules/_io/bufferedio.c ============================================================================== --- python/branches/py3k/Modules/_io/bufferedio.c (original) +++ python/branches/py3k/Modules/_io/bufferedio.c Tue Oct 27 22:49:48 2009 @@ -581,7 +581,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; @@ -614,7 +614,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; From python-checkins at python.org Tue Oct 27 22:51:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 21:51:51 -0000 Subject: [Python-checkins] r75882 - in python/branches/release31-maint: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Tue Oct 27 22:51:51 2009 New Revision: 75882 Log: Merged revisions 75881 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75881 | mark.dickinson | 2009-10-27 21:49:48 +0000 (Tue, 27 Oct 2009) | 10 lines Merged revisions 75879 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75879 | mark.dickinson | 2009-10-27 21:48:20 +0000 (Tue, 27 Oct 2009) | 3 lines Silence gcc warnings when trying to print an off_t using "lld", on platforms where off_t has type long (e.g., 64-bit Linux). ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_io/_iomodule.h python/branches/release31-maint/Modules/_io/bufferedio.c Modified: python/branches/release31-maint/Modules/_io/_iomodule.h ============================================================================== --- python/branches/release31-maint/Modules/_io/_iomodule.h (original) +++ python/branches/release31-maint/Modules/_io/_iomodule.h Tue Oct 27 22:51:51 2009 @@ -70,6 +70,14 @@ * Offset type for positioning. */ +/* Printing a variable of type off_t correctly and without producing + compiler warnings is surprisingly painful. We identify an integer + type whose size matches off_t and then: (1) cast the off_t to that + integer type and (2) use the appropriate conversion specification + for printf. The cast is necessary: gcc complains about formatting + a long with "%lld" even when both long and long long have the same + precision. */ + #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -79,7 +87,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ - +# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ #else /* Other platforms use off_t */ @@ -90,18 +98,21 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" +# define PY_OFF_T_COMPAT long long #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN # define PY_PRIdOFF "ld" +# define PY_OFF_T_COMPAT long #elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) # define PyLong_AsOff_t PyLong_AsSsize_t # define PyLong_FromOff_t PyLong_FromSsize_t # define PY_OFF_T_MAX PY_SSIZE_T_MAX # define PY_OFF_T_MIN PY_SSIZE_T_MIN # define PY_PRIdOFF "zd" +# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/release31-maint/Modules/_io/bufferedio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/bufferedio.c (original) +++ python/branches/release31-maint/Modules/_io/bufferedio.c Tue Oct 27 22:51:51 2009 @@ -581,7 +581,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; @@ -614,7 +614,7 @@ if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, "Raw stream returned invalid position %" PY_PRIdOFF, - n); + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; From python-checkins at python.org Tue Oct 27 23:09:33 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 22:09:33 -0000 Subject: [Python-checkins] r75883 - python/trunk/Lib/test/test_float.py Message-ID: Author: mark.dickinson Date: Tue Oct 27 23:09:33 2009 New Revision: 75883 Log: Test long inputs to float Modified: python/trunk/Lib/test/test_float.py Modified: python/trunk/Lib/test/test_float.py ============================================================================== --- python/trunk/Lib/test/test_float.py (original) +++ python/trunk/Lib/test/test_float.py Tue Oct 27 23:09:33 2009 @@ -32,6 +32,11 @@ self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) + # extra long strings should no longer be a problem + # (in 2.6, long unicode inputs to float raised ValueError) + float('.' + '1'*1000) + float(unicode('.' + '1'*1000)) + @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point From python-checkins at python.org Tue Oct 27 23:09:55 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 22:09:55 -0000 Subject: [Python-checkins] r75884 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Tue Oct 27 23:09:55 2009 New Revision: 75884 Log: Blocked revisions 75883 via svnmerge ........ r75883 | mark.dickinson | 2009-10-27 22:09:33 +0000 (Tue, 27 Oct 2009) | 1 line Test long inputs to float ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Tue Oct 27 23:12:20 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 22:12:20 -0000 Subject: [Python-checkins] r75885 - in python/branches/py3k: Lib/test/test_float.py Message-ID: Author: mark.dickinson Date: Tue Oct 27 23:12:20 2009 New Revision: 75885 Log: Merged revisions 75883 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75883 | mark.dickinson | 2009-10-27 22:09:33 +0000 (Tue, 27 Oct 2009) | 1 line Test long inputs to float ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_float.py Modified: python/branches/py3k/Lib/test/test_float.py ============================================================================== --- python/branches/py3k/Lib/test/test_float.py (original) +++ python/branches/py3k/Lib/test/test_float.py Tue Oct 27 23:12:20 2009 @@ -34,8 +34,12 @@ self.assertRaises(ValueError, float, ".") self.assertRaises(ValueError, float, "-.") self.assertEqual(float(b" \u0663.\u0661\u0664 ".decode('raw-unicode-escape')), 3.14) + # extra long strings should not be a problem + float(b'.' + b'1'*1000) + float('.' + '1'*1000) @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') + def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but From python-checkins at python.org Tue Oct 27 23:13:18 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 22:13:18 -0000 Subject: [Python-checkins] r75886 - in python/branches/release31-maint: Lib/test/test_float.py Message-ID: Author: mark.dickinson Date: Tue Oct 27 23:13:18 2009 New Revision: 75886 Log: Merged revisions 75885 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75885 | mark.dickinson | 2009-10-27 22:12:20 +0000 (Tue, 27 Oct 2009) | 9 lines Merged revisions 75883 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75883 | mark.dickinson | 2009-10-27 22:09:33 +0000 (Tue, 27 Oct 2009) | 1 line Test long inputs to float ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_float.py Modified: python/branches/release31-maint/Lib/test/test_float.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_float.py (original) +++ python/branches/release31-maint/Lib/test/test_float.py Tue Oct 27 23:13:18 2009 @@ -34,8 +34,12 @@ self.assertRaises(ValueError, float, ".") self.assertRaises(ValueError, float, "-.") self.assertEqual(float(b" \u0663.\u0661\u0664 ".decode('raw-unicode-escape')), 3.14) + # extra long strings should not be a problem + float(b'.' + b'1'*1000) + float('.' + '1'*1000) @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') + def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but From python-checkins at python.org Tue Oct 27 23:56:09 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 22:56:09 -0000 Subject: [Python-checkins] r75887 - python/trunk/Lib/test/test_builtin.py Message-ID: Author: georg.brandl Date: Tue Oct 27 23:56:09 2009 New Revision: 75887 Log: Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode. Modified: python/trunk/Lib/test/test_builtin.py Modified: python/trunk/Lib/test/test_builtin.py ============================================================================== --- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Tue Oct 27 23:56:09 2009 @@ -13,6 +13,7 @@ # count the number of test runs. # used to skip running test_execfile() multiple times +# and to create unique strings to intern in test_intern() numruns = 0 class Squares: @@ -646,7 +647,9 @@ def test_intern(self): self.assertRaises(TypeError, intern) - s = "never interned before" + # This fails if the test is run twice with a constant string, + # therefore append the run counter + s = "never interned before " + str(numruns) self.assertTrue(intern(s) is s) s2 = s.swapcase().swapcase() self.assertTrue(intern(s2) is s) From python-checkins at python.org Tue Oct 27 23:57:26 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 22:57:26 -0000 Subject: [Python-checkins] r75888 - in python/branches/release26-maint: Lib/test/test_builtin.py Message-ID: Author: georg.brandl Date: Tue Oct 27 23:57:25 2009 New Revision: 75888 Log: Merged revisions 75887 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75887 | georg.brandl | 2009-10-27 23:56:09 +0100 (Di, 27 Okt 2009) | 1 line Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_builtin.py Modified: python/branches/release26-maint/Lib/test/test_builtin.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_builtin.py (original) +++ python/branches/release26-maint/Lib/test/test_builtin.py Tue Oct 27 23:57:25 2009 @@ -13,6 +13,7 @@ # count the number of test runs. # used to skip running test_execfile() multiple times +# and to create unique strings to intern in test_intern() numruns = 0 class Squares: @@ -646,7 +647,9 @@ def test_intern(self): self.assertRaises(TypeError, intern) - s = "never interned before" + # This fails if the test is run twice with a constant string, + # therefore append the run counter + s = "never interned before " + str(numruns) self.assert_(intern(s) is s) s2 = s.swapcase().swapcase() self.assert_(intern(s2) is s) From python-checkins at python.org Wed Oct 28 00:00:29 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 23:00:29 -0000 Subject: [Python-checkins] r75889 - in python/branches/py3k: Lib/test/test_sys.py Message-ID: Author: georg.brandl Date: Wed Oct 28 00:00:28 2009 New Revision: 75889 Log: Merged revisions 75887 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75887 | georg.brandl | 2009-10-27 23:56:09 +0100 (Di, 27 Okt 2009) | 1 line Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_sys.py Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Wed Oct 28 00:00:28 2009 @@ -5,6 +5,11 @@ import subprocess import textwrap +# count the number of test runs, used to create unique +# strings to intern in test_intern() +numruns = 0 + + class SysModuleTest(unittest.TestCase): def setUp(self): @@ -383,8 +388,10 @@ self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding) def test_intern(self): + global numruns + numruns += 1 self.assertRaises(TypeError, sys.intern) - s = "never interned before" + s = "never interned before" + str(numruns) self.assertTrue(sys.intern(s) is s) s2 = s.swapcase().swapcase() self.assertTrue(sys.intern(s2) is s) From python-checkins at python.org Wed Oct 28 00:00:56 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 23:00:56 -0000 Subject: [Python-checkins] r75890 - python/branches/py3k/Lib/test/test_float.py Message-ID: Author: mark.dickinson Date: Wed Oct 28 00:00:56 2009 New Revision: 75890 Log: Remove extra blank line accidentally introduced in r75885 Modified: python/branches/py3k/Lib/test/test_float.py Modified: python/branches/py3k/Lib/test/test_float.py ============================================================================== --- python/branches/py3k/Lib/test/test_float.py (original) +++ python/branches/py3k/Lib/test/test_float.py Wed Oct 28 00:00:56 2009 @@ -39,7 +39,6 @@ float('.' + '1'*1000) @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') - def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but From python-checkins at python.org Wed Oct 28 00:01:31 2009 From: python-checkins at python.org (georg.brandl) Date: Tue, 27 Oct 2009 23:01:31 -0000 Subject: [Python-checkins] r75891 - in python/branches/release31-maint: Lib/test/test_sys.py Message-ID: Author: georg.brandl Date: Wed Oct 28 00:01:30 2009 New Revision: 75891 Log: Merged revisions 75889 via svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r75889 | georg.brandl | 2009-10-28 00:00:28 +0100 (Mi, 28 Okt 2009) | 9 lines Merged revisions 75887 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75887 | georg.brandl | 2009-10-27 23:56:09 +0100 (Di, 27 Okt 2009) | 1 line Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_sys.py Modified: python/branches/release31-maint/Lib/test/test_sys.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_sys.py (original) +++ python/branches/release31-maint/Lib/test/test_sys.py Wed Oct 28 00:01:30 2009 @@ -5,6 +5,11 @@ import subprocess import textwrap +# count the number of test runs, used to create unique +# strings to intern in test_intern() +numruns = 0 + + class SysModuleTest(unittest.TestCase): def setUp(self): @@ -379,8 +384,10 @@ self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding) def test_intern(self): + global numruns + numruns += 1 self.assertRaises(TypeError, sys.intern) - s = "never interned before" + s = "never interned before" + str(numruns) self.assertTrue(sys.intern(s) is s) s2 = s.swapcase().swapcase() self.assertTrue(sys.intern(s2) is s) From python-checkins at python.org Wed Oct 28 00:02:24 2009 From: python-checkins at python.org (mark.dickinson) Date: Tue, 27 Oct 2009 23:02:24 -0000 Subject: [Python-checkins] r75892 - in python/branches/release31-maint: Lib/test/test_float.py Message-ID: Author: mark.dickinson Date: Wed Oct 28 00:02:24 2009 New Revision: 75892 Log: Merged revisions 75890 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75890 | mark.dickinson | 2009-10-27 23:00:56 +0000 (Tue, 27 Oct 2009) | 1 line Remove extra blank line accidentally introduced in r75885 ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_float.py Modified: python/branches/release31-maint/Lib/test/test_float.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_float.py (original) +++ python/branches/release31-maint/Lib/test/test_float.py Wed Oct 28 00:02:24 2009 @@ -39,7 +39,6 @@ float('.' + '1'*1000) @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') - def test_float_with_comma(self): # set locale to something that doesn't use '.' for the decimal point # float must not accept the locale specific decimal point but From python-checkins at python.org Wed Oct 28 00:06:11 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 23:06:11 -0000 Subject: [Python-checkins] r75893 - in python/trunk: Doc/ACKS.txt Doc/distutils/builtdist.rst Doc/install/index.rst Lib/distutils/core.py Lib/distutils/dist.py Lib/distutils/tests/test_dist.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Wed Oct 28 00:06:10 2009 New Revision: 75893 Log: Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils Modified: python/trunk/Doc/ACKS.txt python/trunk/Doc/distutils/builtdist.rst python/trunk/Doc/install/index.rst python/trunk/Lib/distutils/core.py python/trunk/Lib/distutils/dist.py python/trunk/Lib/distutils/tests/test_dist.py python/trunk/Misc/NEWS Modified: python/trunk/Doc/ACKS.txt ============================================================================== --- python/trunk/Doc/ACKS.txt (original) +++ python/trunk/Doc/ACKS.txt Wed Oct 28 00:06:10 2009 @@ -207,6 +207,7 @@ * Mats Wichmann * Gerry Wiener * Timothy Wild + * Paul Winkler * Collin Winter * Blake Winton * Dan Wolfe Modified: python/trunk/Doc/distutils/builtdist.rst ============================================================================== --- python/trunk/Doc/distutils/builtdist.rst (original) +++ python/trunk/Doc/distutils/builtdist.rst Wed Oct 28 00:06:10 2009 @@ -241,7 +241,8 @@ configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`. If you distribute or package many Python module distributions, you might want to put options that apply to all of them in your personal Distutils configuration -file (:file:`~/.pydistutils.cfg`). +file (:file:`~/.pydistutils.cfg`). If you want to temporarily disable +this file, you can pass the --no-user-cfg option to setup.py. There are three steps to building a binary RPM package, all of which are handled automatically by the Distutils: Modified: python/trunk/Doc/install/index.rst ============================================================================== --- python/trunk/Doc/install/index.rst (original) +++ python/trunk/Doc/install/index.rst Wed Oct 28 00:06:10 2009 @@ -694,6 +694,9 @@ | local | :file:`setup.cfg` | \(3) | +--------------+-------------------------------------------------+-------+ +On all platforms, the "personal" file can be temporarily disabled by +passing the `--no-user-cfg` option. + Notes: (1) Modified: python/trunk/Lib/distutils/core.py ============================================================================== --- python/trunk/Lib/distutils/core.py (original) +++ python/trunk/Lib/distutils/core.py Wed Oct 28 00:06:10 2009 @@ -129,8 +129,9 @@ if _setup_stop_after == "config": return dist - # Parse the command line; any command-line errors are the end user's - # fault, so turn them into SystemExit to suppress tracebacks. + # Parse the command line and override config files; any + # command-line errors are the end user's fault, so turn them into + # SystemExit to suppress tracebacks. try: ok = dist.parse_command_line() except DistutilsArgError, msg: Modified: python/trunk/Lib/distutils/dist.py ============================================================================== --- python/trunk/Lib/distutils/dist.py (original) +++ python/trunk/Lib/distutils/dist.py Wed Oct 28 00:06:10 2009 @@ -56,7 +56,9 @@ ('quiet', 'q', "run quietly (turns verbosity off)"), ('dry-run', 'n', "don't actually do anything"), ('help', 'h', "show detailed help message"), - ] + ('no-user-cfg', None, + 'ignore pydistutils.cfg in your home directory'), + ] # 'common_usage' is a short (2-3 line) string describing the common # usage of the setup script. @@ -264,6 +266,22 @@ else: sys.stderr.write(msg + "\n") + # no-user-cfg is handled before other command line args + # because other args override the config files, and this + # one is needed before we can load the config files. + # If attrs['script_args'] wasn't passed, assume false. + # + # This also make sure we just look at the global options + self.want_user_cfg = True + + if self.script_args is not None: + for arg in self.script_args: + if not arg.startswith('-'): + break + if arg == '--no-user-cfg': + self.want_user_cfg = False + break + self.finalize_options() def get_option_dict(self, command): @@ -316,7 +334,10 @@ Distutils installation directory (ie. where the top-level Distutils __inst__.py file lives), a file in the user's home directory named .pydistutils.cfg on Unix and pydistutils.cfg - on Windows/Mac, and setup.cfg in the current directory. + on Windows/Mac; and setup.cfg in the current directory. + + The file in the user's home directory can be disabled with the + --no-user-cfg option. """ files = [] check_environ() @@ -336,15 +357,19 @@ user_filename = "pydistutils.cfg" # And look for the user config file - user_file = os.path.join(os.path.expanduser('~'), user_filename) - if os.path.isfile(user_file): - files.append(user_file) + if self.want_user_cfg: + user_file = os.path.join(os.path.expanduser('~'), user_filename) + if os.path.isfile(user_file): + files.append(user_file) # All platforms support local setup.cfg local_file = "setup.cfg" if os.path.isfile(local_file): files.append(local_file) + if DEBUG: + self.announce("using config files: %s" % ', '.join(files)) + return files def parse_config_files(self, filenames=None): Modified: python/trunk/Lib/distutils/tests/test_dist.py ============================================================================== --- python/trunk/Lib/distutils/tests/test_dist.py (original) +++ python/trunk/Lib/distutils/tests/test_dist.py Wed Oct 28 00:06:10 2009 @@ -209,6 +209,35 @@ kwargs = {'level': 'ok2'} self.assertRaises(ValueError, dist.announce, args, kwargs) + def test_find_config_files_disable(self): + # Ticket #1180: Allow user to disable their home config file. + temp_home = self.mkdtemp() + if os.name == 'posix': + user_filename = os.path.join(temp_home, ".pydistutils.cfg") + else: + user_filename = os.path.join(temp_home, "pydistutils.cfg") + + with open(user_filename, 'w') as f: + f.write('[distutils]\n') + + def _expander(path): + return temp_home + + old_expander = os.path.expanduser + os.path.expanduser = _expander + try: + d = distutils.dist.Distribution() + all_files = d.find_config_files() + + d = distutils.dist.Distribution(attrs={'script_args': + ['--no-user-cfg']}) + files = d.find_config_files() + finally: + os.path.expanduser = old_expander + + # make sure --no-user-cfg disables the user cfg file + self.assertEquals(len(all_files)-1, len(files)) + class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Oct 28 00:06:10 2009 @@ -427,6 +427,9 @@ Library ------- +- Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in + Distutils. + - Issue #7218: Fix test_site for win32, the directory comparison was done with an uppercase. From python-checkins at python.org Wed Oct 28 00:07:09 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 23:07:09 -0000 Subject: [Python-checkins] r75894 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Wed Oct 28 00:07:08 2009 New Revision: 75894 Log: Blocked revisions 75893 via svnmerge ........ r75893 | tarek.ziade | 2009-10-28 00:06:10 +0100 (Wed, 28 Oct 2009) | 1 line Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 00:12:02 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 23:12:02 -0000 Subject: [Python-checkins] r75895 - in python/branches/py3k: Doc/ACKS.txt Doc/distutils/builtdist.rst Doc/install/index.rst Lib/distutils/core.py Lib/distutils/dist.py Lib/distutils/tests/test_dist.py Misc/NEWS Message-ID: Author: tarek.ziade Date: Wed Oct 28 00:12:01 2009 New Revision: 75895 Log: Merged revisions 75893 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75893 | tarek.ziade | 2009-10-28 00:06:10 +0100 (Wed, 28 Oct 2009) | 1 line Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/distutils/builtdist.rst python/branches/py3k/Doc/install/index.rst python/branches/py3k/Lib/distutils/core.py python/branches/py3k/Lib/distutils/dist.py python/branches/py3k/Lib/distutils/tests/test_dist.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Wed Oct 28 00:12:01 2009 @@ -208,6 +208,7 @@ * Mats Wichmann * Gerry Wiener * Timothy Wild + * Paul Winkler * Collin Winter * Blake Winton * Dan Wolfe Modified: python/branches/py3k/Doc/distutils/builtdist.rst ============================================================================== --- python/branches/py3k/Doc/distutils/builtdist.rst (original) +++ python/branches/py3k/Doc/distutils/builtdist.rst Wed Oct 28 00:12:01 2009 @@ -241,7 +241,8 @@ configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`. If you distribute or package many Python module distributions, you might want to put options that apply to all of them in your personal Distutils configuration -file (:file:`~/.pydistutils.cfg`). +file (:file:`~/.pydistutils.cfg`). If you want to temporarily disable +this file, you can pass the --no-user-cfg option to setup.py. There are three steps to building a binary RPM package, all of which are handled automatically by the Distutils: Modified: python/branches/py3k/Doc/install/index.rst ============================================================================== --- python/branches/py3k/Doc/install/index.rst (original) +++ python/branches/py3k/Doc/install/index.rst Wed Oct 28 00:12:01 2009 @@ -691,6 +691,9 @@ | local | :file:`setup.cfg` | \(3) | +--------------+-------------------------------------------------+-------+ +On all platforms, the "personal" file can be temporarily disabled by +passing the `--no-user-cfg` option. + Notes: (1) Modified: python/branches/py3k/Lib/distutils/core.py ============================================================================== --- python/branches/py3k/Lib/distutils/core.py (original) +++ python/branches/py3k/Lib/distutils/core.py Wed Oct 28 00:12:01 2009 @@ -129,8 +129,9 @@ if _setup_stop_after == "config": return dist - # Parse the command line; any command-line errors are the end user's - # fault, so turn them into SystemExit to suppress tracebacks. + # Parse the command line and override config files; any + # command-line errors are the end user's fault, so turn them into + # SystemExit to suppress tracebacks. try: ok = dist.parse_command_line() except DistutilsArgError as msg: Modified: python/branches/py3k/Lib/distutils/dist.py ============================================================================== --- python/branches/py3k/Lib/distutils/dist.py (original) +++ python/branches/py3k/Lib/distutils/dist.py Wed Oct 28 00:12:01 2009 @@ -53,7 +53,9 @@ ('quiet', 'q', "run quietly (turns verbosity off)"), ('dry-run', 'n', "don't actually do anything"), ('help', 'h', "show detailed help message"), - ] + ('no-user-cfg', None, + 'ignore pydistutils.cfg in your home directory'), + ] # 'common_usage' is a short (2-3 line) string describing the common # usage of the setup script. @@ -260,6 +262,22 @@ else: sys.stderr.write(msg + "\n") + # no-user-cfg is handled before other command line args + # because other args override the config files, and this + # one is needed before we can load the config files. + # If attrs['script_args'] wasn't passed, assume false. + # + # This also make sure we just look at the global options + self.want_user_cfg = True + + if self.script_args is not None: + for arg in self.script_args: + if not arg.startswith('-'): + break + if arg == '--no-user-cfg': + self.want_user_cfg = False + break + self.finalize_options() def get_option_dict(self, command): @@ -311,7 +329,10 @@ Distutils installation directory (ie. where the top-level Distutils __inst__.py file lives), a file in the user's home directory named .pydistutils.cfg on Unix and pydistutils.cfg - on Windows/Mac, and setup.cfg in the current directory. + on Windows/Mac; and setup.cfg in the current directory. + + The file in the user's home directory can be disabled with the + --no-user-cfg option. """ files = [] check_environ() @@ -331,15 +352,19 @@ user_filename = "pydistutils.cfg" # And look for the user config file - user_file = os.path.join(os.path.expanduser('~'), user_filename) - if os.path.isfile(user_file): - files.append(user_file) + if self.want_user_cfg: + user_file = os.path.join(os.path.expanduser('~'), user_filename) + if os.path.isfile(user_file): + files.append(user_file) # All platforms support local setup.cfg local_file = "setup.cfg" if os.path.isfile(local_file): files.append(local_file) + if DEBUG: + self.announce("using config files: %s" % ', '.join(files)) + return files def parse_config_files(self, filenames=None): Modified: python/branches/py3k/Lib/distutils/tests/test_dist.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_dist.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_dist.py Wed Oct 28 00:12:01 2009 @@ -37,7 +37,8 @@ return self._config_files -class DistributionTestCase(support.LoggingSilencer, +class DistributionTestCase(support.TempdirManager, + support.LoggingSilencer, support.EnvironGuard, unittest.TestCase): @@ -180,6 +181,35 @@ kwargs = {'level': 'ok2'} self.assertRaises(ValueError, dist.announce, args, kwargs) + def test_find_config_files_disable(self): + # Ticket #1180: Allow user to disable their home config file. + temp_home = self.mkdtemp() + if os.name == 'posix': + user_filename = os.path.join(temp_home, ".pydistutils.cfg") + else: + user_filename = os.path.join(temp_home, "pydistutils.cfg") + + with open(user_filename, 'w') as f: + f.write('[distutils]\n') + + def _expander(path): + return temp_home + + old_expander = os.path.expanduser + os.path.expanduser = _expander + try: + d = distutils.dist.Distribution() + all_files = d.find_config_files() + + d = distutils.dist.Distribution(attrs={'script_args': + ['--no-user-cfg']}) + files = d.find_config_files() + finally: + os.path.expanduser = old_expander + + # make sure --no-user-cfg disables the user cfg file + self.assertEquals(len(all_files)-1, len(files)) + class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 28 00:12:01 2009 @@ -117,6 +117,9 @@ Library ------- +- Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in + Distutils. + - Issue #7218: Fix test_site for win32, the directory comparison was done with an uppercase. From python-checkins at python.org Wed Oct 28 00:13:00 2009 From: python-checkins at python.org (tarek.ziade) Date: Tue, 27 Oct 2009 23:13:00 -0000 Subject: [Python-checkins] r75896 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Wed Oct 28 00:13:00 2009 New Revision: 75896 Log: Blocked revisions 75895 via svnmerge ................ r75895 | tarek.ziade | 2009-10-28 00:12:01 +0100 (Wed, 28 Oct 2009) | 9 lines Merged revisions 75893 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75893 | tarek.ziade | 2009-10-28 00:06:10 +0100 (Wed, 28 Oct 2009) | 1 line Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Oct 28 00:39:07 2009 From: python-checkins at python.org (r.david.murray) Date: Tue, 27 Oct 2009 23:39:07 -0000 Subject: [Python-checkins] r75897 - in python/branches/release26-maint: Lib/email/message.py Lib/email/test/data/msg_44.txt Misc/ACKS Misc/NEWS Message-ID: Author: r.david.murray Date: Wed Oct 28 00:39:06 2009 New Revision: 75897 Log: Merged revisions 75301 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75301 | r.david.murray | 2009-10-09 17:50:54 -0400 (Fri, 09 Oct 2009) | 5 lines Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. Patch by Darren Worrall. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/email/message.py python/branches/release26-maint/Lib/email/test/data/msg_44.txt python/branches/release26-maint/Misc/ACKS python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/email/message.py ============================================================================== --- python/branches/release26-maint/Lib/email/message.py (original) +++ python/branches/release26-maint/Lib/email/message.py Wed Oct 28 00:39:06 2009 @@ -674,7 +674,7 @@ missing = object() filename = self.get_param('filename', missing, 'content-disposition') if filename is missing: - filename = self.get_param('name', missing, 'content-disposition') + filename = self.get_param('name', missing, 'content-type') if filename is missing: return failobj return utils.collapse_rfc2231_value(filename).strip() Modified: python/branches/release26-maint/Lib/email/test/data/msg_44.txt ============================================================================== --- python/branches/release26-maint/Lib/email/test/data/msg_44.txt (original) +++ python/branches/release26-maint/Lib/email/test/data/msg_44.txt Wed Oct 28 00:39:06 2009 @@ -16,16 +16,14 @@ --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror to reflect upon our own --h90VIIIKmx -Content-Type: text/plain -Content-Disposition: inline; name="msg.txt" +Content-Type: text/plain; name="msg.txt" Content-Transfer-Encoding: 7bit a simple kind of mirror Modified: python/branches/release26-maint/Misc/ACKS ============================================================================== --- python/branches/release26-maint/Misc/ACKS (original) +++ python/branches/release26-maint/Misc/ACKS Wed Oct 28 00:39:06 2009 @@ -781,6 +781,7 @@ Dan Wolfe Richard Wolff Gordon Worley +Darren Worrall Thomas Wouters Heiko Wundram Doug Wyatt Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Wed Oct 28 00:39:06 2009 @@ -24,6 +24,9 @@ Library ------- +- Issue #7082: When falling back to the MIME 'name' parameter, the + correct place to look for it is the Content-Type header. + - Issue #7099: Decimal.is_normal now returns True for numbers with exponent larger than emax. From python-checkins at python.org Wed Oct 28 02:49:04 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 01:49:04 -0000 Subject: [Python-checkins] r75898 - in python/branches/release26-maint: Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Wed Oct 28 02:49:02 2009 New Revision: 75898 Log: Merged revisions 75524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75524 | r.david.murray | 2009-10-19 12:28:24 -0400 (Mon, 19 Oct 2009) | 6 lines Eliminate warning message that looks like an error message. When it was added not finding Lib/test in the path indicated something was wrong, but when running regtest using "python -m" Lib/test isn't typically in the path, so this message is now more disturbing than it is helpful. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/regrtest.py Modified: python/branches/release26-maint/Lib/test/regrtest.py ============================================================================== --- python/branches/release26-maint/Lib/test/regrtest.py (original) +++ python/branches/release26-maint/Lib/test/regrtest.py Wed Oct 28 02:49:02 2009 @@ -1192,6 +1192,4 @@ i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] - if len(sys.path) == pathlen: - print 'Could not find %r in sys.path to remove it' % mydir main() From python-checkins at python.org Wed Oct 28 03:09:27 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 02:09:27 -0000 Subject: [Python-checkins] r75899 - python/branches/release26-maint Message-ID: Author: r.david.murray Date: Wed Oct 28 03:09:26 2009 New Revision: 75899 Log: Blocked revisions 70936 via svnmerge ........ r70936 | r.david.murray | 2009-03-31 23:21:43 -0400 (Tue, 31 Mar 2009) | 4 lines Fix issue 2522. locale.format now checks that it is passed exactly one pattern, which avoids mysterious errors where it had seemed to fail to do localization. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 03:22:08 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 02:22:08 -0000 Subject: [Python-checkins] r75900 - in python/branches/release26-maint: Lib/test/test_support.py Message-ID: Author: r.david.murray Date: Wed Oct 28 03:22:08 2009 New Revision: 75900 Log: Merged revisions 75528 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75528 | r.david.murray | 2009-10-19 13:53:58 -0400 (Mon, 19 Oct 2009) | 4 lines Clarify error report message, and don't recommend running in verbose mode for more information if we are already running in verbose mode. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_support.py Modified: python/branches/release26-maint/Lib/test/test_support.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_support.py (original) +++ python/branches/release26-maint/Lib/test/test_support.py Wed Oct 28 03:22:08 2009 @@ -703,7 +703,9 @@ elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - err = "errors occurred; run in verbose mode for details" + err = "multiple errors occurred" + if not verbose: + err += "; run in verbose mode for details" raise TestFailed(err) From python-checkins at python.org Wed Oct 28 07:45:18 2009 From: python-checkins at python.org (tarek.ziade) Date: Wed, 28 Oct 2009 06:45:18 -0000 Subject: [Python-checkins] r75901 - python/trunk/Lib/distutils/errors.py Message-ID: Author: tarek.ziade Date: Wed Oct 28 07:45:18 2009 New Revision: 75901 Log: removed spurious spaces Modified: python/trunk/Lib/distutils/errors.py Modified: python/trunk/Lib/distutils/errors.py ============================================================================== --- python/trunk/Lib/distutils/errors.py (original) +++ python/trunk/Lib/distutils/errors.py Wed Oct 28 07:45:18 2009 @@ -10,90 +10,79 @@ __revision__ = "$Id$" -class DistutilsError (Exception): +class DistutilsError(Exception): """The root of all Distutils evil.""" - pass -class DistutilsModuleError (DistutilsError): +class DistutilsModuleError(DistutilsError): """Unable to load an expected module, or to find an expected class within some module (in particular, command modules and classes).""" - pass -class DistutilsClassError (DistutilsError): +class DistutilsClassError(DistutilsError): """Some command class (or possibly distribution class, if anyone feels a need to subclass Distribution) is found not to be holding up its end of the bargain, ie. implementing some part of the "command "interface.""" - pass -class DistutilsGetoptError (DistutilsError): +class DistutilsGetoptError(DistutilsError): """The option table provided to 'fancy_getopt()' is bogus.""" - pass -class DistutilsArgError (DistutilsError): +class DistutilsArgError(DistutilsError): """Raised by fancy_getopt in response to getopt.error -- ie. an error in the command line usage.""" - pass -class DistutilsFileError (DistutilsError): +class DistutilsFileError(DistutilsError): """Any problems in the filesystem: expected file not found, etc. Typically this is for problems that we detect before IOError or OSError could be raised.""" - pass -class DistutilsOptionError (DistutilsError): +class DistutilsOptionError(DistutilsError): """Syntactic/semantic errors in command options, such as use of mutually conflicting options, or inconsistent options, badly-spelled values, etc. No distinction is made between option values originating in the setup script, the command line, config files, or what-have-you -- but if we *know* something originated in the setup script, we'll raise DistutilsSetupError instead.""" - pass -class DistutilsSetupError (DistutilsError): +class DistutilsSetupError(DistutilsError): """For errors that can be definitely blamed on the setup script, such as invalid keyword arguments to 'setup()'.""" - pass -class DistutilsPlatformError (DistutilsError): +class DistutilsPlatformError(DistutilsError): """We don't know how to do something on the current platform (but we do know how to do it on some platform) -- eg. trying to compile C files on a platform not supported by a CCompiler subclass.""" - pass -class DistutilsExecError (DistutilsError): +class DistutilsExecError(DistutilsError): """Any problems executing an external program (such as the C compiler, when compiling C files).""" - pass -class DistutilsInternalError (DistutilsError): +class DistutilsInternalError(DistutilsError): """Internal inconsistencies or impossibilities (obviously, this should never be seen if the code is working!).""" - pass -class DistutilsTemplateError (DistutilsError): +class DistutilsTemplateError(DistutilsError): """Syntax error in a file list template.""" class DistutilsByteCompileError(DistutilsError): """Byte compile error.""" # Exception classes used by the CCompiler implementation classes -class CCompilerError (Exception): +class CCompilerError(Exception): """Some compile/link operation failed.""" -class PreprocessError (CCompilerError): +class PreprocessError(CCompilerError): """Failure to preprocess one or more C/C++ files.""" -class CompileError (CCompilerError): +class CompileError(CCompilerError): """Failure to compile one or more C/C++ source files.""" -class LibError (CCompilerError): +class LibError(CCompilerError): """Failure to create a static library from one or more C/C++ object files.""" -class LinkError (CCompilerError): +class LinkError(CCompilerError): """Failure to link one or more C/C++ object files into an executable or shared library file.""" -class UnknownFileError (CCompilerError): +class UnknownFileError(CCompilerError): """Attempt to process an unknown file type.""" From python-checkins at python.org Wed Oct 28 07:46:01 2009 From: python-checkins at python.org (tarek.ziade) Date: Wed, 28 Oct 2009 06:46:01 -0000 Subject: [Python-checkins] r75902 - python/branches/release26-maint Message-ID: Author: tarek.ziade Date: Wed Oct 28 07:46:01 2009 New Revision: 75902 Log: Blocked revisions 75901 via svnmerge ........ r75901 | tarek.ziade | 2009-10-28 07:45:18 +0100 (Wed, 28 Oct 2009) | 1 line removed spurious spaces ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 07:48:27 2009 From: python-checkins at python.org (tarek.ziade) Date: Wed, 28 Oct 2009 06:48:27 -0000 Subject: [Python-checkins] r75903 - in python/branches/py3k: Lib/distutils/errors.py Message-ID: Author: tarek.ziade Date: Wed Oct 28 07:48:27 2009 New Revision: 75903 Log: Merged revisions 75901 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75901 | tarek.ziade | 2009-10-28 07:45:18 +0100 (Wed, 28 Oct 2009) | 1 line removed spurious spaces ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/distutils/errors.py Modified: python/branches/py3k/Lib/distutils/errors.py ============================================================================== --- python/branches/py3k/Lib/distutils/errors.py (original) +++ python/branches/py3k/Lib/distutils/errors.py Wed Oct 28 07:48:27 2009 @@ -10,90 +10,79 @@ __revision__ = "$Id$" -class DistutilsError (Exception): +class DistutilsError(Exception): """The root of all Distutils evil.""" - pass -class DistutilsModuleError (DistutilsError): +class DistutilsModuleError(DistutilsError): """Unable to load an expected module, or to find an expected class within some module (in particular, command modules and classes).""" - pass -class DistutilsClassError (DistutilsError): +class DistutilsClassError(DistutilsError): """Some command class (or possibly distribution class, if anyone feels a need to subclass Distribution) is found not to be holding up its end of the bargain, ie. implementing some part of the "command "interface.""" - pass -class DistutilsGetoptError (DistutilsError): +class DistutilsGetoptError(DistutilsError): """The option table provided to 'fancy_getopt()' is bogus.""" - pass -class DistutilsArgError (DistutilsError): +class DistutilsArgError(DistutilsError): """Raised by fancy_getopt in response to getopt.error -- ie. an error in the command line usage.""" - pass -class DistutilsFileError (DistutilsError): +class DistutilsFileError(DistutilsError): """Any problems in the filesystem: expected file not found, etc. Typically this is for problems that we detect before IOError or OSError could be raised.""" - pass -class DistutilsOptionError (DistutilsError): +class DistutilsOptionError(DistutilsError): """Syntactic/semantic errors in command options, such as use of mutually conflicting options, or inconsistent options, badly-spelled values, etc. No distinction is made between option values originating in the setup script, the command line, config files, or what-have-you -- but if we *know* something originated in the setup script, we'll raise DistutilsSetupError instead.""" - pass -class DistutilsSetupError (DistutilsError): +class DistutilsSetupError(DistutilsError): """For errors that can be definitely blamed on the setup script, such as invalid keyword arguments to 'setup()'.""" - pass -class DistutilsPlatformError (DistutilsError): +class DistutilsPlatformError(DistutilsError): """We don't know how to do something on the current platform (but we do know how to do it on some platform) -- eg. trying to compile C files on a platform not supported by a CCompiler subclass.""" - pass -class DistutilsExecError (DistutilsError): +class DistutilsExecError(DistutilsError): """Any problems executing an external program (such as the C compiler, when compiling C files).""" - pass -class DistutilsInternalError (DistutilsError): +class DistutilsInternalError(DistutilsError): """Internal inconsistencies or impossibilities (obviously, this should never be seen if the code is working!).""" - pass -class DistutilsTemplateError (DistutilsError): +class DistutilsTemplateError(DistutilsError): """Syntax error in a file list template.""" class DistutilsByteCompileError(DistutilsError): """Byte compile error.""" # Exception classes used by the CCompiler implementation classes -class CCompilerError (Exception): +class CCompilerError(Exception): """Some compile/link operation failed.""" -class PreprocessError (CCompilerError): +class PreprocessError(CCompilerError): """Failure to preprocess one or more C/C++ files.""" -class CompileError (CCompilerError): +class CompileError(CCompilerError): """Failure to compile one or more C/C++ source files.""" -class LibError (CCompilerError): +class LibError(CCompilerError): """Failure to create a static library from one or more C/C++ object files.""" -class LinkError (CCompilerError): +class LinkError(CCompilerError): """Failure to link one or more C/C++ object files into an executable or shared library file.""" -class UnknownFileError (CCompilerError): +class UnknownFileError(CCompilerError): """Attempt to process an unknown file type.""" From python-checkins at python.org Wed Oct 28 07:50:03 2009 From: python-checkins at python.org (tarek.ziade) Date: Wed, 28 Oct 2009 06:50:03 -0000 Subject: [Python-checkins] r75904 - python/branches/release31-maint Message-ID: Author: tarek.ziade Date: Wed Oct 28 07:50:03 2009 New Revision: 75904 Log: Blocked revisions 75903 via svnmerge ................ r75903 | tarek.ziade | 2009-10-28 07:48:27 +0100 (Wed, 28 Oct 2009) | 9 lines Merged revisions 75901 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75901 | tarek.ziade | 2009-10-28 07:45:18 +0100 (Wed, 28 Oct 2009) | 1 line removed spurious spaces ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Oct 28 08:23:49 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:23:49 -0000 Subject: [Python-checkins] r75905 - python/trunk/Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:23:49 2009 New Revision: 75905 Log: Replace long long with PY_LONG_LONG Modified: python/trunk/Modules/_io/_iomodule.h Modified: python/trunk/Modules/_io/_iomodule.h ============================================================================== --- python/trunk/Modules/_io/_iomodule.h (original) +++ python/trunk/Modules/_io/_iomodule.h Wed Oct 28 08:23:49 2009 @@ -92,7 +92,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ +# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else /* Other platforms use off_t */ @@ -103,7 +103,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT long long +# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong From python-checkins at python.org Wed Oct 28 08:24:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:24:21 -0000 Subject: [Python-checkins] r75906 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:24:20 2009 New Revision: 75906 Log: Blocked revisions 75905 via svnmerge ........ r75905 | mark.dickinson | 2009-10-28 07:23:49 +0000 (Wed, 28 Oct 2009) | 1 line Replace long long with PY_LONG_LONG ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 08:25:03 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:25:03 -0000 Subject: [Python-checkins] r75907 - in python/branches/py3k: Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:25:03 2009 New Revision: 75907 Log: Merged revisions 75905 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75905 | mark.dickinson | 2009-10-28 07:23:49 +0000 (Wed, 28 Oct 2009) | 1 line Replace long long with PY_LONG_LONG ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/_iomodule.h Modified: python/branches/py3k/Modules/_io/_iomodule.h ============================================================================== --- python/branches/py3k/Modules/_io/_iomodule.h (original) +++ python/branches/py3k/Modules/_io/_iomodule.h Wed Oct 28 08:25:03 2009 @@ -87,7 +87,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ +# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else /* Other platforms use off_t */ @@ -98,7 +98,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT long long +# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong From python-checkins at python.org Wed Oct 28 08:25:44 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:25:44 -0000 Subject: [Python-checkins] r75908 - in python/branches/release31-maint: Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:25:44 2009 New Revision: 75908 Log: Merged revisions 75907 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75907 | mark.dickinson | 2009-10-28 07:25:03 +0000 (Wed, 28 Oct 2009) | 9 lines Merged revisions 75905 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75905 | mark.dickinson | 2009-10-28 07:23:49 +0000 (Wed, 28 Oct 2009) | 1 line Replace long long with PY_LONG_LONG ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_io/_iomodule.h Modified: python/branches/release31-maint/Modules/_io/_iomodule.h ============================================================================== --- python/branches/release31-maint/Modules/_io/_iomodule.h (original) +++ python/branches/release31-maint/Modules/_io/_iomodule.h Wed Oct 28 08:25:44 2009 @@ -87,7 +87,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT long long /* standard type compatible with off_t */ +# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else /* Other platforms use off_t */ @@ -98,7 +98,7 @@ # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT long long +# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong From python-checkins at python.org Wed Oct 28 08:47:32 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:47:32 -0000 Subject: [Python-checkins] r75909 - python/trunk/Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:47:32 2009 New Revision: 75909 Log: Fix format specifier for MSVC Modified: python/trunk/Modules/_io/_iomodule.h Modified: python/trunk/Modules/_io/_iomodule.h ============================================================================== --- python/trunk/Modules/_io/_iomodule.h (original) +++ python/trunk/Modules/_io/_iomodule.h Wed Oct 28 08:47:32 2009 @@ -91,7 +91,7 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ +# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ # define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else From python-checkins at python.org Wed Oct 28 08:48:08 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:48:08 -0000 Subject: [Python-checkins] r75910 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:48:08 2009 New Revision: 75910 Log: Blocked revisions 75909 via svnmerge ........ r75909 | mark.dickinson | 2009-10-28 07:47:32 +0000 (Wed, 28 Oct 2009) | 1 line Fix format specifier for MSVC ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 08:49:26 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:49:26 -0000 Subject: [Python-checkins] r75911 - in python/branches/py3k: Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:49:26 2009 New Revision: 75911 Log: Merged revisions 75909 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75909 | mark.dickinson | 2009-10-28 07:47:32 +0000 (Wed, 28 Oct 2009) | 1 line Fix format specifier for MSVC ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/_iomodule.h Modified: python/branches/py3k/Modules/_io/_iomodule.h ============================================================================== --- python/branches/py3k/Modules/_io/_iomodule.h (original) +++ python/branches/py3k/Modules/_io/_iomodule.h Wed Oct 28 08:49:26 2009 @@ -86,7 +86,7 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ +# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ # define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else From python-checkins at python.org Wed Oct 28 08:50:03 2009 From: python-checkins at python.org (mark.dickinson) Date: Wed, 28 Oct 2009 07:50:03 -0000 Subject: [Python-checkins] r75912 - in python/branches/release31-maint: Modules/_io/_iomodule.h Message-ID: Author: mark.dickinson Date: Wed Oct 28 08:50:03 2009 New Revision: 75912 Log: Merged revisions 75911 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75911 | mark.dickinson | 2009-10-28 07:49:26 +0000 (Wed, 28 Oct 2009) | 9 lines Merged revisions 75909 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75909 | mark.dickinson | 2009-10-28 07:47:32 +0000 (Wed, 28 Oct 2009) | 1 line Fix format specifier for MSVC ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_io/_iomodule.h Modified: python/branches/release31-maint/Modules/_io/_iomodule.h ============================================================================== --- python/branches/release31-maint/Modules/_io/_iomodule.h (original) +++ python/branches/release31-maint/Modules/_io/_iomodule.h Wed Oct 28 08:50:03 2009 @@ -86,7 +86,7 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" /* format to use in printf with type off_t */ +# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ # define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else From python-checkins at python.org Wed Oct 28 09:44:38 2009 From: python-checkins at python.org (eric.smith) Date: Wed, 28 Oct 2009 08:44:38 -0000 Subject: [Python-checkins] r75913 - python/trunk/Modules/_json.c Message-ID: Author: eric.smith Date: Wed Oct 28 09:44:37 2009 New Revision: 75913 Log: Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in _json.c as part of short float repr. Change made after consulting with Bob Ippolito. This completes the removal of calls to PyOS_ascii_strtod. Modified: python/trunk/Modules/_json.c Modified: python/trunk/Modules/_json.c ============================================================================== --- python/trunk/Modules/_json.c (original) +++ python/trunk/Modules/_json.c Wed Oct 28 09:44:37 2009 @@ -1405,7 +1405,11 @@ rval = PyObject_CallFunctionObjArgs(s->parse_float, numstr, NULL); } else { - rval = PyFloat_FromDouble(PyOS_ascii_atof(PyString_AS_STRING(numstr))); + double d = PyOS_string_to_double(PyString_AS_STRING(numstr), + NULL, NULL); + if (d == -1.0 && PyErr_Occurred()) + return NULL; + rval = PyFloat_FromDouble(d); } } else { From python-checkins at python.org Wed Oct 28 09:46:43 2009 From: python-checkins at python.org (eric.smith) Date: Wed, 28 Oct 2009 08:46:43 -0000 Subject: [Python-checkins] r75914 - python/branches/py3k Message-ID: Author: eric.smith Date: Wed Oct 28 09:46:43 2009 New Revision: 75914 Log: Blocked revisions 75913 via svnmerge ........ r75913 | eric.smith | 2009-10-28 04:44:37 -0400 (Wed, 28 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in _json.c as part of short float repr. Change made after consulting with Bob Ippolito. This completes the removal of calls to PyOS_ascii_strtod. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Wed Oct 28 09:47:31 2009 From: python-checkins at python.org (eric.smith) Date: Wed, 28 Oct 2009 08:47:31 -0000 Subject: [Python-checkins] r75915 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Wed Oct 28 09:47:31 2009 New Revision: 75915 Log: Blocked revisions 75913 via svnmerge ........ r75913 | eric.smith | 2009-10-28 04:44:37 -0400 (Wed, 28 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in _json.c as part of short float repr. Change made after consulting with Bob Ippolito. This completes the removal of calls to PyOS_ascii_strtod. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Wed Oct 28 11:10:57 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 28 Oct 2009 10:10:57 -0000 Subject: [Python-checkins] r75916 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Wed Oct 28 11:10:57 2009 New Revision: 75916 Log: Added Handler Id section. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Wed Oct 28 11:10:57 2009 @@ -93,12 +93,14 @@ The logging.config module will have the following additions: * A function, called ``dictConfig()``, which takes a single argument - - the dictionary holding the configuration. Nothing will be - returned, though exceptions will be raised if there are errors - while processing the dictionary. + - the dictionary holding the configuration. Nothing will be + returned, though exceptions will be raised if there are errors while + processing the dictionary. It will be possible to customize this API - see the section on `API -Customization`_. +Customization`_. `Incremental configuration`_ is covered in its own +section. + Dictionary Schema - Overview ---------------------------- @@ -127,11 +129,18 @@ So, for example, consider the following YAML snippet:: + formatters: + brief: + # configuration for formatter with id 'brief' goes here + precise: + # configuration for formatter with id 'precise' goes here handlers: h1: #This is an id - # configuration of handler with id h1 goes here + # configuration of handler with id 'h1' goes here + formatter: brief h2: #This is another id - # configuration of handler with id h2 goes here + # configuration of handler with id 'h2' goes here + formatter: precise loggers: foo.bar.baz: # other configuration for logger 'foo.bar.baz' @@ -142,15 +151,20 @@ The ids for loggers are the logger names which would be used programmatically to obtain a reference to those loggers, e.g. -``foo.bar.baz``. The ids for other objects can be any string value -(such as ``h1``, ``h2`` above) and they are transient, in that they -are only meaningful for processing the configuration dictionary and -used to determine connections between objects, and are not persisted -anywhere when the configuration call is complete. +``foo.bar.baz``. The ids for Formatters and Filters can be any string +value (such as ``brief``, ``precise`` above) and they are transient, +in that they are only meaningful for processing the configuration +dictionary and used to determine connections between objects, and are +not persisted anywhere when the configuration call is complete. + +Handler ids are treated specially, see the section on +`Handler Ids`_, below. The above snippet indicates that logger named ``foo.bar.baz`` should have two handlers attached to it, which are described by the handler -ids ``h1`` and ``h2``. +ids ``h1`` and ``h2``. The formatter for ``h1`` is that described by id +``brief``, and the formatter for ``h2`` is that described by id +``precise``. User-defined objects @@ -260,6 +274,7 @@ ``ext://`` but it will be possible to disable the mechanism completely or provide additional or different prefixes for special handling. + Access to internal objects '''''''''''''''''''''''''' @@ -334,6 +349,35 @@ alternatives are suggested during the PEP review process, they will be used. + +Handler Ids +''''''''''' + +Some specific logging configurations require the use of handler levels +to achieve the desired effect. However, unlike loggers which can +always be identified by their names, handlers have no persistent +handles whereby levels can be changed via an incremental configuration +call. + +Therefore, this PEP proposes to add an optional ``name`` property to +handlers. If used, this will add an entry in a dictionary which maps +the name to the handler. (The entry will be removed when the handler +is closed.) When an incremental configuration call is made, handlers +will be looked up in this dictionary to set the handler level +according to the value in the configuration. See the section on +`incremental configuration`_ for more details. + +In theory, such a "persistent name" facility could also be provided +for Filters and Formatters. However, there is not a strong case to be +made for being able to configure these incrementally. On the basis +that practicality beats purity, only Handlers will be given this new +``name`` property. The id of a handler in the configuration will +become its ``name``. + +The handler name lookup dictionary is for configuration use only and +will not become part of the public API for the package. + + Dictionary Schema - Detail -------------------------- @@ -500,25 +544,22 @@ ========================= It is difficult to provide complete flexibility for incremental -configuration. For example, because objects such as handlers, filters +configuration. For example, because objects such as filters and formatters are anonymous, once a configuration is set up, it is not possible to refer to such anonymous objects when augmenting a -configuration. For example, if an initial call is made to configure -the system where logger ``foo`` has a handler with id ``console`` -attached, then a subsequent call to configure a logger ``bar`` with id -``console`` would create a new handler instance, as the id ``console`` -from the first call isn't kept. +configuration. Furthermore, there is not a compelling case for arbitrarily altering the object graph of loggers, handlers, filters, formatters at -run-time, once a configuration is set up; the verbosity of loggers can -be controlled just by setting levels (and perhaps propagation flags). +run-time, once a configuration is set up; the verbosity of loggers and +handlers can be controlled just by setting levels (and, in the case of +loggers, propagation flags). Thus, when the ``incremental`` key of a configuration dict is present -and is ``True``, the system will ignore any ``formatters``, -``filters``, ``handlers`` entries completely, and process only the -``level`` and ``propagate`` settings in the ``loggers`` and ``root`` -entries. +and is ``True``, the system will ignore any ``formatters`` and +``filters``, entries completely, and process only the ``level`` +settings in the ``handlers`` entries, and the ``level`` and +``propagate`` settings in the ``loggers`` and ``root`` entries. It's certainly possible to provide incremental configuration by other means, for example making ``dictConfig()`` take an ``incremental`` @@ -579,6 +620,8 @@ * An id which does not have a corresponding destination +* A non-existent handler id found during an incremental call + * An invalid logger name * Inability to resolve to an internal or external object From python-checkins at python.org Wed Oct 28 11:19:38 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 28 Oct 2009 10:19:38 -0000 Subject: [Python-checkins] r75917 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Wed Oct 28 11:19:38 2009 New Revision: 75917 Log: Clarification on arbitrary object graph changes. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Wed Oct 28 11:19:38 2009 @@ -553,7 +553,10 @@ the object graph of loggers, handlers, filters, formatters at run-time, once a configuration is set up; the verbosity of loggers and handlers can be controlled just by setting levels (and, in the case of -loggers, propagation flags). +loggers, propagation flags). Changing the object graph arbitrarily in +a safe way is problematic in a multi-threaded environment; while not +impossible, the benefits are not worth the complexity it adds to the +implementation. Thus, when the ``incremental`` key of a configuration dict is present and is ``True``, the system will ignore any ``formatters`` and From python-checkins at python.org Wed Oct 28 11:21:11 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 28 Oct 2009 10:21:11 -0000 Subject: [Python-checkins] r75918 - peps/trunk/pep-0391.txt Message-ID: Author: vinay.sajip Date: Wed Oct 28 11:21:10 2009 New Revision: 75918 Log: Corrected typo. Modified: peps/trunk/pep-0391.txt Modified: peps/trunk/pep-0391.txt ============================================================================== --- peps/trunk/pep-0391.txt (original) +++ peps/trunk/pep-0391.txt Wed Oct 28 11:21:10 2009 @@ -560,7 +560,7 @@ Thus, when the ``incremental`` key of a configuration dict is present and is ``True``, the system will ignore any ``formatters`` and -``filters``, entries completely, and process only the ``level`` +``filters`` entries completely, and process only the ``level`` settings in the ``handlers`` entries, and the ``level`` and ``propagate`` settings in the ``loggers`` and ``root`` entries. From python-checkins at python.org Wed Oct 28 11:50:46 2009 From: python-checkins at python.org (antoine.pitrou) Date: Wed, 28 Oct 2009 10:50:46 -0000 Subject: [Python-checkins] r75919 - in sandbox/trunk/newgil: Demo/comparisons/sortingtest.py Doc/ACKS.txt Doc/distutils/apiref.rst Doc/distutils/builtdist.rst Doc/documenting/markup.rst Doc/faq/design.rst Doc/faq/extending.rst Doc/faq/general.rst Doc/faq/gui.rst Doc/faq/library.rst Doc/faq/programming.rst Doc/faq/windows.rst Doc/howto/unicode.rst Doc/howto/webservers.rst Doc/install/index.rst Doc/library/codecs.rst Doc/library/configparser.rst Doc/library/curses.rst Doc/library/datetime.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/inspect.rst Doc/library/mailbox.rst Doc/library/math.rst Doc/library/msilib.rst Doc/library/os.rst Doc/library/othergui.rst Doc/library/platform.rst Doc/library/signal.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/types.rst Doc/library/weakref.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/tools/sphinxext/pyspecific.py Doc/tools/sphinxext/static/basic.css Doc/tutorial/index.rst Doc/using/cmdline.rst Doc/using/windows.rst Doc/whatsnew/2.0.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.6.rst Lib/distutils/core.py Lib/distutils/dist.py Lib/distutils/errors.py Lib/distutils/tests/test_dist.py Lib/test/regrtest.py Lib/test/test_asyncore.py Lib/test/test_bz2.py Lib/test/test_complex.py Lib/test/test_distutils.py Lib/test/test_float.py Lib/test/test_httpservers.py Lib/test/test_site.py Lib/test/test_smtplib.py Lib/test/test_socketserver.py Lib/test/test_sys.py Lib/test/test_telnetlib.py Lib/test/test_threading.py Lib/test/test_urllib2_localnet.py Lib/threading.py Lib/warnings.py Makefile.pre.in Misc/NEWS Modules/_ctypes/_ctypes.c Modules/_io/_iomodule.h Modules/_io/bufferedio.c Modules/_localemodule.c Modules/_testcapimodule.c Modules/bz2module.c Modules/readline.c Objects/complexobject.c Objects/floatobject.c Objects/unicodeobject.c Python/codecs.c configure configure.in pyconfig.h.in Message-ID: Author: antoine.pitrou Date: Wed Oct 28 11:50:44 2009 New Revision: 75919 Log: Merged revisions 75726,75729,75732-75733,75737-75738,75740-75741,75744,75746,75797,75820,75834,75836,75839,75843,75845,75847,75850,75852,75856,75861,75869-75870,75873,75876-75877,75881,75885,75889-75890,75895,75903,75907,75911,75914 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75726 | antoine.pitrou | 2009-10-26 20:22:14 +0100 (lun., 26 oct. 2009) | 10 lines Merged revisions 75725 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75725 | antoine.pitrou | 2009-10-26 20:16:46 +0100 (lun., 26 oct. 2009) | 4 lines Some platforms have rl_completion_append_character but not rl_completion_suppress_append. Reported by Mark D. ........ ................ r75729 | mark.dickinson | 2009-10-26 21:02:55 +0100 (lun., 26 oct. 2009) | 10 lines Merged revisions 75728 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75728 | mark.dickinson | 2009-10-26 19:59:23 +0000 (Mon, 26 Oct 2009) | 3 lines Use correct conversion specifier and length modifier when printing an integer of type off_t. Also, don't assume that long long is available. ........ ................ r75732 | mark.dickinson | 2009-10-26 22:12:50 +0100 (lun., 26 oct. 2009) | 1 line Fix extra-long line; also makes py3k match trunk here. ................ r75733 | mark.dickinson | 2009-10-26 22:13:15 +0100 (lun., 26 oct. 2009) | 14 lines Blocked revisions 75730-75731 via svnmerge ........ r75730 | mark.dickinson | 2009-10-26 21:09:09 +0000 (Mon, 26 Oct 2009) | 2 lines Issue #7117: Backport missing pystrtod.h declarations from py3k. ........ r75731 | mark.dickinson | 2009-10-26 21:11:20 +0000 (Mon, 26 Oct 2009) | 4 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in floatobject.c. Also, remove limitation on length of unicode inputs to float(). ........ ................ r75737 | mark.dickinson | 2009-10-26 22:51:18 +0100 (lun., 26 oct. 2009) | 1 line Remove length limitation on string arguments to complex() ................ r75738 | mark.dickinson | 2009-10-26 23:05:06 +0100 (lun., 26 oct. 2009) | 1 line Make sure memory is freed on error in complex_subtype_from_string. ................ r75740 | mark.dickinson | 2009-10-26 23:29:02 +0100 (lun., 26 oct. 2009) | 10 lines Blocked revisions 75739 via svnmerge ........ r75739 | mark.dickinson | 2009-10-26 22:28:14 +0000 (Mon, 26 Oct 2009) | 5 lines Issue #7117: Use PyOS_string_to_double instead of PyOS_ascii_strtod in complexobject.c. Also remove length restriction on unicode inputs to the complex constructor. ........ ................ r75741 | mark.dickinson | 2009-10-26 23:48:32 +0100 (lun., 26 oct. 2009) | 2 lines Issue #7207: Fix race condition in telnetlib test; should stop test failures on OS X 10.6. ................ r75744 | eric.smith | 2009-10-27 12:36:44 +0100 (mar., 27 oct. 2009) | 8 lines Blocked revisions 75743 via svnmerge ........ r75743 | eric.smith | 2009-10-27 07:32:11 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in cPickle as part of short float repr. ........ ................ r75746 | eric.smith | 2009-10-27 13:13:06 +0100 (mar., 27 oct. 2009) | 8 lines Blocked revisions 75745 via svnmerge ........ r75745 | eric.smith | 2009-10-27 08:12:44 -0400 (Tue, 27 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr. ........ ................ r75797 | georg.brandl | 2009-10-27 16:28:25 +0100 (mar., 27 oct. 2009) | 129 lines Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. ........ r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line Fix markup. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line #7126: os.environ changes *do* take effect in subprocesses started with os.system(). ........ r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line #7116: str.join() takes an iterable. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line Fix missing word. ........ r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line Fix punctuation. ........ r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line Revert unintended change. ........ r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line Fix markup. ........ r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line Fix duplicate target. ........ r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line Add a new directive marking up implementation details and start using it. ........ r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line Make it more robust. ........ r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line Document new directive. ........ r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line Allow short form with text as argument. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line Use "impl-detail" directive where applicable. ........ r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line #6324: membership test tries iteration via __iter__. ........ r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line #7088: document new functions in signal as Unix-only. ........ r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line Reorder __slots__ fine print and add a clarification. ........ r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line #7035: improve docs of the various _errors() functions, and give them docstrings. ........ r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line #7156: document curses as Unix-only. ........ r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line #6977: getopt does not support optional option arguments. ........ r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line Add proper references. ........ r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line Make printout margin important. ........ r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line #7188: fix optionxform() docs. ........ r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines add further note about what's passed to optionxform ........ r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines Improve some docstrings in the 'warnings' module. ........ r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line Fix markup. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........ r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line Fix a strange mis-edit. ........ ................ r75820 | antoine.pitrou | 2009-10-27 18:47:14 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75818 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. ........ ................ r75834 | eric.smith | 2009-10-27 19:47:34 +0100 (mar., 27 oct. 2009) | 8 lines Blocked revisions 75824 via svnmerge ........ r75824 | eric.smith | 2009-10-27 14:33:14 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from ast.c, as mentioned in issue 7117. ........ ................ r75836 | antoine.pitrou | 2009-10-27 19:49:23 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75826 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75826 | antoine.pitrou | 2009-10-27 19:36:47 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_asyncore ........ ................ r75839 | antoine.pitrou | 2009-10-27 19:52:30 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75838 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75838 | antoine.pitrou | 2009-10-27 19:50:52 +0100 (mar., 27 oct. 2009) | 3 lines (Hopefully) suppress transient refleaks in test_httpservers. ........ ................ r75843 | antoine.pitrou | 2009-10-27 20:25:57 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75842 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75842 | antoine.pitrou | 2009-10-27 20:23:56 +0100 (mar., 27 oct. 2009) | 3 lines Fix transient refleak in test_sys. ........ ................ r75845 | antoine.pitrou | 2009-10-27 20:39:10 +0100 (mar., 27 oct. 2009) | 8 lines Blocked revisions 75844 via svnmerge ........ r75844 | antoine.pitrou | 2009-10-27 20:36:44 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_file2k. ........ ................ r75847 | eric.smith | 2009-10-27 20:44:06 +0100 (mar., 27 oct. 2009) | 8 lines Blocked revisions 75846 via svnmerge ........ r75846 | eric.smith | 2009-10-27 15:42:57 -0400 (Tue, 27 Oct 2009) | 1 line Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. ........ ................ r75850 | antoine.pitrou | 2009-10-27 20:49:45 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75849 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75849 | antoine.pitrou | 2009-10-27 20:47:30 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_smtplib. ........ ................ r75852 | antoine.pitrou | 2009-10-27 21:05:26 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75851 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75851 | antoine.pitrou | 2009-10-27 21:02:23 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_threading. ........ ................ r75856 | antoine.pitrou | 2009-10-27 21:17:03 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75855 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75855 | antoine.pitrou | 2009-10-27 21:14:04 +0100 (mar., 27 oct. 2009) | 3 lines Fix transient refleaks in test_urllib2_localnet. ........ ................ r75861 | antoine.pitrou | 2009-10-27 21:21:45 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75860 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75860 | antoine.pitrou | 2009-10-27 21:20:41 +0100 (mar., 27 oct. 2009) | 3 lines Try to fix transient refleaks in test_distutils. ........ ................ r75869 | georg.brandl | 2009-10-27 22:02:11 +0100 (mar., 27 oct. 2009) | 13 lines Merged revisions 75866-75867 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75866 | georg.brandl | 2009-10-27 21:52:02 +0100 (Di, 27 Okt 2009) | 1 line Add a regrtest option to re-run in verbose mode immediately after a test fails, and use that option on the buildbots. ........ r75867 | georg.brandl | 2009-10-27 21:55:44 +0100 (Di, 27 Okt 2009) | 1 line Reformat the regrtest command-line option help and group the options into sections. ........ ................ r75870 | benjamin.peterson | 2009-10-27 22:14:50 +0100 (mar., 27 oct. 2009) | 1 line remove shadowing declartion ................ r75873 | tarek.ziade | 2009-10-27 22:24:21 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75871 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75871 | tarek.ziade | 2009-10-27 22:20:27 +0100 (Tue, 27 Oct 2009) | 1 line Issue #7218: Fix test_site for win32 ........ ................ r75876 | antoine.pitrou | 2009-10-27 22:32:38 +0100 (mar., 27 oct. 2009) | 10 lines Merged revisions 75874 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75874 | antoine.pitrou | 2009-10-27 22:27:24 +0100 (mar., 27 oct. 2009) | 4 lines Reduce the probability of refleaks in test_socketserver. Not completely suppressed though, see issue #7222. ........ ................ r75877 | georg.brandl | 2009-10-27 22:37:48 +0100 (mar., 27 oct. 2009) | 1 line Only declare variable when it's used. ................ r75881 | mark.dickinson | 2009-10-27 22:49:48 +0100 (mar., 27 oct. 2009) | 10 lines Merged revisions 75879 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75879 | mark.dickinson | 2009-10-27 21:48:20 +0000 (Tue, 27 Oct 2009) | 3 lines Silence gcc warnings when trying to print an off_t using "lld", on platforms where off_t has type long (e.g., 64-bit Linux). ........ ................ r75885 | mark.dickinson | 2009-10-27 23:12:20 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75883 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75883 | mark.dickinson | 2009-10-27 22:09:33 +0000 (Tue, 27 Oct 2009) | 1 line Test long inputs to float ........ ................ r75889 | georg.brandl | 2009-10-28 00:00:28 +0100 (mer., 28 oct. 2009) | 9 lines Merged revisions 75887 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75887 | georg.brandl | 2009-10-27 23:56:09 +0100 (Di, 27 Okt 2009) | 1 line Make sure every run of test_intern() interns a new string, otherwise that test fails e.g. when some other test in test_builtin fails and it is rerun in verbose mode. ........ ................ r75890 | mark.dickinson | 2009-10-28 00:00:56 +0100 (mer., 28 oct. 2009) | 1 line Remove extra blank line accidentally introduced in r75885 ................ r75895 | tarek.ziade | 2009-10-28 00:12:01 +0100 (mer., 28 oct. 2009) | 9 lines Merged revisions 75893 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75893 | tarek.ziade | 2009-10-28 00:06:10 +0100 (Wed, 28 Oct 2009) | 1 line Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils ........ ................ r75903 | tarek.ziade | 2009-10-28 07:48:27 +0100 (mer., 28 oct. 2009) | 9 lines Merged revisions 75901 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75901 | tarek.ziade | 2009-10-28 07:45:18 +0100 (Wed, 28 Oct 2009) | 1 line removed spurious spaces ........ ................ r75907 | mark.dickinson | 2009-10-28 08:25:03 +0100 (mer., 28 oct. 2009) | 9 lines Merged revisions 75905 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75905 | mark.dickinson | 2009-10-28 07:23:49 +0000 (Wed, 28 Oct 2009) | 1 line Replace long long with PY_LONG_LONG ........ ................ r75911 | mark.dickinson | 2009-10-28 08:49:26 +0100 (mer., 28 oct. 2009) | 9 lines Merged revisions 75909 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75909 | mark.dickinson | 2009-10-28 07:47:32 +0000 (Wed, 28 Oct 2009) | 1 line Fix format specifier for MSVC ........ ................ r75914 | eric.smith | 2009-10-28 09:46:43 +0100 (mer., 28 oct. 2009) | 8 lines Blocked revisions 75913 via svnmerge ........ r75913 | eric.smith | 2009-10-28 04:44:37 -0400 (Wed, 28 Oct 2009) | 1 line Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in _json.c as part of short float repr. Change made after consulting with Bob Ippolito. This completes the removal of calls to PyOS_ascii_strtod. ........ ................ Modified: sandbox/trunk/newgil/ (props changed) sandbox/trunk/newgil/Demo/comparisons/sortingtest.py sandbox/trunk/newgil/Doc/ACKS.txt sandbox/trunk/newgil/Doc/distutils/apiref.rst sandbox/trunk/newgil/Doc/distutils/builtdist.rst sandbox/trunk/newgil/Doc/documenting/markup.rst sandbox/trunk/newgil/Doc/faq/design.rst sandbox/trunk/newgil/Doc/faq/extending.rst sandbox/trunk/newgil/Doc/faq/general.rst sandbox/trunk/newgil/Doc/faq/gui.rst sandbox/trunk/newgil/Doc/faq/library.rst sandbox/trunk/newgil/Doc/faq/programming.rst sandbox/trunk/newgil/Doc/faq/windows.rst sandbox/trunk/newgil/Doc/howto/unicode.rst sandbox/trunk/newgil/Doc/howto/webservers.rst sandbox/trunk/newgil/Doc/install/index.rst sandbox/trunk/newgil/Doc/library/codecs.rst sandbox/trunk/newgil/Doc/library/configparser.rst sandbox/trunk/newgil/Doc/library/curses.rst sandbox/trunk/newgil/Doc/library/datetime.rst sandbox/trunk/newgil/Doc/library/functions.rst sandbox/trunk/newgil/Doc/library/getopt.rst sandbox/trunk/newgil/Doc/library/inspect.rst sandbox/trunk/newgil/Doc/library/mailbox.rst sandbox/trunk/newgil/Doc/library/math.rst sandbox/trunk/newgil/Doc/library/msilib.rst sandbox/trunk/newgil/Doc/library/os.rst sandbox/trunk/newgil/Doc/library/othergui.rst sandbox/trunk/newgil/Doc/library/platform.rst sandbox/trunk/newgil/Doc/library/signal.rst sandbox/trunk/newgil/Doc/library/stdtypes.rst sandbox/trunk/newgil/Doc/library/sys.rst sandbox/trunk/newgil/Doc/library/types.rst sandbox/trunk/newgil/Doc/library/weakref.rst sandbox/trunk/newgil/Doc/reference/datamodel.rst sandbox/trunk/newgil/Doc/reference/executionmodel.rst sandbox/trunk/newgil/Doc/reference/expressions.rst sandbox/trunk/newgil/Doc/reference/simple_stmts.rst sandbox/trunk/newgil/Doc/tools/sphinxext/pyspecific.py sandbox/trunk/newgil/Doc/tools/sphinxext/static/basic.css sandbox/trunk/newgil/Doc/tutorial/index.rst sandbox/trunk/newgil/Doc/using/cmdline.rst sandbox/trunk/newgil/Doc/using/windows.rst sandbox/trunk/newgil/Doc/whatsnew/2.0.rst sandbox/trunk/newgil/Doc/whatsnew/2.2.rst sandbox/trunk/newgil/Doc/whatsnew/2.3.rst sandbox/trunk/newgil/Doc/whatsnew/2.4.rst sandbox/trunk/newgil/Doc/whatsnew/2.6.rst sandbox/trunk/newgil/Lib/distutils/core.py sandbox/trunk/newgil/Lib/distutils/dist.py sandbox/trunk/newgil/Lib/distutils/errors.py sandbox/trunk/newgil/Lib/distutils/tests/test_dist.py sandbox/trunk/newgil/Lib/test/regrtest.py sandbox/trunk/newgil/Lib/test/test_asyncore.py sandbox/trunk/newgil/Lib/test/test_bz2.py sandbox/trunk/newgil/Lib/test/test_complex.py sandbox/trunk/newgil/Lib/test/test_distutils.py sandbox/trunk/newgil/Lib/test/test_float.py sandbox/trunk/newgil/Lib/test/test_httpservers.py sandbox/trunk/newgil/Lib/test/test_site.py sandbox/trunk/newgil/Lib/test/test_smtplib.py sandbox/trunk/newgil/Lib/test/test_socketserver.py sandbox/trunk/newgil/Lib/test/test_sys.py sandbox/trunk/newgil/Lib/test/test_telnetlib.py sandbox/trunk/newgil/Lib/test/test_threading.py sandbox/trunk/newgil/Lib/test/test_urllib2_localnet.py sandbox/trunk/newgil/Lib/threading.py sandbox/trunk/newgil/Lib/warnings.py sandbox/trunk/newgil/Makefile.pre.in sandbox/trunk/newgil/Misc/NEWS sandbox/trunk/newgil/Modules/_ctypes/_ctypes.c sandbox/trunk/newgil/Modules/_io/_iomodule.h sandbox/trunk/newgil/Modules/_io/bufferedio.c sandbox/trunk/newgil/Modules/_localemodule.c sandbox/trunk/newgil/Modules/_testcapimodule.c sandbox/trunk/newgil/Modules/bz2module.c sandbox/trunk/newgil/Modules/readline.c sandbox/trunk/newgil/Objects/complexobject.c sandbox/trunk/newgil/Objects/floatobject.c sandbox/trunk/newgil/Objects/unicodeobject.c sandbox/trunk/newgil/Python/codecs.c sandbox/trunk/newgil/configure sandbox/trunk/newgil/configure.in sandbox/trunk/newgil/pyconfig.h.in Modified: sandbox/trunk/newgil/Demo/comparisons/sortingtest.py ============================================================================== --- sandbox/trunk/newgil/Demo/comparisons/sortingtest.py (original) +++ sandbox/trunk/newgil/Demo/comparisons/sortingtest.py Wed Oct 28 11:50:44 2009 @@ -24,7 +24,6 @@ # - Handles blank input lines correctly import re -import string import sys def main(): @@ -32,18 +31,13 @@ def makekey(item, prog=prog): match = prog.match(item) if match: - var, num = match.group(1, 2) - return string.atoi(num), var + var, num = match.groups() + return int(num), var else: # Bad input -- pretend it's a var with value 0 return 0, item - while 1: - line = sys.stdin.readline() - if not line: - break - items = line.split() - items = list(map(makekey, items)) - items.sort() + for line in sys.stdin: + items = sorted(makekey(item) for item in line.split()) for num, var in items: print("%s=%s" % (var, num), end=' ') print() Modified: sandbox/trunk/newgil/Doc/ACKS.txt ============================================================================== --- sandbox/trunk/newgil/Doc/ACKS.txt (original) +++ sandbox/trunk/newgil/Doc/ACKS.txt Wed Oct 28 11:50:44 2009 @@ -208,6 +208,7 @@ * Mats Wichmann * Gerry Wiener * Timothy Wild + * Paul Winkler * Collin Winter * Blake Winton * Dan Wolfe Modified: sandbox/trunk/newgil/Doc/distutils/apiref.rst ============================================================================== --- sandbox/trunk/newgil/Doc/distutils/apiref.rst (original) +++ sandbox/trunk/newgil/Doc/distutils/apiref.rst Wed Oct 28 11:50:44 2009 @@ -1976,9 +1976,9 @@ Subclasses of :class:`Command` must define the following methods. -.. method:: Command.initialize_options()(S) +.. method:: Command.initialize_options() - et default values for all the options that this command supports. Note that + Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, :meth:`initialize_options` Modified: sandbox/trunk/newgil/Doc/distutils/builtdist.rst ============================================================================== --- sandbox/trunk/newgil/Doc/distutils/builtdist.rst (original) +++ sandbox/trunk/newgil/Doc/distutils/builtdist.rst Wed Oct 28 11:50:44 2009 @@ -241,7 +241,8 @@ configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`. If you distribute or package many Python module distributions, you might want to put options that apply to all of them in your personal Distutils configuration -file (:file:`~/.pydistutils.cfg`). +file (:file:`~/.pydistutils.cfg`). If you want to temporarily disable +this file, you can pass the --no-user-cfg option to setup.py. There are three steps to building a binary RPM package, all of which are handled automatically by the Distutils: Modified: sandbox/trunk/newgil/Doc/documenting/markup.rst ============================================================================== --- sandbox/trunk/newgil/Doc/documenting/markup.rst (original) +++ sandbox/trunk/newgil/Doc/documenting/markup.rst Wed Oct 28 11:50:44 2009 @@ -626,6 +626,24 @@ -------------- +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + .. describe:: seealso Many sections include a list of references to module documentation or Modified: sandbox/trunk/newgil/Doc/faq/design.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/design.rst (original) +++ sandbox/trunk/newgil/Doc/faq/design.rst Wed Oct 28 11:50:44 2009 @@ -396,12 +396,13 @@ ``x+1``. Several projects described in the Python newsgroup or at past `Python -conferences `_ have shown that this approach is feasible, -although the speedups reached so far are only modest (e.g. 2x). Jython uses the -same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated -that in combination with whole-program analysis, speedups of 1000x are feasible -for small demo programs. See the proceedings from the `1997 Python conference -`_ for more information.) +conferences `_ have shown that this +approach is feasible, although the speedups reached so far are only modest +(e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim +Hugunin has demonstrated that in combination with whole-program analysis, +speedups of 1000x are feasible for small demo programs. See the proceedings +from the `1997 Python conference +`_ for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual Modified: sandbox/trunk/newgil/Doc/faq/extending.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/extending.rst (original) +++ sandbox/trunk/newgil/Doc/faq/extending.rst Wed Oct 28 11:50:44 2009 @@ -48,7 +48,7 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`_, `CXX +`__, `CXX `_ `Boost `_, or `Weave `_ are also alternatives for wrapping Modified: sandbox/trunk/newgil/Doc/faq/general.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/general.rst (original) +++ sandbox/trunk/newgil/Doc/faq/general.rst Wed Oct 28 11:50:44 2009 @@ -164,9 +164,10 @@ several useful pieces of freely distributable software. The source will compile and run out of the box on most UNIX platforms. -Consult the `Developer FAQ -`__ for more information -on getting the source code and compiling it. +.. XXX update link once the dev faq is relocated + +Consult the `Developer FAQ `__ for more +information on getting the source code and compiling it. How do I get documentation on Python? @@ -176,7 +177,7 @@ The standard documentation for the current stable version of Python is available at http://docs.python.org/. PDF, plain text, and downloadable HTML versions are -also available at http://docs.python.org/download/. +also available at http://docs.python.org/download.html. The documentation is written in reStructuredText and processed by `the Sphinx documentation tool `__. The reStructuredText source @@ -220,8 +221,10 @@ newsgroups and on the Python home page at http://www.python.org/; an RSS feed of news is available. +.. XXX update link once the dev faq is relocated + You can also access the development version of Python through Subversion. See -http://www.python.org/dev/devfaq.html#subversion-svn for details. +http://www.python.org/dev/faq/ for details. How do I submit bug reports and patches for Python? Modified: sandbox/trunk/newgil/Doc/faq/gui.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/gui.rst (original) +++ sandbox/trunk/newgil/Doc/faq/gui.rst Wed Oct 28 11:50:44 2009 @@ -45,11 +45,12 @@ ''' There are bindings available for the Qt toolkit (`PyQt -`_) and for KDE (PyKDE). If you're -writing open source software, you don't need to pay for PyQt, but if you want to -write proprietary applications, you must buy a PyQt license from `Riverbank -Computing `_ and a Qt license from -`Trolltech `_. +`_) and for KDE (PyKDE). If +you're writing open source software, you don't need to pay for PyQt, but if you +want to write proprietary applications, you must buy a PyQt license from +`Riverbank Computing `_ and (up to Qt 4.4; +Qt 4.5 upwards is licensed under the LGPL license) a Qt license from `Trolltech +`_. Gtk+ '''' Modified: sandbox/trunk/newgil/Doc/faq/library.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/library.rst (original) +++ sandbox/trunk/newgil/Doc/faq/library.rst Wed Oct 28 11:50:44 2009 @@ -16,14 +16,10 @@ standard library module. (Eventually you'll learn what's in the standard library and will able to skip this step.) -Search the `Python Package Index `_. - -Next, check the `Vaults of Parnassus `_, an older -index of packages. - -Finally, try `Google `_ or other Web search engine. -Searching for "Python" plus a keyword or two for your topic of interest will -usually find something helpful. +For third-party packages, search the `Python Package Index +`_ or try `Google `_ or +another Web search engine. Searching for "Python" plus a keyword or two for +your topic of interest will usually find something helpful. Where is the math.py (socket.py, regex.py, etc.) source file? @@ -181,11 +177,10 @@ How do I create documentation from doc strings? ----------------------------------------------- -.. XXX mention Sphinx/epydoc - The :mod:`pydoc` module can create HTML from the doc strings in your Python -source code. An alternative is `pythondoc -`_. +source code. An alternative for creating API documentation purely from +docstrings is `epydoc `_. `Sphinx +`_ can also include docstring content. How do I get a single keypress at a time? @@ -237,7 +232,7 @@ low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see -http://starship.python.net/crew/aahz/OSCON2001/. +http://www.pythoncraft.com/OSCON2001/. None of my threads seem to run: why? @@ -397,6 +392,7 @@ ------------------------------------------------ .. XXX mention multiprocessing +.. XXX link to dbeazley's talk about GIL? The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded @@ -583,7 +579,7 @@ ("ptys") instead of pipes. Or you can use a Python interface to Don Libes' "expect" library. A Python extension that interfaces to expect is called "expy" and available from http://expectpy.sourceforge.net. A pure Python solution that -works like expect is ` pexpect `_. +works like expect is `pexpect `_. How do I access the serial (RS232) port? Modified: sandbox/trunk/newgil/Doc/faq/programming.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/programming.rst (original) +++ sandbox/trunk/newgil/Doc/faq/programming.rst Wed Oct 28 11:50:44 2009 @@ -67,8 +67,8 @@ PyChecker performs, Pylint offers some additional features such as checking line length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://www.logilab.org/projects/pylint/documentation provides a full list of -Pylint's features. +http://www.logilab.org/card/pylint_manual provides a full list of Pylint's +features. How can I create a stand-alone binary from a Python script? @@ -1141,7 +1141,7 @@ A = [[None] * w for i in range(h)] Or, you can use an extension that provides a matrix datatype; `Numeric Python -`_ is the best known. +`_ is the best known. How do I apply a method to a sequence of objects? Modified: sandbox/trunk/newgil/Doc/faq/windows.rst ============================================================================== --- sandbox/trunk/newgil/Doc/faq/windows.rst (original) +++ sandbox/trunk/newgil/Doc/faq/windows.rst Wed Oct 28 11:50:44 2009 @@ -389,10 +389,10 @@ .py :REG_SZ: c:\\python.exe -u %s %s This line will allow you to call your script with a simple reference like: -http://yourserver/scripts/yourscript.py provided "scripts" is an "executable" -directory for your server (which it usually is by default). The "-u" flag -specifies unbuffered and binary mode for stdin - needed when working with binary -data. +``http://yourserver/scripts/yourscript.py`` provided "scripts" is an +"executable" directory for your server (which it usually is by default). The +:option:`-u` flag specifies unbuffered and binary mode for stdin - needed when +working with binary data. In addition, it is recommended that using ".py" may not be a good idea for the file extensions when used in this context (you might want to reserve ``*.py`` @@ -517,7 +517,7 @@ There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will -find links to the knowledge base at: http://www.microsoft.com/kb. +find links to the knowledge base at: http://support.microsoft.com/. PyRun_SimpleFile() crashes on Windows but not on Unix; why? @@ -604,4 +604,4 @@ we can't fix it). David A Burton has written a little program to fix this. Go to -http://www.burtonsys.com/download.html and click on "ctl3dfix.zip". +http://www.burtonsys.com/downloads.html and click on "ctl3dfix.zip". Modified: sandbox/trunk/newgil/Doc/howto/unicode.rst ============================================================================== --- sandbox/trunk/newgil/Doc/howto/unicode.rst (original) +++ sandbox/trunk/newgil/Doc/howto/unicode.rst Wed Oct 28 11:50:44 2009 @@ -403,7 +403,7 @@ from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol, other". See - for a + for a list of category codes. References Modified: sandbox/trunk/newgil/Doc/howto/webservers.rst ============================================================================== --- sandbox/trunk/newgil/Doc/howto/webservers.rst (original) +++ sandbox/trunk/newgil/Doc/howto/webservers.rst Wed Oct 28 11:50:44 2009 @@ -270,8 +270,7 @@ * lighttpd ships its own `FastCGI module `_ as well as an `SCGI module `_. -* nginx also supports `FastCGI - `_. +* nginx also supports `FastCGI `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -525,7 +524,7 @@ informations on a web server. Often relational database engines like `MySQL `_ or -`PostgreSQL `_ are used due to their good +`PostgreSQL `_ are used due to their good performance handling very large databases consisting of up to millions of entries. These are *queried* using a language called `SQL `_. Python programmers in general do not like @@ -629,7 +628,7 @@ It has a big, international community which has created many sites using Django. There are also quite a lot of add-on projects which extend Django's normal functionality. This is partly due to Django's well written `online -documentation `_ and the `Django book +documentation `_ and the `Django book `_. Modified: sandbox/trunk/newgil/Doc/install/index.rst ============================================================================== --- sandbox/trunk/newgil/Doc/install/index.rst (original) +++ sandbox/trunk/newgil/Doc/install/index.rst Wed Oct 28 11:50:44 2009 @@ -691,6 +691,9 @@ | local | :file:`setup.cfg` | \(3) | +--------------+-------------------------------------------------+-------+ +On all platforms, the "personal" file can be temporarily disabled by +passing the `--no-user-cfg` option. + Notes: (1) @@ -937,7 +940,8 @@ These compilers require some special libraries. This task is more complex than for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find -a good program for this task at http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html) +a good program for this task at +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) Modified: sandbox/trunk/newgil/Doc/library/codecs.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/codecs.rst (original) +++ sandbox/trunk/newgil/Doc/library/codecs.rst Wed Oct 28 11:50:44 2009 @@ -53,7 +53,7 @@ *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: - ``factory(errors='strict')`` + ``factory(errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, @@ -62,21 +62,25 @@ *streamreader* and *streamwriter*: These have to be factory functions providing the following interface: - ``factory(stream, errors='strict')`` + ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. - Possible values for errors are ``'strict'`` (raise an exception in case of an - encoding error), ``'replace'`` (replace malformed data with a suitable - replacement marker, such as ``'?'``), ``'ignore'`` (ignore malformed data and - continue without further notice), ``'xmlcharrefreplace'`` (replace with the - appropriate XML character reference (for encoding only)), - ``'backslashreplace'`` (replace with backslashed escape sequences (for - encoding only)), ``'surrogateescape'`` (replace with surrogate U+DCxx, see - :pep:`383`) as well as any other error handling name defined via - :func:`register_error`. + Possible values for errors are + + * ``'strict'``: raise an exception in case of an encoding error + * ``'replace'``: replace malformed data with a suitable replacement marker, + such as ``'?'`` or ``'\ufffd'`` + * ``'ignore'``: ignore malformed data and continue without further notice + * ``'xmlcharrefreplace'``: replace with the appropriate XML character + reference (for encoding only) + * ``'backslashreplace'``: replace with backslashed escape sequences (for + encoding only + * ``'surrogateescape'``: replace with surrogate U+DCxx, see :pep:`383` + + as well as any other error handling name defined via :func:`register_error`. In case a search function cannot find a given encoding, it should return ``None``. @@ -173,27 +177,33 @@ .. function:: strict_errors(exception) - Implements the ``strict`` error handling. + Implements the ``strict`` error handling: each encoding or decoding error + raises a :exc:`UnicodeError`. .. function:: replace_errors(exception) - Implements the ``replace`` error handling. + Implements the ``replace`` error handling: malformed data is replaced with a + suitable replacement character such as ``'?'`` in bytestrings and + ``'\ufffd'`` in Unicode strings. .. function:: ignore_errors(exception) - Implements the ``ignore`` error handling. + Implements the ``ignore`` error handling: malformed data is ignored and + encoding or decoding is continued without further notice. .. function:: xmlcharrefreplace_errors(exception) - Implements the ``xmlcharrefreplace`` error handling. + Implements the ``xmlcharrefreplace`` error handling (for encoding only): the + unencodable character is replaced by an appropriate XML character reference. .. function:: backslashreplace_errors(exception) - Implements the ``backslashreplace`` error handling. + Implements the ``backslashreplace`` error handling (for encoding only): the + unencodable character is replaced by a backslashed escape sequence. To simplify working with encoded files or stream, the module also defines these utility functions: Modified: sandbox/trunk/newgil/Doc/library/configparser.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/configparser.rst (original) +++ sandbox/trunk/newgil/Doc/library/configparser.rst Wed Oct 28 11:50:44 2009 @@ -301,12 +301,23 @@ .. method:: RawConfigParser.optionxform(option) - Transforms the option name *option* as found in an input file or as passed in by - client code to the form that should be used in the internal structures. The - default implementation returns a lower-case version of *option*; subclasses may - override this or client code can set an attribute of this name on instances to - affect this behavior. Setting this to :func:`str`, for example, would make - option names case sensitive. + Transforms the option name *option* as found in an input file or as passed in + by client code to the form that should be used in the internal structures. + The default implementation returns a lower-case version of *option*; + subclasses may override this or client code can set an attribute of this name + on instances to affect this behavior. + + You don't necessarily need to subclass a ConfigParser to use this method, you + can also re-set it on an instance, to a function that takes a string + argument. Setting it to ``str``, for example, would make option names case + sensitive:: + + cfgparser = ConfigParser() + ... + cfgparser.optionxform = str + + Note that when reading configuration files, whitespace around the + option names are stripped before :meth:`optionxform` is called. .. _configparser-objects: Modified: sandbox/trunk/newgil/Doc/library/curses.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/curses.rst (original) +++ sandbox/trunk/newgil/Doc/library/curses.rst Wed Oct 28 11:50:44 2009 @@ -4,10 +4,10 @@ .. module:: curses :synopsis: An interface to the curses library, providing portable terminal handling. + :platform: Unix .. sectionauthor:: Moshe Zadka .. sectionauthor:: Eric Raymond - The :mod:`curses` module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling. Modified: sandbox/trunk/newgil/Doc/library/datetime.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/datetime.rst (original) +++ sandbox/trunk/newgil/Doc/library/datetime.rst Wed Oct 28 11:50:44 2009 @@ -233,7 +233,7 @@ | | (-*t1.days*, -*t1.seconds*, | | | -*t1.microseconds*), and to *t1*\* -1. (1)(4) | +--------------------------------+-----------------------------------------------+ -| ``abs(t)`` | equivalent to +*t* when ``t.days >= 0``, and | +| ``abs(t)`` | equivalent to +\ *t* when ``t.days >= 0``, and| | | to -*t* when ``t.days < 0``. (2) | +--------------------------------+-----------------------------------------------+ Modified: sandbox/trunk/newgil/Doc/library/functions.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/functions.rst (original) +++ sandbox/trunk/newgil/Doc/library/functions.rst Wed Oct 28 11:50:44 2009 @@ -499,8 +499,10 @@ Return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. - Two objects with non-overlapping lifetimes may have the same :func:`id` value. - (Implementation note: this is the address of the object.) + Two objects with non-overlapping lifetimes may have the same :func:`id` + value. + + .. impl-detail:: This is the address of the object. .. function:: input([prompt]) Modified: sandbox/trunk/newgil/Doc/library/getopt.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/getopt.rst (original) +++ sandbox/trunk/newgil/Doc/library/getopt.rst Wed Oct 28 11:50:44 2009 @@ -36,12 +36,13 @@ *longopts*, if specified, must be a list of strings with the names of the long options which should be supported. The leading ``'--'`` characters should not be included in the option name. Long options which require an - argument should be followed by an equal sign (``'='``). To accept only long - options, *shortopts* should be an empty string. Long options on the command line - can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *longopts* is - ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, - but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. + argument should be followed by an equal sign (``'='``). Optional arguments + are not supported. To accept only long options, *shortopts* should be an + empty string. Long options on the command line can be recognized so long as + they provide a prefix of the option name that matches exactly one of the + accepted options. For example, if *longopts* is ``['foo', 'frob']``, the + option :option:`--fo` will match as :option:`--foo`, but :option:`--f` will + not match uniquely, so :exc:`GetoptError` will be raised. The return value consists of two elements: the first is a list of ``(option, value)`` pairs; the second is the list of program arguments left after the Modified: sandbox/trunk/newgil/Doc/library/inspect.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/inspect.rst (original) +++ sandbox/trunk/newgil/Doc/library/inspect.rst Wed Oct 28 11:50:44 2009 @@ -290,18 +290,22 @@ Return true if the object is a getset descriptor. - getsets are attributes defined in extension modules via ``PyGetSetDef`` - structures. For Python implementations without such types, this method will - always return ``False``. + .. impl-detail:: + + getsets are attributes defined in extension modules via + :ctype:`PyGetSetDef` structures. For Python implementations without such + types, this method will always return ``False``. .. function:: ismemberdescriptor(object) Return true if the object is a member descriptor. - Member descriptors are attributes defined in extension modules via - ``PyMemberDef`` structures. For Python implementations without such types, - this method will always return ``False``. + .. impl-detail:: + + Member descriptors are attributes defined in extension modules via + :ctype:`PyMemberDef` structures. For Python implementations without such + types, this method will always return ``False``. .. _inspect-source: @@ -508,10 +512,12 @@ Return the frame object for the caller's stack frame. - This function relies on Python stack frame support in the interpreter, which - isn't guaranteed to exist in all implementations of Python. If running in - an implementation without Python stack frame support this function returns - ``None``. + .. impl-detail:: + + This function relies on Python stack frame support in the interpreter, + which isn't guaranteed to exist in all implementations of Python. If + running in an implementation without Python stack frame support this + function returns ``None``. .. function:: stack(context=1) Modified: sandbox/trunk/newgil/Doc/library/mailbox.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/mailbox.rst (original) +++ sandbox/trunk/newgil/Doc/library/mailbox.rst Wed Oct 28 11:50:44 2009 @@ -595,7 +595,7 @@ `nmh - Message Handling System `_ Home page of :program:`nmh`, an updated version of the original :program:`mh`. - `MH & nmh: Email for Users & Programmers `_ + `MH & nmh: Email for Users & Programmers `_ A GPL-licensed book on :program:`mh` and :program:`nmh`, with some information on the mailbox format. Modified: sandbox/trunk/newgil/Doc/library/math.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/math.rst (original) +++ sandbox/trunk/newgil/Doc/library/math.rst Wed Oct 28 11:50:44 2009 @@ -301,7 +301,7 @@ The mathematical constant *e*. -.. note:: +.. impl-detail:: The :mod:`math` module consists mostly of thin wrappers around the platform C math library functions. Behavior in exceptional cases is loosely specified Modified: sandbox/trunk/newgil/Doc/library/msilib.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/msilib.rst (original) +++ sandbox/trunk/newgil/Doc/library/msilib.rst Wed Oct 28 11:50:44 2009 @@ -394,10 +394,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -422,7 +422,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -516,13 +516,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: @@ -551,5 +551,3 @@ This module contains definitions for the UIText and ActionText tables, for the standard installer actions. - - Modified: sandbox/trunk/newgil/Doc/library/os.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/os.rst (original) +++ sandbox/trunk/newgil/Doc/library/os.rst Wed Oct 28 11:50:44 2009 @@ -1576,9 +1576,9 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :cfunc:`system`, and has the same limitations. Changes - to :data:`os.environ`, :data:`sys.stdin`, etc. are not reflected in the - environment of the executed command. + the Standard C function :cfunc:`system`, and has the same limitations. + Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the + executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning Modified: sandbox/trunk/newgil/Doc/library/othergui.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/othergui.rst (original) +++ sandbox/trunk/newgil/Doc/library/othergui.rst Wed Oct 28 11:50:44 2009 @@ -43,7 +43,7 @@ `PythonCAD `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool Modified: sandbox/trunk/newgil/Doc/library/platform.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/platform.rst (original) +++ sandbox/trunk/newgil/Doc/library/platform.rst Wed Oct 28 11:50:44 2009 @@ -94,7 +94,7 @@ .. function:: python_implementation() Returns a string identifying the Python implementation. Possible return values - are: 'CPython', 'IronPython', 'Jython' + are: 'CPython', 'IronPython', 'Jython'. .. function:: python_revision() Modified: sandbox/trunk/newgil/Doc/library/signal.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/signal.rst (original) +++ sandbox/trunk/newgil/Doc/library/signal.rst Wed Oct 28 11:50:44 2009 @@ -157,13 +157,14 @@ The old values are returned as a tuple: (delay, interval). - Attempting to pass an invalid interval timer will cause a - :exc:`ItimerError`. + Attempting to pass an invalid interval timer will cause an + :exc:`ItimerError`. Availability: Unix. .. function:: getitimer(which) Returns current value of a given interval timer specified by *which*. + Availability: Unix. .. function:: set_wakeup_fd(fd) @@ -184,7 +185,7 @@ Change system call restart behaviour: if *flag* is :const:`False`, system calls will be restarted when interrupted by signal *signalnum*, otherwise - system calls will be interrupted. Returns nothing. Availability: Unix (see + system calls will be interrupted. Returns nothing. Availability: Unix (see the man page :manpage:`siginterrupt(3)` for further information). Note that installing a signal handler with :func:`signal` will reset the Modified: sandbox/trunk/newgil/Doc/library/stdtypes.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/stdtypes.rst (original) +++ sandbox/trunk/newgil/Doc/library/stdtypes.rst Wed Oct 28 11:50:44 2009 @@ -772,13 +772,15 @@ If *k* is ``None``, it is treated like ``1``. (6) - If *s* and *t* are both strings, some Python implementations such as CPython can - usually perform an in-place optimization for assignments of the form ``s=s+t`` - or ``s+=t``. When applicable, this optimization makes quadratic run-time much - less likely. This optimization is both version and implementation dependent. - For performance sensitive code, it is preferable to use the :meth:`str.join` - method which assures consistent linear concatenation performance across versions - and implementations. + .. impl-detail:: + + If *s* and *t* are both strings, some Python implementations such as + CPython can usually perform an in-place optimization for assignments of + the form ``s = s + t`` or ``s += t``. When applicable, this optimization + makes quadratic run-time much less likely. This optimization is both + version and implementation dependent. For performance sensitive code, it + is preferable to use the :meth:`str.join` method which assures consistent + linear concatenation performance across versions and implementations. .. _string-methods: @@ -951,12 +953,12 @@ least one cased character, false otherwise. -.. method:: str.join(seq) +.. method:: str.join(iterable) - Return a string which is the concatenation of the strings in the sequence - *seq*. A :exc:`TypeError` will be raised if there are any non-string values - in *seq*, including :class:`bytes` objects. The separator between elements - is the string providing this method. + Return a string which is the concatenation of the strings in the + :term:`iterable` *iterable*. A :exc:`TypeError` will be raised if there are + any non-string values in *seq*, including :class:`bytes` objects. The + separator between elements is the string providing this method. .. method:: str.ljust(width[, fillchar]) @@ -1510,14 +1512,17 @@ that compare equal --- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). - While a list is being sorted, the effect of attempting to mutate, or even - inspect, the list is undefined. The C implementation - makes the list appear empty for the duration, and raises :exc:`ValueError` if it - can detect that the list has been mutated during a sort. + .. impl-detail:: + + While a list is being sorted, the effect of attempting to mutate, or even + inspect, the list is undefined. The C implementation of Python makes the + list appear empty for the duration, and raises :exc:`ValueError` if it can + detect that the list has been mutated during a sort. (8) :meth:`sort` is not supported by :class:`bytearray` objects. + .. _bytes-methods: Bytes and Byte Array Methods Modified: sandbox/trunk/newgil/Doc/library/sys.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/sys.rst (original) +++ sandbox/trunk/newgil/Doc/library/sys.rst Wed Oct 28 11:50:44 2009 @@ -352,8 +352,10 @@ that is deeper than the call stack, :exc:`ValueError` is raised. The default for *depth* is zero, returning the frame at the top of the call stack. - This function should be used for internal and specialized purposes only. It - is not guaranteed to exist in all implementations of Python. + .. impl-detail:: + + This function should be used for internal and specialized purposes only. + It is not guaranteed to exist in all implementations of Python. .. function:: getprofile() @@ -373,12 +375,12 @@ Get the trace function as set by :func:`settrace`. - .. note:: + .. impl-detail:: The :func:`gettrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, - and thus may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: getwindowsversion() @@ -750,12 +752,12 @@ For more information on code and frame objects, refer to :ref:`types`. - .. note:: + .. impl-detail:: The :func:`settrace` function is intended only for implementing debuggers, - profilers, coverage tools and the like. Its behavior is part of the - implementation platform, rather than part of the language definition, and thus - may not be available in all Python implementations. + profilers, coverage tools and the like. Its behavior is part of the + implementation platform, rather than part of the language definition, and + thus may not be available in all Python implementations. .. function:: settscdump(on_flag) Modified: sandbox/trunk/newgil/Doc/library/types.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/types.rst (original) +++ sandbox/trunk/newgil/Doc/library/types.rst Wed Oct 28 11:50:44 2009 @@ -77,5 +77,8 @@ as ``datetime.timedelta.days``. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the :class:`property` type, but for classes defined in extension modules. - In other implementations of Python, this type may be identical to - ``GetSetDescriptorType``. + + .. impl-detail:: + + In other implementations of Python, this type may be identical to + ``GetSetDescriptorType``. Modified: sandbox/trunk/newgil/Doc/library/weakref.rst ============================================================================== --- sandbox/trunk/newgil/Doc/library/weakref.rst (original) +++ sandbox/trunk/newgil/Doc/library/weakref.rst Wed Oct 28 11:50:44 2009 @@ -72,9 +72,10 @@ obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable -Other built-in types such as :class:`tuple` and :class:`int` do not support -weak references even when subclassed (those types implemented as a -:ctype:`PyVarObject`). +.. impl-detail:: + + Other built-in types such as :class:`tuple` and :class:`long` do not support + weak references even when subclassed. Extension types can easily be made to support weak references; see :ref:`weakref-support`. Modified: sandbox/trunk/newgil/Doc/reference/datamodel.rst ============================================================================== --- sandbox/trunk/newgil/Doc/reference/datamodel.rst (original) +++ sandbox/trunk/newgil/Doc/reference/datamodel.rst Wed Oct 28 11:50:44 2009 @@ -59,13 +59,16 @@ they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether --- it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that -are still reachable. (Implementation note: CPython currently uses a -reference-counting scheme with (optional) delayed detection of cyclically linked -garbage, which collects most objects as soon as they become unreachable, but is -not guaranteed to collect garbage containing circular references. See the -documentation of the :mod:`gc` module for information on controlling the -collection of cyclic garbage. Other implementations act differently and CPython -may change.) +are still reachable. + +.. impl-detail:: + + CPython currently uses a reference-counting scheme with (optional) delayed + detection of cyclically linked garbage, which collects most objects as soon + as they become unreachable, but is not guaranteed to collect garbage + containing circular references. See the documentation of the :mod:`gc` + module for information on controlling the collection of cyclic garbage. + Other implementations act differently and CPython may change. Note that the use of the implementation's tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching @@ -1469,15 +1472,15 @@ *__slots__*; otherwise, the class attribute would overwrite the descriptor assignment. +* The action of a *__slots__* declaration is limited to the class where it is + defined. As a result, subclasses will have a *__dict__* unless they also define + *__slots__* (which must only contain names of any *additional* slots). + * If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). This renders the meaning of the program undefined. In the future, a check may be added to prevent this. -* The action of a *__slots__* declaration is limited to the class where it is - defined. As a result, subclasses will have a *__dict__* unless they also define - *__slots__*. - * Nonempty *__slots__* does not work for classes derived from "variable-length" built-in types such as :class:`int`, :class:`str` and :class:`tuple`. @@ -1714,12 +1717,16 @@ supply the following special method with a more efficient implementation, which also does not require the object be a sequence. - .. method:: object.__contains__(self, item) - Called to implement membership test operators. Should return true if *item* is - in *self*, false otherwise. For mapping objects, this should consider the keys - of the mapping rather than the values or the key-item pairs. + Called to implement membership test operators. Should return true if *item* + is in *self*, false otherwise. For mapping objects, this should consider the + keys of the mapping rather than the values or the key-item pairs. + + For objects that don't define :meth:`__contains__`, the membership test first + tries iteration via :meth:`__iter__`, then the old sequence iteration + protocol via :meth:`__getitem__`, see :ref:`this section in the language + reference `. .. _numeric-types: Modified: sandbox/trunk/newgil/Doc/reference/executionmodel.rst ============================================================================== --- sandbox/trunk/newgil/Doc/reference/executionmodel.rst (original) +++ sandbox/trunk/newgil/Doc/reference/executionmodel.rst Wed Oct 28 11:50:44 2009 @@ -129,7 +129,7 @@ itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. -.. note:: +.. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should Modified: sandbox/trunk/newgil/Doc/reference/expressions.rst ============================================================================== --- sandbox/trunk/newgil/Doc/reference/expressions.rst (original) +++ sandbox/trunk/newgil/Doc/reference/expressions.rst Wed Oct 28 11:50:44 2009 @@ -639,13 +639,13 @@ raised. Otherwise, the list of filled slots is used as the argument list for the call. -.. note:: +.. impl-detail:: - An implementation may provide built-in functions whose positional parameters do - not have names, even if they are 'named' for the purpose of documentation, and - which therefore cannot be supplied by keyword. In CPython, this is the case for - functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their - arguments. + An implementation may provide built-in functions whose positional parameters + do not have names, even if they are 'named' for the purpose of documentation, + and which therefore cannot be supplied by keyword. In CPython, this is the + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to + parse their arguments. If there are more positional arguments than there are formal parameter slots, a :exc:`TypeError` exception is raised, unless a formal parameter using the syntax @@ -1053,6 +1053,8 @@ supported cross-type comparisons and unsupported comparisons. For example, ``Decimal(2) == 2`` and `2 == float(2)`` but ``Decimal(2) != float(2)``. +.. _membership-test-details: + The operators :keyword:`in` and :keyword:`not in` test for membership. ``x in s`` evaluates to true if *x* is a member of *s*, and false otherwise. ``x not in s`` returns the negation of ``x in s``. All built-in sequences and set types @@ -1069,7 +1071,12 @@ For user-defined classes which define the :meth:`__contains__` method, ``x in y`` is true if and only if ``y.__contains__(x)`` is true. -For user-defined classes which do not define :meth:`__contains__` and do define +For user-defined classes which do not define :meth:`__contains__` but do define +:meth:`__iter__`, ``x in y`` is true if some value ``z`` with ``x == z`` is +produced while iterating over ``y``. If an exception is raised during the +iteration, it is as if :keyword:`in` raised that exception. + +Lastly, the old-style iteration protocol is tried: if a class defines :meth:`__getitem__`, ``x in y`` is true if and only if there is a non-negative integer index *i* such that ``x == y[i]``, and all lower integer indices do not raise :exc:`IndexError` exception. (If any other exception is raised, it is as Modified: sandbox/trunk/newgil/Doc/reference/simple_stmts.rst ============================================================================== --- sandbox/trunk/newgil/Doc/reference/simple_stmts.rst (original) +++ sandbox/trunk/newgil/Doc/reference/simple_stmts.rst Wed Oct 28 11:50:44 2009 @@ -236,9 +236,11 @@ from the length of the assigned sequence, thus changing the length of the target sequence, if the object allows it. -(In the current implementation, the syntax for targets is taken to be the same -as for expressions, and invalid syntax is rejected during the code generation -phase, causing less detailed error messages.) +.. impl-detail:: + + In the current implementation, the syntax for targets is taken to be the same + as for expressions, and invalid syntax is rejected during the code generation + phase, causing less detailed error messages. WARNING: Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are 'safe' (for example ``a, b = b, a`` @@ -937,9 +939,11 @@ parameters or in a :keyword:`for` loop control target, :keyword:`class` definition, function definition, or :keyword:`import` statement. -(The current implementation does not enforce the latter two restrictions, but -programs should not abuse this freedom, as future implementations may enforce -them or silently change the meaning of the program.) +.. impl-detail:: + + The current implementation does not enforce the latter two restrictions, but + programs should not abuse this freedom, as future implementations may enforce + them or silently change the meaning of the program. .. index:: builtin: exec Modified: sandbox/trunk/newgil/Doc/tools/sphinxext/pyspecific.py ============================================================================== --- sandbox/trunk/newgil/Doc/tools/sphinxext/pyspecific.py (original) +++ sandbox/trunk/newgil/Doc/tools/sphinxext/pyspecific.py Wed Oct 28 11:50:44 2009 @@ -35,6 +35,8 @@ HTMLTranslator.visit_versionmodified = new_visit_versionmodified +# Support for marking up and linking to bugs.python.org issues + def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): issue = utils.unescape(text) text = 'issue ' + issue @@ -42,6 +44,34 @@ return [refnode], [] +# Support for marking up implementation details + +from sphinx.util.compat import Directive + +class ImplementationDetail(Directive): + + has_content = True + required_arguments = 0 + optional_arguments = 1 + final_argument_whitespace = True + + def run(self): + pnode = nodes.compound(classes=['impl-detail']) + content = self.content + add_text = nodes.strong('CPython implementation detail:', + 'CPython implementation detail:') + if self.arguments: + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.append(nodes.paragraph('', '', *(n + m))) + self.state.nested_parse(content, self.content_offset, pnode) + if pnode.children and isinstance(pnode[0], nodes.paragraph): + pnode[0].insert(0, add_text) + pnode[0].insert(1, nodes.Text(' ')) + else: + pnode.insert(0, nodes.paragraph('', '', add_text)) + return [pnode] + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -108,10 +138,12 @@ finally: f.close() + # Support for checking for suspicious markup import suspicious + # Support for documenting Opcodes import re @@ -134,6 +166,7 @@ def setup(app): app.add_role('issue', issue_role) + app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', Modified: sandbox/trunk/newgil/Doc/tools/sphinxext/static/basic.css ============================================================================== --- sandbox/trunk/newgil/Doc/tools/sphinxext/static/basic.css (original) +++ sandbox/trunk/newgil/Doc/tools/sphinxext/static/basic.css Wed Oct 28 11:50:44 2009 @@ -345,6 +345,21 @@ background-color: #ffa } +.impl-detail { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; + border: 1px solid #ccc; +} + +.impl-detail .compound-first { + margin-top: 0; +} + +.impl-detail .compound-last { + margin-bottom: 0; +} + /* -- code displays --------------------------------------------------------- */ pre { @@ -405,7 +420,7 @@ div.document, div.documentwrapper, div.bodywrapper { - margin: 0; + margin: 0 !important; width: 100%; } Modified: sandbox/trunk/newgil/Doc/tutorial/index.rst ============================================================================== --- sandbox/trunk/newgil/Doc/tutorial/index.rst (original) +++ sandbox/trunk/newgil/Doc/tutorial/index.rst Wed Oct 28 11:50:44 2009 @@ -28,18 +28,17 @@ interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. -For a description of standard objects and modules, see the Python Library -Reference document. The Python Reference Manual gives a more formal definition -of the language. To write extensions in C or C++, read Extending and Embedding -the Python Interpreter and Python/C API Reference. There are also several books -covering Python in depth. +For a description of standard objects and modules, see :ref:`library-index`. +:ref:`reference-index` gives a more formal definition of the language. To write +extensions in C or C++, read :ref:`extending-index` and +:ref:`c-api-index`. There are also several books covering Python in depth. This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python's most noteworthy features, and will give you a good idea of the language's flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the -various Python library modules described in the Python Library Reference. +various Python library modules described in :ref:`library-index`. The :ref:`glossary` is also worth going through. Modified: sandbox/trunk/newgil/Doc/using/cmdline.rst ============================================================================== --- sandbox/trunk/newgil/Doc/using/cmdline.rst (original) +++ sandbox/trunk/newgil/Doc/using/cmdline.rst Wed Oct 28 11:50:44 2009 @@ -8,7 +8,7 @@ The CPython interpreter scans the command line and the environment for various settings. -.. note:: +.. impl-detail:: Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. Modified: sandbox/trunk/newgil/Doc/using/windows.rst ============================================================================== --- sandbox/trunk/newgil/Doc/using/windows.rst (original) +++ sandbox/trunk/newgil/Doc/using/windows.rst Wed Oct 28 11:50:44 2009 @@ -67,7 +67,7 @@ `ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Python Enthought Edition `_ +`Enthought Python Distribution `_ Popular modules (such as PyWin32) with their respective documentation, tool suite for building extensible python applications @@ -221,8 +221,7 @@ * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces `PythonWin `_ + `MingW -- Python extensions `_ by Trent Apted et al, 2007 Modified: sandbox/trunk/newgil/Doc/whatsnew/2.0.rst ============================================================================== --- sandbox/trunk/newgil/Doc/whatsnew/2.0.rst (original) +++ sandbox/trunk/newgil/Doc/whatsnew/2.0.rst Wed Oct 28 11:50:44 2009 @@ -572,8 +572,7 @@ mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still ``'win32'`` on Win64 because it seems that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) PythonWin also supports Windows CE; see the -Python CE page at http://starship.python.net/crew/mhammond/ce/ for more -information. +Python CE page at http://pythonce.sourceforge.net/ for more information. Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify "configure --with-dyld --with-suffix=.x". @@ -1041,8 +1040,8 @@ to include SSL support, which adds an additional function to the :mod:`socket` module: :func:`socket.ssl(socket, keyfile, certfile)`, which takes a socket object and returns an SSL socket. The :mod:`httplib` and :mod:`urllib` modules -were also changed to support "https://" URLs, though no one has implemented FTP -or SMTP over SSL. +were also changed to support ``https://`` URLs, though no one has implemented +FTP or SMTP over SSL. The :mod:`httplib` module has been rewritten by Greg Stein to support HTTP/1.1. Backward compatibility with the 1.5 version of :mod:`httplib` is provided, Modified: sandbox/trunk/newgil/Doc/whatsnew/2.2.rst ============================================================================== --- sandbox/trunk/newgil/Doc/whatsnew/2.2.rst (original) +++ sandbox/trunk/newgil/Doc/whatsnew/2.2.rst Wed Oct 28 11:50:44 2009 @@ -30,7 +30,7 @@ to the PEP for a particular new feature. -.. seealso:: +.. seealso (now defunct) http://www.unixreview.com/documents/s=1356/urm0109h/0109h.htm "What's So Special About Python 2.2?" is also about the new 2.2 features, and @@ -49,14 +49,14 @@ complicated section of this article, I'll provide an overview of the changes and offer some comments. -A long time ago I wrote a Web page (http://www.amk.ca/python/writing/warts.html) -listing flaws in Python's design. One of the most significant flaws was that -it's impossible to subclass Python types implemented in C. In particular, it's -not possible to subclass built-in types, so you can't just subclass, say, lists -in order to add a single useful method to them. The :mod:`UserList` module -provides a class that supports all of the methods of lists and that can be -subclassed further, but there's lots of C code that expects a regular Python -list and won't accept a :class:`UserList` instance. +A long time ago I wrote a Web page listing flaws in Python's design. One of the +most significant flaws was that it's impossible to subclass Python types +implemented in C. In particular, it's not possible to subclass built-in types, +so you can't just subclass, say, lists in order to add a single useful method to +them. The :mod:`UserList` module provides a class that supports all of the +methods of lists and that can be subclassed further, but there's lots of C code +that expects a regular Python list and won't accept a :class:`UserList` +instance. Python 2.2 fixes this, and in the process adds some exciting new capabilities. A brief summary: Modified: sandbox/trunk/newgil/Doc/whatsnew/2.3.rst ============================================================================== --- sandbox/trunk/newgil/Doc/whatsnew/2.3.rst (original) +++ sandbox/trunk/newgil/Doc/whatsnew/2.3.rst Wed Oct 28 11:50:44 2009 @@ -1855,10 +1855,10 @@ .. seealso:: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c - For the full details of the pymalloc implementation, see the comments at the top - of the file :file:`Objects/obmalloc.c` in the Python source code. The above - link points to the file within the SourceForge CVS browser. + http://svn.python.org/view/python/trunk/Objects/obmalloc.c + For the full details of the pymalloc implementation, see the comments at + the top of the file :file:`Objects/obmalloc.c` in the Python source code. + The above link points to the file within the python.org SVN browser. .. ====================================================================== Modified: sandbox/trunk/newgil/Doc/whatsnew/2.4.rst ============================================================================== --- sandbox/trunk/newgil/Doc/whatsnew/2.4.rst (original) +++ sandbox/trunk/newgil/Doc/whatsnew/2.4.rst Wed Oct 28 11:50:44 2009 @@ -680,9 +680,6 @@ Written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. - http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html - A more detailed overview of the IEEE-754 representation. - http://www.lahey.com/float.htm The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. @@ -756,7 +753,7 @@ :ctype:`double` to an ASCII string. The code for these functions came from the GLib library -(http://developer.gnome.org/arch/gtk/glib.html), whose developers kindly +(http://library.gnome.org/devel/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. Modified: sandbox/trunk/newgil/Doc/whatsnew/2.6.rst ============================================================================== --- sandbox/trunk/newgil/Doc/whatsnew/2.6.rst (original) +++ sandbox/trunk/newgil/Doc/whatsnew/2.6.rst Wed Oct 28 11:50:44 2009 @@ -1828,7 +1828,7 @@ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol available, instead of restricting itself to protocol 1. - (Contributed by W. Barnes; :issue:`1551443`.) + (Contributed by W. Barnes.) * The :mod:`cgi` module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions @@ -2977,7 +2977,7 @@ * The BerkeleyDB module now has a C API object, available as ``bsddb.db.api``. This object can be used by other C extensions that wish to use the :mod:`bsddb` module for their own purposes. - (Contributed by Duncan Grisby; :issue:`1551895`.) + (Contributed by Duncan Grisby.) * The new buffer interface, previously described in `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__, Modified: sandbox/trunk/newgil/Lib/distutils/core.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/core.py (original) +++ sandbox/trunk/newgil/Lib/distutils/core.py Wed Oct 28 11:50:44 2009 @@ -129,8 +129,9 @@ if _setup_stop_after == "config": return dist - # Parse the command line; any command-line errors are the end user's - # fault, so turn them into SystemExit to suppress tracebacks. + # Parse the command line and override config files; any + # command-line errors are the end user's fault, so turn them into + # SystemExit to suppress tracebacks. try: ok = dist.parse_command_line() except DistutilsArgError as msg: Modified: sandbox/trunk/newgil/Lib/distutils/dist.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/dist.py (original) +++ sandbox/trunk/newgil/Lib/distutils/dist.py Wed Oct 28 11:50:44 2009 @@ -53,7 +53,9 @@ ('quiet', 'q', "run quietly (turns verbosity off)"), ('dry-run', 'n', "don't actually do anything"), ('help', 'h', "show detailed help message"), - ] + ('no-user-cfg', None, + 'ignore pydistutils.cfg in your home directory'), + ] # 'common_usage' is a short (2-3 line) string describing the common # usage of the setup script. @@ -260,6 +262,22 @@ else: sys.stderr.write(msg + "\n") + # no-user-cfg is handled before other command line args + # because other args override the config files, and this + # one is needed before we can load the config files. + # If attrs['script_args'] wasn't passed, assume false. + # + # This also make sure we just look at the global options + self.want_user_cfg = True + + if self.script_args is not None: + for arg in self.script_args: + if not arg.startswith('-'): + break + if arg == '--no-user-cfg': + self.want_user_cfg = False + break + self.finalize_options() def get_option_dict(self, command): @@ -311,7 +329,10 @@ Distutils installation directory (ie. where the top-level Distutils __inst__.py file lives), a file in the user's home directory named .pydistutils.cfg on Unix and pydistutils.cfg - on Windows/Mac, and setup.cfg in the current directory. + on Windows/Mac; and setup.cfg in the current directory. + + The file in the user's home directory can be disabled with the + --no-user-cfg option. """ files = [] check_environ() @@ -331,15 +352,19 @@ user_filename = "pydistutils.cfg" # And look for the user config file - user_file = os.path.join(os.path.expanduser('~'), user_filename) - if os.path.isfile(user_file): - files.append(user_file) + if self.want_user_cfg: + user_file = os.path.join(os.path.expanduser('~'), user_filename) + if os.path.isfile(user_file): + files.append(user_file) # All platforms support local setup.cfg local_file = "setup.cfg" if os.path.isfile(local_file): files.append(local_file) + if DEBUG: + self.announce("using config files: %s" % ', '.join(files)) + return files def parse_config_files(self, filenames=None): Modified: sandbox/trunk/newgil/Lib/distutils/errors.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/errors.py (original) +++ sandbox/trunk/newgil/Lib/distutils/errors.py Wed Oct 28 11:50:44 2009 @@ -10,90 +10,79 @@ __revision__ = "$Id$" -class DistutilsError (Exception): +class DistutilsError(Exception): """The root of all Distutils evil.""" - pass -class DistutilsModuleError (DistutilsError): +class DistutilsModuleError(DistutilsError): """Unable to load an expected module, or to find an expected class within some module (in particular, command modules and classes).""" - pass -class DistutilsClassError (DistutilsError): +class DistutilsClassError(DistutilsError): """Some command class (or possibly distribution class, if anyone feels a need to subclass Distribution) is found not to be holding up its end of the bargain, ie. implementing some part of the "command "interface.""" - pass -class DistutilsGetoptError (DistutilsError): +class DistutilsGetoptError(DistutilsError): """The option table provided to 'fancy_getopt()' is bogus.""" - pass -class DistutilsArgError (DistutilsError): +class DistutilsArgError(DistutilsError): """Raised by fancy_getopt in response to getopt.error -- ie. an error in the command line usage.""" - pass -class DistutilsFileError (DistutilsError): +class DistutilsFileError(DistutilsError): """Any problems in the filesystem: expected file not found, etc. Typically this is for problems that we detect before IOError or OSError could be raised.""" - pass -class DistutilsOptionError (DistutilsError): +class DistutilsOptionError(DistutilsError): """Syntactic/semantic errors in command options, such as use of mutually conflicting options, or inconsistent options, badly-spelled values, etc. No distinction is made between option values originating in the setup script, the command line, config files, or what-have-you -- but if we *know* something originated in the setup script, we'll raise DistutilsSetupError instead.""" - pass -class DistutilsSetupError (DistutilsError): +class DistutilsSetupError(DistutilsError): """For errors that can be definitely blamed on the setup script, such as invalid keyword arguments to 'setup()'.""" - pass -class DistutilsPlatformError (DistutilsError): +class DistutilsPlatformError(DistutilsError): """We don't know how to do something on the current platform (but we do know how to do it on some platform) -- eg. trying to compile C files on a platform not supported by a CCompiler subclass.""" - pass -class DistutilsExecError (DistutilsError): +class DistutilsExecError(DistutilsError): """Any problems executing an external program (such as the C compiler, when compiling C files).""" - pass -class DistutilsInternalError (DistutilsError): +class DistutilsInternalError(DistutilsError): """Internal inconsistencies or impossibilities (obviously, this should never be seen if the code is working!).""" - pass -class DistutilsTemplateError (DistutilsError): +class DistutilsTemplateError(DistutilsError): """Syntax error in a file list template.""" class DistutilsByteCompileError(DistutilsError): """Byte compile error.""" # Exception classes used by the CCompiler implementation classes -class CCompilerError (Exception): +class CCompilerError(Exception): """Some compile/link operation failed.""" -class PreprocessError (CCompilerError): +class PreprocessError(CCompilerError): """Failure to preprocess one or more C/C++ files.""" -class CompileError (CCompilerError): +class CompileError(CCompilerError): """Failure to compile one or more C/C++ source files.""" -class LibError (CCompilerError): +class LibError(CCompilerError): """Failure to create a static library from one or more C/C++ object files.""" -class LinkError (CCompilerError): +class LinkError(CCompilerError): """Failure to link one or more C/C++ object files into an executable or shared library file.""" -class UnknownFileError (CCompilerError): +class UnknownFileError(CCompilerError): """Attempt to process an unknown file type.""" Modified: sandbox/trunk/newgil/Lib/distutils/tests/test_dist.py ============================================================================== --- sandbox/trunk/newgil/Lib/distutils/tests/test_dist.py (original) +++ sandbox/trunk/newgil/Lib/distutils/tests/test_dist.py Wed Oct 28 11:50:44 2009 @@ -37,7 +37,8 @@ return self._config_files -class DistributionTestCase(support.LoggingSilencer, +class DistributionTestCase(support.TempdirManager, + support.LoggingSilencer, support.EnvironGuard, unittest.TestCase): @@ -180,6 +181,35 @@ kwargs = {'level': 'ok2'} self.assertRaises(ValueError, dist.announce, args, kwargs) + def test_find_config_files_disable(self): + # Ticket #1180: Allow user to disable their home config file. + temp_home = self.mkdtemp() + if os.name == 'posix': + user_filename = os.path.join(temp_home, ".pydistutils.cfg") + else: + user_filename = os.path.join(temp_home, "pydistutils.cfg") + + with open(user_filename, 'w') as f: + f.write('[distutils]\n') + + def _expander(path): + return temp_home + + old_expander = os.path.expanduser + os.path.expanduser = _expander + try: + d = distutils.dist.Distribution() + all_files = d.find_config_files() + + d = distutils.dist.Distribution(attrs={'script_args': + ['--no-user-cfg']}) + files = d.find_config_files() + finally: + os.path.expanduser = old_expander + + # make sure --no-user-cfg disables the user cfg file + self.assertEquals(len(all_files)-1, len(files)) + class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): Modified: sandbox/trunk/newgil/Lib/test/regrtest.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/regrtest.py (original) +++ sandbox/trunk/newgil/Lib/test/regrtest.py Wed Oct 28 11:50:44 2009 @@ -8,27 +8,43 @@ Command line options: --v: verbose -- run tests in verbose mode with output to stdout --w: verbose2 -- re-run failed tests in verbose mode --d: debug -- print traceback for failed tests --q: quiet -- don't print anything except if a test fails --x: exclude -- arguments are tests to *exclude* --s: single -- run only a single test (see below) --S: slow -- print the slowest 10 tests --r: random -- randomize test execution order --f: fromfile -- read names of tests to run from a file (see below) --l: findleaks -- if GC is available detect tests that leak memory --u: use -- specify which special resource intensive tests to run --h: help -- print this text and exit --t: threshold -- call gc.set_threshold(N) --T: coverage -- turn on code coverage using the trace module --D: coverdir -- Directory where coverage files are put --N: nocoverdir -- Put coverage files alongside modules --L: runleaks -- run the leaks(1) command just before exit --R: huntrleaks -- search for reference leaks (needs debug build, v. slow) --M: memlimit -- run very large memory-consuming tests --n: nowindows -- suppress error message boxes on Windows --j: multiprocess -- run several processes at once +-h/--help -- print this text and exit + +Verbosity + +-v/--verbose -- run tests in verbose mode with output to stdout +-w/--verbose2 -- re-run failed tests in verbose mode +-W/--verbose3 -- re-run failed tests in verbose mode immediately +-d/--debug -- print traceback for failed tests +-q/--quiet -- don't print anything except if a test fails +-S/--slow -- print the slowest 10 tests + +Selecting tests + +-r/--random -- randomize test execution order +-f/--fromfile -- read names of tests to run from a file (see below) +-x/--exclude -- arguments are tests to *exclude* +-s/--single -- run only a single test (see below) +-u/--use RES1,RES2,... + -- specify which special resource intensive tests to run +-M/--memlimit LIMIT + -- run very large memory-consuming tests + +Special runs + +-l/--findleaks -- if GC is available detect tests that leak memory +-L/--runleaks -- run the leaks(1) command just before exit +-R/--huntrleaks RUNCOUNTS + -- search for reference leaks (needs debug build, v. slow) +-j/--multiprocess PROCESSES + -- run PROCESSES processes at once +-T/--coverage -- turn on code coverage using the trace module +-D/--coverdir DIRECTORY + -- Directory where coverage files are put +-N/--nocoverdir -- Put coverage files alongside modules +-t/--threshold THRESHOLD + -- call gc.set_threshold(THRESHOLD) +-n/--nowindows -- suppress error message boxes on Windows If non-option arguments are present, they are names for tests to run, unless -x is given, in which case they are names for tests not to run. @@ -193,7 +209,7 @@ exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, - random_seed=None, use_mp=None): + random_seed=None, use_mp=None, verbose3=False): """Execute a test suite. This also parses command-line options and modifies its behavior @@ -219,15 +235,12 @@ support.record_original_stdout(sys.stdout) try: - opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:wM:nj:', - ['help', 'verbose', 'quiet', 'exclude', - 'single', 'slow', 'random', 'fromfile', - 'findleaks', 'use=', 'threshold=', 'trace', - 'coverdir=', 'nocoverdir', 'runleaks', - 'huntrleaks=', 'verbose2', 'memlimit=', - 'debug', 'start=', 'nowindows', - 'randseed=', 'multiprocess=', 'slaveargs=', - ]) + opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:wWM:nj:', + ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', + 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', + 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', + 'runleaks', 'huntrleaks=', 'memlimit=', 'debug', 'start=', + 'nowindows', 'randseed=', 'multiprocess=', 'slaveargs=']) except getopt.error as msg: usage(msg) @@ -248,6 +261,8 @@ verbose2 = True elif o in ('-d', '--debug'): debug = True + elif o in ('-W', '--verbose3'): + verbose3 = True elif o in ('-q', '--quiet'): quiet = True; verbose = 0 @@ -430,14 +445,17 @@ test_times.append((test_time, test)) if ok > 0: good.append(test) + return 'good' elif -2 < ok <= 0: bad.append(test) if ok == -1: environment_changed.append(test) + return 'bad' else: skipped.append(test) if ok == -3: resource_denieds.append(test) + return 'skipped' if use_mp: from threading import Thread @@ -514,7 +532,10 @@ try: result = runtest(test, verbose, quiet, testdir, huntrleaks, debug) - accumulate_result(test, result) + which = accumulate_result(test, result) + if verbose3 and which == 'bad': + print("Re-running test {} in verbose mode".format(test)) + runtest(test, True, quiet, testdir, huntrleaks, debug) except KeyboardInterrupt: # print a newline separate from the ^C print() Modified: sandbox/trunk/newgil/Lib/test/test_asyncore.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_asyncore.py (original) +++ sandbox/trunk/newgil/Lib/test/test_asyncore.py Wed Oct 28 11:50:44 2009 @@ -320,40 +320,44 @@ def tearDown(self): asyncore.close_all() + @support.reap_threads def test_send(self): - self.evt = threading.Event() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(3) - self.port = support.bind_port(self.sock) + evt = threading.Event() + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(3) + port = support.bind_port(sock) cap = BytesIO() - args = (self.evt, cap, self.sock) - threading.Thread(target=capture_server, args=args).start() - - # wait a little longer for the server to initialize (it sometimes - # refuses connections on slow machines without this wait) - time.sleep(0.2) - - data = b"Suppose there isn't a 16-ton weight?" - d = dispatcherwithsend_noread() - d.create_socket(socket.AF_INET, socket.SOCK_STREAM) - d.connect((HOST, self.port)) - - # give time for socket to connect - time.sleep(0.1) - - d.send(data) - d.send(data) - d.send(b'\n') - - n = 1000 - while d.out_buffer and n > 0: - asyncore.poll() - n -= 1 - - self.evt.wait() - - self.assertEqual(cap.getvalue(), data*2) + args = (evt, cap, sock) + t = threading.Thread(target=capture_server, args=args) + t.start() + try: + # wait a little longer for the server to initialize (it sometimes + # refuses connections on slow machines without this wait) + time.sleep(0.2) + + data = b"Suppose there isn't a 16-ton weight?" + d = dispatcherwithsend_noread() + d.create_socket(socket.AF_INET, socket.SOCK_STREAM) + d.connect((HOST, port)) + + # give time for socket to connect + time.sleep(0.1) + + d.send(data) + d.send(data) + d.send(b'\n') + + n = 1000 + while d.out_buffer and n > 0: + asyncore.poll() + n -= 1 + + evt.wait() + + self.assertEqual(cap.getvalue(), data*2) + finally: + t.join() class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): Modified: sandbox/trunk/newgil/Lib/test/test_bz2.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_bz2.py (original) +++ sandbox/trunk/newgil/Lib/test/test_bz2.py Wed Oct 28 11:50:44 2009 @@ -7,6 +7,7 @@ import os import subprocess import sys +import threading # Skip tests if the bz2 module doesn't exist. bz2 = support.import_module('bz2') @@ -282,6 +283,23 @@ else: self.fail("1/0 didn't raise an exception") + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = b"1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): Modified: sandbox/trunk/newgil/Lib/test/test_complex.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_complex.py (original) +++ sandbox/trunk/newgil/Lib/test/test_complex.py Wed Oct 28 11:50:44 2009 @@ -284,7 +284,6 @@ self.assertRaises(ValueError, complex, "1+2j)") self.assertRaises(ValueError, complex, "1+(2j)") self.assertRaises(ValueError, complex, "(1+2j)123") - self.assertRaises(ValueError, complex, "1"*500) self.assertRaises(ValueError, complex, "x") self.assertRaises(ValueError, complex, "1j+2") self.assertRaises(ValueError, complex, "1e1ej") @@ -295,6 +294,9 @@ self.assertRaises(ValueError, complex, "1.11.1j") self.assertRaises(ValueError, complex, "1e1.1j") + # check that complex accepts long unicode strings + self.assertEqual(type(complex("1"*500)), complex) + class EvilExc(Exception): pass Modified: sandbox/trunk/newgil/Lib/test/test_distutils.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_distutils.py (original) +++ sandbox/trunk/newgil/Lib/test/test_distutils.py Wed Oct 28 11:50:44 2009 @@ -11,6 +11,7 @@ def test_main(): test.support.run_unittest(distutils.tests.test_suite()) + test.support.reap_children() if __name__ == "__main__": Modified: sandbox/trunk/newgil/Lib/test/test_float.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_float.py (original) +++ sandbox/trunk/newgil/Lib/test/test_float.py Wed Oct 28 11:50:44 2009 @@ -34,6 +34,9 @@ self.assertRaises(ValueError, float, ".") self.assertRaises(ValueError, float, "-.") self.assertEqual(float(b" \u0663.\u0661\u0664 ".decode('raw-unicode-escape')), 3.14) + # extra long strings should not be a problem + float(b'.' + b'1'*1000) + float('.' + '1'*1000) @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): Modified: sandbox/trunk/newgil/Lib/test/test_httpservers.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_httpservers.py (original) +++ sandbox/trunk/newgil/Lib/test/test_httpservers.py Wed Oct 28 11:50:44 2009 @@ -51,6 +51,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): + self._threads = support.threading_setup() os.environ = support.EnvironmentVarGuard() self.lock = threading.Lock() self.thread = TestServerThread(self, self.request_handler) @@ -61,6 +62,7 @@ self.lock.release() self.thread.stop() os.environ.__exit__() + support.threading_cleanup(*self._threads) def request(self, uri, method='GET', body=None, headers={}): self.connection = http.client.HTTPConnection('localhost', self.PORT) Modified: sandbox/trunk/newgil/Lib/test/test_site.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_site.py (original) +++ sandbox/trunk/newgil/Lib/test/test_site.py Wed Oct 28 11:50:44 2009 @@ -168,7 +168,7 @@ else: self.assertTrue(len(dirs), 2) self.assertEquals(dirs[0], 'xoxo') - wanted = os.path.join('xoxo', 'Lib', 'site-packages') + wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEquals(dirs[1], wanted) # let's try the specific Apple location Modified: sandbox/trunk/newgil/Lib/test/test_smtplib.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_smtplib.py (original) +++ sandbox/trunk/newgil/Lib/test/test_smtplib.py Wed Oct 28 11:50:44 2009 @@ -47,17 +47,21 @@ class GeneralTests(TestCase): def setUp(self): + self._threads = support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = support.bind_port(self.sock) servargs = (self.evt, b"220 Hola mundo\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) def testBasic1(self): # connects @@ -150,12 +154,14 @@ self.output = io.StringIO() sys.stdout = self.output + self._threads = support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = support.find_unused_port() self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -166,6 +172,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout @@ -261,17 +269,21 @@ self.output = io.StringIO() sys.stdout = self.output + self._threads = support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = support.bind_port(self.sock) servargs = (self.evt, b"199 no hello for you!\n", self.sock) - threading.Thread(target=server, args=servargs).start() + self.thread = threading.Thread(target=server, args=servargs) + self.thread.start() self.evt.wait() self.evt.clear() def tearDown(self): self.evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) sys.stdout = self.old_stdout def testFailingHELO(self): @@ -377,12 +389,14 @@ class SMTPSimTests(TestCase): def setUp(self): + self._threads = support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() self.port = support.find_unused_port() self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1)) serv_args = (self.serv, self.serv_evt, self.client_evt) - threading.Thread(target=debugging_server, args=serv_args).start() + self.thread = threading.Thread(target=debugging_server, args=serv_args) + self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() @@ -393,6 +407,8 @@ self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() + self.thread.join() + support.threading_cleanup(*self._threads) def testBasic(self): # smoke test Modified: sandbox/trunk/newgil/Lib/test/test_socketserver.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_socketserver.py (original) +++ sandbox/trunk/newgil/Lib/test/test_socketserver.py Wed Oct 28 11:50:44 2009 @@ -16,7 +16,7 @@ import socketserver import test.support -from test.support import reap_children, verbose +from test.support import reap_children, reap_threads, verbose from test.support import TESTFN as TEST_FILE test.support.requires("network") @@ -122,6 +122,7 @@ self.assertEquals(server.server_address, server.socket.getsockname()) return server + @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) Modified: sandbox/trunk/newgil/Lib/test/test_sys.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_sys.py (original) +++ sandbox/trunk/newgil/Lib/test/test_sys.py Wed Oct 28 11:50:44 2009 @@ -5,6 +5,11 @@ import subprocess import textwrap +# count the number of test runs, used to create unique +# strings to intern in test_intern() +numruns = 0 + + class SysModuleTest(unittest.TestCase): def setUp(self): @@ -16,6 +21,7 @@ sys.stdout = self.orig_stdout sys.stderr = self.orig_stderr sys.displayhook = self.orig_displayhook + test.support.reap_children() def test_original_displayhook(self): import builtins @@ -276,6 +282,7 @@ self.current_frames_without_threads() # Test sys._current_frames() in a WITH_THREADS build. + @test.support.reap_threads def current_frames_with_threads(self): import threading, _thread import traceback @@ -396,8 +403,10 @@ self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding) def test_intern(self): + global numruns + numruns += 1 self.assertRaises(TypeError, sys.intern) - s = "never interned before" + s = "never interned before" + str(numruns) self.assertTrue(sys.intern(s) is s) s2 = s.swapcase().swapcase() self.assertTrue(sys.intern(s2) is s) @@ -439,13 +448,13 @@ env["PYTHONIOENCODING"] = "cp424" p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read() + out = p.communicate()[0].strip() self.assertEqual(out, "\xa2\n".encode("cp424")) env["PYTHONIOENCODING"] = "ascii:replace" p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'], stdout = subprocess.PIPE, env=env) - out = p.stdout.read().strip() + out = p.communicate()[0].strip() self.assertEqual(out, b'?') Modified: sandbox/trunk/newgil/Lib/test/test_telnetlib.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_telnetlib.py (original) +++ sandbox/trunk/newgil/Lib/test/test_telnetlib.py Wed Oct 28 11:50:44 2009 @@ -12,12 +12,14 @@ HOST = support.HOST EOF_sigil = object() -def server(evt, serv, dataq=None): - """ Open a tcp server in three steps +def server(evt, serv, dataq=None, test_done=None): + """ Open a tcp server in four steps 1) set evt to true to let the parent know we are ready 2) [optional] if is not False, write the list of data from dataq.get() to the socket. - 3) set evt to true to let the parent know we're done + 3) [optional] if test_done is not None, it's an event; wait + for parent to set test_done before closing connection + 4) set evt to true to let the parent know we're done """ serv.listen(5) evt.set() @@ -39,6 +41,8 @@ except socket.timeout: pass finally: + if test_done is not None: + test_done.wait() serv.close() evt.set() @@ -324,8 +328,24 @@ class WriteTests(TestCase): '''The only thing that write does is replace each tl.IAC for tl.IAC+tl.IAC''' - setUp = _read_setUp - tearDown = _read_tearDown + def setUp(self): + self.evt = threading.Event() + self.test_done = threading.Event() + self.dataq = queue.Queue() + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.settimeout(3) + self.port = support.bind_port(self.sock) + self.thread = threading.Thread(target=server, args=( + self.evt, self.sock, self.dataq, self.test_done)) + self.thread.start() + self.evt.wait() + self.evt.clear() + time.sleep(.1) + + def tearDown(self): + self.test_done.set() + self.evt.wait() + self.thread.join() def _test_write(self, data): self.telnet.sock._raw_sent = b'' Modified: sandbox/trunk/newgil/Lib/test/test_threading.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_threading.py (original) +++ sandbox/trunk/newgil/Lib/test/test_threading.py Wed Oct 28 11:50:44 2009 @@ -56,7 +56,16 @@ (self.name, self.nrunning.get())) -class ThreadTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test.support.threading_setup() + + def tearDown(self): + test.support.threading_cleanup(*self._threads) + test.support.reap_children() + + +class ThreadTests(BaseTestCase): # Create a bunch of threads, let each do some work, wait until all are # done. @@ -389,7 +398,7 @@ threading.activeCount() -class ThreadJoinOnShutdown(unittest.TestCase): +class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): script = """if 1: @@ -470,7 +479,7 @@ self._run_and_join(script) -class ThreadingExceptionTests(unittest.TestCase): +class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called # multiple times. def test_start_thread_again(self): Modified: sandbox/trunk/newgil/Lib/test/test_urllib2_localnet.py ============================================================================== --- sandbox/trunk/newgil/Lib/test/test_urllib2_localnet.py (original) +++ sandbox/trunk/newgil/Lib/test/test_urllib2_localnet.py Wed Oct 28 11:50:44 2009 @@ -221,7 +221,15 @@ # Test cases -class ProxyAuthTests(unittest.TestCase): +class BaseTestCase(unittest.TestCase): + def setUp(self): + self._threads = test_support.threading_setup() + + def tearDown(self): + test_support.threading_cleanup(*self._threads) + + +class ProxyAuthTests(BaseTestCase): URL = "http://localhost" USER = "tester" @@ -329,7 +337,7 @@ return FakeHTTPRequestHandler -class TestUrlopen(unittest.TestCase): +class TestUrlopen(BaseTestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a Modified: sandbox/trunk/newgil/Lib/threading.py ============================================================================== --- sandbox/trunk/newgil/Lib/threading.py (original) +++ sandbox/trunk/newgil/Lib/threading.py Wed Oct 28 11:50:44 2009 @@ -119,7 +119,7 @@ def release(self): if self._owner is not current_thread(): - raise RuntimeError("cannot release un-aquired lock") + raise RuntimeError("cannot release un-acquired lock") self._count = count = self._count - 1 if not count: self._owner = None @@ -211,7 +211,7 @@ def wait(self, timeout=None): if not self._is_owned(): - raise RuntimeError("cannot wait on un-aquired lock") + raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() waiter.acquire() self._waiters.append(waiter) @@ -253,7 +253,7 @@ def notify(self, n=1): if not self._is_owned(): - raise RuntimeError("cannot notify on un-aquired lock") + raise RuntimeError("cannot notify on un-acquired lock") __waiters = self._waiters waiters = __waiters[:n] if not waiters: Modified: sandbox/trunk/newgil/Lib/warnings.py ============================================================================== --- sandbox/trunk/newgil/Lib/warnings.py (original) +++ sandbox/trunk/newgil/Lib/warnings.py Wed Oct 28 11:50:44 2009 @@ -32,7 +32,14 @@ append=False): """Insert an entry into the list of warnings filters (at the front). - Use assertions to check that all arguments have the right type.""" + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'message' -- a regex that the warning message must match + 'category' -- a class that the warning must be a subclass of + 'module' -- a regex that the module name must match + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters + """ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) @@ -53,6 +60,11 @@ """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. + 'action' -- one of "error", "ignore", "always", "default", "module", + or "once" + 'category' -- a class that the warning must be a subclass of + 'lineno' -- an integer line number, 0 matches all warnings + 'append' -- if true, append to the list of filters """ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) Modified: sandbox/trunk/newgil/Makefile.pre.in ============================================================================== --- sandbox/trunk/newgil/Makefile.pre.in (original) +++ sandbox/trunk/newgil/Makefile.pre.in Wed Oct 28 11:50:44 2009 @@ -735,7 +735,7 @@ - at if which pybuildbot.identify >/dev/null 2>&1; then \ pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \ fi - $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw + $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rwW QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \ test_multibytecodec test_urllib2_localnet test_itertools \ Modified: sandbox/trunk/newgil/Misc/NEWS ============================================================================== --- sandbox/trunk/newgil/Misc/NEWS (original) +++ sandbox/trunk/newgil/Misc/NEWS Wed Oct 28 11:50:44 2009 @@ -12,6 +12,8 @@ Core and Builtins ----------------- +- Remove length limitation when constructing a complex number from a string. + - Issue #1087418: Boost performance of bitwise operations for longs. - Support for AtheOS has been completely removed from the code base. It was @@ -115,6 +117,15 @@ Library ------- +- Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in + Distutils. + +- Issue #7218: Fix test_site for win32, the directory comparison was done with + an uppercase. + +- Issue #7205: Fix a possible deadlock when using a BZ2File object from + several threads at once. + - Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424. - Issue #7099: Decimal.is_normal now returns True for numbers with exponent Modified: sandbox/trunk/newgil/Modules/_ctypes/_ctypes.c ============================================================================== --- sandbox/trunk/newgil/Modules/_ctypes/_ctypes.c (original) +++ sandbox/trunk/newgil/Modules/_ctypes/_ctypes.c Wed Oct 28 11:50:44 2009 @@ -1865,16 +1865,15 @@ } fmt = _ctypes_get_fielddesc(proto_str); if (fmt == NULL) { - Py_DECREF((PyObject *)result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", proto_str); - return NULL; + goto error; } stgdict = (StgDictObject *)PyObject_CallObject( (PyObject *)&PyCStgDict_Type, NULL); if (!stgdict) - return NULL; + goto error; stgdict->ffi_type_pointer = *fmt->pffi_type; stgdict->align = fmt->pffi_type->alignment; @@ -1889,6 +1888,7 @@ #endif if (stgdict->format == NULL) { Py_DECREF(result); + Py_DECREF(proto); Py_DECREF((PyObject *)stgdict); return NULL; } Modified: sandbox/trunk/newgil/Modules/_io/_iomodule.h ============================================================================== --- sandbox/trunk/newgil/Modules/_io/_iomodule.h (original) +++ sandbox/trunk/newgil/Modules/_io/_iomodule.h Wed Oct 28 11:50:44 2009 @@ -70,6 +70,14 @@ * Offset type for positioning. */ +/* Printing a variable of type off_t correctly and without producing + compiler warnings is surprisingly painful. We identify an integer + type whose size matches off_t and then: (1) cast the off_t to that + integer type and (2) use the appropriate conversion specification + for printf. The cast is necessary: gcc complains about formatting + a long with "%lld" even when both long and long long have the same + precision. */ + #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -78,26 +86,33 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN - +# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ +# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN +# define PY_PRIdOFF "lld" +# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN +# define PY_PRIdOFF "ld" +# define PY_OFF_T_COMPAT long +#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +# define PY_PRIdOFF "zd" +# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: sandbox/trunk/newgil/Modules/_io/bufferedio.c ============================================================================== --- sandbox/trunk/newgil/Modules/_io/bufferedio.c (original) +++ sandbox/trunk/newgil/Modules/_io/bufferedio.c Wed Oct 28 11:50:44 2009 @@ -580,7 +580,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; @@ -612,7 +613,8 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %zd", n); + "Raw stream returned invalid position %" PY_PRIdOFF, + (PY_OFF_T_COMPAT)n); return -1; } self->abs_pos = n; Modified: sandbox/trunk/newgil/Modules/_localemodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/_localemodule.c (original) +++ sandbox/trunk/newgil/Modules/_localemodule.c Wed Oct 28 11:50:44 2009 @@ -281,7 +281,9 @@ wchar_t *s, *buf = NULL; size_t n1, n2; PyObject *result = NULL; +#ifndef HAVE_USABLE_WCHAR_T Py_ssize_t i; +#endif if (!PyArg_ParseTuple(args, "u#:strxfrm", &s0, &n0)) return NULL; Modified: sandbox/trunk/newgil/Modules/_testcapimodule.c ============================================================================== --- sandbox/trunk/newgil/Modules/_testcapimodule.c (original) +++ sandbox/trunk/newgil/Modules/_testcapimodule.c Wed Oct 28 11:50:44 2009 @@ -627,7 +627,6 @@ PyObject *tuple, *obj; Py_UNICODE *value; Py_ssize_t len; - int x; /* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */ /* Just use the macro and check that it compiles */ Modified: sandbox/trunk/newgil/Modules/bz2module.c ============================================================================== --- sandbox/trunk/newgil/Modules/bz2module.c (original) +++ sandbox/trunk/newgil/Modules/bz2module.c Wed Oct 28 11:50:44 2009 @@ -78,7 +78,12 @@ #ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) +#define ACQUIRE_LOCK(obj) do { \ + if (!PyThread_acquire_lock(obj->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(obj->lock, 1); \ + Py_END_ALLOW_THREADS \ + } } while(0) #define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) #else #define ACQUIRE_LOCK(obj) Modified: sandbox/trunk/newgil/Modules/readline.c ============================================================================== --- sandbox/trunk/newgil/Modules/readline.c (original) +++ sandbox/trunk/newgil/Modules/readline.c Wed Oct 28 11:50:44 2009 @@ -802,6 +802,8 @@ { #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER rl_completion_append_character ='\0'; +#endif +#ifdef HAVE_RL_COMPLETION_SUPPRESS_APPEND rl_completion_suppress_append = 0; #endif Py_XDECREF(begidx); Modified: sandbox/trunk/newgil/Objects/complexobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/complexobject.c (original) +++ sandbox/trunk/newgil/Objects/complexobject.c Wed Oct 28 11:50:44 2009 @@ -740,20 +740,18 @@ char *end; double x=0.0, y=0.0, z; int got_bracket=0; - char s_buffer[256]; + char *s_buffer = NULL; Py_ssize_t len; if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "complex() literal too large to convert"); - return NULL; - } + s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v) + 1); + if (s_buffer == NULL) + return PyErr_NoMemory(); if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, NULL)) - return NULL; + goto error; s = s_buffer; len = strlen(s); } @@ -802,7 +800,7 @@ if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) { /* all 4 forms starting with land here */ @@ -815,7 +813,7 @@ if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) /* j */ @@ -870,11 +868,16 @@ if (s-start != len) goto parse_error; + if (s_buffer) + PyMem_FREE(s_buffer); return complex_subtype_from_doubles(type, x, y); parse_error: PyErr_SetString(PyExc_ValueError, "complex() arg is a malformed string"); + error: + if (s_buffer) + PyMem_FREE(s_buffer); return NULL; } Modified: sandbox/trunk/newgil/Objects/floatobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/floatobject.c (original) +++ sandbox/trunk/newgil/Objects/floatobject.c Wed Oct 28 11:50:44 2009 @@ -183,7 +183,7 @@ } else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, - "float() argument must be a string or a number"); + "float() argument must be a string or a number"); return NULL; } last = s + len; Modified: sandbox/trunk/newgil/Objects/unicodeobject.c ============================================================================== --- sandbox/trunk/newgil/Objects/unicodeobject.c (original) +++ sandbox/trunk/newgil/Objects/unicodeobject.c Wed Oct 28 11:50:44 2009 @@ -7710,10 +7710,10 @@ } PyDoc_STRVAR(join__doc__, - "S.join(sequence) -> str\n\ + "S.join(iterable) -> str\n\ \n\ Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); +iterable. The separator between elements is S."); static PyObject* unicode_join(PyObject *self, PyObject *data) Modified: sandbox/trunk/newgil/Python/codecs.c ============================================================================== --- sandbox/trunk/newgil/Python/codecs.c (original) +++ sandbox/trunk/newgil/Python/codecs.c Wed Oct 28 11:50:44 2009 @@ -957,7 +957,9 @@ { "strict_errors", strict_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'strict' error handling, which " + "raises a UnicodeError on coding errors.") } }, { @@ -965,7 +967,9 @@ { "ignore_errors", ignore_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'ignore' error handling, which " + "ignores malformed data and continues.") } }, { @@ -973,7 +977,9 @@ { "replace_errors", replace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'replace' error handling, which " + "replaces malformed data with a replacement marker.") } }, { @@ -981,7 +987,10 @@ { "xmlcharrefreplace_errors", xmlcharrefreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'xmlcharrefreplace' error handling, " + "which replaces an unencodable character with the " + "appropriate XML character reference.") } }, { @@ -989,7 +998,10 @@ { "backslashreplace_errors", backslashreplace_errors, - METH_O + METH_O, + PyDoc_STR("Implements the 'backslashreplace' error handling, " + "which replaces an unencodable character with a " + "backslashed escape sequence.") } }, { Modified: sandbox/trunk/newgil/configure ============================================================================== --- sandbox/trunk/newgil/configure (original) +++ sandbox/trunk/newgil/configure Wed Oct 28 11:50:44 2009 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 75678 . +# From configure.in Revision: 75684 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -25056,6 +25056,25 @@ fi rm -f conftest* + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "extern int rl_completion_suppress_append;" >/dev/null 2>&1; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1 +_ACEOF + +fi +rm -f conftest* + fi # check for readline 4.0 Modified: sandbox/trunk/newgil/configure.in ============================================================================== --- sandbox/trunk/newgil/configure.in (original) +++ sandbox/trunk/newgil/configure.in Wed Oct 28 11:50:44 2009 @@ -3528,6 +3528,10 @@ [readline/readline.h], AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) fi # check for readline 4.0 Modified: sandbox/trunk/newgil/pyconfig.h.in ============================================================================== --- sandbox/trunk/newgil/pyconfig.h.in (original) +++ sandbox/trunk/newgil/pyconfig.h.in Wed Oct 28 11:50:44 2009 @@ -533,6 +533,9 @@ /* Define if you have readline 4.2 */ #undef HAVE_RL_COMPLETION_MATCHES +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK From nnorwitz at gmail.com Wed Oct 28 13:04:35 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 28 Oct 2009 07:04:35 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091028120435.GA1025@python.psfb.org> More important issues: ---------------------- test_urllib2_localnet leaked [-269, 278, -278] references, sum=-269 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_docxmlrpc leaked [0, 175, -175] references, sum=0 test_popen2 leaked [54, 0, -54] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 From python-checkins at python.org Wed Oct 28 15:03:44 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 14:03:44 -0000 Subject: [Python-checkins] r75920 - python/trunk/Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Wed Oct 28 15:03:43 2009 New Revision: 75920 Log: Remove variable that is no longer used. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Wed Oct 28 15:03:43 2009 @@ -1462,7 +1462,7 @@ # much of the testing framework relies on the globals in the # test.test_support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) - i = pathlen = len(sys.path) + i = len(sys.path) while i >= 0: i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: From python-checkins at python.org Wed Oct 28 15:05:34 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 14:05:34 -0000 Subject: [Python-checkins] r75921 - in python/branches/release26-maint: Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Wed Oct 28 15:05:34 2009 New Revision: 75921 Log: Merged revisions 75920 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75920 | r.david.murray | 2009-10-28 10:03:43 -0400 (Wed, 28 Oct 2009) | 2 lines Remove variable that is no longer used. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/regrtest.py Modified: python/branches/release26-maint/Lib/test/regrtest.py ============================================================================== --- python/branches/release26-maint/Lib/test/regrtest.py (original) +++ python/branches/release26-maint/Lib/test/regrtest.py Wed Oct 28 15:05:34 2009 @@ -1187,7 +1187,7 @@ # much of the testing framework relies on the globals in the # test.test_support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) - i = pathlen = len(sys.path) + i = len(sys.path) while i >= 0: i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: From python-checkins at python.org Wed Oct 28 15:07:51 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 14:07:51 -0000 Subject: [Python-checkins] r75922 - in python/branches/py3k: Lib/test/regrtest.py Message-ID: Author: r.david.murray Date: Wed Oct 28 15:07:51 2009 New Revision: 75922 Log: Merged revisions 75920 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75920 | r.david.murray | 2009-10-28 10:03:43 -0400 (Wed, 28 Oct 2009) | 2 lines Remove variable that is no longer used. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/regrtest.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Wed Oct 28 15:07:51 2009 @@ -1368,7 +1368,7 @@ # much of the testing framework relies on the globals in the # test.support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) - i = pathlen = len(sys.path) + i = len(sys.path) while i >= 0: i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: From python-checkins at python.org Wed Oct 28 15:47:16 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 14:47:16 -0000 Subject: [Python-checkins] r75923 - in python/branches/release31-maint: Lib/test/regrtest.py Lib/test/support.py Message-ID: Author: r.david.murray Date: Wed Oct 28 15:47:15 2009 New Revision: 75923 Log: Merged revisions 75525,75530,75922 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75525 | r.david.murray | 2009-10-19 12:33:43 -0400 (Mon, 19 Oct 2009) | 12 lines Merged revisions 75524 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75524 | r.david.murray | 2009-10-19 12:28:24 -0400 (Mon, 19 Oct 2009) | 6 lines Eliminate warning message that looks like an error message. When it was added not finding Lib/test in the path indicated something was wrong, but when running regtest using "python -m" Lib/test isn't typically in the path, so this message is now more disturbing than it is helpful. ........ ................ r75530 | r.david.murray | 2009-10-19 14:06:17 -0400 (Mon, 19 Oct 2009) | 10 lines Merged revisions 75528 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75528 | r.david.murray | 2009-10-19 13:53:58 -0400 (Mon, 19 Oct 2009) | 4 lines Clarify error report message, and don't recommend running in verbose mode for more information if we are already running in verbose mode. ........ ................ r75922 | r.david.murray | 2009-10-28 10:07:51 -0400 (Wed, 28 Oct 2009) | 9 lines Merged revisions 75920 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75920 | r.david.murray | 2009-10-28 10:03:43 -0400 (Wed, 28 Oct 2009) | 2 lines Remove variable that is no longer used. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/regrtest.py python/branches/release31-maint/Lib/test/support.py Modified: python/branches/release31-maint/Lib/test/regrtest.py ============================================================================== --- python/branches/release31-maint/Lib/test/regrtest.py (original) +++ python/branches/release31-maint/Lib/test/regrtest.py Wed Oct 28 15:47:15 2009 @@ -1227,11 +1227,9 @@ # much of the testing framework relies on the globals in the # test.support module. mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) - i = pathlen = len(sys.path) + i = len(sys.path) while i >= 0: i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] - if len(sys.path) == pathlen: - print('Could not find %r in sys.path to remove it' % mydir) main() Modified: python/branches/release31-maint/Lib/test/support.py ============================================================================== --- python/branches/release31-maint/Lib/test/support.py (original) +++ python/branches/release31-maint/Lib/test/support.py Wed Oct 28 15:47:15 2009 @@ -857,7 +857,8 @@ elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: - err = "errors occurred; run in verbose mode for details" + err = "multiple errors occurred" + if not verbose: err += "; run in verbose mode for details" raise TestFailed(err) From python-checkins at python.org Wed Oct 28 18:09:53 2009 From: python-checkins at python.org (phillip.eby) Date: Wed, 28 Oct 2009 17:09:53 -0000 Subject: [Python-checkins] r75924 - sandbox/trunk/setuptools/setuptools/package_index.py Message-ID: Author: phillip.eby Date: Wed Oct 28 18:09:53 2009 New Revision: 75924 Log: Fix for issue 88 Modified: sandbox/trunk/setuptools/setuptools/package_index.py Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Wed Oct 28 18:09:53 2009 @@ -1,6 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO -import httplib +import httplib, urllib from pkg_resources import * from distutils import log from distutils.errors import DistutilsError @@ -701,7 +701,7 @@ scheme, netloc, path, params, query, frag = urlparse.urlparse(url) if scheme in ('http', 'https'): - auth, host = urllib2.splituser(netloc) + auth, host = urllib.splituser(netloc) else: auth = None From python-checkins at python.org Wed Oct 28 18:12:45 2009 From: python-checkins at python.org (phillip.eby) Date: Wed, 28 Oct 2009 17:12:45 -0000 Subject: [Python-checkins] r75925 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setup.py setuptools/__init__.py version.dat Message-ID: Author: phillip.eby Date: Wed Oct 28 18:12:45 2009 New Revision: 75925 Log: Bump version Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/version.dat Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Wed Oct 28 18:12:45 2009 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6c11" +DEFAULT_VERSION = "0.6c12" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Wed Oct 28 18:12:45 2009 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6c11" +export VERSION="0.6c12" python2.3 setup.py -q egg_info # force upload to be available python2.3 setup.py -q release source --target-version=2.3 upload && \ python2.4 setup.py -q release binary --target-version=2.4 upload && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Wed Oct 28 18:12:45 2009 @@ -7,7 +7,7 @@ execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6c11" +VERSION = "0.6c12" from setuptools import setup, find_packages import sys Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Wed Oct 28 18:12:45 2009 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6c11' +__version__ = '0.6c12' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Wed Oct 28 18:12:45 2009 @@ -1,6 +1,6 @@ [setuptools] status = 'release candidate' major = 0 -build = 11 +build = 12 minor = 6 From python-checkins at python.org Wed Oct 28 18:12:58 2009 From: python-checkins at python.org (phillip.eby) Date: Wed, 28 Oct 2009 17:12:58 -0000 Subject: [Python-checkins] r75926 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/package_index.py Message-ID: Author: phillip.eby Date: Wed Oct 28 18:12:57 2009 New Revision: 75926 Log: Fix for issue 88 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/package_index.py Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Wed Oct 28 18:12:57 2009 @@ -1217,6 +1217,10 @@ Release Notes/Change History ============================ +0.6final + * Fixed AttributeError under Python 2.3 when processing "HTTP authentication" + URLs (i.e., ones with a ``user:password at host``). + 0.6c11 * Fix installed script .exe files not working with 64-bit Python on Windows (wasn't actually released in 0.6c10 due to a lost checkin) Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Wed Oct 28 18:12:57 2009 @@ -1,6 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO -import httplib +import httplib, urllib from pkg_resources import * from distutils import log from distutils.errors import DistutilsError @@ -701,7 +701,7 @@ scheme, netloc, path, params, query, frag = urlparse.urlparse(url) if scheme in ('http', 'https'): - auth, host = urllib2.splituser(netloc) + auth, host = urllib.splituser(netloc) else: auth = None From python-checkins at python.org Wed Oct 28 22:40:23 2009 From: python-checkins at python.org (r.david.murray) Date: Wed, 28 Oct 2009 21:40:23 -0000 Subject: [Python-checkins] r75927 - python/branches/release31-maint Message-ID: Author: r.david.murray Date: Wed Oct 28 22:40:22 2009 New Revision: 75927 Log: Blocked revisions 75710 via svnmerge ........ r75710 | r.david.murray | 2009-10-26 04:24:14 -0400 (Mon, 26 Oct 2009) | 6 lines Make the XMLRCP CGIHandlerTestCase pass like it did before the change of the test to use StringIO instead of a temp file. There may or may not be an underlying problem here, so this patch makes the test function as originally designed until a determination can be made as to whether or not there is an underlying bug here. See issue 7165 for discussion. ........ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Wed Oct 28 22:59:39 2009 From: python-checkins at python.org (benjamin.peterson) Date: Wed, 28 Oct 2009 21:59:39 -0000 Subject: [Python-checkins] r75928 - in python/branches/py3k: Lib/test/test_pep263.py Misc/NEWS Python/ast.c Message-ID: Author: benjamin.peterson Date: Wed Oct 28 22:59:39 2009 New Revision: 75928 Log: in wide builds, avoid storing high unicode characters from source code with surrogates This is accomplished by decoding with utf-32 instead of utf-16 on all builds. The patch is by Adam Olsen. Modified: python/branches/py3k/Lib/test/test_pep263.py python/branches/py3k/Misc/NEWS python/branches/py3k/Python/ast.c Modified: python/branches/py3k/Lib/test/test_pep263.py ============================================================================== --- python/branches/py3k/Lib/test/test_pep263.py (original) +++ python/branches/py3k/Lib/test/test_pep263.py Wed Oct 28 22:59:39 2009 @@ -36,6 +36,14 @@ exec(c, d) self.assertEquals(d['\xc6'], '\xc6') + def test_issue3297(self): + c = compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec") + d = {} + exec(c, d) + self.assertEqual(d['a'], d['b']) + self.assertEqual(len(d['a']), len(d['b'])) + self.assertEqual(ascii(d['a']), ascii(d['b'])) + def test_main(): support.run_unittest(PEP263Test) Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Oct 28 22:59:39 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #3297: On wide unicode builds, do not split unicode characters into + surrogates. + - Remove length limitation when constructing a complex number from a string. - Issue #1087418: Boost performance of bitwise operations for longs. Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Wed Oct 28 22:59:39 2009 @@ -3246,10 +3246,11 @@ u = NULL; } else { /* check for integer overflow */ - if (len > PY_SIZE_MAX / 4) + if (len > PY_SIZE_MAX / 6) return NULL; - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyBytes_FromStringAndSize((char *)NULL, len * 4); + /* "?" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\?" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + u = PyBytes_FromStringAndSize((char *)NULL, len * 6); if (u == NULL) return NULL; p = buf = PyBytes_AsString(u); @@ -3266,20 +3267,24 @@ PyObject *w; char *r; Py_ssize_t rn, i; - w = decode_utf8(c, &s, end, "utf-16-be"); + w = decode_utf8(c, &s, end, "utf-32-be"); if (w == NULL) { Py_DECREF(u); return NULL; } r = PyBytes_AS_STRING(w); rn = Py_SIZE(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", + assert(rn % 4 == 0); + for (i = 0; i < rn; i += 4) { + sprintf(p, "\\U%02x%02x%02x%02x", r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; + r[i + 1] & 0xFF, + r[i + 2] & 0xFF, + r[i + 3] & 0xFF); + p += 10; } + /* Should be impossible to overflow */ + assert(p - buf <= Py_SIZE(u)); Py_DECREF(w); } else { *p++ = *s++; From python-checkins at python.org Thu Oct 29 00:28:17 2009 From: python-checkins at python.org (vinay.sajip) Date: Wed, 28 Oct 2009 23:28:17 -0000 Subject: [Python-checkins] r75929 - in python: branches/py3k/Doc/library/logging.rst branches/release26-maint/Doc/library/logging.rst trunk/Doc/library/logging.rst Message-ID: Author: vinay.sajip Date: Thu Oct 29 00:28:16 2009 New Revision: 75929 Log: Issue 7199: Documentation made slightly more consistent w.r.t. logging level enumeration. Modified: python/branches/py3k/Doc/library/logging.rst python/branches/release26-maint/Doc/library/logging.rst python/trunk/Doc/library/logging.rst Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Thu Oct 29 00:28:16 2009 @@ -119,7 +119,7 @@ messages at different log levels. This allows you to instrument your code with debug messages, for example, but turning the log level down so that those debug messages are not written for your production system. The default levels are -``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``NOTSET``. +``NOTSET``, ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR`` and ``CRITICAL``. The logger, handler, and log message call each specify a level. The log message is only emitted if the handler and logger are configured to emit messages of 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 Oct 29 00:28:16 2009 @@ -121,7 +121,7 @@ messages at different log levels. This allows you to instrument your code with debug messages, for example, but turning the log level down so that those debug messages are not written for your production system. The default levels are -``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``NOTSET``. +``NOTSET``, ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR`` and ``CRITICAL``. The logger, handler, and log message call each specify a level. The log message is only emitted if the handler and logger are configured to emit messages of Modified: python/trunk/Doc/library/logging.rst ============================================================================== --- python/trunk/Doc/library/logging.rst (original) +++ python/trunk/Doc/library/logging.rst Thu Oct 29 00:28:16 2009 @@ -121,7 +121,7 @@ messages at different log levels. This allows you to instrument your code with debug messages, for example, but turning the log level down so that those debug messages are not written for your production system. The default levels are -``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``NOTSET``. +``NOTSET``, ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR`` and ``CRITICAL``. The logger, handler, and log message call each specify a level. The log message is only emitted if the handler and logger are configured to emit messages of From python-checkins at python.org Thu Oct 29 02:22:38 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 29 Oct 2009 01:22:38 -0000 Subject: [Python-checkins] r75930 - in python/branches/release31-maint: Lib/test/test_pep263.py Misc/NEWS Python/ast.c Message-ID: Author: benjamin.peterson Date: Thu Oct 29 02:22:38 2009 New Revision: 75930 Log: Merged revisions 75928 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75928 | benjamin.peterson | 2009-10-28 16:59:39 -0500 (Wed, 28 Oct 2009) | 5 lines in wide builds, avoid storing high unicode characters from source code with surrogates This is accomplished by decoding with utf-32 instead of utf-16 on all builds. The patch is by Adam Olsen. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_pep263.py python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Python/ast.c Modified: python/branches/release31-maint/Lib/test/test_pep263.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_pep263.py (original) +++ python/branches/release31-maint/Lib/test/test_pep263.py Thu Oct 29 02:22:38 2009 @@ -36,6 +36,14 @@ exec(c, d) self.assertEquals(d['\xc6'], '\xc6') + def test_issue3297(self): + c = compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec") + d = {} + exec(c, d) + self.assertEqual(d['a'], d['b']) + self.assertEqual(len(d['a']), len(d['b'])) + self.assertEqual(ascii(d['a']), ascii(d['b'])) + def test_main(): support.run_unittest(PEP263Test) Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Thu Oct 29 02:22:38 2009 @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #3297: On wide unicode builds, do not split unicode characters into + surrogates. + - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. Modified: python/branches/release31-maint/Python/ast.c ============================================================================== --- python/branches/release31-maint/Python/ast.c (original) +++ python/branches/release31-maint/Python/ast.c Thu Oct 29 02:22:38 2009 @@ -3217,10 +3217,11 @@ u = NULL; } else { /* check for integer overflow */ - if (len > PY_SIZE_MAX / 4) + if (len > PY_SIZE_MAX / 6) return NULL; - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyBytes_FromStringAndSize((char *)NULL, len * 4); + /* "?" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\?" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + u = PyBytes_FromStringAndSize((char *)NULL, len * 6); if (u == NULL) return NULL; p = buf = PyBytes_AsString(u); @@ -3237,20 +3238,24 @@ PyObject *w; char *r; Py_ssize_t rn, i; - w = decode_utf8(c, &s, end, "utf-16-be"); + w = decode_utf8(c, &s, end, "utf-32-be"); if (w == NULL) { Py_DECREF(u); return NULL; } r = PyBytes_AS_STRING(w); rn = Py_SIZE(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", + assert(rn % 4 == 0); + for (i = 0; i < rn; i += 4) { + sprintf(p, "\\U%02x%02x%02x%02x", r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; + r[i + 1] & 0xFF, + r[i + 2] & 0xFF, + r[i + 3] & 0xFF); + p += 10; } + /* Should be impossible to overflow */ + assert(p - buf <= Py_SIZE(u)); Py_DECREF(w); } else { *p++ = *s++; From python-checkins at python.org Thu Oct 29 02:49:07 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 29 Oct 2009 01:49:07 -0000 Subject: [Python-checkins] r75931 - in python/trunk: Lib/test/test_pep263.py Python/ast.c Message-ID: Author: benjamin.peterson Date: Thu Oct 29 02:49:07 2009 New Revision: 75931 Log: do a backport of r75928 The added test does not fail without the patch, but we still fix the issue of surrogates being used in wide builds where they should not be. Modified: python/trunk/Lib/test/test_pep263.py python/trunk/Python/ast.c Modified: python/trunk/Lib/test/test_pep263.py ============================================================================== --- python/trunk/Lib/test/test_pep263.py (original) +++ python/trunk/Lib/test/test_pep263.py Thu Oct 29 02:49:07 2009 @@ -23,6 +23,13 @@ self.assertEqual(d['u'], u'\xf3') + def test_issue3297(self): + c = compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec") + d = {} + exec(c, d) + self.assertEqual(d['a'], d['b']) + self.assertEqual(len(d['a']), len(d['b'])) + def test_main(): test_support.run_unittest(PEP263Test) Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Thu Oct 29 02:49:07 2009 @@ -3289,10 +3289,11 @@ u = NULL; } else { /* check for integer overflow */ - if (len > PY_SIZE_MAX / 4) + if (len > PY_SIZE_MAX / 6) return NULL; - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); + /* "" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\?" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + u = PyString_FromStringAndSize((char *)NULL, len * 6); if (u == NULL) return NULL; p = buf = PyString_AsString(u); @@ -3309,19 +3310,21 @@ PyObject *w; char *r; Py_ssize_t rn, i; - w = decode_utf8(c, &s, end, "utf-16-be"); + w = decode_utf8(c, &s, end, "utf-32-be"); if (w == NULL) { Py_DECREF(u); return NULL; } r = PyString_AsString(w); rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", + assert(rn % 4 == 0); + for (i = 0; i < rn; i += 4) { + sprintf(p, "\\U%02x%02x%02x%02x", r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; + r[i + 1] & 0xFF, + r[i + 2] & 0xFF, + r[i + 3] & 0xFF); + p += 10; } Py_DECREF(w); } else { From python-checkins at python.org Thu Oct 29 02:50:07 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 29 Oct 2009 01:50:07 -0000 Subject: [Python-checkins] r75932 - python/branches/py3k Message-ID: Author: benjamin.peterson Date: Thu Oct 29 02:50:06 2009 New Revision: 75932 Log: Blocked revisions 75931 via svnmerge ........ r75931 | benjamin.peterson | 2009-10-28 20:49:07 -0500 (Wed, 28 Oct 2009) | 5 lines do a backport of r75928 The added test does not fail without the patch, but we still fix the issue of surrogates being used in wide builds where they should not be. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Thu Oct 29 02:57:09 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 29 Oct 2009 01:57:09 -0000 Subject: [Python-checkins] r75933 - python/branches/release26-maint/Lib/test/test_pep263.py Message-ID: Author: benjamin.peterson Date: Thu Oct 29 02:57:08 2009 New Revision: 75933 Log: remove binary mimetype Modified: python/branches/release26-maint/Lib/test/test_pep263.py (contents, props changed) Modified: python/branches/release26-maint/Lib/test/test_pep263.py ============================================================================== Binary files. No diff available. From python-checkins at python.org Thu Oct 29 03:02:48 2009 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 29 Oct 2009 02:02:48 -0000 Subject: [Python-checkins] r75934 - in python/branches/release26-maint: Lib/test/test_pep263.py Python/ast.c Message-ID: Author: benjamin.peterson Date: Thu Oct 29 03:02:47 2009 New Revision: 75934 Log: Merged revisions 75931 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75931 | benjamin.peterson | 2009-10-28 20:49:07 -0500 (Wed, 28 Oct 2009) | 5 lines do a backport of r75928 The added test does not fail without the patch, but we still fix the issue of surrogates being used in wide builds where they should not be. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_pep263.py python/branches/release26-maint/Python/ast.c Modified: python/branches/release26-maint/Lib/test/test_pep263.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_pep263.py (original) +++ python/branches/release26-maint/Lib/test/test_pep263.py Thu Oct 29 03:02:47 2009 @@ -1,30 +1,37 @@ -#! -*- coding: koi8-r -*- - -import unittest -from test import test_support - -class PEP263Test(unittest.TestCase): - - def test_pep263(self): - self.assertEqual( - u"?????".encode("utf-8"), - '\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd' - ) - self.assertEqual( - u"\?".encode("utf-8"), - '\\\xd0\x9f' - ) - - def test_compilestring(self): - # see #1882 - c = compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec") - d = {} - exec c in d - self.assertEqual(d['u'], u'\xf3') - - -def test_main(): - test_support.run_unittest(PEP263Test) - -if __name__=="__main__": - test_main() +# -*- coding: koi8-r -*- + +import unittest +from test import test_support + +class PEP263Test(unittest.TestCase): + + def test_pep263(self): + self.assertEqual( + u"?????".encode("utf-8"), + '\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd' + ) + self.assertEqual( + u"\?".encode("utf-8"), + '\\\xd0\x9f' + ) + + def test_compilestring(self): + # see #1882 + c = compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec") + d = {} + exec c in d + self.assertEqual(d['u'], u'\xf3') + + + def test_issue3297(self): + c = compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec") + d = {} + exec(c, d) + self.assertEqual(d['a'], d['b']) + self.assertEqual(len(d['a']), len(d['b'])) + +def test_main(): + test_support.run_unittest(PEP263Test) + +if __name__=="__main__": + test_main() Modified: python/branches/release26-maint/Python/ast.c ============================================================================== --- python/branches/release26-maint/Python/ast.c (original) +++ python/branches/release26-maint/Python/ast.c Thu Oct 29 03:02:47 2009 @@ -3248,10 +3248,11 @@ u = NULL; } else { /* check for integer overflow */ - if (len > PY_SIZE_MAX / 4) + if (len > PY_SIZE_MAX / 6) return NULL; - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); + /* "" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\??" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + u = PyString_FromStringAndSize((char *)NULL, len * 6); if (u == NULL) return NULL; p = buf = PyString_AsString(u); @@ -3268,19 +3269,21 @@ PyObject *w; char *r; Py_ssize_t rn, i; - w = decode_utf8(c, &s, end, "utf-16-be"); + w = decode_utf8(c, &s, end, "utf-32-be"); if (w == NULL) { Py_DECREF(u); return NULL; } r = PyString_AsString(w); rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", + assert(rn % 4 == 0); + for (i = 0; i < rn; i += 4) { + sprintf(p, "\\U%02x%02x%02x%02x", r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; + r[i + 1] & 0xFF, + r[i + 2] & 0xFF, + r[i + 3] & 0xFF); + p += 10; } Py_DECREF(w); } else { From python-checkins at python.org Thu Oct 29 10:15:00 2009 From: python-checkins at python.org (lars.gustaebel) Date: Thu, 29 Oct 2009 09:15:00 -0000 Subject: [Python-checkins] r75935 - in python/trunk: Lib/gzip.py Misc/NEWS Message-ID: Author: lars.gustaebel Date: Thu Oct 29 10:15:00 2009 New Revision: 75935 Log: Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. Modified: python/trunk/Lib/gzip.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/gzip.py ============================================================================== --- python/trunk/Lib/gzip.py (original) +++ python/trunk/Lib/gzip.py Thu Oct 29 10:15:00 2009 @@ -5,7 +5,7 @@ # based on Andrew Kuchling's minigzip.py distributed with the zlib module -import struct, sys, time +import struct, sys, time, os import zlib import __builtin__ @@ -143,7 +143,7 @@ def _write_gzip_header(self): self.fileobj.write('\037\213') # magic header self.fileobj.write('\010') # compression method - fname = self.name + fname = os.path.basename(self.name) if fname.endswith(".gz"): fname = fname[:-3] flags = 0 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 29 10:15:00 2009 @@ -427,6 +427,9 @@ Library ------- +- Issue #4750: Store the basename of the original filename in the gzip FNAME + header as required by RFC 1952. + - Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in Distutils. From python-checkins at python.org Thu Oct 29 10:21:20 2009 From: python-checkins at python.org (lars.gustaebel) Date: Thu, 29 Oct 2009 09:21:20 -0000 Subject: [Python-checkins] r75936 - python/branches/release26-maint Message-ID: Author: lars.gustaebel Date: Thu Oct 29 10:21:19 2009 New Revision: 75936 Log: Blocked revisions 75935 via svnmerge ........ r75935 | lars.gustaebel | 2009-10-29 10:15:00 +0100 (Thu, 29 Oct 2009) | 3 lines Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Thu Oct 29 10:39:48 2009 From: python-checkins at python.org (lars.gustaebel) Date: Thu, 29 Oct 2009 09:39:48 -0000 Subject: [Python-checkins] r75937 - in python/branches/py3k: Lib/gzip.py Misc/NEWS Message-ID: Author: lars.gustaebel Date: Thu Oct 29 10:39:47 2009 New Revision: 75937 Log: Merged revisions 75935 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75935 | lars.gustaebel | 2009-10-29 10:15:00 +0100 (Thu, 29 Oct 2009) | 3 lines Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/gzip.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/gzip.py ============================================================================== --- python/branches/py3k/Lib/gzip.py (original) +++ python/branches/py3k/Lib/gzip.py Thu Oct 29 10:39:47 2009 @@ -5,7 +5,7 @@ # based on Andrew Kuchling's minigzip.py distributed with the zlib module -import struct, sys, time +import struct, sys, time, os import zlib import builtins @@ -158,7 +158,8 @@ try: # RFC 1952 requires the FNAME field to be Latin-1. Do not # include filenames that cannot be represented that way. - fname = self.name.encode('latin-1') + fname = os.path.basename(self.name) + fname = fname.encode('latin-1') if fname.endswith(b'.gz'): fname = fname[:-3] except UnicodeEncodeError: Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Oct 29 10:39:47 2009 @@ -120,6 +120,9 @@ Library ------- +- Issue #4750: Store the basename of the original filename in the gzip FNAME + header as required by RFC 1952. + - Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in Distutils. From python-checkins at python.org Thu Oct 29 10:41:17 2009 From: python-checkins at python.org (lars.gustaebel) Date: Thu, 29 Oct 2009 09:41:17 -0000 Subject: [Python-checkins] r75938 - python/branches/release31-maint Message-ID: Author: lars.gustaebel Date: Thu Oct 29 10:41:17 2009 New Revision: 75938 Log: Blocked revisions 75937 via svnmerge ................ r75937 | lars.gustaebel | 2009-10-29 10:39:47 +0100 (Thu, 29 Oct 2009) | 10 lines Merged revisions 75935 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75935 | lars.gustaebel | 2009-10-29 10:15:00 +0100 (Thu, 29 Oct 2009) | 3 lines Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Thu Oct 29 10:46:05 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 09:46:05 -0000 Subject: [Python-checkins] r75939 - in python/trunk/Modules/_io: _iomodule.h bufferedio.c Message-ID: Author: mark.dickinson Date: Thu Oct 29 10:46:04 2009 New Revision: 75939 Log: Roll back ill-considered attempts to fix printf specifier mismatch for off_t. The sensible solution seems to be to implement %lld for PyString_FromFormat(V) and PyErr_Format. See issue #7228. Modified: python/trunk/Modules/_io/_iomodule.h python/trunk/Modules/_io/bufferedio.c Modified: python/trunk/Modules/_io/_iomodule.h ============================================================================== --- python/trunk/Modules/_io/_iomodule.h (original) +++ python/trunk/Modules/_io/_iomodule.h Thu Oct 29 10:46:04 2009 @@ -75,14 +75,6 @@ * Offset type for positioning. */ -/* Printing a variable of type off_t correctly and without producing - compiler warnings is surprisingly painful. We identify an integer - type whose size matches off_t and then: (1) cast the off_t to that - integer type and (2) use the appropriate conversion specification - for printf. The cast is necessary: gcc complains about formatting - a long with "%lld" even when both long and long long have the same - precision. */ - #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -91,33 +83,26 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ + #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN -# define PY_PRIdOFF "ld" -# define PY_OFF_T_COMPAT long -#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -# define PY_PRIdOFF "zd" -# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/trunk/Modules/_io/bufferedio.c ============================================================================== --- python/trunk/Modules/_io/bufferedio.c (original) +++ python/trunk/Modules/_io/bufferedio.c Thu Oct 29 10:46:04 2009 @@ -580,8 +580,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; @@ -613,8 +612,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; From python-checkins at python.org Thu Oct 29 10:55:14 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 09:55:14 -0000 Subject: [Python-checkins] r75940 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Thu Oct 29 10:55:14 2009 New Revision: 75940 Log: Blocked revisions 75939 via svnmerge ........ r75939 | mark.dickinson | 2009-10-29 09:46:04 +0000 (Thu, 29 Oct 2009) | 5 lines Roll back ill-considered attempts to fix printf specifier mismatch for off_t. The sensible solution seems to be to implement %lld for PyString_FromFormat(V) and PyErr_Format. See issue #7228. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Thu Oct 29 10:58:06 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 09:58:06 -0000 Subject: [Python-checkins] r75941 - in python/branches/py3k: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Thu Oct 29 10:58:06 2009 New Revision: 75941 Log: Merged revisions 75939 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75939 | mark.dickinson | 2009-10-29 09:46:04 +0000 (Thu, 29 Oct 2009) | 5 lines Roll back ill-considered attempts to fix printf specifier mismatch for off_t. The sensible solution seems to be to implement %lld for PyString_FromFormat(V) and PyErr_Format. See issue #7228. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Modules/_io/_iomodule.h python/branches/py3k/Modules/_io/bufferedio.c Modified: python/branches/py3k/Modules/_io/_iomodule.h ============================================================================== --- python/branches/py3k/Modules/_io/_iomodule.h (original) +++ python/branches/py3k/Modules/_io/_iomodule.h Thu Oct 29 10:58:06 2009 @@ -70,14 +70,6 @@ * Offset type for positioning. */ -/* Printing a variable of type off_t correctly and without producing - compiler warnings is surprisingly painful. We identify an integer - type whose size matches off_t and then: (1) cast the off_t to that - integer type and (2) use the appropriate conversion specification - for printf. The cast is necessary: gcc complains about formatting - a long with "%lld" even when both long and long long have the same - precision. */ - #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -86,33 +78,26 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ + #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN -# define PY_PRIdOFF "ld" -# define PY_OFF_T_COMPAT long -#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -# define PY_PRIdOFF "zd" -# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/py3k/Modules/_io/bufferedio.c ============================================================================== --- python/branches/py3k/Modules/_io/bufferedio.c (original) +++ python/branches/py3k/Modules/_io/bufferedio.c Thu Oct 29 10:58:06 2009 @@ -580,8 +580,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; @@ -613,8 +612,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; From python-checkins at python.org Thu Oct 29 11:01:23 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 10:01:23 -0000 Subject: [Python-checkins] r75942 - in python/branches/release31-maint: Modules/_io/_iomodule.h Modules/_io/bufferedio.c Message-ID: Author: mark.dickinson Date: Thu Oct 29 11:01:23 2009 New Revision: 75942 Log: Merged revisions 75941 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75941 | mark.dickinson | 2009-10-29 09:58:06 +0000 (Thu, 29 Oct 2009) | 11 lines Merged revisions 75939 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75939 | mark.dickinson | 2009-10-29 09:46:04 +0000 (Thu, 29 Oct 2009) | 5 lines Roll back ill-considered attempts to fix printf specifier mismatch for off_t. The sensible solution seems to be to implement %lld for PyString_FromFormat(V) and PyErr_Format. See issue #7228. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Modules/_io/_iomodule.h python/branches/release31-maint/Modules/_io/bufferedio.c Modified: python/branches/release31-maint/Modules/_io/_iomodule.h ============================================================================== --- python/branches/release31-maint/Modules/_io/_iomodule.h (original) +++ python/branches/release31-maint/Modules/_io/_iomodule.h Thu Oct 29 11:01:23 2009 @@ -70,14 +70,6 @@ * Offset type for positioning. */ -/* Printing a variable of type off_t correctly and without producing - compiler warnings is surprisingly painful. We identify an integer - type whose size matches off_t and then: (1) cast the off_t to that - integer type and (2) use the appropriate conversion specification - for printf. The cast is necessary: gcc complains about formatting - a long with "%lld" even when both long and long long have the same - precision. */ - #if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ @@ -86,33 +78,26 @@ # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "I64d" /* format to use in printf with type off_t */ -# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ + #else /* Other platforms use off_t */ typedef off_t Py_off_t; -#if (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) +#if (SIZEOF_OFF_T == SIZEOF_SIZE_T) +# define PyLong_AsOff_t PyLong_AsSsize_t +# define PyLong_FromOff_t PyLong_FromSsize_t +# define PY_OFF_T_MAX PY_SSIZE_T_MAX +# define PY_OFF_T_MIN PY_SSIZE_T_MIN +#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN -# define PY_PRIdOFF "lld" -# define PY_OFF_T_COMPAT PY_LONG_LONG #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN -# define PY_PRIdOFF "ld" -# define PY_OFF_T_COMPAT long -#elif (SIZEOF_OFF_T == SIZEOF_SIZE_T) -# define PyLong_AsOff_t PyLong_AsSsize_t -# define PyLong_FromOff_t PyLong_FromSsize_t -# define PY_OFF_T_MAX PY_SSIZE_T_MAX -# define PY_OFF_T_MIN PY_SSIZE_T_MIN -# define PY_PRIdOFF "zd" -# define PY_OFF_T_COMPAT Py_ssize_t #else # error off_t does not match either size_t, long, or long long! #endif Modified: python/branches/release31-maint/Modules/_io/bufferedio.c ============================================================================== --- python/branches/release31-maint/Modules/_io/bufferedio.c (original) +++ python/branches/release31-maint/Modules/_io/bufferedio.c Thu Oct 29 11:01:23 2009 @@ -580,8 +580,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; @@ -613,8 +612,7 @@ if (n < 0) { if (!PyErr_Occurred()) PyErr_Format(PyExc_IOError, - "Raw stream returned invalid position %" PY_PRIdOFF, - (PY_OFF_T_COMPAT)n); + "Raw stream returned invalid position %zd", n); return -1; } self->abs_pos = n; From python-checkins at python.org Thu Oct 29 12:09:09 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 11:09:09 -0000 Subject: [Python-checkins] r75943 - python/trunk/Lib/test/decimaltestdata/extra.decTest Message-ID: Author: mark.dickinson Date: Thu Oct 29 12:09:09 2009 New Revision: 75943 Log: Fix duplicate test numbers in extra.decTest Modified: python/trunk/Lib/test/decimaltestdata/extra.decTest Modified: python/trunk/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/extra.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/extra.decTest Thu Oct 29 12:09:09 2009 @@ -154,22 +154,6 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation --- Issue #6794: when comparing NaNs using compare_total, payloads --- should be compared as though positive integers; not --- lexicographically as strings. -extr1400 comparetotal NaN123 NaN45 -> 1 -extr1401 comparetotal sNaN123 sNaN45 -> 1 -extr1402 comparetotal -NaN123 -NaN45 -> -1 -extr1403 comparetotal -sNaN123 -sNaN45 -> -1 -extr1404 comparetotal NaN45 NaN123 -> -1 -extr1405 comparetotal sNaN45 sNaN123 -> -1 -extr1406 comparetotal -NaN45 -NaN123 -> 1 -extr1407 comparetotal -sNaN45 -sNaN123 -> 1 - -extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 -extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 - - -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions @@ -187,6 +171,21 @@ extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1500 comparetotal NaN123 NaN45 -> 1 +extr1501 comparetotal sNaN123 sNaN45 -> 1 +extr1502 comparetotal -NaN123 -NaN45 -> -1 +extr1503 comparetotal -sNaN123 -sNaN45 -> -1 +extr1504 comparetotal NaN45 NaN123 -> -1 +extr1505 comparetotal sNaN45 sNaN123 -> -1 +extr1506 comparetotal -NaN45 -NaN123 -> 1 +extr1507 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 From python-checkins at python.org Thu Oct 29 13:04:01 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:04:01 -0000 Subject: [Python-checkins] r75944 - in python/trunk: Lib/decimal.py Lib/test/test_decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:04:00 2009 New Revision: 75944 Log: Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. Modified: python/trunk/Lib/decimal.py python/trunk/Lib/test/test_decimal.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Thu Oct 29 13:04:00 2009 @@ -2723,6 +2723,8 @@ value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2792,6 +2794,8 @@ Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3160,6 +3164,9 @@ """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3181,6 +3188,9 @@ """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3195,6 +3205,9 @@ """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3408,6 +3421,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3432,11 +3447,13 @@ return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3460,6 +3477,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans Modified: python/trunk/Lib/test/test_decimal.py ============================================================================== --- python/trunk/Lib/test/test_decimal.py (original) +++ python/trunk/Lib/test/test_decimal.py Thu Oct 29 13:04:00 2009 @@ -1476,6 +1476,53 @@ self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + class DecimalPythonAPItests(unittest.TestCase): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 29 13:04:00 2009 @@ -427,6 +427,9 @@ Library ------- +- Issue #7233: Fix a number of two-argument Decimal methods to make sure + that they accept an int or long as the second argument. + - Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. From python-checkins at python.org Thu Oct 29 13:11:19 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:11:19 -0000 Subject: [Python-checkins] r75945 - in python/trunk: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Misc/NEWS Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:11:18 2009 New Revision: 75945 Log: Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. Modified: python/trunk/Lib/decimal.py python/trunk/Lib/test/decimaltestdata/extra.decTest python/trunk/Misc/NEWS Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Thu Oct 29 13:11:18 2009 @@ -3439,8 +3439,10 @@ torot = int(other) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's rotate! rotated = rotdig[torot:] + rotdig[:torot] @@ -3493,22 +3495,22 @@ # get values, pad if necessary torot = int(other) - if not torot: - return Decimal(self) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's shift! if torot < 0: - rotated = rotdig[:torot] + shifted = rotdig[:torot] else: - rotated = rotdig + '0'*torot - rotated = rotated[-context.prec:] + shifted = rotdig + '0'*torot + shifted = shifted[-context.prec:] return _dec_from_triple(self._sign, - rotated.lstrip('0') or '0', self._exp) + shifted.lstrip('0') or '0', self._exp) # Support for pickling, copy, and deepcopy def __reduce__(self): Modified: python/trunk/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/trunk/Lib/test/decimaltestdata/extra.decTest (original) +++ python/trunk/Lib/test/decimaltestdata/extra.decTest Thu Oct 29 13:11:18 2009 @@ -186,6 +186,35 @@ extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 +-- Issue #7233: rotate and scale should truncate an argument +-- of length greater than the current precision. +precision: 4 +extr1600 rotate 1234567 -5 -> NaN Invalid_operation +extr1601 rotate 1234567 -4 -> 4567 +extr1602 rotate 1234567 -3 -> 5674 +extr1603 rotate 1234567 -2 -> 6745 +extr1604 rotate 1234567 -1 -> 7456 +extr1605 rotate 1234567 0 -> 4567 +extr1606 rotate 1234567 1 -> 5674 +extr1607 rotate 1234567 2 -> 6745 +extr1608 rotate 1234567 3 -> 7456 +extr1609 rotate 1234567 4 -> 4567 +extr1610 rotate 1234567 5 -> NaN Invalid_operation + +extr1650 shift 1234567 -5 -> NaN Invalid_operation +extr1651 shift 1234567 -4 -> 0 +extr1652 shift 1234567 -3 -> 4 +extr1653 shift 1234567 -2 -> 45 +extr1654 shift 1234567 -1 -> 456 +extr1655 shift 1234567 0 -> 4567 +extr1656 shift 1234567 1 -> 5670 +extr1657 shift 1234567 2 -> 6700 +extr1658 shift 1234567 3 -> 7000 +extr1659 shift 1234567 4 -> 0 +extr1660 shift 1234567 5 -> NaN Invalid_operation + + + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Oct 29 13:11:18 2009 @@ -427,8 +427,10 @@ Library ------- -- Issue #7233: Fix a number of two-argument Decimal methods to make sure - that they accept an int or long as the second argument. +- Issue #7233: Fix a number of two-argument Decimal methods to make + sure that they accept an int or long as the second argument. Also + fix buggy handling of large arguments (those with coefficient longer + than the current precision) in shift and rotate. - Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. From python-checkins at python.org Thu Oct 29 13:16:16 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:16:16 -0000 Subject: [Python-checkins] r75946 - in python/branches/release26-maint: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Lib/test/test_decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:16:15 2009 New Revision: 75946 Log: Merged revisions 75943-75945 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line Fix duplicate test numbers in extra.decTest ........ r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. ........ r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/decimal.py python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest python/branches/release26-maint/Lib/test/test_decimal.py python/branches/release26-maint/Misc/NEWS Modified: python/branches/release26-maint/Lib/decimal.py ============================================================================== --- python/branches/release26-maint/Lib/decimal.py (original) +++ python/branches/release26-maint/Lib/decimal.py Thu Oct 29 13:16:15 2009 @@ -2680,6 +2680,8 @@ value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2749,6 +2751,8 @@ Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3117,6 +3121,9 @@ """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3138,6 +3145,9 @@ """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3152,6 +3162,9 @@ """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3365,6 +3378,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3381,19 +3396,23 @@ torot = int(other) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's rotate! rotated = rotdig[torot:] + rotdig[:torot] return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3417,6 +3436,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3431,22 +3452,22 @@ # get values, pad if necessary torot = int(other) - if not torot: - return Decimal(self) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's shift! if torot < 0: - rotated = rotdig[:torot] + shifted = rotdig[:torot] else: - rotated = rotdig + '0'*torot - rotated = rotated[-context.prec:] + shifted = rotdig + '0'*torot + shifted = shifted[-context.prec:] return _dec_from_triple(self._sign, - rotated.lstrip('0') or '0', self._exp) + shifted.lstrip('0') or '0', self._exp) # Support for pickling, copy, and deepcopy def __reduce__(self): Modified: python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/release26-maint/Lib/test/decimaltestdata/extra.decTest Thu Oct 29 13:16:15 2009 @@ -154,22 +154,6 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation --- Issue #6794: when comparing NaNs using compare_total, payloads --- should be compared as though positive integers; not --- lexicographically as strings. -extr1400 comparetotal NaN123 NaN45 -> 1 -extr1401 comparetotal sNaN123 sNaN45 -> 1 -extr1402 comparetotal -NaN123 -NaN45 -> -1 -extr1403 comparetotal -sNaN123 -sNaN45 -> -1 -extr1404 comparetotal NaN45 NaN123 -> -1 -extr1405 comparetotal sNaN45 sNaN123 -> -1 -extr1406 comparetotal -NaN45 -NaN123 -> 1 -extr1407 comparetotal -sNaN45 -sNaN123 -> 1 - -extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 -extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 - - -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions @@ -187,6 +171,50 @@ extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1500 comparetotal NaN123 NaN45 -> 1 +extr1501 comparetotal sNaN123 sNaN45 -> 1 +extr1502 comparetotal -NaN123 -NaN45 -> -1 +extr1503 comparetotal -sNaN123 -sNaN45 -> -1 +extr1504 comparetotal NaN45 NaN123 -> -1 +extr1505 comparetotal sNaN45 sNaN123 -> -1 +extr1506 comparetotal -NaN45 -NaN123 -> 1 +extr1507 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 + +-- Issue #7233: rotate and scale should truncate an argument +-- of length greater than the current precision. +precision: 4 +extr1600 rotate 1234567 -5 -> NaN Invalid_operation +extr1601 rotate 1234567 -4 -> 4567 +extr1602 rotate 1234567 -3 -> 5674 +extr1603 rotate 1234567 -2 -> 6745 +extr1604 rotate 1234567 -1 -> 7456 +extr1605 rotate 1234567 0 -> 4567 +extr1606 rotate 1234567 1 -> 5674 +extr1607 rotate 1234567 2 -> 6745 +extr1608 rotate 1234567 3 -> 7456 +extr1609 rotate 1234567 4 -> 4567 +extr1610 rotate 1234567 5 -> NaN Invalid_operation + +extr1650 shift 1234567 -5 -> NaN Invalid_operation +extr1651 shift 1234567 -4 -> 0 +extr1652 shift 1234567 -3 -> 4 +extr1653 shift 1234567 -2 -> 45 +extr1654 shift 1234567 -1 -> 456 +extr1655 shift 1234567 0 -> 4567 +extr1656 shift 1234567 1 -> 5670 +extr1657 shift 1234567 2 -> 6700 +extr1658 shift 1234567 3 -> 7000 +extr1659 shift 1234567 4 -> 0 +extr1660 shift 1234567 5 -> NaN Invalid_operation + + + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 Modified: python/branches/release26-maint/Lib/test/test_decimal.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_decimal.py (original) +++ python/branches/release26-maint/Lib/test/test_decimal.py Thu Oct 29 13:16:15 2009 @@ -1358,6 +1358,53 @@ self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + class DecimalPythonAPItests(unittest.TestCase): Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Thu Oct 29 13:16:15 2009 @@ -24,6 +24,11 @@ Library ------- +- Issue #7233: Fix a number of two-argument Decimal methods to make + sure that they accept an int or long as the second argument. Also + fix buggy handling of large arguments (those with coefficient longer + than the current precision) in shift and rotate. + - Issue #7082: When falling back to the MIME 'name' parameter, the correct place to look for it is the Content-Type header. From python-checkins at python.org Thu Oct 29 13:23:02 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:23:02 -0000 Subject: [Python-checkins] r75947 - in python/branches/py3k: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Lib/test/test_decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:23:02 2009 New Revision: 75947 Log: Merged revisions 75943-75945 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line Fix duplicate test numbers in extra.decTest ........ r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. ........ r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/decimaltestdata/extra.decTest python/branches/py3k/Lib/test/test_decimal.py python/branches/py3k/Misc/NEWS Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Thu Oct 29 13:23:02 2009 @@ -2806,6 +2806,8 @@ value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2875,6 +2877,8 @@ Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3243,6 +3247,9 @@ """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3264,6 +3271,9 @@ """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3278,6 +3288,9 @@ """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3491,6 +3504,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3507,19 +3522,23 @@ torot = int(other) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's rotate! rotated = rotdig[torot:] + rotdig[:torot] return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3543,6 +3562,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3557,22 +3578,22 @@ # get values, pad if necessary torot = int(other) - if not torot: - return Decimal(self) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's shift! if torot < 0: - rotated = rotdig[:torot] + shifted = rotdig[:torot] else: - rotated = rotdig + '0'*torot - rotated = rotated[-context.prec:] + shifted = rotdig + '0'*torot + shifted = shifted[-context.prec:] return _dec_from_triple(self._sign, - rotated.lstrip('0') or '0', self._exp) + shifted.lstrip('0') or '0', self._exp) # Support for pickling, copy, and deepcopy def __reduce__(self): Modified: python/branches/py3k/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/py3k/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/py3k/Lib/test/decimaltestdata/extra.decTest Thu Oct 29 13:23:02 2009 @@ -154,22 +154,6 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation --- Issue #6794: when comparing NaNs using compare_total, payloads --- should be compared as though positive integers; not --- lexicographically as strings. -extr1400 comparetotal NaN123 NaN45 -> 1 -extr1401 comparetotal sNaN123 sNaN45 -> 1 -extr1402 comparetotal -NaN123 -NaN45 -> -1 -extr1403 comparetotal -sNaN123 -sNaN45 -> -1 -extr1404 comparetotal NaN45 NaN123 -> -1 -extr1405 comparetotal sNaN45 sNaN123 -> -1 -extr1406 comparetotal -NaN45 -NaN123 -> 1 -extr1407 comparetotal -sNaN45 -sNaN123 -> 1 - -extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 -extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 - - -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions @@ -187,6 +171,50 @@ extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1500 comparetotal NaN123 NaN45 -> 1 +extr1501 comparetotal sNaN123 sNaN45 -> 1 +extr1502 comparetotal -NaN123 -NaN45 -> -1 +extr1503 comparetotal -sNaN123 -sNaN45 -> -1 +extr1504 comparetotal NaN45 NaN123 -> -1 +extr1505 comparetotal sNaN45 sNaN123 -> -1 +extr1506 comparetotal -NaN45 -NaN123 -> 1 +extr1507 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 + +-- Issue #7233: rotate and scale should truncate an argument +-- of length greater than the current precision. +precision: 4 +extr1600 rotate 1234567 -5 -> NaN Invalid_operation +extr1601 rotate 1234567 -4 -> 4567 +extr1602 rotate 1234567 -3 -> 5674 +extr1603 rotate 1234567 -2 -> 6745 +extr1604 rotate 1234567 -1 -> 7456 +extr1605 rotate 1234567 0 -> 4567 +extr1606 rotate 1234567 1 -> 5674 +extr1607 rotate 1234567 2 -> 6745 +extr1608 rotate 1234567 3 -> 7456 +extr1609 rotate 1234567 4 -> 4567 +extr1610 rotate 1234567 5 -> NaN Invalid_operation + +extr1650 shift 1234567 -5 -> NaN Invalid_operation +extr1651 shift 1234567 -4 -> 0 +extr1652 shift 1234567 -3 -> 4 +extr1653 shift 1234567 -2 -> 45 +extr1654 shift 1234567 -1 -> 456 +extr1655 shift 1234567 0 -> 4567 +extr1656 shift 1234567 1 -> 5670 +extr1657 shift 1234567 2 -> 6700 +extr1658 shift 1234567 3 -> 7000 +extr1659 shift 1234567 4 -> 0 +extr1660 shift 1234567 5 -> NaN Invalid_operation + + + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 Modified: python/branches/py3k/Lib/test/test_decimal.py ============================================================================== --- python/branches/py3k/Lib/test/test_decimal.py (original) +++ python/branches/py3k/Lib/test/test_decimal.py Thu Oct 29 13:23:02 2009 @@ -1530,6 +1530,53 @@ self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + class DecimalPythonAPItests(unittest.TestCase): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Oct 29 13:23:02 2009 @@ -120,6 +120,11 @@ Library ------- +- Issue #7233: Fix a number of two-argument Decimal methods to make + sure that they accept an int or long as the second argument. Also + fix buggy handling of large arguments (those with coefficient longer + than the current precision) in shift and rotate. + - Issue #4750: Store the basename of the original filename in the gzip FNAME header as required by RFC 1952. From python-checkins at python.org Thu Oct 29 13:25:07 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:25:07 -0000 Subject: [Python-checkins] r75948 - in python/branches/release31-maint: Lib/decimal.py Lib/test/decimaltestdata/extra.decTest Lib/test/test_decimal.py Misc/NEWS Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:25:07 2009 New Revision: 75948 Log: Merged revisions 75947 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75947 | mark.dickinson | 2009-10-29 12:23:02 +0000 (Thu, 29 Oct 2009) | 20 lines Merged revisions 75943-75945 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line Fix duplicate test numbers in extra.decTest ........ r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. ........ r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/decimal.py python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest python/branches/release31-maint/Lib/test/test_decimal.py python/branches/release31-maint/Misc/NEWS Modified: python/branches/release31-maint/Lib/decimal.py ============================================================================== --- python/branches/release31-maint/Lib/decimal.py (original) +++ python/branches/release31-maint/Lib/decimal.py Thu Oct 29 13:25:07 2009 @@ -2806,6 +2806,8 @@ value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2875,6 +2877,8 @@ Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3243,6 +3247,9 @@ """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3264,6 +3271,9 @@ """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3278,6 +3288,9 @@ """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3491,6 +3504,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3507,19 +3522,23 @@ torot = int(other) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's rotate! rotated = rotdig[torot:] + rotdig[:torot] return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3543,6 +3562,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3557,22 +3578,22 @@ # get values, pad if necessary torot = int(other) - if not torot: - return Decimal(self) rotdig = self._int topad = context.prec - len(rotdig) - if topad: + if topad > 0: rotdig = '0'*topad + rotdig + elif topad < 0: + rotdig = rotdig[-topad:] # let's shift! if torot < 0: - rotated = rotdig[:torot] + shifted = rotdig[:torot] else: - rotated = rotdig + '0'*torot - rotated = rotated[-context.prec:] + shifted = rotdig + '0'*torot + shifted = shifted[-context.prec:] return _dec_from_triple(self._sign, - rotated.lstrip('0') or '0', self._exp) + shifted.lstrip('0') or '0', self._exp) # Support for pickling, copy, and deepcopy def __reduce__(self): Modified: python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest ============================================================================== --- python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest (original) +++ python/branches/release31-maint/Lib/test/decimaltestdata/extra.decTest Thu Oct 29 13:25:07 2009 @@ -154,22 +154,6 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation --- Issue #6794: when comparing NaNs using compare_total, payloads --- should be compared as though positive integers; not --- lexicographically as strings. -extr1400 comparetotal NaN123 NaN45 -> 1 -extr1401 comparetotal sNaN123 sNaN45 -> 1 -extr1402 comparetotal -NaN123 -NaN45 -> -1 -extr1403 comparetotal -sNaN123 -sNaN45 -> -1 -extr1404 comparetotal NaN45 NaN123 -> -1 -extr1405 comparetotal sNaN45 sNaN123 -> -1 -extr1406 comparetotal -NaN45 -NaN123 -> 1 -extr1407 comparetotal -sNaN45 -sNaN123 -> 1 - -extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 -extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 - - -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions @@ -187,6 +171,50 @@ extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1500 comparetotal NaN123 NaN45 -> 1 +extr1501 comparetotal sNaN123 sNaN45 -> 1 +extr1502 comparetotal -NaN123 -NaN45 -> -1 +extr1503 comparetotal -sNaN123 -sNaN45 -> -1 +extr1504 comparetotal NaN45 NaN123 -> -1 +extr1505 comparetotal sNaN45 sNaN123 -> -1 +extr1506 comparetotal -NaN45 -NaN123 -> 1 +extr1507 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 + +-- Issue #7233: rotate and scale should truncate an argument +-- of length greater than the current precision. +precision: 4 +extr1600 rotate 1234567 -5 -> NaN Invalid_operation +extr1601 rotate 1234567 -4 -> 4567 +extr1602 rotate 1234567 -3 -> 5674 +extr1603 rotate 1234567 -2 -> 6745 +extr1604 rotate 1234567 -1 -> 7456 +extr1605 rotate 1234567 0 -> 4567 +extr1606 rotate 1234567 1 -> 5674 +extr1607 rotate 1234567 2 -> 6745 +extr1608 rotate 1234567 3 -> 7456 +extr1609 rotate 1234567 4 -> 4567 +extr1610 rotate 1234567 5 -> NaN Invalid_operation + +extr1650 shift 1234567 -5 -> NaN Invalid_operation +extr1651 shift 1234567 -4 -> 0 +extr1652 shift 1234567 -3 -> 4 +extr1653 shift 1234567 -2 -> 45 +extr1654 shift 1234567 -1 -> 456 +extr1655 shift 1234567 0 -> 4567 +extr1656 shift 1234567 1 -> 5670 +extr1657 shift 1234567 2 -> 6700 +extr1658 shift 1234567 3 -> 7000 +extr1659 shift 1234567 4 -> 0 +extr1660 shift 1234567 5 -> NaN Invalid_operation + + + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 Modified: python/branches/release31-maint/Lib/test/test_decimal.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_decimal.py (original) +++ python/branches/release31-maint/Lib/test/test_decimal.py Thu Oct 29 13:25:07 2009 @@ -1529,6 +1529,53 @@ self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + class DecimalPythonAPItests(unittest.TestCase): Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Thu Oct 29 13:25:07 2009 @@ -37,6 +37,11 @@ Library ------- +- Issue #7233: Fix a number of two-argument Decimal methods to make + sure that they accept an int or long as the second argument. Also + fix buggy handling of large arguments (those with coefficient longer + than the current precision) in shift and rotate. + - Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. From python-checkins at python.org Thu Oct 29 13:52:52 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:52:52 -0000 Subject: [Python-checkins] r75949 - sandbox/trunk/decimal/decimal_in_c/deccoeff.c Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:52:51 2009 New Revision: 75949 Log: Fix typo in assert Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c Modified: sandbox/trunk/decimal/decimal_in_c/deccoeff.c ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/deccoeff.c (original) +++ sandbox/trunk/decimal/decimal_in_c/deccoeff.c Thu Oct 29 13:52:51 2009 @@ -633,7 +633,7 @@ carry = limbs_sub(aa, aa, rem, b_size); carry = limb_adc(&top, top, LIMB_ZERO, carry); assert(!carry); - assert(atop <= top); + assert(a_top <= top); /* correct if necessary */ while (a_top < top) { carry = limbs_add(aa, aa, bb, b_size); From python-checkins at python.org Thu Oct 29 13:59:53 2009 From: python-checkins at python.org (mark.dickinson) Date: Thu, 29 Oct 2009 12:59:53 -0000 Subject: [Python-checkins] r75950 - in sandbox/trunk/decimal/decimal_in_c: decimal.py decimaltestdata/extra.decTest test_decimal.py Message-ID: Author: mark.dickinson Date: Thu Oct 29 13:59:53 2009 New Revision: 75950 Log: Manual merge of r75947 from py3k: always convert integer arguments of Decimal methods Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest sandbox/trunk/decimal/decimal_in_c/test_decimal.py Modified: sandbox/trunk/decimal/decimal_in_c/decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/decimal.py Thu Oct 29 13:59:53 2009 @@ -2846,6 +2846,8 @@ value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + return [Dec_0, Dec_p1, Dec_n1][self._cmp_total(other)] def compare_total_mag(self, other): @@ -2853,6 +2855,8 @@ Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3214,6 +3218,9 @@ """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._is_logical() or not other._is_logical(): return context._raise_error(InvalidOperation) acc = deccoeff_zero @@ -3238,6 +3245,9 @@ """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._is_logical() or not other._is_logical(): return context._raise_error(InvalidOperation) acc = deccoeff_zero @@ -3250,6 +3260,9 @@ """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._is_logical() or not other._is_logical(): return context._raise_error(InvalidOperation) acc = deccoeff_zero @@ -3487,6 +3500,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3513,6 +3528,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3536,6 +3553,8 @@ if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans Modified: sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest (original) +++ sandbox/trunk/decimal/decimal_in_c/decimaltestdata/extra.decTest Thu Oct 29 13:59:53 2009 @@ -154,22 +154,6 @@ extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation --- Issue #6794: when comparing NaNs using compare_total, payloads --- should be compared as though positive integers; not --- lexicographically as strings. -extr1400 comparetotal NaN123 NaN45 -> 1 -extr1401 comparetotal sNaN123 sNaN45 -> 1 -extr1402 comparetotal -NaN123 -NaN45 -> -1 -extr1403 comparetotal -sNaN123 -sNaN45 -> -1 -extr1404 comparetotal NaN45 NaN123 -> -1 -extr1405 comparetotal sNaN45 sNaN123 -> -1 -extr1406 comparetotal -NaN45 -NaN123 -> 1 -extr1407 comparetotal -sNaN45 -sNaN123 -> 1 - -extr1410 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 -extr1411 comparetotmag NaN1222222222222 -NaN999999 -> 1 - - -- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave -- incorrect answers when the finite number required rounding; similarly -- for the other thre functions @@ -187,6 +171,50 @@ extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded +-- Issue #6794: when comparing NaNs using compare_total, payloads +-- should be compared as though positive integers; not +-- lexicographically as strings. +extr1500 comparetotal NaN123 NaN45 -> 1 +extr1501 comparetotal sNaN123 sNaN45 -> 1 +extr1502 comparetotal -NaN123 -NaN45 -> -1 +extr1503 comparetotal -sNaN123 -sNaN45 -> -1 +extr1504 comparetotal NaN45 NaN123 -> -1 +extr1505 comparetotal sNaN45 sNaN123 -> -1 +extr1506 comparetotal -NaN45 -NaN123 -> 1 +extr1507 comparetotal -sNaN45 -sNaN123 -> 1 + +extr1510 comparetotal -sNaN63450748854172416 -sNaN911993 -> -1 +extr1511 comparetotmag NaN1222222222222 -NaN999999 -> 1 + +-- Issue #7233: rotate and scale should truncate an argument +-- of length greater than the current precision. +precision: 4 +extr1600 rotate 1234567 -5 -> NaN Invalid_operation +extr1601 rotate 1234567 -4 -> 4567 +extr1602 rotate 1234567 -3 -> 5674 +extr1603 rotate 1234567 -2 -> 6745 +extr1604 rotate 1234567 -1 -> 7456 +extr1605 rotate 1234567 0 -> 4567 +extr1606 rotate 1234567 1 -> 5674 +extr1607 rotate 1234567 2 -> 6745 +extr1608 rotate 1234567 3 -> 7456 +extr1609 rotate 1234567 4 -> 4567 +extr1610 rotate 1234567 5 -> NaN Invalid_operation + +extr1650 shift 1234567 -5 -> NaN Invalid_operation +extr1651 shift 1234567 -4 -> 0 +extr1652 shift 1234567 -3 -> 4 +extr1653 shift 1234567 -2 -> 45 +extr1654 shift 1234567 -1 -> 456 +extr1655 shift 1234567 0 -> 4567 +extr1656 shift 1234567 1 -> 5670 +extr1657 shift 1234567 2 -> 6700 +extr1658 shift 1234567 3 -> 7000 +extr1659 shift 1234567 4 -> 0 +extr1660 shift 1234567 5 -> NaN Invalid_operation + + + -- Tests for the is_* boolean operations precision: 9 maxExponent: 999 Modified: sandbox/trunk/decimal/decimal_in_c/test_decimal.py ============================================================================== --- sandbox/trunk/decimal/decimal_in_c/test_decimal.py (original) +++ sandbox/trunk/decimal/decimal_in_c/test_decimal.py Thu Oct 29 13:59:53 2009 @@ -1530,6 +1530,53 @@ self.assertEqual(str(Decimal(0).sqrt()), str(c.sqrt(Decimal(0)))) + def test_conversions_from_int(self): + # Check that methods taking a second Decimal argument will + # always accept an integer in place of a Decimal. + self.assertEqual(Decimal(4).compare(3), + Decimal(4).compare(Decimal(3))) + self.assertEqual(Decimal(4).compare_signal(3), + Decimal(4).compare_signal(Decimal(3))) + self.assertEqual(Decimal(4).compare_total(3), + Decimal(4).compare_total(Decimal(3))) + self.assertEqual(Decimal(4).compare_total_mag(3), + Decimal(4).compare_total_mag(Decimal(3))) + self.assertEqual(Decimal(10101).logical_and(1001), + Decimal(10101).logical_and(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_or(1001), + Decimal(10101).logical_or(Decimal(1001))) + self.assertEqual(Decimal(10101).logical_xor(1001), + Decimal(10101).logical_xor(Decimal(1001))) + self.assertEqual(Decimal(567).max(123), + Decimal(567).max(Decimal(123))) + self.assertEqual(Decimal(567).max_mag(123), + Decimal(567).max_mag(Decimal(123))) + self.assertEqual(Decimal(567).min(123), + Decimal(567).min(Decimal(123))) + self.assertEqual(Decimal(567).min_mag(123), + Decimal(567).min_mag(Decimal(123))) + self.assertEqual(Decimal(567).next_toward(123), + Decimal(567).next_toward(Decimal(123))) + self.assertEqual(Decimal(1234).quantize(100), + Decimal(1234).quantize(Decimal(100))) + self.assertEqual(Decimal(768).remainder_near(1234), + Decimal(768).remainder_near(Decimal(1234))) + self.assertEqual(Decimal(123).rotate(1), + Decimal(123).rotate(Decimal(1))) + self.assertEqual(Decimal(1234).same_quantum(1000), + Decimal(1234).same_quantum(Decimal(1000))) + self.assertEqual(Decimal('9.123').scaleb(-100), + Decimal('9.123').scaleb(Decimal(-100))) + self.assertEqual(Decimal(456).shift(-1), + Decimal(456).shift(Decimal(-1))) + + self.assertEqual(Decimal(-12).fma(Decimal(45), 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, 67), + Decimal(-12).fma(Decimal(45), Decimal(67))) + self.assertEqual(Decimal(-12).fma(45, Decimal(67)), + Decimal(-12).fma(Decimal(45), Decimal(67))) + class DecimalPythonAPItests(unittest.TestCase): From python-checkins at python.org Thu Oct 29 21:38:33 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 20:38:33 -0000 Subject: [Python-checkins] r75952 - python/trunk/Modules/mathmodule.c Message-ID: Author: georg.brandl Date: Thu Oct 29 21:38:32 2009 New Revision: 75952 Log: Use the correct function name in docstring. Modified: python/trunk/Modules/mathmodule.c Modified: python/trunk/Modules/mathmodule.c ============================================================================== --- python/trunk/Modules/mathmodule.c (original) +++ python/trunk/Modules/mathmodule.c Thu Oct 29 21:38:32 2009 @@ -870,7 +870,7 @@ #undef NUM_PARTIALS PyDoc_STRVAR(math_fsum_doc, -"sum(iterable)\n\n\ +"fsum(iterable)\n\n\ Return an accurate floating point sum of values in the iterable.\n\ Assumes IEEE-754 floating point arithmetic."); From python-checkins at python.org Thu Oct 29 21:39:51 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 20:39:51 -0000 Subject: [Python-checkins] r75953 - python/trunk/Misc/Porting Message-ID: Author: georg.brandl Date: Thu Oct 29 21:39:50 2009 New Revision: 75953 Log: Remove mention of the old -X command line switch. Modified: python/trunk/Misc/Porting Modified: python/trunk/Misc/Porting ============================================================================== --- python/trunk/Misc/Porting (original) +++ python/trunk/Misc/Porting Thu Oct 29 21:39:50 2009 @@ -31,8 +31,7 @@ it out of the config.c file. Bang on it until you get a >>> prompt. (You may have to disable the -importing of "site.py" and "exceptions.py" by passing -X and -S -options. +importing of "site.py" by passing the -S options.) Then bang on it until it executes very simple Python statements. From python-checkins at python.org Thu Oct 29 21:53:00 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 20:53:00 -0000 Subject: [Python-checkins] r75954 - python/trunk/Lib/test/regrtest.py Message-ID: Author: georg.brandl Date: Thu Oct 29 21:53:00 2009 New Revision: 75954 Log: Use constants instead of magic integers for test result. Do not re-run with --verbose3 for environment changing tests. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Thu Oct 29 21:53:00 2009 @@ -194,6 +194,14 @@ newsoft = min(hard, max(soft, 1024*2048)) resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) +# Test result constants. +PASSED = 1 +FAILED = 0 +ENV_CHANGED = -1 +SKIPPED = -2 +RESOURCE_DENIED = -3 +INTERRUPTED = -4 + from test import test_support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', @@ -328,7 +336,7 @@ try: result = runtest(*args, **kwargs) except BaseException, e: - result = -4, e.__class__.__name__ + result = INTERRUPTED, e.__class__.__name__ print # Force a newline (just in case) print json.dumps(result) sys.exit(0) @@ -410,19 +418,18 @@ def accumulate_result(test, result): ok, test_time = result test_times.append((test_time, test)) - if ok > 0: + if ok == PASSED: good.append(test) - return 'good' - elif -2 < ok <= 0: + elif ok == FAILED: bad.append(test) - if ok == -1: - environment_changed.append(test) - return 'bad' - else: + elif ok == ENV_CHANGED: + bad.append(test) + environment_changed.append(test) + elif ok == SKIPPED: + skipped.append(test) + elif ok == RESOURCE_DENIED: skipped.append(test) - if ok == -3: - resource_denieds.append(test) - return 'skipped' + resource_denieds.append(test) if use_mp: from threading import Thread @@ -477,7 +484,7 @@ print stdout if stderr: print >>sys.stderr, stderr - if result[0] == -4: + if result[0] == INTERRUPTED: assert result[1] == 'KeyboardInterrupt' pending.clear() raise KeyboardInterrupt # What else? @@ -498,8 +505,8 @@ try: result = runtest(test, verbose, quiet, testdir, huntrleaks) - which = accumulate_result(test, result) - if verbose3 and which == 'bad': + accumulate_result(test, result) + if verbose3 and result[0] == FAILED: print "Re-running test %r in verbose mode" % test runtest(test, True, quiet, testdir, huntrleaks) except KeyboardInterrupt: @@ -646,13 +653,13 @@ testdir -- test directory huntrleaks -- run multiple times to test for leaks; requires a debug build; a triple corresponding to -R's three arguments - Return: - -4 KeyboardInterrupt when run under -j - -3 test skipped because resource denied - -2 test skipped for some other reason - -1 test failed because it changed the execution environment - 0 test failed - 1 test passed + Returns one of the test result constants: + INTERRUPTED KeyboardInterrupt when run under -j + RESOURCE_DENIED test skipped because resource denied + SKIPPED test skipped for some other reason + ENV_CHANGED test failed because it changed the execution environment + FAILED test failed + PASSED test passed """ test_support.verbose = verbose # Tell tests to be moderately quiet @@ -823,18 +830,18 @@ if not quiet: print test, "skipped --", msg sys.stdout.flush() - return -3, test_time + return RESOURCE_DENIED, test_time except unittest.SkipTest, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() - return -2, test_time + return SKIPPED, test_time except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() - return 0, test_time + return FAILED, test_time except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value @@ -842,24 +849,24 @@ if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() - return 0, test_time + return FAILED, test_time else: if refleak: - return 0, test_time + return FAILED, test_time if environment.changed: - return -1, test_time + return ENVIRONMENT_CHANGED, test_time # Except in verbose mode, tests should not print anything if verbose or huntrleaks: - return 1, test_time + return PASSED, test_time output = capture_stdout.getvalue() if not output: - return 1, test_time + return PASSED, test_time print "test", test, "produced unexpected output:" print "*" * 70 print output print "*" * 70 sys.stdout.flush() - return 0, test_time + return FAILED, test_time def cleanup_test_droppings(testname, verbose): import shutil From python-checkins at python.org Thu Oct 29 21:54:04 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 20:54:04 -0000 Subject: [Python-checkins] r75955 - python/trunk/Modules/mathmodule.c Message-ID: Author: georg.brandl Date: Thu Oct 29 21:54:03 2009 New Revision: 75955 Log: Use a single style for all the docstrings in the math module. Modified: python/trunk/Modules/mathmodule.c Modified: python/trunk/Modules/mathmodule.c ============================================================================== --- python/trunk/Modules/mathmodule.c (original) +++ python/trunk/Modules/mathmodule.c Thu Oct 29 21:54:03 2009 @@ -625,7 +625,7 @@ "ceil(x)\n\nReturn the ceiling of x as a float.\n" "This is the smallest integral value >= x.") FUNC2(copysign, copysign, - "copysign(x,y)\n\nReturn x with the sign of y.") + "copysign(x, y)\n\nReturn x with the sign of y.") FUNC1(cos, cos, 0, "cos(x)\n\nReturn the cosine of x (measured in radians).") FUNC1(cosh, cosh, 1, @@ -640,8 +640,8 @@ FUNC1A(gamma, m_tgamma, "gamma(x)\n\nGamma function at x.") FUNC1(log1p, log1p, 1, - "log1p(x)\n\nReturn the natural logarithm of 1+x (base e).\n\ - The result is computed in a way which is accurate for x near zero.") + "log1p(x)\n\nReturn the natural logarithm of 1+x (base e).\n" + "The result is computed in a way which is accurate for x near zero.") FUNC1(sin, sin, 0, "sin(x)\n\nReturn the sine of x (measured in radians).") FUNC1(sinh, sinh, 1, @@ -1028,7 +1028,8 @@ } PyDoc_STRVAR(math_ldexp_doc, -"ldexp(x, i) -> x * (2**i)"); +"ldexp(x, i)\n\n\ +Return x * (2**i)."); static PyObject * math_modf(PyObject *self, PyObject *arg) @@ -1119,7 +1120,8 @@ } PyDoc_STRVAR(math_log_doc, -"log(x[, base]) -> the logarithm of x to the given base.\n\ +"log(x[, base])\n\n\ +Return the logarithm of x to the given base.\n\ If the base not specified, returns the natural logarithm (base e) of x."); static PyObject * @@ -1129,7 +1131,7 @@ } PyDoc_STRVAR(math_log10_doc, -"log10(x) -> the base 10 logarithm of x."); +"log10(x)\n\nReturn the base 10 logarithm of x."); static PyObject * math_fmod(PyObject *self, PyObject *args) @@ -1162,7 +1164,7 @@ } PyDoc_STRVAR(math_fmod_doc, -"fmod(x,y)\n\nReturn fmod(x, y), according to platform C." +"fmod(x, y)\n\nReturn fmod(x, y), according to platform C." " x % y may differ."); static PyObject * @@ -1204,7 +1206,7 @@ } PyDoc_STRVAR(math_hypot_doc, -"hypot(x,y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y)."); +"hypot(x, y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y)."); /* pow can't use math_2, but needs its own wrapper: the problem is that an infinite result can arise either as a result of overflow @@ -1291,7 +1293,7 @@ } PyDoc_STRVAR(math_pow_doc, -"pow(x,y)\n\nReturn x**y (x to the power of y)."); +"pow(x, y)\n\nReturn x**y (x to the power of y)."); static const double degToRad = Py_MATH_PI / 180.0; static const double radToDeg = 180.0 / Py_MATH_PI; @@ -1306,7 +1308,8 @@ } PyDoc_STRVAR(math_degrees_doc, -"degrees(x) -> converts angle x from radians to degrees"); +"degrees(x)\n\n\ +Convert angle x from radians to degrees."); static PyObject * math_radians(PyObject *self, PyObject *arg) @@ -1318,7 +1321,8 @@ } PyDoc_STRVAR(math_radians_doc, -"radians(x) -> converts angle x from degrees to radians"); +"radians(x)\n\n\ +Convert angle x from degrees to radians."); static PyObject * math_isnan(PyObject *self, PyObject *arg) @@ -1330,8 +1334,8 @@ } PyDoc_STRVAR(math_isnan_doc, -"isnan(x) -> bool\n\ -Checks if float x is not a number (NaN)"); +"isnan(x) -> bool\n\n\ +Check if float x is not a number (NaN)."); static PyObject * math_isinf(PyObject *self, PyObject *arg) @@ -1343,8 +1347,8 @@ } PyDoc_STRVAR(math_isinf_doc, -"isinf(x) -> bool\n\ -Checks if float x is infinite (positive or negative)"); +"isinf(x) -> bool\n\n\ +Check if float x is infinite (positive or negative)."); static PyMethodDef math_methods[] = { {"acos", math_acos, METH_O, math_acos_doc}, From python-checkins at python.org Thu Oct 29 22:16:34 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 21:16:34 -0000 Subject: [Python-checkins] r75956 - python/trunk/Grammar/Grammar Message-ID: Author: georg.brandl Date: Thu Oct 29 22:16:34 2009 New Revision: 75956 Log: I do not think the "railroad" program mentioned is still available. Modified: python/trunk/Grammar/Grammar Modified: python/trunk/Grammar/Grammar ============================================================================== --- python/trunk/Grammar/Grammar (original) +++ python/trunk/Grammar/Grammar Thu Oct 29 22:16:34 2009 @@ -10,18 +10,6 @@ # NOTE WELL: You should also follow all the steps listed in PEP 306, # "How to Change Python's Grammar" -# Commands for Kees Blom's railroad program -#diagram:token NAME -#diagram:token NUMBER -#diagram:token STRING -#diagram:token NEWLINE -#diagram:token ENDMARKER -#diagram:token INDENT -#diagram:output\input python.bla -#diagram:token DEDENT -#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm -#diagram:rules - # Start symbols for the grammar: # single_input is a single interactive statement; # file_input is a module or sequence of commands read from an input file; From python-checkins at python.org Thu Oct 29 22:44:57 2009 From: python-checkins at python.org (georg.brandl) Date: Thu, 29 Oct 2009 21:44:57 -0000 Subject: [Python-checkins] r75957 - python/trunk/Lib/test/regrtest.py Message-ID: Author: georg.brandl Date: Thu Oct 29 22:44:56 2009 New Revision: 75957 Log: Fix constant name. Modified: python/trunk/Lib/test/regrtest.py Modified: python/trunk/Lib/test/regrtest.py ============================================================================== --- python/trunk/Lib/test/regrtest.py (original) +++ python/trunk/Lib/test/regrtest.py Thu Oct 29 22:44:56 2009 @@ -854,7 +854,7 @@ if refleak: return FAILED, test_time if environment.changed: - return ENVIRONMENT_CHANGED, test_time + return ENV_CHANGED, test_time # Except in verbose mode, tests should not print anything if verbose or huntrleaks: return PASSED, test_time From python-checkins at python.org Fri Oct 30 18:07:08 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:07:08 -0000 Subject: [Python-checkins] r75958 - in python/trunk: Doc/library/thread.rst Lib/test/test_support.py Lib/test/test_thread.py Misc/NEWS Modules/threadmodule.c Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:07:08 2009 New Revision: 75958 Log: Issue #7222: Make thread "reaping" more reliable so that reference leak-chasing test runs give sensible results. The previous method of reaping threads could return successfully while some Thread objects were still referenced. This also introduces a new private function: :func:hread._count(). Modified: python/trunk/Doc/library/thread.rst python/trunk/Lib/test/test_support.py python/trunk/Lib/test/test_thread.py python/trunk/Misc/NEWS python/trunk/Modules/threadmodule.c Modified: python/trunk/Doc/library/thread.rst ============================================================================== --- python/trunk/Doc/library/thread.rst (original) +++ python/trunk/Doc/library/thread.rst Fri Oct 30 18:07:08 2009 @@ -112,6 +112,20 @@ .. versionadded:: 2.5 + +.. function:: _count() + + Return the number of currently running Python threads, excluding the main + thread. The returned number comprises all threads created through + :func:`start_new_thread` as well as :class:`threading.Thread`, and not + yet finished. + + This function is meant for internal and specialized purposes only. In + most applications :func:`threading.enumerate()` should be used instead. + + .. versionadded:: 2.7 + + Lock objects have the following methods: Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Fri Oct 30 18:07:08 2009 @@ -952,24 +952,29 @@ #======================================================================= # Threading support to prevent reporting refleaks when running regrtest.py -R +# NOTE: we use thread._count() rather than threading.enumerate() (or the +# moral equivalent thereof) because a threading.Thread object is still alive +# until its __bootstrap() method has returned, even after it has been +# unregistered from the threading module. +# thread._count(), on the other hand, only gets decremented *after* the +# __bootstrap() method has returned, which gives us reliable reference counts +# at the end of a test run. + def threading_setup(): - import threading - return len(threading._active), len(threading._limbo) + import thread + return thread._count(), -def threading_cleanup(num_active, num_limbo): - import threading +def threading_cleanup(nb_threads): + import thread import time _MAX_COUNT = 10 - count = 0 - while len(threading._active) != num_active and count < _MAX_COUNT: - count += 1 - time.sleep(0.1) - - count = 0 - while len(threading._limbo) != num_limbo and count < _MAX_COUNT: - count += 1 + for count in range(_MAX_COUNT): + n = thread._count() + if n == nb_threads: + break time.sleep(0.1) + # XXX print a warning in case of failure? def reap_threads(func): @functools.wraps(func) Modified: python/trunk/Lib/test/test_thread.py ============================================================================== --- python/trunk/Lib/test/test_thread.py (original) +++ python/trunk/Lib/test/test_thread.py Fri Oct 30 18:07:08 2009 @@ -4,6 +4,7 @@ from test import test_support import thread import time +import weakref NUMTASKS = 10 @@ -101,6 +102,32 @@ thread.stack_size(0) + def test__count(self): + # Test the _count() function. + orig = thread._count() + mut = thread.allocate_lock() + mut.acquire() + started = [] + def task(): + started.append(None) + mut.acquire() + mut.release() + thread.start_new_thread(task, ()) + while not started: + time.sleep(0.01) + self.assertEquals(thread._count(), orig + 1) + # Allow the task to finish. + mut.release() + # The only reliable way to be sure that the thread ended from the + # interpreter's point of view is to wait for the function object to be + # destroyed. + done = [] + wr = weakref.ref(task, lambda _: done.append(None)) + del task + while not done: + time.sleep(0.01) + self.assertEquals(thread._count(), orig) + class Barrier: def __init__(self, num_threads): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Oct 30 18:07:08 2009 @@ -1525,6 +1525,12 @@ Tests ----- +- Issue #7222: Make thread "reaping" more reliable so that reference + leak-chasing test runs give sensible results. The previous method of + reaping threads could return successfully while some Thread objects were + still referenced. This also introduces a new private function: + :func:`thread._count()`. + - Issue #7151: fixed regrtest -j so that output to stderr from a test no longer runs the risk of causing the worker thread to fail. Modified: python/trunk/Modules/threadmodule.c ============================================================================== --- python/trunk/Modules/threadmodule.c (original) +++ python/trunk/Modules/threadmodule.c Fri Oct 30 18:07:08 2009 @@ -14,7 +14,7 @@ #include "pythread.h" static PyObject *ThreadError; - +static long nb_threads = 0; /* Lock objects */ @@ -439,6 +439,7 @@ tstate = PyThreadState_New(boot->interp); PyEval_AcquireThread(tstate); + nb_threads++; res = PyEval_CallObjectWithKeywords( boot->func, boot->args, boot->keyw); if (res == NULL) { @@ -463,6 +464,7 @@ Py_DECREF(boot->args); Py_XDECREF(boot->keyw); PyMem_DEL(boot_raw); + nb_threads--; PyThreadState_Clear(tstate); PyThreadState_DeleteCurrent(); PyThread_exit_thread(); @@ -606,6 +608,18 @@ A thread's identity may be reused for another thread after it exits."); static PyObject * +thread__count(PyObject *self) +{ + return PyInt_FromLong(nb_threads); +} + +PyDoc_STRVAR(_count_doc, +"_count() -> integer\n\ +\n\ +Return the number of currently running (sub)threads.\n\ +This excludes the main thread."); + +static PyObject * thread_stack_size(PyObject *self, PyObject *args) { size_t old_size; @@ -678,6 +692,8 @@ METH_NOARGS, interrupt_doc}, {"get_ident", (PyCFunction)thread_get_ident, METH_NOARGS, get_ident_doc}, + {"_count", (PyCFunction)thread__count, + METH_NOARGS, _count_doc}, {"stack_size", (PyCFunction)thread_stack_size, METH_VARARGS, stack_size_doc}, @@ -735,6 +751,8 @@ if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) return; + nb_threads = 0; + /* Initialize the C thread library */ PyThread_init_thread(); } From python-checkins at python.org Fri Oct 30 18:25:12 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:25:12 -0000 Subject: [Python-checkins] r75959 - in python/branches/py3k: Doc/library/_thread.rst Lib/test/support.py Lib/test/test_thread.py Misc/NEWS Modules/_threadmodule.c Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:25:12 2009 New Revision: 75959 Log: Merged revisions 75958 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75958 | antoine.pitrou | 2009-10-30 18:07:08 +0100 (ven., 30 oct. 2009) | 7 lines Issue #7222: Make thread "reaping" more reliable so that reference leak-chasing test runs give sensible results. The previous method of reaping threads could return successfully while some Thread objects were still referenced. This also introduces a new private function: :func:hread._count(). ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/_thread.rst python/branches/py3k/Lib/test/support.py python/branches/py3k/Lib/test/test_thread.py python/branches/py3k/Misc/NEWS python/branches/py3k/Modules/_threadmodule.c Modified: python/branches/py3k/Doc/library/_thread.rst ============================================================================== --- python/branches/py3k/Doc/library/_thread.rst (original) +++ python/branches/py3k/Doc/library/_thread.rst Fri Oct 30 18:25:12 2009 @@ -103,6 +103,19 @@ Availability: Windows, systems with POSIX threads. +.. function:: _count() + + Return the number of currently running Python threads, excluding the main + thread. The returned number comprises all threads created through + :func:`start_new_thread` as well as :class:`threading.Thread`, and not + yet finished. + + This function is meant for internal and specialized purposes only. In + most applications :func:`threading.enumerate()` should be used instead. + + .. versionadded:: 3.2 + + Lock objects have the following methods: Modified: python/branches/py3k/Lib/test/support.py ============================================================================== --- python/branches/py3k/Lib/test/support.py (original) +++ python/branches/py3k/Lib/test/support.py Fri Oct 30 18:25:12 2009 @@ -947,24 +947,29 @@ #======================================================================= # Threading support to prevent reporting refleaks when running regrtest.py -R +# NOTE: we use thread._count() rather than threading.enumerate() (or the +# moral equivalent thereof) because a threading.Thread object is still alive +# until its __bootstrap() method has returned, even after it has been +# unregistered from the threading module. +# thread._count(), on the other hand, only gets decremented *after* the +# __bootstrap() method has returned, which gives us reliable reference counts +# at the end of a test run. + def threading_setup(): - import threading - return len(threading._active), len(threading._limbo) + import _thread + return _thread._count(), -def threading_cleanup(num_active, num_limbo): - import threading +def threading_cleanup(nb_threads): + import _thread import time _MAX_COUNT = 10 - count = 0 - while len(threading._active) != num_active and count < _MAX_COUNT: - count += 1 - time.sleep(0.1) - - count = 0 - while len(threading._limbo) != num_limbo and count < _MAX_COUNT: - count += 1 + for count in range(_MAX_COUNT): + n = _thread._count() + if n == nb_threads: + break time.sleep(0.1) + # XXX print a warning in case of failure? def reap_threads(func): @functools.wraps(func) Modified: python/branches/py3k/Lib/test/test_thread.py ============================================================================== --- python/branches/py3k/Lib/test/test_thread.py (original) +++ python/branches/py3k/Lib/test/test_thread.py Fri Oct 30 18:25:12 2009 @@ -4,6 +4,7 @@ from test import support import _thread as thread import time +import weakref NUMTASKS = 10 @@ -99,6 +100,32 @@ thread.stack_size(0) + def test__count(self): + # Test the _count() function. + orig = thread._count() + mut = thread.allocate_lock() + mut.acquire() + started = [] + def task(): + started.append(None) + mut.acquire() + mut.release() + thread.start_new_thread(task, ()) + while not started: + time.sleep(0.01) + self.assertEquals(thread._count(), orig + 1) + # Allow the task to finish. + mut.release() + # The only reliable way to be sure that the thread ended from the + # interpreter's point of view is to wait for the function object to be + # destroyed. + done = [] + wr = weakref.ref(task, lambda _: done.append(None)) + del task + while not done: + time.sleep(0.01) + self.assertEquals(thread._count(), orig) + class Barrier: def __init__(self, num_threads): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Fri Oct 30 18:25:12 2009 @@ -334,6 +334,12 @@ Tests ----- +- Issue #7222: Make thread "reaping" more reliable so that reference + leak-chasing test runs give sensible results. The previous method of + reaping threads could return successfully while some Thread objects were + still referenced. This also introduces a new private function: + :func:`_thread._count()`. + - Issue #7151: fixed regrtest -j so that output to stderr from a test no longer runs the risk of causing the worker thread to fail. Modified: python/branches/py3k/Modules/_threadmodule.c ============================================================================== --- python/branches/py3k/Modules/_threadmodule.c (original) +++ python/branches/py3k/Modules/_threadmodule.c Fri Oct 30 18:25:12 2009 @@ -14,7 +14,7 @@ #include "pythread.h" static PyObject *ThreadError; - +static long nb_threads = 0; /* Lock objects */ @@ -439,6 +439,7 @@ tstate = PyThreadState_New(boot->interp); PyEval_AcquireThread(tstate); + nb_threads++; res = PyEval_CallObjectWithKeywords( boot->func, boot->args, boot->keyw); if (res == NULL) { @@ -463,6 +464,7 @@ Py_DECREF(boot->args); Py_XDECREF(boot->keyw); PyMem_DEL(boot_raw); + nb_threads--; PyThreadState_Clear(tstate); PyThreadState_DeleteCurrent(); PyThread_exit_thread(); @@ -606,6 +608,18 @@ A thread's identity may be reused for another thread after it exits."); static PyObject * +thread__count(PyObject *self) +{ + return PyLong_FromLong(nb_threads); +} + +PyDoc_STRVAR(_count_doc, +"_count() -> integer\n\ +\n\ +Return the number of currently running (sub)threads.\n\ +This excludes the main thread."); + +static PyObject * thread_stack_size(PyObject *self, PyObject *args) { size_t old_size; @@ -678,6 +692,8 @@ METH_NOARGS, interrupt_doc}, {"get_ident", (PyCFunction)thread_get_ident, METH_NOARGS, get_ident_doc}, + {"_count", (PyCFunction)thread__count, + METH_NOARGS, _count_doc}, {"stack_size", (PyCFunction)thread_stack_size, METH_VARARGS, stack_size_doc}, @@ -748,6 +764,8 @@ if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) return NULL; + nb_threads = 0; + /* Initialize the C thread library */ PyThread_init_thread(); return m; From python-checkins at python.org Fri Oct 30 18:33:28 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:33:28 -0000 Subject: [Python-checkins] r75960 - python/trunk/Lib/test/test_docxmlrpc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:33:28 2009 New Revision: 75960 Log: Fix transient refleaks in test_docxmlrpc. Modified: python/trunk/Lib/test/test_docxmlrpc.py Modified: python/trunk/Lib/test/test_docxmlrpc.py ============================================================================== --- python/trunk/Lib/test/test_docxmlrpc.py (original) +++ python/trunk/Lib/test/test_docxmlrpc.py Fri Oct 30 18:33:28 2009 @@ -54,6 +54,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): def setUp(self): + self._threads = test_support.threading_setup() # Enable server feedback DocXMLRPCServer._send_traceback_header = True @@ -75,6 +76,7 @@ # Disable server feedback DocXMLRPCServer._send_traceback_header = False + test_support.threading_cleanup(*self._threads) def test_valid_get_response(self): self.client.request("GET", "/") From python-checkins at python.org Fri Oct 30 18:34:49 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:34:49 -0000 Subject: [Python-checkins] r75961 - in python/branches/py3k: Lib/test/test_docxmlrpc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:34:49 2009 New Revision: 75961 Log: Merged revisions 75960 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75960 | antoine.pitrou | 2009-10-30 18:33:28 +0100 (ven., 30 oct. 2009) | 3 lines Fix transient refleaks in test_docxmlrpc. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_docxmlrpc.py Modified: python/branches/py3k/Lib/test/test_docxmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_docxmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_docxmlrpc.py Fri Oct 30 18:34:49 2009 @@ -53,6 +53,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): def setUp(self): + self._threads = support.threading_setup() # Enable server feedback DocXMLRPCServer._send_traceback_header = True @@ -74,6 +75,7 @@ # Disable server feedback DocXMLRPCServer._send_traceback_header = False + support.threading_cleanup(*self._threads) def test_valid_get_response(self): self.client.request("GET", "/") From python-checkins at python.org Fri Oct 30 18:55:22 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:55:22 -0000 Subject: [Python-checkins] r75962 - python/trunk/Lib/test/test_asynchat.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:55:21 2009 New Revision: 75962 Log: Try to fix transient refleaks in test_asynchat. Modified: python/trunk/Lib/test/test_asynchat.py Modified: python/trunk/Lib/test/test_asynchat.py ============================================================================== --- python/trunk/Lib/test/test_asynchat.py (original) +++ python/trunk/Lib/test/test_asynchat.py Fri Oct 30 18:55:21 2009 @@ -92,10 +92,10 @@ usepoll = False def setUp (self): - pass + self._threads = test_support.threading_setup() def tearDown (self): - pass + test_support.threading_cleanup(*self._threads) def line_terminator_check(self, term, server_chunk): event = threading.Event() From python-checkins at python.org Fri Oct 30 18:56:00 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:56:00 -0000 Subject: [Python-checkins] r75963 - python/trunk/Lib/test/test_xmlrpc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:56:00 2009 New Revision: 75963 Log: Try to fix transient refleaks in test_xmlrpc. Modified: python/trunk/Lib/test/test_xmlrpc.py Modified: python/trunk/Lib/test/test_xmlrpc.py ============================================================================== --- python/trunk/Lib/test/test_xmlrpc.py (original) +++ python/trunk/Lib/test/test_xmlrpc.py Fri Oct 30 18:56:00 2009 @@ -973,6 +973,7 @@ req = self.issue_request(TestTransport) self.assertTrue("X-Test: test_send_content\r\n" in req) + at test_support.reap_threads def test_main(): xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase, BinaryTestCase, FaultTestCase, TransportSubclassTestCase] From python-checkins at python.org Fri Oct 30 18:58:27 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 17:58:27 -0000 Subject: [Python-checkins] r75964 - in python/branches/py3k: Lib/test/test_asynchat.py Lib/test/test_xmlrpc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 18:58:27 2009 New Revision: 75964 Log: Merged revisions 75962-75963 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75962 | antoine.pitrou | 2009-10-30 18:55:21 +0100 (ven., 30 oct. 2009) | 3 lines Try to fix transient refleaks in test_asynchat. ........ r75963 | antoine.pitrou | 2009-10-30 18:56:00 +0100 (ven., 30 oct. 2009) | 3 lines Try to fix transient refleaks in test_xmlrpc. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_asynchat.py python/branches/py3k/Lib/test/test_xmlrpc.py Modified: python/branches/py3k/Lib/test/test_asynchat.py ============================================================================== --- python/branches/py3k/Lib/test/test_asynchat.py (original) +++ python/branches/py3k/Lib/test/test_asynchat.py Fri Oct 30 18:58:27 2009 @@ -93,10 +93,10 @@ usepoll = False def setUp (self): - pass + self._threads = support.threading_setup() def tearDown (self): - pass + support.threading_cleanup(*self._threads) def line_terminator_check(self, term, server_chunk): event = threading.Event() Modified: python/branches/py3k/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_xmlrpc.py Fri Oct 30 18:58:27 2009 @@ -798,6 +798,7 @@ len(content)) + at support.reap_threads def test_main(): xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase, BinaryTestCase, FaultTestCase] From python-checkins at python.org Fri Oct 30 19:15:03 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 18:15:03 -0000 Subject: [Python-checkins] r75965 - python/branches/py3k/Lib/test/test_uuid.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 19:15:02 2009 New Revision: 75965 Log: Fix a refleak in test_uuid when run with -j. The "refleak" was simply the effect of internal buffering in block buffering mode (rather than line buffering when sys.stdout is a terminal) Modified: python/branches/py3k/Lib/test/test_uuid.py Modified: python/branches/py3k/Lib/test/test_uuid.py ============================================================================== --- python/branches/py3k/Lib/test/test_uuid.py (original) +++ python/branches/py3k/Lib/test/test_uuid.py Fri Oct 30 19:15:02 2009 @@ -314,6 +314,7 @@ import sys print(""" WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) + sys.__stdout__.flush() return import os @@ -342,6 +343,7 @@ import sys print(""" WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) + sys.__stdout__.flush() return import os @@ -357,6 +359,7 @@ import sys print(""" WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) + sys.__stdout__.flush() return node1 = uuid.getnode() From python-checkins at python.org Fri Oct 30 19:30:35 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 18:30:35 -0000 Subject: [Python-checkins] r75966 - in python/branches/py3k/Lib/test: regrtest.py test_uuid.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 19:30:35 2009 New Revision: 75966 Log: Followup to r75965: replace the test_uuid-specific patch with a generic fix (other tests may have the same problem). Modified: python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/test_uuid.py Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Fri Oct 30 19:30:35 2009 @@ -996,6 +996,12 @@ obj._abc_cache.clear() obj._abc_negative_cache.clear() + # Flush standard output, so that buffered data is sent to the OS and + # associated Python objects are reclaimed. + for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__): + if stream is not None: + stream.flush() + # Clear assorted module caches. _path_created.clear() re.purge() Modified: python/branches/py3k/Lib/test/test_uuid.py ============================================================================== --- python/branches/py3k/Lib/test/test_uuid.py (original) +++ python/branches/py3k/Lib/test/test_uuid.py Fri Oct 30 19:30:35 2009 @@ -314,7 +314,6 @@ import sys print(""" WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - sys.__stdout__.flush() return import os @@ -343,7 +342,6 @@ import sys print(""" WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - sys.__stdout__.flush() return import os @@ -359,7 +357,6 @@ import sys print(""" WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__) - sys.__stdout__.flush() return node1 = uuid.getnode() From brett at python.org Fri Oct 30 21:13:11 2009 From: brett at python.org (Brett Cannon) Date: Fri, 30 Oct 2009 13:13:11 -0700 Subject: [Python-checkins] r75958 - in python/trunk: Doc/library/thread.rst Lib/test/test_support.py Lib/test/test_thread.py Misc/NEWS Modules/threadmodule.c In-Reply-To: <4aeb21f0.0c67f10a.493b.53ceSMTPIN_ADDED@mx.google.com> References: <4aeb21f0.0c67f10a.493b.53ceSMTPIN_ADDED@mx.google.com> Message-ID: If the new function is private, why document it? On Fri, Oct 30, 2009 at 10:27, antoine.pitrou wrote: > Author: antoine.pitrou > Date: Fri Oct 30 18:07:08 2009 > New Revision: 75958 > > Log: > Issue #7222: Make thread "reaping" more reliable so that reference > leak-chasing test runs give sensible results. The previous method of > reaping threads could return successfully while some Thread objects were > still referenced. This also introduces a new private function: > :func: hread._count(). > > > > Modified: > ? python/trunk/Doc/library/thread.rst > ? python/trunk/Lib/test/test_support.py > ? python/trunk/Lib/test/test_thread.py > ? python/trunk/Misc/NEWS > ? python/trunk/Modules/threadmodule.c > > Modified: python/trunk/Doc/library/thread.rst > ============================================================================== > --- python/trunk/Doc/library/thread.rst (original) > +++ python/trunk/Doc/library/thread.rst Fri Oct 30 18:07:08 2009 > @@ -112,6 +112,20 @@ > > ? ?.. versionadded:: 2.5 > > + > +.. function:: _count() > + > + ? Return the number of currently running Python threads, excluding the main > + ? thread. ?The returned number comprises all threads created through > + ? :func:`start_new_thread` as well as :class:`threading.Thread`, and not > + ? yet finished. > + > + ? This function is meant for internal and specialized purposes only. In > + ? most applications :func:`threading.enumerate()` should be used instead. > + > + ? .. versionadded:: 2.7 > + > + > ?Lock objects have the following methods: > > > > Modified: python/trunk/Lib/test/test_support.py > ============================================================================== > --- python/trunk/Lib/test/test_support.py ? ? ? (original) > +++ python/trunk/Lib/test/test_support.py ? ? ? Fri Oct 30 18:07:08 2009 > @@ -952,24 +952,29 @@ > ?#======================================================================= > ?# Threading support to prevent reporting refleaks when running regrtest.py -R > > +# NOTE: we use thread._count() rather than threading.enumerate() (or the > +# moral equivalent thereof) because a threading.Thread object is still alive > +# until its __bootstrap() method has returned, even after it has been > +# unregistered from the threading module. > +# thread._count(), on the other hand, only gets decremented *after* the > +# __bootstrap() method has returned, which gives us reliable reference counts > +# at the end of a test run. > + > ?def threading_setup(): > - ? ?import threading > - ? ?return len(threading._active), len(threading._limbo) > + ? ?import thread > + ? ?return thread._count(), > > -def threading_cleanup(num_active, num_limbo): > - ? ?import threading > +def threading_cleanup(nb_threads): > + ? ?import thread > ? ? import time > > ? ? _MAX_COUNT = 10 > - ? ?count = 0 > - ? ?while len(threading._active) != num_active and count < _MAX_COUNT: > - ? ? ? ?count += 1 > - ? ? ? ?time.sleep(0.1) > - > - ? ?count = 0 > - ? ?while len(threading._limbo) != num_limbo and count < _MAX_COUNT: > - ? ? ? ?count += 1 > + ? ?for count in range(_MAX_COUNT): > + ? ? ? ?n = thread._count() > + ? ? ? ?if n == nb_threads: > + ? ? ? ? ? ?break > ? ? ? ? time.sleep(0.1) > + ? ?# XXX print a warning in case of failure? > > ?def reap_threads(func): > ? ? @functools.wraps(func) > > Modified: python/trunk/Lib/test/test_thread.py > ============================================================================== > --- python/trunk/Lib/test/test_thread.py ? ? ? ?(original) > +++ python/trunk/Lib/test/test_thread.py ? ? ? ?Fri Oct 30 18:07:08 2009 > @@ -4,6 +4,7 @@ > ?from test import test_support > ?import thread > ?import time > +import weakref > > > ?NUMTASKS = 10 > @@ -101,6 +102,32 @@ > > ? ? ? ? ? ? thread.stack_size(0) > > + ? ?def test__count(self): > + ? ? ? ?# Test the _count() function. > + ? ? ? ?orig = thread._count() > + ? ? ? ?mut = thread.allocate_lock() > + ? ? ? ?mut.acquire() > + ? ? ? ?started = [] > + ? ? ? ?def task(): > + ? ? ? ? ? ?started.append(None) > + ? ? ? ? ? ?mut.acquire() > + ? ? ? ? ? ?mut.release() > + ? ? ? ?thread.start_new_thread(task, ()) > + ? ? ? ?while not started: > + ? ? ? ? ? ?time.sleep(0.01) > + ? ? ? ?self.assertEquals(thread._count(), orig + 1) > + ? ? ? ?# Allow the task to finish. > + ? ? ? ?mut.release() > + ? ? ? ?# The only reliable way to be sure that the thread ended from the > + ? ? ? ?# interpreter's point of view is to wait for the function object to be > + ? ? ? ?# destroyed. > + ? ? ? ?done = [] > + ? ? ? ?wr = weakref.ref(task, lambda _: done.append(None)) > + ? ? ? ?del task > + ? ? ? ?while not done: > + ? ? ? ? ? ?time.sleep(0.01) > + ? ? ? ?self.assertEquals(thread._count(), orig) > + > > ?class Barrier: > ? ? def __init__(self, num_threads): > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS ? ? ?(original) > +++ python/trunk/Misc/NEWS ? ? ?Fri Oct 30 18:07:08 2009 > @@ -1525,6 +1525,12 @@ > ?Tests > ?----- > > +- Issue #7222: Make thread "reaping" more reliable so that reference > + ?leak-chasing test runs give sensible results. The previous method of > + ?reaping threads could return successfully while some Thread objects were > + ?still referenced. This also introduces a new private function: > + ?:func:`thread._count()`. > + > ?- Issue #7151: fixed regrtest -j so that output to stderr from a test no > ? longer runs the risk of causing the worker thread to fail. > > > Modified: python/trunk/Modules/threadmodule.c > ============================================================================== > --- python/trunk/Modules/threadmodule.c (original) > +++ python/trunk/Modules/threadmodule.c Fri Oct 30 18:07:08 2009 > @@ -14,7 +14,7 @@ > ?#include "pythread.h" > > ?static PyObject *ThreadError; > - > +static long nb_threads = 0; > > ?/* Lock objects */ > > @@ -439,6 +439,7 @@ > ? ? ? ?tstate = PyThreadState_New(boot->interp); > > ? ? ? ?PyEval_AcquireThread(tstate); > + ? ? ? nb_threads++; > ? ? ? ?res = PyEval_CallObjectWithKeywords( > ? ? ? ? ? ? ? ?boot->func, boot->args, boot->keyw); > ? ? ? ?if (res == NULL) { > @@ -463,6 +464,7 @@ > ? ? ? ?Py_DECREF(boot->args); > ? ? ? ?Py_XDECREF(boot->keyw); > ? ? ? ?PyMem_DEL(boot_raw); > + ? ? ? nb_threads--; > ? ? ? ?PyThreadState_Clear(tstate); > ? ? ? ?PyThreadState_DeleteCurrent(); > ? ? ? ?PyThread_exit_thread(); > @@ -606,6 +608,18 @@ > ?A thread's identity may be reused for another thread after it exits."); > > ?static PyObject * > +thread__count(PyObject *self) > +{ > + ? ? ? return PyInt_FromLong(nb_threads); > +} > + > +PyDoc_STRVAR(_count_doc, > +"_count() -> integer\n\ > +\n\ > +Return the number of currently running (sub)threads.\n\ > +This excludes the main thread."); > + > +static PyObject * > ?thread_stack_size(PyObject *self, PyObject *args) > ?{ > ? ? ? ?size_t old_size; > @@ -678,6 +692,8 @@ > ? ? ? ? METH_NOARGS, interrupt_doc}, > ? ? ? ?{"get_ident", ? ? ? ? ? (PyCFunction)thread_get_ident, > ? ? ? ? METH_NOARGS, get_ident_doc}, > + ? ? ? {"_count", ? ? ? ? ? ? ?(PyCFunction)thread__count, > + ? ? ? ?METH_NOARGS, _count_doc}, > ? ? ? ?{"stack_size", ? ? ? ? ?(PyCFunction)thread_stack_size, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?METH_VARARGS, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?stack_size_doc}, > @@ -735,6 +751,8 @@ > ? ? ? ?if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) > ? ? ? ? ? ? ? ?return; > > + ? ? ? nb_threads = 0; > + > ? ? ? ?/* Initialize the C thread library */ > ? ? ? ?PyThread_init_thread(); > ?} > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From solipsis at pitrou.net Fri Oct 30 22:40:36 2009 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 30 Oct 2009 21:40:36 +0000 (UTC) Subject: [Python-checkins] =?utf-8?q?r75958_-_in_python/trunk=3A=09Doc/lib?= =?utf-8?q?rary/thread=2ErstLib/test/test=5Fsupport=2Epy=09Lib/test?= =?utf-8?q?/test=5Fthread=2Epy_Misc/NEWS_Modules/threadmodule=2Ec?= References: <4aeb21f0.0c67f10a.493b.53ceSMTPIN_ADDED@mx.google.com> Message-ID: Brett Cannon python.org> writes: > > If the new function is private, why document it? I was wondering whether to document it or not, actually, and I thought I might just do it. But I agree it might be better to remove it, or comment out the doc. What do others think? Regards Antoine. From python-checkins at python.org Fri Oct 30 22:41:22 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 21:41:22 -0000 Subject: [Python-checkins] r75967 - python/trunk/Lib/test/test_pydoc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 22:41:22 2009 New Revision: 75967 Log: Try to fix transient refleaks in test_pydoc. Modified: python/trunk/Lib/test/test_pydoc.py Modified: python/trunk/Lib/test/test_pydoc.py ============================================================================== --- python/trunk/Lib/test/test_pydoc.py (original) +++ python/trunk/Lib/test/test_pydoc.py Fri Oct 30 22:41:22 2009 @@ -9,7 +9,8 @@ import unittest import test.test_support from contextlib import contextmanager -from test.test_support import TESTFN, forget, rmtree, EnvironmentVarGuard +from test.test_support import ( + TESTFN, forget, rmtree, EnvironmentVarGuard, reap_children) from test import pydoc_mod @@ -178,8 +179,11 @@ output of pydoc. """ cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name] - output = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read() - return output.strip() + try: + output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] + return output.strip() + finally: + reap_children() def get_pydoc_html(module): "Returns pydoc generated output as html" From python-checkins at python.org Fri Oct 30 22:45:40 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 21:45:40 -0000 Subject: [Python-checkins] r75968 - in python/branches/py3k: Lib/test/test_pydoc.py Message-ID: Author: antoine.pitrou Date: Fri Oct 30 22:45:40 2009 New Revision: 75968 Log: Merged revisions 75967 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75967 | antoine.pitrou | 2009-10-30 22:41:22 +0100 (ven., 30 oct. 2009) | 3 lines Try to fix transient refleaks in test_pydoc. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_pydoc.py Modified: python/branches/py3k/Lib/test/test_pydoc.py ============================================================================== --- python/branches/py3k/Lib/test/test_pydoc.py (original) +++ python/branches/py3k/Lib/test/test_pydoc.py Fri Oct 30 22:45:40 2009 @@ -9,7 +9,8 @@ import unittest import test.support from contextlib import contextmanager -from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard +from test.support import ( + TESTFN, forget, rmtree, EnvironmentVarGuard, reap_children) from test import pydoc_mod @@ -195,8 +196,11 @@ output of pydoc. """ cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name] - output = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read() - return output.strip() + try: + output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] + return output.strip() + finally: + reap_children() def get_pydoc_html(module): "Returns pydoc generated output as html" From eric at trueblade.com Fri Oct 30 23:00:57 2009 From: eric at trueblade.com (Eric Smith) Date: Fri, 30 Oct 2009 18:00:57 -0400 Subject: [Python-checkins] r75958 - in python/trunk: Doc/library/thread.rstLib/test/test_support.py Lib/test/test_thread.py Misc/NEWS Modules/threadmodule.c In-Reply-To: References: <4aeb21f0.0c67f10a.493b.53ceSMTPIN_ADDED@mx.google.com> Message-ID: <4AEB6219.2030408@trueblade.com> Antoine Pitrou wrote: > Brett Cannon python.org> writes: >> If the new function is private, why document it? > > I was wondering whether to document it or not, actually, and I thought I might > just do it. But I agree it might be better to remove it, or comment out the doc. > What do others think? I would move the description to the docstring, if it's not already there. I agree it shouldn't be in the docs themselves. Eric. From solipsis at pitrou.net Fri Oct 30 23:18:28 2009 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 30 Oct 2009 22:18:28 +0000 (UTC) Subject: [Python-checkins] =?utf-8?q?r75958_-_in_python/trunk=3A_Doc/libra?= =?utf-8?q?ry/thread=2ErstLib/test/test=5Fsupport=2EpyLib/test/test?= =?utf-8?q?=5Fthread=2Epy_Misc/NEWS_Modules/threadmodule=2Ec?= References: <4aeb21f0.0c67f10a.493b.53ceSMTPIN_ADDED@mx.google.com> <4AEB6219.2030408@trueblade.com> Message-ID: Eric Smith trueblade.com> writes: > > I would move the description to the docstring, if it's not already > there. I agree it shouldn't be in the docs themselves. Ok, I'm gonna suppress the doc entry and make the docstring more precise instead. Thanks Antoine. From python-checkins at python.org Fri Oct 30 23:19:10 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 22:19:10 -0000 Subject: [Python-checkins] r75969 - in python/trunk: Doc/library/thread.rst Modules/threadmodule.c Message-ID: Author: antoine.pitrou Date: Fri Oct 30 23:19:09 2009 New Revision: 75969 Log: Remove official documentation entry for thread._count() and make the docstring more descriptive instead. Modified: python/trunk/Doc/library/thread.rst python/trunk/Modules/threadmodule.c Modified: python/trunk/Doc/library/thread.rst ============================================================================== --- python/trunk/Doc/library/thread.rst (original) +++ python/trunk/Doc/library/thread.rst Fri Oct 30 23:19:09 2009 @@ -113,19 +113,6 @@ .. versionadded:: 2.5 -.. function:: _count() - - Return the number of currently running Python threads, excluding the main - thread. The returned number comprises all threads created through - :func:`start_new_thread` as well as :class:`threading.Thread`, and not - yet finished. - - This function is meant for internal and specialized purposes only. In - most applications :func:`threading.enumerate()` should be used instead. - - .. versionadded:: 2.7 - - Lock objects have the following methods: Modified: python/trunk/Modules/threadmodule.c ============================================================================== --- python/trunk/Modules/threadmodule.c (original) +++ python/trunk/Modules/threadmodule.c Fri Oct 30 23:19:09 2009 @@ -616,8 +616,14 @@ PyDoc_STRVAR(_count_doc, "_count() -> integer\n\ \n\ -Return the number of currently running (sub)threads.\n\ -This excludes the main thread."); +\ +Return the number of currently running Python threads, excluding \n\ +the main thread. The returned number comprises all threads created\n\ +through `start_new_thread()` as well as `threading.Thread`, and not\n\ +yet finished.\n\ +\n\ +This function is meant for internal and specialized purposes only.\n\ +In most applications `threading.enumerate()` should be used instead."); static PyObject * thread_stack_size(PyObject *self, PyObject *args) From python-checkins at python.org Fri Oct 30 23:23:03 2009 From: python-checkins at python.org (antoine.pitrou) Date: Fri, 30 Oct 2009 22:23:03 -0000 Subject: [Python-checkins] r75970 - in python/branches/py3k: Doc/library/_thread.rst Modules/_threadmodule.c Message-ID: Author: antoine.pitrou Date: Fri Oct 30 23:23:02 2009 New Revision: 75970 Log: Merged revisions 75969 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75969 | antoine.pitrou | 2009-10-30 23:19:09 +0100 (ven., 30 oct. 2009) | 5 lines Remove official documentation entry for thread._count() and make the docstring more descriptive instead. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/_thread.rst python/branches/py3k/Modules/_threadmodule.c Modified: python/branches/py3k/Doc/library/_thread.rst ============================================================================== --- python/branches/py3k/Doc/library/_thread.rst (original) +++ python/branches/py3k/Doc/library/_thread.rst Fri Oct 30 23:23:02 2009 @@ -103,19 +103,6 @@ Availability: Windows, systems with POSIX threads. -.. function:: _count() - - Return the number of currently running Python threads, excluding the main - thread. The returned number comprises all threads created through - :func:`start_new_thread` as well as :class:`threading.Thread`, and not - yet finished. - - This function is meant for internal and specialized purposes only. In - most applications :func:`threading.enumerate()` should be used instead. - - .. versionadded:: 3.2 - - Lock objects have the following methods: Modified: python/branches/py3k/Modules/_threadmodule.c ============================================================================== --- python/branches/py3k/Modules/_threadmodule.c (original) +++ python/branches/py3k/Modules/_threadmodule.c Fri Oct 30 23:23:02 2009 @@ -616,8 +616,14 @@ PyDoc_STRVAR(_count_doc, "_count() -> integer\n\ \n\ -Return the number of currently running (sub)threads.\n\ -This excludes the main thread."); +\ +Return the number of currently running Python threads, excluding \n\ +the main thread. The returned number comprises all threads created\n\ +through `start_new_thread()` as well as `threading.Thread`, and not\n\ +yet finished.\n\ +\n\ +This function is meant for internal and specialized purposes only.\n\ +In most applications `threading.enumerate()` should be used instead."); static PyObject * thread_stack_size(PyObject *self, PyObject *args) From python-checkins at python.org Sat Oct 31 04:56:16 2009 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 31 Oct 2009 03:56:16 -0000 Subject: [Python-checkins] r75971 - python/trunk/Lib/test/test_grammar.py Message-ID: Author: benjamin.peterson Date: Sat Oct 31 04:56:15 2009 New Revision: 75971 Log: add some checks for evaluation order with parenthesis #7210 Modified: python/trunk/Lib/test/test_grammar.py Modified: python/trunk/Lib/test/test_grammar.py ============================================================================== --- python/trunk/Lib/test/test_grammar.py (original) +++ python/trunk/Lib/test/test_grammar.py Sat Oct 31 04:56:15 2009 @@ -966,6 +966,14 @@ self.assertEqual((6 / 2 if 1 else 3), 3) self.assertEqual((6 < 4 if 0 else 2), 2) + def test_paren_evaluation(self): + self.assertEqual(16 // (4 // 2), 8) + self.assertEqual((16 // 4) // 2, 2) + self.assertEqual(16 // 4 // 2, 2) + self.assertTrue(False is (2 is 3)) + self.assertFalse((False is 2) is 3) + self.assertFalse(False is 2 is 3) + def test_main(): run_unittest(TokenTests, GrammarTests) From python-checkins at python.org Sat Oct 31 10:28:12 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:28:12 -0000 Subject: [Python-checkins] r75974 - python/trunk/Misc/NEWS Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:28:12 2009 New Revision: 75974 Log: Move a Misc/NEWS entry to right section. Modified: python/trunk/Misc/NEWS Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 31 10:28:12 2009 @@ -15,10 +15,6 @@ - Remove length limitation when constructing a complex number from a unicode string. -- Removed _PyOS_double_to_string. Use PyOS_double_to_string - instead. This is in preparation for (but not strictly related to) - issue #7117, short float repr. - - Issue #1087418: Boost performance of bitwise operations for longs. - Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which @@ -1418,6 +1414,10 @@ C-API ----- +- Removed _PyOS_double_to_string. Use PyOS_double_to_string + instead. This is in preparation for (but not strictly related to) + issue #7117, short float repr. + - Issue #6624: PyArg_ParseTuple with "s" format when parsing argument with NULL: Bogus TypeError detail string. From python-checkins at python.org Sat Oct 31 10:28:55 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:28:55 -0000 Subject: [Python-checkins] r75975 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:28:55 2009 New Revision: 75975 Log: Blocked revisions 75974 via svnmerge ........ r75974 | mark.dickinson | 2009-10-31 09:28:12 +0000 (Sat, 31 Oct 2009) | 1 line Move a Misc/NEWS entry to right section. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 31 10:29:47 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:29:47 -0000 Subject: [Python-checkins] r75976 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:29:47 2009 New Revision: 75976 Log: Blocked revisions 75974 via svnmerge ........ r75974 | mark.dickinson | 2009-10-31 09:28:12 +0000 (Sat, 31 Oct 2009) | 1 line Move a Misc/NEWS entry to right section. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 31 10:39:52 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:39:52 -0000 Subject: [Python-checkins] r75977 - python/branches/py3k/Doc/c-api/conversion.rst Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:39:52 2009 New Revision: 75977 Log: Fix ReST markup. Modified: python/branches/py3k/Doc/c-api/conversion.rst Modified: python/branches/py3k/Doc/c-api/conversion.rst ============================================================================== --- python/branches/py3k/Doc/c-api/conversion.rst (original) +++ python/branches/py3k/Doc/c-api/conversion.rst Sat Oct 31 10:39:52 2009 @@ -155,7 +155,7 @@ See the Unix man page :manpage:`atof(2)` for details. .. deprecated:: 3.1 - Use PyOS_string_to_double instead. + Use :cfunc:`PyOS_string_to_double` instead. .. cfunction:: char* PyOS_stricmp(char *s1, char *s2) From python-checkins at python.org Sat Oct 31 10:40:57 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:40:57 -0000 Subject: [Python-checkins] r75978 - in python/branches/release31-maint: Doc/c-api/conversion.rst Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:40:56 2009 New Revision: 75978 Log: Merged revisions 75977 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ........ r75977 | mark.dickinson | 2009-10-31 09:39:52 +0000 (Sat, 31 Oct 2009) | 1 line Fix ReST markup. ........ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Doc/c-api/conversion.rst Modified: python/branches/release31-maint/Doc/c-api/conversion.rst ============================================================================== --- python/branches/release31-maint/Doc/c-api/conversion.rst (original) +++ python/branches/release31-maint/Doc/c-api/conversion.rst Sat Oct 31 10:40:56 2009 @@ -155,7 +155,7 @@ See the Unix man page :manpage:`atof(2)` for details. .. deprecated:: 3.1 - Use PyOS_string_to_double instead. + Use :cfunc:`PyOS_string_to_double` instead. .. cfunction:: char* PyOS_stricmp(char *s1, char *s2) From python-checkins at python.org Sat Oct 31 10:42:39 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:42:39 -0000 Subject: [Python-checkins] r75979 - in python/trunk: Doc/c-api/conversion.rst Misc/NEWS Python/pystrtod.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:42:39 2009 New Revision: 75979 Log: Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double. Modified: python/trunk/Doc/c-api/conversion.rst python/trunk/Misc/NEWS python/trunk/Python/pystrtod.c Modified: python/trunk/Doc/c-api/conversion.rst ============================================================================== --- python/trunk/Doc/c-api/conversion.rst (original) +++ python/trunk/Doc/c-api/conversion.rst Sat Oct 31 10:42:39 2009 @@ -51,6 +51,40 @@ The following functions provide locale-independent string to number conversions. +.. cfunction:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) + + Convert a string ``s`` to a :ctype:`double`, raising a Python + exception on failure. The set of accepted strings corresponds to + the set of strings accepted by Python's :func:`float` constructor, + except that ``s`` must not have leading or trailing whitespace. + The conversion is independent of the current locale. + + If ``endptr`` is ``NULL``, convert the whole string. Raise + ValueError and return ``-1.0`` if the string is not a valid + representation of a floating-point number. + + If endptr is not ``NULL``, convert as much of the string as + possible and set ``*endptr`` to point to the first unconverted + character. If no initial segment of the string is the valid + representation of a floating-point number, set ``*endptr`` to point + to the beginning of the string, raise ValueError, and return + ``-1.0``. + + If ``s`` represents a value that is too large to store in a float + (for example, ``"1e500"`` is such a string on many platforms) then + if ``overflow_exception`` is ``NULL`` return ``Py_HUGE_VAL`` (with + an appropriate sign) and don't set any exception. Otherwise, + ``overflow_exception`` must point to a Python exception object; + raise that exception and return ``-1.0``. In both cases, set + ``*endptr`` to point to the first character after the converted value. + + If any other error occurs during the conversion (for example an + out-of-memory error), set the appropriate Python exception and + return ``-1.0``. + + .. versionadded:: 2.7 + + .. cfunction:: double PyOS_ascii_strtod(const char *nptr, char **endptr) Convert a string to a :ctype:`double`. This function behaves like the Standard C @@ -60,9 +94,13 @@ :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration files or other non-user input that should be locale independent. + See the Unix man page :manpage:`strtod(2)` for details. + .. versionadded:: 2.4 - See the Unix man page :manpage:`strtod(2)` for details. + .. deprecated:: 2.7 + Use :cfunc:`PyOS_string_to_double` instead. + .. cfunction:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d) @@ -119,9 +157,12 @@ Convert a string to a :ctype:`double` in a locale-independent way. + See the Unix man page :manpage:`atof(2)` for details. + .. versionadded:: 2.4 - See the Unix man page :manpage:`atof(2)` for details. + .. deprecated:: 3.1 + Use :cfunc:`PyOS_string_to_double` instead. .. cfunction:: char* PyOS_stricmp(char *s1, char *s2) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 31 10:42:39 2009 @@ -1414,6 +1414,9 @@ C-API ----- +- Add new C-API function PyOS_string_to_double, and deprecated + PyOS_ascii_atof and PyOS_ascii_strtod. + - Removed _PyOS_double_to_string. Use PyOS_double_to_string instead. This is in preparation for (but not strictly related to) issue #7117, short float repr. Modified: python/trunk/Python/pystrtod.c ============================================================================== --- python/trunk/Python/pystrtod.c (original) +++ python/trunk/Python/pystrtod.c Sat Oct 31 10:42:39 2009 @@ -270,6 +270,8 @@ #endif +/* PyOS_ascii_strtod is DEPRECATED in Python 2.7 and 3.1 */ + double PyOS_ascii_strtod(const char *nptr, char **endptr) { @@ -277,6 +279,12 @@ const char *p; double x; + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyOS_ascii_strtod and PyOS_ascii_atof are " + "deprecated. Use PyOS_string_to_double " + "instead.", 1) < 0) + return -1.0; + /* _PyOS_ascii_strtod already does everything that we want, except that it doesn't parse leading whitespace */ p = nptr; @@ -290,13 +298,15 @@ return x; } +/* PyOS_ascii_strtod is DEPRECATED in Python 2.7 and 3.1 */ + double PyOS_ascii_atof(const char *nptr) { return PyOS_ascii_strtod(nptr, NULL); } -/* PyOS_string_to_double is the recommended replacement for the +/* PyOS_string_to_double is the recommended replacement for the deprecated PyOS_ascii_strtod and PyOS_ascii_atof functions. It converts a null-terminated byte string s (interpreted as a string of ASCII characters) to a float. The string should not have leading or trailing whitespace (in @@ -332,7 +342,7 @@ errno = 0; PyFPE_START_PROTECT("PyOS_string_to_double", return -1.0) - x = PyOS_ascii_strtod(s, &fail_pos); + x = _PyOS_ascii_strtod(s, &fail_pos); PyFPE_END_PROTECT(x) if (errno == ENOMEM) { From python-checkins at python.org Sat Oct 31 10:43:04 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:43:04 -0000 Subject: [Python-checkins] r75980 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:43:04 2009 New Revision: 75980 Log: Blocked revisions 75979 via svnmerge ........ r75979 | mark.dickinson | 2009-10-31 09:42:39 +0000 (Sat, 31 Oct 2009) | 1 line Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 31 10:43:46 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 09:43:46 -0000 Subject: [Python-checkins] r75981 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 31 10:43:46 2009 New Revision: 75981 Log: Blocked revisions 75979 via svnmerge ........ r75979 | mark.dickinson | 2009-10-31 09:42:39 +0000 (Sat, 31 Oct 2009) | 1 line Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 31 11:11:28 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:11:28 -0000 Subject: [Python-checkins] r75982 - in python/trunk: Misc/NEWS Python/ceval.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:11:28 2009 New Revision: 75982 Log: Issue #6603: Fix --with-tsc build failures on x86-64 that resulted from a gcc inline assembler peculiarity. (gcc's "A" constraint apparently means 'rax or rdx' in 64-bit mode, not edx:eax or rdx:rax as one might expect.) Modified: python/trunk/Misc/NEWS python/trunk/Python/ceval.c Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Oct 31 11:11:28 2009 @@ -1345,6 +1345,10 @@ Build ----- +- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it + compiles correctly under gcc on x86-64. This fixes a reported + problem with the --with-tsc build on x86-64. + - Add 2 new options to ``--with-universal-archs`` on MacOSX: ``intel`` builds a distribution with ``i386`` and ``x86_64`` architectures, while ``3-way`` builds a distribution with the ``ppc``, ``i386`` Modified: python/trunk/Python/ceval.c ============================================================================== --- python/trunk/Python/ceval.c (original) +++ python/trunk/Python/ceval.c Sat Oct 31 11:11:28 2009 @@ -51,11 +51,29 @@ ((long*)(v))[1] = tb; } -#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */ +#elif defined(__i386__) + +/* this is for linux/x86 (and probably any other GCC/x86 combo) */ #define READ_TIMESTAMP(val) \ __asm__ __volatile__("rdtsc" : "=A" (val)) +#elif defined(__x86_64__) + +/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx; + not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax + even in 64-bit mode, we need to use "a" and "d" for the lower and upper + 32-bit pieces of the result. */ + +#define READ_TIMESTAMP(val) \ + __asm__ __volatile__("rdtsc" : \ + "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1])); + + +#else + +#error "Don't know how to implement timestamp counter for this architecture" + #endif void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, From python-checkins at python.org Sat Oct 31 11:14:34 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:14:34 -0000 Subject: [Python-checkins] r75983 - in python/branches/release26-maint: Misc/NEWS Python/ceval.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:14:33 2009 New Revision: 75983 Log: Merged revisions 75982 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines Issue #6603: Fix --with-tsc build failures on x86-64 that resulted from a gcc inline assembler peculiarity. (gcc's "A" constraint apparently means 'rax or rdx' in 64-bit mode, not edx:eax or rdx:rax as one might expect.) ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Misc/NEWS python/branches/release26-maint/Python/ceval.c Modified: python/branches/release26-maint/Misc/NEWS ============================================================================== --- python/branches/release26-maint/Misc/NEWS (original) +++ python/branches/release26-maint/Misc/NEWS Sat Oct 31 11:14:33 2009 @@ -41,6 +41,13 @@ - Issue #7048: Force Decimal.logb to round its result when that result is too large to fit in the current precision. +Build +----- + +- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it + compiles correctly under gcc on x86-64. This fixes a reported + problem with the --with-tsc build on x86-64. + Tests ----- Modified: python/branches/release26-maint/Python/ceval.c ============================================================================== --- python/branches/release26-maint/Python/ceval.c (original) +++ python/branches/release26-maint/Python/ceval.c Sat Oct 31 11:14:33 2009 @@ -51,11 +51,29 @@ ((long*)(v))[1] = tb; } -#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */ +#elif defined(__i386__) + +/* this is for linux/x86 (and probably any other GCC/x86 combo) */ #define READ_TIMESTAMP(val) \ __asm__ __volatile__("rdtsc" : "=A" (val)) +#elif defined(__x86_64__) + +/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx; + not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax + even in 64-bit mode, we need to use "a" and "d" for the lower and upper + 32-bit pieces of the result. */ + +#define READ_TIMESTAMP(val) \ + __asm__ __volatile__("rdtsc" : \ + "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1])); + + +#else + +#error "Don't know how to implement timestamp counter for this architecture" + #endif void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, From python-checkins at python.org Sat Oct 31 11:18:44 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:18:44 -0000 Subject: [Python-checkins] r75984 - in python/branches/py3k: Misc/NEWS Python/ceval.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:18:44 2009 New Revision: 75984 Log: Merged revisions 75982 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines Issue #6603: Fix --with-tsc build failures on x86-64 that resulted from a gcc inline assembler peculiarity. (gcc's "A" constraint apparently means 'rax or rdx' in 64-bit mode, not edx:eax or rdx:rax as one might expect.) ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Misc/NEWS python/branches/py3k/Python/ceval.c Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sat Oct 31 11:18:44 2009 @@ -312,6 +312,10 @@ Build ----- +- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it + compiles correctly under gcc on x86-64. This fixes a reported + problem with the --with-tsc build on x86-64. + - Issue #6802: Fix build issues on MacOSX 10.6 - Issue #6244: Allow detect_tkinter to look for Tcl/Tk 8.6. Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Sat Oct 31 11:18:44 2009 @@ -51,11 +51,29 @@ ((long*)(v))[1] = tb; } -#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */ +#elif defined(__i386__) + +/* this is for linux/x86 (and probably any other GCC/x86 combo) */ #define READ_TIMESTAMP(val) \ __asm__ __volatile__("rdtsc" : "=A" (val)) +#elif defined(__x86_64__) + +/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx; + not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax + even in 64-bit mode, we need to use "a" and "d" for the lower and upper + 32-bit pieces of the result. */ + +#define READ_TIMESTAMP(val) \ + __asm__ __volatile__("rdtsc" : \ + "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1])); + + +#else + +#error "Don't know how to implement timestamp counter for this architecture" + #endif void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, From python-checkins at python.org Sat Oct 31 11:20:38 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:20:38 -0000 Subject: [Python-checkins] r75985 - in python/branches/release31-maint: Misc/NEWS Python/ceval.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:20:38 2009 New Revision: 75985 Log: Merged revisions 75984 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75984 | mark.dickinson | 2009-10-31 10:18:44 +0000 (Sat, 31 Oct 2009) | 12 lines Merged revisions 75982 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines Issue #6603: Fix --with-tsc build failures on x86-64 that resulted from a gcc inline assembler peculiarity. (gcc's "A" constraint apparently means 'rax or rdx' in 64-bit mode, not edx:eax or rdx:rax as one might expect.) ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Misc/NEWS python/branches/release31-maint/Python/ceval.c Modified: python/branches/release31-maint/Misc/NEWS ============================================================================== --- python/branches/release31-maint/Misc/NEWS (original) +++ python/branches/release31-maint/Misc/NEWS Sat Oct 31 11:20:38 2009 @@ -130,6 +130,10 @@ Build ----- +- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it + compiles correctly under gcc on x86-64. This fixes a reported + problem with the --with-tsc build on x86-64. + - Issue #6802: Fix build issues on MacOSX 10.6 - Issue #6801 : symmetric_difference_update also accepts |. Modified: python/branches/release31-maint/Python/ceval.c ============================================================================== --- python/branches/release31-maint/Python/ceval.c (original) +++ python/branches/release31-maint/Python/ceval.c Sat Oct 31 11:20:38 2009 @@ -51,11 +51,29 @@ ((long*)(v))[1] = tb; } -#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */ +#elif defined(__i386__) + +/* this is for linux/x86 (and probably any other GCC/x86 combo) */ #define READ_TIMESTAMP(val) \ __asm__ __volatile__("rdtsc" : "=A" (val)) +#elif defined(__x86_64__) + +/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx; + not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax + even in 64-bit mode, we need to use "a" and "d" for the lower and upper + 32-bit pieces of the result. */ + +#define READ_TIMESTAMP(val) \ + __asm__ __volatile__("rdtsc" : \ + "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1])); + + +#else + +#error "Don't know how to implement timestamp counter for this architecture" + #endif void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, From python-checkins at python.org Sat Oct 31 11:36:06 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:36:06 -0000 Subject: [Python-checkins] r75986 - python/trunk/Lib/test/test_signal.py Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:36:06 2009 New Revision: 75986 Log: Issue #7042: Use a better mechanism for testing timers in test_signal. Modified: python/trunk/Lib/test/test_signal.py Modified: python/trunk/Lib/test/test_signal.py ============================================================================== --- python/trunk/Lib/test/test_signal.py (original) +++ python/trunk/Lib/test/test_signal.py Sat Oct 31 11:36:06 2009 @@ -360,11 +360,14 @@ signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) - for i in xrange(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer + else: + self.fail('timeout waiting for sig_vtalrm signal') # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) @@ -376,9 +379,14 @@ signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) - for i in xrange(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: + # do some work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer + else: + self.fail('timeout waiting for sig_prof signal') # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) From python-checkins at python.org Sat Oct 31 11:37:15 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:37:15 -0000 Subject: [Python-checkins] r75987 - in python/branches/release26-maint: Lib/test/test_signal.py Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:37:15 2009 New Revision: 75987 Log: Merged revisions 75986 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75986 | mark.dickinson | 2009-10-31 10:36:06 +0000 (Sat, 31 Oct 2009) | 2 lines Issue #7042: Use a better mechanism for testing timers in test_signal. ........ Modified: python/branches/release26-maint/ (props changed) python/branches/release26-maint/Lib/test/test_signal.py Modified: python/branches/release26-maint/Lib/test/test_signal.py ============================================================================== --- python/branches/release26-maint/Lib/test/test_signal.py (original) +++ python/branches/release26-maint/Lib/test/test_signal.py Sat Oct 31 11:37:15 2009 @@ -360,11 +360,14 @@ signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) - for i in xrange(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer + else: + self.fail('timeout waiting for sig_vtalrm signal') # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) @@ -376,9 +379,14 @@ signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) - for i in xrange(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: + # do some work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer + else: + self.fail('timeout waiting for sig_prof signal') # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) From python-checkins at python.org Sat Oct 31 11:38:43 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:38:43 -0000 Subject: [Python-checkins] r75988 - in python/branches/py3k: Lib/test/test_signal.py Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:38:43 2009 New Revision: 75988 Log: Merged revisions 75986 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75986 | mark.dickinson | 2009-10-31 10:36:06 +0000 (Sat, 31 Oct 2009) | 2 lines Issue #7042: Use a better mechanism for testing timers in test_signal. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_signal.py Modified: python/branches/py3k/Lib/test/test_signal.py ============================================================================== --- python/branches/py3k/Lib/test/test_signal.py (original) +++ python/branches/py3k/Lib/test/test_signal.py Sat Oct 31 11:38:43 2009 @@ -360,11 +360,14 @@ signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer + else: + self.fail('timeout waiting for sig_vtalrm signal') # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) @@ -376,9 +379,14 @@ signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: + # do some work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer + else: + self.fail('timeout waiting for sig_prof signal') # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) From python-checkins at python.org Sat Oct 31 11:39:21 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 10:39:21 -0000 Subject: [Python-checkins] r75989 - in python/branches/release31-maint: Lib/test/test_signal.py Message-ID: Author: mark.dickinson Date: Sat Oct 31 11:39:21 2009 New Revision: 75989 Log: Merged revisions 75988 via svnmerge from svn+ssh://pythondev at svn.python.org/python/branches/py3k ................ r75988 | mark.dickinson | 2009-10-31 10:38:43 +0000 (Sat, 31 Oct 2009) | 9 lines Merged revisions 75986 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75986 | mark.dickinson | 2009-10-31 10:36:06 +0000 (Sat, 31 Oct 2009) | 2 lines Issue #7042: Use a better mechanism for testing timers in test_signal. ........ ................ Modified: python/branches/release31-maint/ (props changed) python/branches/release31-maint/Lib/test/test_signal.py Modified: python/branches/release31-maint/Lib/test/test_signal.py ============================================================================== --- python/branches/release31-maint/Lib/test/test_signal.py (original) +++ python/branches/release31-maint/Lib/test/test_signal.py Sat Oct 31 11:39:21 2009 @@ -360,11 +360,14 @@ signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer + else: + self.fail('timeout waiting for sig_vtalrm signal') # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) @@ -376,9 +379,14 @@ signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: + # do some work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer + else: + self.fail('timeout waiting for sig_prof signal') # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) From python-checkins at python.org Sat Oct 31 13:18:41 2009 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 31 Oct 2009 12:18:41 -0000 Subject: [Python-checkins] r75990 - tracker/roundup-src/roundup/cgi/actions.py Message-ID: Author: martin.v.loewis Date: Sat Oct 31 13:18:40 2009 New Revision: 75990 Log: reject invalid numbers, so that postgres doesn't have to Modified: tracker/roundup-src/roundup/cgi/actions.py Modified: tracker/roundup-src/roundup/cgi/actions.py ============================================================================== --- tracker/roundup-src/roundup/cgi/actions.py (original) +++ tracker/roundup-src/roundup/cgi/actions.py Sat Oct 31 13:18:40 2009 @@ -245,6 +245,11 @@ # replace the single value with the split list for v in l: self.form.value.append(cgi.MiniFieldStorage(key, v)) + elif isinstance(prop, hyperdb.Number): + try: + float(self.form[key].value) + except ValueError: + raise exceptions.FormError, "Invalid number: "+self.form[key].value self.form.value.append(cgi.MiniFieldStorage('@filter', key)) From python-checkins at python.org Sat Oct 31 13:47:47 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 12:47:47 -0000 Subject: [Python-checkins] r75991 - python/trunk/Python/marshal.c Message-ID: Author: mark.dickinson Date: Sat Oct 31 13:47:47 2009 New Revision: 75991 Log: Set retval on PyOS_string_to_double failure. Modified: python/trunk/Python/marshal.c Modified: python/trunk/Python/marshal.c ============================================================================== --- python/trunk/Python/marshal.c (original) +++ python/trunk/Python/marshal.c Sat Oct 31 13:47:47 2009 @@ -699,8 +699,10 @@ } buf[n] = '\0'; dx = PyOS_string_to_double(buf, NULL, NULL); - if (dx == -1.0 && PyErr_Occurred()) + if (dx == -1.0 && PyErr_Occurred()) { + retval = NULL; break; + } retval = PyFloat_FromDouble(dx); break; } @@ -738,8 +740,10 @@ } buf[n] = '\0'; c.real = PyOS_string_to_double(buf, NULL, NULL); - if (c.real == -1.0 && PyErr_Occurred()) + if (c.real == -1.0 && PyErr_Occurred()) { + retval = NULL; break; + } n = r_byte(p); if (n == EOF || r_string(buf, (int)n, p) != n) { PyErr_SetString(PyExc_EOFError, @@ -749,8 +753,10 @@ } buf[n] = '\0'; c.imag = PyOS_string_to_double(buf, NULL, NULL); - if (c.imag == -1.0 && PyErr_Occurred()) + if (c.imag == -1.0 && PyErr_Occurred()) { + retval = NULL; break; + } retval = PyComplex_FromCComplex(c); break; } From python-checkins at python.org Sat Oct 31 13:48:28 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 12:48:28 -0000 Subject: [Python-checkins] r75992 - python/branches/py3k Message-ID: Author: mark.dickinson Date: Sat Oct 31 13:48:28 2009 New Revision: 75992 Log: Blocked revisions 75991 via svnmerge ........ r75991 | mark.dickinson | 2009-10-31 12:47:47 +0000 (Sat, 31 Oct 2009) | 1 line Set retval on PyOS_string_to_double failure. ........ Modified: python/branches/py3k/ (props changed) From python-checkins at python.org Sat Oct 31 13:48:51 2009 From: python-checkins at python.org (mark.dickinson) Date: Sat, 31 Oct 2009 12:48:51 -0000 Subject: [Python-checkins] r75993 - python/branches/release26-maint Message-ID: Author: mark.dickinson Date: Sat Oct 31 13:48:51 2009 New Revision: 75993 Log: Blocked revisions 75991 via svnmerge ........ r75991 | mark.dickinson | 2009-10-31 12:47:47 +0000 (Sat, 31 Oct 2009) | 1 line Set retval on PyOS_string_to_double failure. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 31 16:10:15 2009 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 31 Oct 2009 15:10:15 -0000 Subject: [Python-checkins] r75994 - tracker/instances/python-dev/html/issue.item.html Message-ID: Author: martin.v.loewis Date: Sat Oct 31 16:10:15 2009 New Revision: 75994 Log: Add keywords classhelp. Modified: tracker/instances/python-dev/html/issue.item.html Modified: tracker/instances/python-dev/html/issue.item.html ============================================================================== --- tracker/instances/python-dev/html/issue.item.html (original) +++ tracker/instances/python-dev/html/issue.item.html Sat Oct 31 16:10:15 2009 @@ -144,7 +144,7 @@ : priority - Keywords: + keywords From python-checkins at python.org Sat Oct 31 18:07:18 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 31 Oct 2009 17:07:18 -0000 Subject: [Python-checkins] r75995 - python/trunk/Lib/test/test_ascii_formatd.py Message-ID: Author: eric.smith Date: Sat Oct 31 18:07:17 2009 New Revision: 75995 Log: Improved test for a deprecation warning. Modified: python/trunk/Lib/test/test_ascii_formatd.py Modified: python/trunk/Lib/test/test_ascii_formatd.py ============================================================================== --- python/trunk/Lib/test/test_ascii_formatd.py (original) +++ python/trunk/Lib/test/test_ascii_formatd.py Sat Oct 31 18:07:17 2009 @@ -21,8 +21,7 @@ c_double(10.0)) self.assertEqual(buf.value, '+10.0000000000') - self.assertEqual(str(w.message), 'PyOS_ascii_formatd is deprecated, ' - 'use PyOS_double_to_string instead') + self.assertEqual(w.category, DeprecationWarning) class FormatTests(unittest.TestCase): # ensure that, for the restricted set of format codes, From python-checkins at python.org Sat Oct 31 18:07:52 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 31 Oct 2009 17:07:52 -0000 Subject: [Python-checkins] r75996 - python/branches/release26-maint Message-ID: Author: eric.smith Date: Sat Oct 31 18:07:52 2009 New Revision: 75996 Log: Blocked revisions 75995 via svnmerge ........ r75995 | eric.smith | 2009-10-31 13:07:17 -0400 (Sat, 31 Oct 2009) | 1 line Improved test for a deprecation warning. ........ Modified: python/branches/release26-maint/ (props changed) From python-checkins at python.org Sat Oct 31 18:08:48 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 31 Oct 2009 17:08:48 -0000 Subject: [Python-checkins] r75997 - in python/branches/py3k: Lib/test/test_ascii_formatd.py Message-ID: Author: eric.smith Date: Sat Oct 31 18:08:48 2009 New Revision: 75997 Log: Merged revisions 75995 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75995 | eric.smith | 2009-10-31 13:07:17 -0400 (Sat, 31 Oct 2009) | 1 line Improved test for a deprecation warning. ........ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/test/test_ascii_formatd.py Modified: python/branches/py3k/Lib/test/test_ascii_formatd.py ============================================================================== --- python/branches/py3k/Lib/test/test_ascii_formatd.py (original) +++ python/branches/py3k/Lib/test/test_ascii_formatd.py Sat Oct 31 18:08:48 2009 @@ -20,8 +20,7 @@ c_double(10.0)) self.assertEqual(buf.value, b'+10.0000000000') - self.assertEqual(str(w.message), 'PyOS_ascii_formatd is deprecated, ' - 'use PyOS_double_to_string instead') + self.assertEqual(w.category, DeprecationWarning) class FormatTests(unittest.TestCase): # ensure that, for the restricted set of format codes, From python-checkins at python.org Sat Oct 31 18:09:43 2009 From: python-checkins at python.org (eric.smith) Date: Sat, 31 Oct 2009 17:09:43 -0000 Subject: [Python-checkins] r75998 - python/branches/release31-maint Message-ID: Author: eric.smith Date: Sat Oct 31 18:09:43 2009 New Revision: 75998 Log: Blocked revisions 75997 via svnmerge ................ r75997 | eric.smith | 2009-10-31 13:08:48 -0400 (Sat, 31 Oct 2009) | 9 lines Merged revisions 75995 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r75995 | eric.smith | 2009-10-31 13:07:17 -0400 (Sat, 31 Oct 2009) | 1 line Improved test for a deprecation warning. ........ ................ Modified: python/branches/release31-maint/ (props changed) From python-checkins at python.org Sat Oct 31 22:23:40 2009 From: python-checkins at python.org (gregory.p.smith) Date: Sat, 31 Oct 2009 21:23:40 -0000 Subject: [Python-checkins] r75999 - python/trunk/Modules/termios.c Message-ID: Author: gregory.p.smith Date: Sat Oct 31 22:23:39 2009 New Revision: 75999 Log: Define TCSASOFT if the flag exists. Modified: python/trunk/Modules/termios.c Modified: python/trunk/Modules/termios.c ============================================================================== --- python/trunk/Modules/termios.c (original) +++ python/trunk/Modules/termios.c Sat Oct 31 22:23:39 2009 @@ -357,6 +357,9 @@ {"TCSANOW", TCSANOW}, {"TCSADRAIN", TCSADRAIN}, {"TCSAFLUSH", TCSAFLUSH}, +#ifdef TCSASOFT + {"TCSASOFT", TCSASOFT}, +#endif /* tcflush() constants */ {"TCIFLUSH", TCIFLUSH}, From python-checkins at python.org Sat Oct 31 22:26:08 2009 From: python-checkins at python.org (gregory.p.smith) Date: Sat, 31 Oct 2009 21:26:08 -0000 Subject: [Python-checkins] r76000 - python/trunk/Lib/getpass.py Message-ID: Author: gregory.p.smith Date: Sat Oct 31 22:26:08 2009 New Revision: 76000 Log: Fixes issue7208 - getpass would still allow the password to be echoed on Solaris due to not flushing the input buffer. This change also incorporates some additional getpass implementation suggestions for security based on an analysis of getpass.c linked to from the issue. Modified: python/trunk/Lib/getpass.py Modified: python/trunk/Lib/getpass.py ============================================================================== --- python/trunk/Lib/getpass.py (original) +++ python/trunk/Lib/getpass.py Sat Oct 31 22:26:08 2009 @@ -62,12 +62,16 @@ try: old = termios.tcgetattr(fd) # a copy to save new = old[:] - new[3] &= ~termios.ECHO # 3 == 'lflags' + new[3] &= ~(termios.ECHO|termios.ISIG) # 3 == 'lflags' + tcsetattr_flags = termios.TCSAFLUSH + if hasattr(termios, 'TCSASOFT'): + tcsetattr_flags |= termios.TCSASOFT try: - termios.tcsetattr(fd, termios.TCSADRAIN, new) + termios.tcsetattr(fd, tcsetattr_flags, new) passwd = _raw_input(prompt, stream, input=input) finally: - termios.tcsetattr(fd, termios.TCSADRAIN, old) + termios.tcsetattr(fd, tcsetattr_flags, old) + stream.flush() # issue7208 except termios.error, e: if passwd is not None: # _raw_input succeeded. The final tcsetattr failed. Reraise @@ -125,6 +129,7 @@ if prompt: stream.write(prompt) stream.flush() + # NOTE: The Python C API calls flockfile() (and unlock) during readline. line = input.readline() if not line: raise EOFError From nnorwitz at gmail.com Fri Oct 30 11:46:44 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 30 Oct 2009 05:46:44 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (2) Message-ID: <20091030104644.GA19724@python.psfb.org> More important issues: ---------------------- test_bz2 leaked [-69, 0, 0] references, sum=-69 test_urllib2_localnet leaked [-278, 0, 0] references, sum=-278 Less important issues: ---------------------- test_asynchat leaked [-126, 0, 0] references, sum=-126 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Thu Oct 29 00:04:28 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 28 Oct 2009 18:04:28 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091028230428.GA26043@python.psfb.org> More important issues: ---------------------- test_urllib2_localnet leaked [-269, 278, -278] references, sum=-269 Less important issues: ---------------------- test_asynchat leaked [-139, 0, 0] references, sum=-139 test_socketserver leaked [80, -80, 80] references, sum=80 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Thu Oct 29 22:40:27 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 29 Oct 2009 16:40:27 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091029214027.GA30716@python.psfb.org> More important issues: ---------------------- test_bz2 leaked [-69, 0, 0] references, sum=-69 Less important issues: ---------------------- test_cmd_line leaked [25, 0, 0] references, sum=25 From nnorwitz at gmail.com Sat Oct 31 12:37:57 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 31 Oct 2009 06:37:57 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091031113757.GA28833@kbk-i386-bb.psfb.org> More important issues: ---------------------- test_warnings leaked [0, 0, 120] references, sum=120 Less important issues: ---------------------- test_popen2 leaked [-50, 0, -29] references, sum=-79 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Sat Oct 31 00:23:22 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 30 Oct 2009 18:23:22 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091030232322.GA24299@python.psfb.org> More important issues: ---------------------- test_ssl leaked [420, 0, 0] references, sum=420 Less important issues: ---------------------- test_popen2 leaked [25, -25, 25] references, sum=25 test_threading leaked [48, 48, 48] references, sum=144 From nnorwitz at gmail.com Thu Oct 29 12:48:14 2009 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 29 Oct 2009 06:48:14 -0500 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20091029114814.GA23291@python.psfb.org> More important issues: ---------------------- test_ssl leaked [0, 0, -339] references, sum=-339 Less important issues: ---------------------- test_docxmlrpc leaked [5, 0, -4] references, sum=1 test_file2k leaked [80, -80, 0] references, sum=0 test_threading leaked [48, 48, 48] references, sum=144 test_xmlrpc leaked [-85, 0, -6] references, sum=-91