diff --git a/.hgtags b/.hgtags index 9ccde1e10e6..7ac43b08043 100644 --- a/.hgtags +++ b/.hgtags @@ -77,6 +77,7 @@ d18e9d71f369d8211f6ac87252c6d3211f9bd09f v3.1.3rc1 a4f75773c0060cee38b0bb651a7aba6f56b0e996 v3.1.3 32fcb9e94985cb19ce37ba9543f091c0dbe9d7dd v3.1.4rc1 c918ec9f3a76d6afedfbb5d455004de880443a3d v3.1.4 +ee26aca3219cf4bb0b93352e83edcc9cb28c7802 v3.1.5rc1 b37b7834757492d009b99cf0ca4d42d2153d7fac v3.2a1 56d4373cecb73c8b45126ba7b045b3c7b3f94b0b v3.2a2 da012d9a2c23d144e399d2e01a55b8a83ad94573 v3.2a3 diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 427e4a06273..ee88379edba 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -240,7 +240,7 @@ default values. The arguments that are most commonly needed are: When *stdout* or *stderr* are pipes and *universal_newlines* is :const:`True` then the output data is assumed to be encoded as UTF-8 and will automatically be decoded to text. All line endings will be converted - to ``'\n'`` as described for the universal newlines `'U'`` mode argument + to ``'\n'`` as described for the universal newlines ``'U'`` mode argument to :func:`open`. If *shell* is :const:`True`, the specified command will be executed through diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 3af43543c40..da87be74ed6 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -195,7 +195,7 @@ always available. be set at build time with the ``--exec-prefix`` argument to the :program:`configure` script. Specifically, all configuration files (e.g. the :file:`pyconfig.h` header file) are installed in the directory - :file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are + :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* is the version number of Python, for example ``3.2``. @@ -756,6 +756,7 @@ always available. always use the ``startswith`` idiom presented above. .. seealso:: + :attr:`os.name` has a coarser granularity. :func:`os.uname` gives system-dependent version information. @@ -771,7 +772,7 @@ always available. argument to the :program:`configure` script. The main collection of Python library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}`` while the platform independent header files (all except :file:`pyconfig.h`) are - stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version + stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version number of Python, for example ``3.2``. diff --git a/Doc/library/time.rst b/Doc/library/time.rst index 0412e157ff8..817f5a510cb 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -228,8 +228,9 @@ The module defines the following functions and data items: .. function:: monotonic() - Monotonic clock. The reference point of the returned value is undefined so - only the difference of consecutive calls is valid. + Monotonic non-decreasing clock. The clock is not related to the system clock + and cannot go backward. The reference point of the returned + value is undefined so only the difference of consecutive calls is valid. .. versionadded:: 3.3 diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 8fe5bd99b2c..e79018f5be2 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -16,9 +16,9 @@ """ Logging package for Python. Based on PEP 282 and comments thereto in -comp.lang.python, and influenced by Apache's log4j system. +comp.lang.python. -Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ @@ -914,8 +914,12 @@ class StreamHandler(Handler): """ Flushes the stream. """ - if self.stream and hasattr(self.stream, "flush"): - self.stream.flush() + self.acquire() + try: + if self.stream and hasattr(self.stream, "flush"): + self.stream.flush() + finally: + self.release() def emit(self, record): """ @@ -964,12 +968,16 @@ class FileHandler(StreamHandler): """ Closes the stream. """ - if self.stream: - self.flush() - if hasattr(self.stream, "close"): - self.stream.close() - StreamHandler.close(self) - self.stream = None + self.acquire() + try: + if self.stream: + self.flush() + if hasattr(self.stream, "close"): + self.stream.close() + StreamHandler.close(self) + self.stream = None + finally: + self.release() def _open(self): """ diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 822b4efc7c4..ee0096a8cb7 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1,4 +1,4 @@ -# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2012 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, @@ -16,10 +16,9 @@ """ Additional handlers for the logging package for Python. The core package is -based on PEP 282 and comments thereto in comp.lang.python, and influenced by -Apache's log4j system. +based on PEP 282 and comments thereto in comp.lang.python. -Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. To use, simply 'import logging.handlers' and log away! """ @@ -594,10 +593,14 @@ class SocketHandler(logging.Handler): """ Closes the socket. """ - if self.sock: - self.sock.close() - self.sock = None - logging.Handler.close(self) + self.acquire() + try: + if self.sock: + self.sock.close() + self.sock = None + logging.Handler.close(self) + finally: + self.release() class DatagramHandler(SocketHandler): """ @@ -792,8 +795,12 @@ class SysLogHandler(logging.Handler): """ Closes the socket. """ - self.socket.close() - logging.Handler.close(self) + self.acquire() + try: + self.socket.close() + logging.Handler.close(self) + finally: + self.release() def mapPriority(self, levelName): """ @@ -1137,7 +1144,11 @@ class BufferingHandler(logging.Handler): This version just zaps the buffer to empty. """ - self.buffer = [] + self.acquire() + try: + self.buffer = [] + finally: + self.release() def close(self): """ @@ -1187,18 +1198,26 @@ class MemoryHandler(BufferingHandler): The record buffer is also cleared by this operation. """ - if self.target: - for record in self.buffer: - self.target.handle(record) - self.buffer = [] + self.acquire() + try: + if self.target: + for record in self.buffer: + self.target.handle(record) + self.buffer = [] + finally: + self.release() def close(self): """ Flush, set the target to None and lose the buffer. """ self.flush() - self.target = None - BufferingHandler.close(self) + self.acquire() + try: + self.target = None + BufferingHandler.close(self) + finally: + self.release() class QueueHandler(logging.Handler):