]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 68630 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Fri, 16 Jan 2009 04:13:17 +0000 (04:13 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 16 Jan 2009 04:13:17 +0000 (04:13 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r68630 | benjamin.peterson | 2009-01-15 21:54:08 -0600 (Thu, 15 Jan 2009) | 108 lines

  Merged revisions 68450,68480-68481,68493,68495,68501,68512,68514-68515,68534-68536,68552,68563,68570-68572,68575,68582,68596,68623-68624,68628 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r68450 | jeffrey.yasskin | 2009-01-09 10:47:07 -0600 (Fri, 09 Jan 2009) | 3 lines

    Fix issue 4884, preventing a crash in the socket code when python is compiled
    with llvm-gcc and run with a glibc <2.10.
  ........
    r68480 | vinay.sajip | 2009-01-10 07:38:04 -0600 (Sat, 10 Jan 2009) | 1 line

    Minor documentation changes cross-referencing NullHandler to the documentation on configuring logging in a library.
  ........
    r68481 | vinay.sajip | 2009-01-10 07:42:04 -0600 (Sat, 10 Jan 2009) | 1 line

    Corrected an incorrect self-reference.
  ........
    r68493 | benjamin.peterson | 2009-01-10 11:18:55 -0600 (Sat, 10 Jan 2009) | 1 line

    rewrite verbose conditionals
  ........
    r68495 | benjamin.peterson | 2009-01-10 11:36:44 -0600 (Sat, 10 Jan 2009) | 1 line

    tp_iter only exists with Py_TPFLAGS_HAVE_ITER #4901
  ........
    r68501 | vinay.sajip | 2009-01-10 13:22:57 -0600 (Sat, 10 Jan 2009) | 1 line

    Corrected minor typo and added .currentmodule directives to fix missing cross-references.
  ........
    r68512 | benjamin.peterson | 2009-01-10 16:42:10 -0600 (Sat, 10 Jan 2009) | 1 line

    make tests fail if they can't be imported
  ........
    r68514 | benjamin.peterson | 2009-01-10 17:41:59 -0600 (Sat, 10 Jan 2009) | 1 line

    move seealso to a more appropiate place
  ........
    r68515 | benjamin.peterson | 2009-01-10 17:49:08 -0600 (Sat, 10 Jan 2009) | 1 line

    macos 9 isn't supported
  ........
    r68534 | gregory.p.smith | 2009-01-11 11:53:33 -0600 (Sun, 11 Jan 2009) | 2 lines

    correct email address
  ........
    r68535 | gregory.p.smith | 2009-01-11 11:57:54 -0600 (Sun, 11 Jan 2009) | 9 lines

    Update the documentation for binascii and zlib crc32/adler32 functions
    to better describe the signed vs unsigned return value behavior on
    different platforms and versions of python.  Mention the workaround to
    make them all return the same thing by using & 0xffffffff.

    Fixes issue4903.

    Also needs to be merged into release26-maint, release30-maint, & py3k.
  ........
    r68536 | benjamin.peterson | 2009-01-11 13:48:15 -0600 (Sun, 11 Jan 2009) | 1 line

    add email addresses
  ........
    r68552 | vinay.sajip | 2009-01-12 14:36:18 -0600 (Mon, 12 Jan 2009) | 1 line

    Minor changes/corrections in markup.
  ........
    r68563 | benjamin.peterson | 2009-01-12 19:49:10 -0600 (Mon, 12 Jan 2009) | 1 line

    small logic correction
  ........
    r68570 | raymond.hettinger | 2009-01-13 03:08:32 -0600 (Tue, 13 Jan 2009) | 5 lines

    Issue 4922: Incorrect comments for MutableSet.add() and MutableSet.discard().

    Needs to be backported to 2.6 and forward ported to 3.0 and 3.1.
  ........
    r68571 | armin.ronacher | 2009-01-13 05:52:23 -0600 (Tue, 13 Jan 2009) | 3 lines

    ast.literal_eval can properly evaluate complex numbers now.  This fixes issue4907.
  ........
    r68572 | andrew.kuchling | 2009-01-13 07:40:54 -0600 (Tue, 13 Jan 2009) | 1 line

    Note that first coord. is left alone
  ........
    r68575 | thomas.heller | 2009-01-13 11:32:28 -0600 (Tue, 13 Jan 2009) | 1 line

    Fix refcount leak in error cases.  Bug found by coverity.
  ........
    r68582 | georg.brandl | 2009-01-13 16:14:01 -0600 (Tue, 13 Jan 2009) | 2 lines

    Use assertRaises.
  ........
    r68596 | amaury.forgeotdarc | 2009-01-13 17:39:22 -0600 (Tue, 13 Jan 2009) | 3 lines

    #1162154: inspect.getmembers() now skips attributes that raise AttributeError,
    e.g. a __slots__ attribute which has not been set.
  ........
    r68623 | vinay.sajip | 2009-01-15 16:48:13 -0600 (Thu, 15 Jan 2009) | 1 line

    Made minor changes/corrections in markup. Added a couple of section headings.
  ........
    r68624 | vinay.sajip | 2009-01-15 17:04:47 -0600 (Thu, 15 Jan 2009) | 1 line

    Minor changes/corrections in markup.
  ........
    r68628 | benjamin.peterson | 2009-01-15 20:55:24 -0600 (Thu, 15 Jan 2009) | 1 line

    compare with == not is #4946
  ........
................

19 files changed:
Doc/c-api/typeobj.rst
Doc/library/2to3.rst
Doc/library/binascii.rst
Doc/library/hashlib.rst
Doc/library/io.rst
Doc/library/logging.rst
Doc/library/sys.rst
Doc/library/turtle.rst
Doc/library/zlib.rst
Include/pyport.h
Lib/_abcoll.py
Lib/ast.py
Lib/ctypes/test/__init__.py
Lib/inspect.py
Lib/test/test_ast.py
Lib/test/test_inspect.py
Modules/_ctypes/cfield.c
Modules/socketmodule.c
Tools/scripts/patchcheck.py

index 2ef431268bb7f4980249e9759d26d14010272819..83559862512bc5d80033138fede8658aff1e5491 100644 (file)
@@ -652,7 +652,6 @@ type objects) *must* have the :attr:`ob_size` field.
    :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its
    base type.
 
-
 .. cmember:: getiterfunc PyTypeObject.tp_iter
 
    An optional pointer to a function that returns an iterator for the object.  Its
index 40234ef6362c68824f7c1574d9e2aafe2a3730ed..375bd10e965f976347f19e280e4fc5df4346c2a4 100644 (file)
@@ -3,7 +3,7 @@
 2to3 - Automated Python 2 to 3 code translation
 ===============================================
 
-.. sectionauthor:: Benjamin Peterson
+.. sectionauthor:: Benjamin Peterson <benjamin@python.org>
 
 2to3 is a Python program that reads Python 2.x source code and applies a series
 of *fixers* to transform it into valid Python 3.x code.  The standard library
index 2ea0e50d53d179a7d2533bc13f9deda51696cf0c..39130a85a6efdd4d984b559a66a30bc7bdfc924c 100644 (file)
@@ -113,8 +113,19 @@ The :mod:`binascii` module defines the following functions:
       print(binascii.crc32("hello world"))
       # Or, in two pieces:
       crc = binascii.crc32("hello")
-      crc = binascii.crc32(" world", crc)
-      print(crc)
+      crc = binascii.crc32(" world", crc) & 0xffffffff
+      print('crc32 = 0x%08x' % crc)
+
+.. note::
+   To generate the same numeric value across all Python versions and
+   platforms use crc32(data) & 0xffffffff.  If you are only using
+   the checksum in packed binary format this is not necessary as the
+   return value will have the correct 32bit binary representation
+   regardless of sign.
+
+.. versionchanged:: 3.0
+   The return value will always be unsigned and in the range [0, 2**32-1]
+   regardless of platform.
 
 
 .. function:: b2a_hex(data)
index ad2bfa53d32dced80daa098433c79fbdc13edc3e..6d514fb3b90db4e10693ed1187598f85c4884ce2 100644 (file)
@@ -4,8 +4,8 @@
 
 .. module:: hashlib
    :synopsis: Secure hash and message digest algorithms.
-.. moduleauthor:: Gregory P. Smith <greg@users.sourceforge.net>
-.. sectionauthor:: Gregory P. Smith <greg@users.sourceforge.net>
+.. moduleauthor:: Gregory P. Smith <greg@krypto.org>
+.. sectionauthor:: Gregory P. Smith <greg@krypto.org>
 
 
 .. index::
index 3b699ccd5321a7ed5e6b5a3ed11c38b42365ec6e..45c99b5a50d8f0aa5dd9373d3ac97eedf2745c66 100644 (file)
@@ -6,7 +6,7 @@
 .. moduleauthor:: Guido van Rossum <guido@python.org>
 .. moduleauthor:: Mike Verdone <mike.verdone@gmail.com>
 .. moduleauthor:: Mark Russell <mark.russell@zen.co.uk>
-.. sectionauthor:: Benjamin Peterson
+.. sectionauthor:: Benjamin Peterson <benjamin@python.org>
 
 The :mod:`io` module provides the Python interfaces to stream handling.  The
 builtin :func:`open` function is defined in this module.
index 50de9e55169eb4c83ca438aaa458dc92171b3257..6e88b709939b6c0ebfb77eefb058ea046acabe44 100644 (file)
@@ -119,7 +119,7 @@ Another useful feature of the logging API is the ability to produce different
 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 ``UNSET``.
+``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``NOTSET``.
 
 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
@@ -420,6 +420,8 @@ You can see that the config file approach has a few advantages over the Python
 code approach, mainly separation of configuration and code and the ability of
 noncoders to easily modify the logging properties.
 
+.. _library-config:
+
 Configuring Logging for a Library
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -459,6 +461,12 @@ should have the desired effect. If an organisation produces a number of
 libraries, then the logger name specified can be "orgname.foo" rather than
 just "foo".
 
+.. versionadded:: 3.1
+
+The :class:`NullHandler` class was not present in previous versions, but is now
+included, so that it need not be defined in library code.
+
+
 
 Logging Levels
 --------------
@@ -514,6 +522,9 @@ decides to actually dispatch an event, the :meth:`emit` method is used to send
 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:
 
@@ -522,39 +533,61 @@ provided:
 
 #. :class:`FileHandler` 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`.
+.. 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:`RotatingFileHandler` 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
+   disk files, rotating the log file at certain timed intervals.
+
+#. :class:`SocketHandler` instances send error messages to TCP/IP
+   sockets.
 
-#. :class:`RotatingFileHandler` instances send error messages to disk files,
-   with support for maximum log file sizes and log file rotation.
+#. :class:`DatagramHandler` instances send error messages to UDP
+   sockets.
 
-#. :class:`TimedRotatingFileHandler` instances send error messages to disk files
-   rotating the log file at certain timed intervals.
+#. :class:`SMTPHandler` instances send error messages to a designated
+   email address.
 
-#. :class:`SocketHandler` instances send error messages to TCP/IP sockets.
+#. :class:`SysLogHandler` instances send error messages to a Unix
+   syslog daemon, possibly on a remote machine.
 
-#. :class:`DatagramHandler` instances send error messages to UDP sockets.
+#. :class:`NTEventLogHandler` instances send error messages to a
+   Windows NT/2000/XP event log.
 
-#. :class:`SMTPHandler` instances send error messages to a designated email
-   address.
+#. :class:`MemoryHandler` instances send error messages to a buffer
+   in memory, which is flushed whenever specific criteria are met.
 
-#. :class:`SysLogHandler` instances send error messages to a Unix syslog daemon,
-   possibly on a remote machine.
+#. :class:`HTTPHandler` instances send error messages to an HTTP
+   server using either ``GET`` or ``POST`` semantics.
+
+#. :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.
+
+.. currentmodule:: logging
 
-#. :class:`NTEventLogHandler` instances send error messages to a Windows
-   NT/2000/XP event log.
+#. :class:`NullHandler` instances do nothing with error messages. They are used
+   by library developers who want to use logging, but want to avoid the "No
+   handlers could be found for logger XXX" message which can be displayed if
+   the library user has not configured logging. See :ref:`library-config` for
+   more information.
 
-#. :class:`MemoryHandler` instances send error messages to a buffer in memory,
-   which is flushed whenever specific criteria are met.
+.. versionadded:: 3.1
 
-#. :class:`HTTPHandler` instances send error messages to an HTTP server using
-   either ``GET`` or ``POST`` semantics.
+The :class:`NullHandler` class was not present in previous versions.
 
-The :class:`StreamHandler` and :class:`FileHandler` classes are defined in the
-core logging package. The other handlers are defined in a sub- module,
-:mod:`logging.handlers`. (There is also another sub-module,
-:mod:`logging.config`, for configuration functionality.)
+The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler`
+classes are defined in the core logging package. The other handlers are
+defined in a sub- module, :mod:`logging.handlers`. (There is also another
+sub-module, :mod:`logging.config`, for configuration functionality.)
 
 Logged messages are formatted for presentation through instances of the
 :class:`Formatter` class. They are initialized with a format string suitable for
@@ -576,6 +609,9 @@ The basic :class:`Filter` functionality allows filtering by specific logger
 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.
 
@@ -1519,8 +1555,6 @@ subclasses. However, the :meth:`__init__` method in subclasses needs to call
 StreamHandler
 ^^^^^^^^^^^^^
 
-.. module:: logging.handlers
-
 The :class:`StreamHandler` class, located in the core :mod:`logging` package,
 sends logging output to streams such as *sys.stdout*, *sys.stderr* or any
 file-like object (or, more precisely, any object which supports :meth:`write`
@@ -1576,11 +1610,33 @@ sends logging output to a disk file.  It inherits the output functionality from
       Outputs the record to the file.
 
 
+NullHandler
+^^^^^^^^^^^
+
+.. versionadded:: 3.1
+
+The :class:`NullHandler` class, located in the core :mod:`logging` package,
+does not do any formatting or output. It is essentially a "no-op" handler
+for use by library developers.
+
 
+.. class:: NullHandler()
+
+   Returns a new instance of the :class:`NullHandler` class.
+
+
+   .. method:: emit(record)
+
+      This method does nothing.
+
+See :ref:`library-config` for more information on how to use
+:class:`NullHandler`.
 
 WatchedFileHandler
 ^^^^^^^^^^^^^^^^^^
 
+.. currentmodule:: logging.handlers
+
 The :class:`WatchedFileHandler` class, located in the :mod:`logging.handlers`
 module, is a :class:`FileHandler` which watches the file it is logging to. If
 the file changes, it is closed and reopened using the file name.
index 8596bd0efcb11956721e628f877fd298f4d581f6..9a55ec8e5be0342269c9f67621e452505c19cf06 100644 (file)
@@ -484,6 +484,11 @@ always available.
    A program is free to modify this list for its own purposes.
 
 
+   .. seealso::
+      Module :mod:`site` This describes how to use .pth files to extend
+      :data:`sys.path`.
+
+
 .. data:: platform
 
    This string contains a platform identifier that can be used to append
@@ -500,7 +505,6 @@ always available.
    Windows          ``'win32'``
    Windows/Cygwin   ``'cygwin'``
    Mac OS X         ``'darwin'``
-   Mac OS 9         ``'mac'``
    OS/2             ``'os2'``
    OS/2 EMX         ``'os2emx'``
    RiscOS           ``'riscos'``
@@ -783,11 +787,3 @@ always available.
    first three characters of :const:`version`.  It is provided in the :mod:`sys`
    module for informational purposes; modifying this value has no effect on the
    registry keys used by Python. Availability: Windows.
-
-
-.. seealso::
-
-   Module :mod:`site`
-      This describes how to use .pth files to extend ``sys.path``.
-
-
index 0a7aceae6480fea2750cdeef2e0f5031aca2603a..da3e475ba91a491204b250f221dfdb90282bcdcf 100644 (file)
@@ -322,8 +322,7 @@ Turtle motion
 
    :param y: a number (integer or float)
 
-   Set the turtle's first coordinate to *y*, leave second coordinate
-   unchanged.
+   Set the turtle's second coordinate to *y*, leave first coordinate unchanged.
 
    >>> turtle.position()
    (0.00, 40.00)
index e55e52a1ca86698bc42453ebcba5feaeacf1e35f..b5875ee037c1362189cb449fb619f6ae0c388538 100644 (file)
@@ -31,19 +31,30 @@ The available exception and functions in this module are:
    Exception raised on compression and decompression errors.
 
 
-.. function:: adler32(string[, value])
+.. function:: adler32(data[, value])
 
-   Computes a Adler-32 checksum of *string*.  (An Adler-32 checksum is almost as
+   Computes a Adler-32 checksum of *data*.  (An Adler-32 checksum is almost as
    reliable as a CRC32 but can be computed much more quickly.)  If *value* is
    present, it is used as the starting value of the checksum; otherwise, a fixed
    default value is used.  This allows computing a running checksum over the
-   concatenation of several input strings.  The algorithm is not cryptographically
+   concatenation of several inputs.  The algorithm is not cryptographically
    strong, and should not be used for authentication or digital signatures.  Since
    the algorithm is designed for use as a checksum algorithm, it is not suitable
    for use as a general hash algorithm.
 
    Always returns an unsigned 32-bit integer.
 
+.. note::
+   To generate the same numeric value across all Python versions and
+   platforms use adler32(data) & 0xffffffff.  If you are only using
+   the checksum in packed binary format this is not necessary as the
+   return value will have the correct 32bit binary representation
+   regardless of sign.
+
+.. versionchanged:: 3.0
+   The return value will always be unsigned and in the range [0, 2**32-1]
+   regardless of platform.
+
 
 .. function:: compress(string[, level])
 
@@ -62,22 +73,33 @@ The available exception and functions in this module are:
    ``9`` is slowest and produces the most.  The default value is ``6``.
 
 
-.. function:: crc32(string[, value])
+.. function:: crc32(data[, value])
 
    .. index::
       single: Cyclic Redundancy Check
       single: checksum; Cyclic Redundancy Check
 
-   Computes a CRC (Cyclic Redundancy Check)  checksum of *string*. If *value* is
+   Computes a CRC (Cyclic Redundancy Check)  checksum of *data*. If *value* is
    present, it is used as the starting value of the checksum; otherwise, a fixed
    default value is used.  This allows computing a running checksum over the
-   concatenation of several input strings.  The algorithm is not cryptographically
+   concatenation of several inputs.  The algorithm is not cryptographically
    strong, and should not be used for authentication or digital signatures.  Since
    the algorithm is designed for use as a checksum algorithm, it is not suitable
    for use as a general hash algorithm.
 
    Always returns an unsigned 32-bit integer.
 
+.. note::
+   To generate the same numeric value across all Python versions and
+   platforms use crc32(data) & 0xffffffff.  If you are only using
+   the checksum in packed binary format this is not necessary as the
+   return value will have the correct 32bit binary representation
+   regardless of sign.
+
+.. versionchanged:: 3.0
+   The return value will always be unsigned and in the range [0, 2**32-1]
+   regardless of platform.
+
 
 .. function:: decompress(string[, wbits[, bufsize]])
 
index 3991bc5506b108204a62d5f909e70a9ec37f12f1..97cc68db982f378cb1b3fbcdca135f62ede88af7 100644 (file)
@@ -616,6 +616,15 @@ extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
 #define Py_FORMAT_PARSETUPLE(func,p1,p2)
 #endif
 
+/*
+ * Specify alignment on compilers that support it.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define Py_ALIGNED(x) __attribute__((aligned(x)))
+#else
+#define Py_ALIGNED(x)
+#endif
+
 /* Eliminate end-of-loop code not reached warnings from SunPro C
  * when using do{...}while(0) macros
  */
index 72f139748aef3f382067e2a81d0dadcf347b33f5..ca82c4113c247631820a95f1da2787ad72c7f41e 100644 (file)
@@ -283,12 +283,12 @@ class MutableSet(Set):
 
     @abstractmethod
     def add(self, value):
-        """Return True if it was added, False if already there."""
+        """Add an element."""
         raise NotImplementedError
 
     @abstractmethod
     def discard(self, value):
-        """Return True if it was deleted, False if not there."""
+        """Remove an element.  Do not raise an exception if absent."""
         raise NotImplementedError
 
     def remove(self, value):
index 53130cf3c5f227f34543876061f0a832f1ca1649..0b8baf752e04e763e9d05394cbfaad8a0a3403f1 100644 (file)
@@ -64,6 +64,18 @@ def literal_eval(node_or_string):
         elif isinstance(node, Name):
             if node.id in _safe_names:
                 return _safe_names[node.id]
+        elif isinstance(node, BinOp) and \
+             isinstance(node.op, (Add, Sub)) and \
+             isinstance(node.right, Num) and \
+             isinstance(node.right.n, complex) and \
+             isinstance(node.left, Num) and \
+             isinstance(node.left.n, (int, float)):
+            left = node.left.n
+            right = node.right.n
+            if isinstance(node.op, Add):
+                return left + right
+            else:
+                return left - right
         raise ValueError('malformed string')
     return _convert(node_or_string)
 
index bdcf62bc5389492d1ec7a7fa24f4fe6ee9d91ffc..1e0460a891b75342a5a02edd0bff1d3229fcbfc7 100644 (file)
@@ -67,9 +67,6 @@ def get_tests(package, mask, verbosity, exclude=()):
             if verbosity > 1:
                 print("Skipped %s: %s" % (modname, detail), file=sys.stderr)
             continue
-        except Exception as detail:
-            print("Warning: could not import %s: %s" % (modname, detail), file=sys.stderr)
-            continue
         for name in dir(mod):
             if name.startswith("_"):
                 continue
index da55ac6baebed53cf10036d0595f0caf0922fadb..b84aec0f6aaff7dc21012b520c405f233c94042c 100644 (file)
@@ -249,7 +249,10 @@ def getmembers(object, predicate=None):
     Optionally, only return members that satisfy a given predicate."""
     results = []
     for key in dir(object):
-        value = getattr(object, key)
+        try:
+            value = getattr(object, key)
+        except AttributeError:
+            continue
         if not predicate or predicate(value):
             results.append((key, value))
     results.sort()
index 2aa3b8fb009216f61df380e40f73104680561ada..54a3b35b7a2ab20945c2dfc30c4c0c1e03397c14 100644 (file)
@@ -265,6 +265,12 @@ class ASTHelpers_Test(unittest.TestCase):
         self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None))
         self.assertRaises(ValueError, ast.literal_eval, 'foo()')
 
+    def test_literal_eval_issue4907(self):
+        self.assertEqual(ast.literal_eval('2j'), 2j)
+        self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j)
+        self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j)
+        self.assertRaises(ValueError, ast.literal_eval, '2 + (3 + 4j)')
+
 
 def test_main():
     support.run_unittest(AST_Tests, ASTHelpers_Test)
index bde6d6c83c7ef0b80a39f221bd90ff0484ee2f90..ac9fcd7999ce42963ba57cf8bb5db09334af515b 100644 (file)
@@ -99,6 +99,17 @@ class TestPredicates(IsTestBase):
         self.assert_(inspect.isroutine(mod.spam))
         self.assert_(inspect.isroutine([].count))
 
+    def test_get_slot_members(self):
+        class C(object):
+            __slots__ = ("a", "b")
+
+        x = C()
+        x.a = 42
+        members = dict(inspect.getmembers(x))
+        self.assert_('a' in members)
+        self.assert_('b' not in members)
+
+
 class TestInterpreterStack(IsTestBase):
     def __init__(self, *args, **kwargs):
         unittest.TestCase.__init__(self, *args, **kwargs)
index b6f41fe00a18c8f5e5ac9d6ac364c7ff4a719e39..ecb86beb9bbea66586d0d17c72330065299d279d 100644 (file)
@@ -1472,11 +1472,14 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
                size += 1; /* terminating NUL */
                size *= sizeof(wchar_t);
                buffer = (wchar_t *)PyMem_Malloc(size);
-               if (!buffer)
+               if (!buffer) {
+                       Py_DECREF(value);
                        return PyErr_NoMemory();
+               }
                memset(buffer, 0, size);
                keep = PyCObject_FromVoidPtr(buffer, PyMem_Free);
                if (!keep) {
+                       Py_DECREF(value);
                        PyMem_Free(buffer);
                        return NULL;
                }
index 7d91af22da08ad0c24161b2aeba1a9a93ed79aa3..b7b9a649af0163e643ba12bcdcf319a2d75205dd 100644 (file)
@@ -3159,7 +3159,11 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
 #ifdef HAVE_GETHOSTBYNAME_R_3_ARG
        struct hostent_data data;
 #else
-       char buf[16384];
+       /* glibcs up to 2.10 assume that the buf argument to
+          gethostbyaddr_r is 8-byte aligned, which at least llvm-gcc
+          does not ensure. The attribute below instructs the compiler
+          to maintain this alignment. */
+       char buf[16384] Py_ALIGNED(8);
        int buf_len = (sizeof buf) - 1;
        int errnop;
 #endif
index 73b190a25c80f93c5771bdef148a8f2a9ce0a406..544b00eae76a4e3d70d992eb59bf9e673ae35584 100644 (file)
@@ -62,12 +62,12 @@ def docs_modified(file_paths):
 @status("Misc/ACKS updated", modal=True)
 def credit_given(file_paths):
     """Check if Misc/ACKS has been changed."""
-    return True if 'Misc/ACKS' in file_paths else False
+    return 'Misc/ACKS' in file_paths
 
 @status("Misc/NEWS updated", modal=True)
 def reported_news(file_paths):
     """Check if Misc/NEWS has been changed."""
-    return True if 'Misc/NEWS' in file_paths else False
+    return 'Misc/NEWS' in file_paths
 
 
 def main():