diff options
64 files changed, 126 insertions, 118 deletions
diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index d4dda7c..a171ac7 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -260,9 +260,11 @@ Numbers ``n`` (:class:`int`) [Py_ssize_t] Convert a Python integer to a C :c:type:`Py_ssize_t`. -``c`` (:class:`bytes` of length 1) [char] - Convert a Python byte, represented as a :class:`bytes` object of length 1, - to a C :c:type:`char`. +``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char] + Convert a Python byte, represented as a :class:`bytes` or + :class:`bytearray` object of length 1, to a C :c:type:`char`. + + .. versionchanged:: 3.3 Allow :class:`bytearray` objects ``C`` (:class:`str` of length 1) [int] Convert a Python character, represented as a :class:`str` object of diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c72b63e..5660224 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1464,7 +1464,7 @@ components, which must occur in this order: object to convert comes after the minimum field width and optional precision. #. Precision (optional), given as a ``'.'`` (dot) followed by the precision. If - specified as ``'*'`` (an asterisk), the actual width is read from the next + specified as ``'*'`` (an asterisk), the actual precision is read from the next element of the tuple in *values*, and the value to convert comes after the precision. @@ -1546,9 +1546,12 @@ The conversion types are: | ``'r'`` | String (converts any Python object using | \(5) | | | :func:`repr`). | | +------------+-----------------------------------------------------+-------+ -| ``'s'`` | String (converts any Python object using | | +| ``'s'`` | String (converts any Python object using | \(5) | | | :func:`str`). | | +------------+-----------------------------------------------------+-------+ +| ``'a'`` | String (converts any Python object using | \(5) | +| | :func:`ascii`). | | ++------------+-----------------------------------------------------+-------+ | ``'%'`` | No argument is converted, results in a ``'%'`` | | | | character in the result. | | +------------+-----------------------------------------------------+-------+ @@ -1581,7 +1584,7 @@ Notes: decimal point and defaults to 6. (5) - The precision determines the maximal number of characters used. + If precision is ``N``, the output is truncated to ``N`` characters. (7) diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 5656b23..8dba9c9 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -447,7 +447,7 @@ The :mod:`test.support` module defines the following functions: Module and package deprecation messages are suppressed during this import if *deprecated* is ``True``. - This function will raise :exc:`unittest.SkipTest` is the named module + This function will raise :exc:`unittest.SkipTest` if the named module cannot be imported. Example use:: diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py index 5cd4eda..61ce443 100644 --- a/Lib/curses/__init__.py +++ b/Lib/curses/__init__.py @@ -10,8 +10,6 @@ the package, and perhaps a particular module inside it. """ -__revision__ = "$Id$" - from _curses import * import os as _os import sys as _sys diff --git a/Lib/curses/panel.py b/Lib/curses/panel.py index aacca85..067afef 100644 --- a/Lib/curses/panel.py +++ b/Lib/curses/panel.py @@ -3,6 +3,4 @@ Module for using panels with curses. """ -__revision__ = "$Id$" - from _curses_panel import * diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py index bd7d9dd..f883916 100644 --- a/Lib/distutils/__init__.py +++ b/Lib/distutils/__init__.py @@ -8,8 +8,6 @@ used from a setup script as setup (...) """ -__revision__ = "$Id$" - # Distutils version # # Updated automatically by the Python release process. diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py index c06eba3..fcda08e 100644 --- a/Lib/distutils/archive_util.py +++ b/Lib/distutils/archive_util.py @@ -3,8 +3,6 @@ Utility functions for creating archive files (tarballs, zip files, that sort of thing).""" -__revision__ = "$Id$" - import os from warnings import warn import sys diff --git a/Lib/distutils/bcppcompiler.py b/Lib/distutils/bcppcompiler.py index c5e5cd2..9f4c432 100644 --- a/Lib/distutils/bcppcompiler.py +++ b/Lib/distutils/bcppcompiler.py @@ -11,8 +11,6 @@ for the Borland C++ compiler. # someone should sit down and factor out the common code as # WindowsCCompiler! --GPW -__revision__ = "$Id$" - import os from distutils.errors import \ diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index 291c008..c795c95 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -3,8 +3,6 @@ Contains CCompiler, an abstract base class that defines the interface for the Distutils compiler abstraction model.""" -__revision__ = "$Id$" - import sys, os, re from distutils.errors import * from distutils.spawn import spawn diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py index 5b1d085..3ea0810 100644 --- a/Lib/distutils/cmd.py +++ b/Lib/distutils/cmd.py @@ -4,8 +4,6 @@ Provides the Command class, the base class for the command classes in the distutils.command package. """ -__revision__ = "$Id$" - import sys, os, re from distutils.errors import DistutilsOptionError from distutils import util, dir_util, file_util, archive_util, dep_util diff --git a/Lib/distutils/command/__init__.py b/Lib/distutils/command/__init__.py index c379edb..481eea9 100644 --- a/Lib/distutils/command/__init__.py +++ b/Lib/distutils/command/__init__.py @@ -3,8 +3,6 @@ Package containing implementation of all the standard Distutils commands.""" -__revision__ = "$Id$" - __all__ = ['build', 'build_py', 'build_ext', diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py index 1a360b5..c5188eb 100644 --- a/Lib/distutils/command/bdist.py +++ b/Lib/distutils/command/bdist.py @@ -3,8 +3,6 @@ Implements the Distutils 'bdist' command (create a built [binary] distribution).""" -__revision__ = "$Id$" - import os from distutils.core import Command from distutils.errors import * diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py index 2d39922..170e889 100644 --- a/Lib/distutils/command/bdist_dumb.py +++ b/Lib/distutils/command/bdist_dumb.py @@ -4,8 +4,6 @@ Implements the Distutils 'bdist_dumb' command (create a "dumb" built distribution -- i.e., just an archive to be unpacked under $prefix or $exec_prefix).""" -__revision__ = "$Id$" - import os from distutils.core import Command from distutils.util import get_platform diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py index e2ae877..678e118 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -3,8 +3,6 @@ Implements the Distutils 'bdist_rpm' command (create RPM source and binary distributions).""" -__revision__ = "$Id$" - import sys, os from distutils.core import Command from distutils.debug import DEBUG diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py index b886055..52e34ec 100644 --- a/Lib/distutils/command/bdist_wininst.py +++ b/Lib/distutils/command/bdist_wininst.py @@ -3,8 +3,6 @@ Implements the Distutils 'bdist_wininst' command: create a windows installer exe-program.""" -__revision__ = "$Id$" - import sys, os from distutils.core import Command from distutils.util import get_platform diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py index 9c2667c..cfc15cf 100644 --- a/Lib/distutils/command/build.py +++ b/Lib/distutils/command/build.py @@ -2,8 +2,6 @@ Implements the Distutils 'build' command.""" -__revision__ = "$Id$" - import sys, os from distutils.core import Command from distutils.errors import DistutilsOptionError diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py index 428011a..3e20ef2 100644 --- a/Lib/distutils/command/build_clib.py +++ b/Lib/distutils/command/build_clib.py @@ -4,8 +4,6 @@ Implements the Distutils 'build_clib' command, to build a C/C++ library that is included in the module distribution and needed by an extension module.""" -__revision__ = "$Id$" - # XXX this module has *lots* of code ripped-off quite transparently from # build_ext.py -- not surprisingly really, as the work required to build diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index fb31648..8d843d6 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -4,8 +4,6 @@ Implements the Distutils 'build_ext' command, for building extension modules (currently limited to C extensions, should accommodate C++ extensions ASAP).""" -__revision__ = "$Id$" - import sys, os, re from distutils.core import Command from distutils.errors import * diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py index 26002e4..3868c12 100644 --- a/Lib/distutils/command/build_py.py +++ b/Lib/distutils/command/build_py.py @@ -2,8 +2,6 @@ Implements the Distutils 'build_py' command.""" -__revision__ = "$Id$" - import sys, os import sys from glob import glob diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py index 31be793..4b5b22e 100644 --- a/Lib/distutils/command/build_scripts.py +++ b/Lib/distutils/command/build_scripts.py @@ -2,8 +2,6 @@ Implements the Distutils 'build_scripts' command.""" -__revision__ = "$Id$" - import os, re from stat import ST_MODE from distutils import sysconfig diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py index 2657c69..b67c795 100644 --- a/Lib/distutils/command/check.py +++ b/Lib/distutils/command/check.py @@ -2,8 +2,6 @@ Implements the Distutils 'check' command. """ -__revision__ = "$Id$" - from distutils.core import Command from distutils.errors import DistutilsSetupError diff --git a/Lib/distutils/command/clean.py b/Lib/distutils/command/clean.py index ae1d22c..0cb2701 100644 --- a/Lib/distutils/command/clean.py +++ b/Lib/distutils/command/clean.py @@ -4,8 +4,6 @@ Implements the Distutils 'clean' command.""" # contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18 -__revision__ = "$Id$" - import os from distutils.core import Command from distutils.dir_util import remove_tree diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py index ac80a54..847e858 100644 --- a/Lib/distutils/command/config.py +++ b/Lib/distutils/command/config.py @@ -9,8 +9,6 @@ configure-like tasks: "try to compile this C code", or "figure out where this header file lives". """ -__revision__ = "$Id$" - import sys, os, re from distutils.core import Command diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py index bdc3a09..0161898 100644 --- a/Lib/distutils/command/install.py +++ b/Lib/distutils/command/install.py @@ -2,8 +2,6 @@ Implements the Distutils 'install' command.""" -__revision__ = "$Id$" - import sys import os diff --git a/Lib/distutils/command/install_data.py b/Lib/distutils/command/install_data.py index ab40797..947cd76 100644 --- a/Lib/distutils/command/install_data.py +++ b/Lib/distutils/command/install_data.py @@ -5,8 +5,6 @@ platform-independent data files.""" # contributed by Bastian Kleineidam -__revision__ = "$Id$" - import os from distutils.core import Command from distutils.util import change_root, convert_path diff --git a/Lib/distutils/command/install_headers.py b/Lib/distutils/command/install_headers.py index 38125b5..9bb0b18 100644 --- a/Lib/distutils/command/install_headers.py +++ b/Lib/distutils/command/install_headers.py @@ -3,8 +3,6 @@ Implements the Distutils 'install_headers' command, to install C/C++ header files to the Python include directory.""" -__revision__ = "$Id$" - from distutils.core import Command diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py index 6022d30..3d01d07 100644 --- a/Lib/distutils/command/install_lib.py +++ b/Lib/distutils/command/install_lib.py @@ -3,8 +3,6 @@ Implements the Distutils 'install_lib' command (install all Python modules).""" -__revision__ = "$Id$" - import os import sys diff --git a/Lib/distutils/command/install_scripts.py b/Lib/distutils/command/install_scripts.py index ea8d5aa..31a1130 100644 --- a/Lib/distutils/command/install_scripts.py +++ b/Lib/distutils/command/install_scripts.py @@ -5,8 +5,6 @@ Python scripts.""" # contributed by Bastian Kleineidam -__revision__ = "$Id$" - import os from distutils.core import Command from distutils import log diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py index bdf5f8f..99545af 100644 --- a/Lib/distutils/command/register.py +++ b/Lib/distutils/command/register.py @@ -5,8 +5,6 @@ Implements the Distutils 'register' command (register with the repository). # created 2002/10/21, Richard Jones -__revision__ = "$Id$" - import os, string, getpass import io import urllib.parse, urllib.request diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py index fdbebd7..48cb26b 100644 --- a/Lib/distutils/command/sdist.py +++ b/Lib/distutils/command/sdist.py @@ -2,8 +2,6 @@ Implements the Distutils 'sdist' command (create a source distribution).""" -__revision__ = "$Id$" - import os import string import sys diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py index c0a04de..260332a 100644 --- a/Lib/distutils/core.py +++ b/Lib/distutils/core.py @@ -6,8 +6,6 @@ indirectly provides the Distribution and Command classes, although they are really defined in distutils.dist and distutils.cmd. """ -__revision__ = "$Id$" - import os import sys diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py index 536aa6b..819e1a9 100644 --- a/Lib/distutils/cygwinccompiler.py +++ b/Lib/distutils/cygwinccompiler.py @@ -45,8 +45,6 @@ cygwin in no-cygwin mode). # * mingw gcc 3.2/ld 2.13 works # (ld supports -shared) -__revision__ = "$Id$" - import os import sys import copy diff --git a/Lib/distutils/debug.py b/Lib/distutils/debug.py index 2886744..daf1660 100644 --- a/Lib/distutils/debug.py +++ b/Lib/distutils/debug.py @@ -1,7 +1,5 @@ import os -__revision__ = "$Id$" - # If DISTUTILS_DEBUG is anything other than the empty string, we run in # debug mode. DEBUG = os.environ.get('DISTUTILS_DEBUG') diff --git a/Lib/distutils/dep_util.py b/Lib/distutils/dep_util.py index 07b3549..d74f5e4 100644 --- a/Lib/distutils/dep_util.py +++ b/Lib/distutils/dep_util.py @@ -4,8 +4,6 @@ Utility functions for simple, timestamp-based dependency of files and groups of files; also, function based entirely on such timestamp dependency analysis.""" -__revision__ = "$Id$" - import os from distutils.errors import DistutilsFileError diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index 5b005f0..30daf49 100644 --- a/Lib/distutils/dir_util.py +++ b/Lib/distutils/dir_util.py @@ -2,8 +2,6 @@ Utility functions for manipulating directories and directory trees.""" -__revision__ = "$Id$" - import os, sys import errno from distutils.errors import DistutilsFileError, DistutilsInternalError diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 01f1f1c..02cd79b 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -4,8 +4,6 @@ Provides the Distribution class, which represents the module distribution being built/installed/distributed. """ -__revision__ = "$Id$" - import sys, os, re try: diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py index 16dce53..3675f8d 100644 --- a/Lib/distutils/emxccompiler.py +++ b/Lib/distutils/emxccompiler.py @@ -19,8 +19,6 @@ handles the EMX port of the GNU C compiler to OS/2. # # * EMX gcc 2.81/EMX 0.9d fix03 -__revision__ = "$Id$" - import os,sys,copy from distutils.ccompiler import gen_preprocess_options, gen_lib_options from distutils.unixccompiler import UnixCCompiler diff --git a/Lib/distutils/errors.py b/Lib/distutils/errors.py index acecacc..eb13c98 100644 --- a/Lib/distutils/errors.py +++ b/Lib/distutils/errors.py @@ -8,8 +8,6 @@ usually raised for errors that are obviously the end-user's fault This module is safe to use in "from ... import *" mode; it only exports symbols whose names start with "Distutils" and end with "Error".""" -__revision__ = "$Id$" - class DistutilsError (Exception): """The root of all Distutils evil.""" pass diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py index 2d1c36b..a93655a 100644 --- a/Lib/distutils/extension.py +++ b/Lib/distutils/extension.py @@ -3,8 +3,6 @@ Provides the Extension class, used to describe C/C++ extension modules in setup scripts.""" -__revision__ = "$Id$" - import os import sys import warnings diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py index 879d4d2..7d170dd 100644 --- a/Lib/distutils/fancy_getopt.py +++ b/Lib/distutils/fancy_getopt.py @@ -8,8 +8,6 @@ additional features: * options set attributes of a passed-in object """ -__revision__ = "$Id$" - import sys, string, re import getopt from distutils.errors import * diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py index e1eb932..9bdd14e 100644 --- a/Lib/distutils/file_util.py +++ b/Lib/distutils/file_util.py @@ -3,8 +3,6 @@ Utility functions for operating on single files. """ -__revision__ = "$Id$" - import os from distutils.errors import DistutilsFileError from distutils import log diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index 06a8da9..a94b5c8 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -4,8 +4,6 @@ Provides the FileList class, used for poking about the filesystem and building lists of files. """ -__revision__ = "$Id$" - import os, re import fnmatch from distutils.util import convert_path diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py index e849e16..0cddb5c 100644 --- a/Lib/distutils/msvc9compiler.py +++ b/Lib/distutils/msvc9compiler.py @@ -12,8 +12,6 @@ for older versions of VS in distutils.msvccompiler. # finding DevStudio (through the registry) # ported to VS2005 and VS 2008 by Christian Heimes -__revision__ = "$Id$" - import os import subprocess import sys diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py index 1cd0f91..8116656 100644 --- a/Lib/distutils/msvccompiler.py +++ b/Lib/distutils/msvccompiler.py @@ -8,8 +8,6 @@ for the Microsoft Visual Studio. # hacked by Robin Becker and Thomas Heller to do a better job of # finding DevStudio (through the registry) -__revision__ = "$Id$" - import sys, os from distutils.errors import \ DistutilsExecError, DistutilsPlatformError, \ diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py index 2b62c96..f58c55f 100644 --- a/Lib/distutils/spawn.py +++ b/Lib/distutils/spawn.py @@ -6,8 +6,6 @@ Also provides the 'find_executable()' to search the path for a given executable name. """ -__revision__ = "$Id$" - import sys import os diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index 9d7d190..5ea724c 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -9,8 +9,6 @@ Written by: Fred L. Drake, Jr. Email: <fdrake@acm.org> """ -__revision__ = "$Id$" - import os import re import sys diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py index f969849..8edfab4 100644 --- a/Lib/distutils/tests/test_archive_util.py +++ b/Lib/distutils/tests/test_archive_util.py @@ -1,6 +1,4 @@ """Tests for distutils.archive_util.""" -__revision__ = "$Id$" - import unittest import os import tarfile diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py index 454725c..40b8484 100644 --- a/Lib/distutils/text_file.py +++ b/Lib/distutils/text_file.py @@ -4,8 +4,6 @@ provides the TextFile class, which gives an interface to text files that (optionally) takes care of stripping comments, ignoring blank lines, and joining lines with backslashes.""" -__revision__ = "$Id$" - import sys, os, io diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index bf73416..c70a3cc 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -13,8 +13,6 @@ the "typical" Unix-style command-line C compiler: * link shared library handled by 'cc -shared' """ -__revision__ = "$Id$" - import os, sys, re from distutils import sysconfig diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index d6f89d6..023ddff 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -4,8 +4,6 @@ Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. """ -__revision__ = "$Id$" - import sys, os, string, re from distutils.errors import DistutilsPlatformError from distutils.dep_util import newer diff --git a/Lib/pydoc.py b/Lib/pydoc.py index ffb4f89..ebd8a61 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -218,8 +218,8 @@ def source_synopsis(file): def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename).st_mtime - lastupdate, result = cache.get(filename, (0, None)) - if lastupdate < mtime: + lastupdate, result = cache.get(filename, (None, None)) + if lastupdate is None or lastupdate < mtime: info = inspect.getmoduleinfo(filename) try: file = tokenize.open(filename) diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 8129a80..bd92ded 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -31,8 +31,8 @@ version = "0.9.0" __author__ = "Lars Gust\u00e4bel (lars@gustaebel.de)" -__date__ = "$Date$" -__cvsid__ = "$Id$" +__date__ = "$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $" +__cvsid__ = "$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $" __credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend." #--------- diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index 7bcc436..12871c1 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -834,12 +834,12 @@ class BarrierTests(BaseTestCase): """ Test the barrier's default timeout """ - #create a barrier with a low default timeout - barrier = self.barriertype(self.N, timeout=0.1) + # create a barrier with a low default timeout + barrier = self.barriertype(self.N, timeout=0.3) def f(): i = barrier.wait() if i == self.N // 2: - # One thread is later than the default timeout of 0.1s. + # One thread is later than the default timeout of 0.3s. time.sleep(1.0) self.assertRaises(threading.BrokenBarrierError, barrier.wait) self.run_threads(f) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index c3d2fcb..9bb4307 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -800,6 +800,7 @@ STDTESTS = [ 'test_unittest', 'test_doctest', 'test_doctest2', + 'test_support' ] # set of tests that we don't want to be executed when using regrtest diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 234b56c..d32a44b 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -475,6 +475,27 @@ class BaseBytesTest(unittest.TestCase): self.assertRaises(TypeError, self.type2test(b'abc').lstrip, 'b') self.assertRaises(TypeError, self.type2test(b'abc').rstrip, 'b') + def test_center(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.center(7, fill_type(b'-')), + self.type2test(b'--abc--')) + + def test_ljust(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.ljust(7, fill_type(b'-')), + self.type2test(b'abc----')) + + def test_rjust(self): + # Fill character can be either bytes or bytearray (issue 12380) + b = self.type2test(b'abc') + for fill_type in (bytes, bytearray): + self.assertEqual(b.rjust(7, fill_type(b'-')), + self.type2test(b'----abc')) + def test_ord(self): b = self.type2test(b'\0A\x7f\x80\xff') self.assertEqual([ord(b[i:i+1]) for i in range(len(b))], diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 4a02ec1..1f2039e 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -2068,9 +2068,6 @@ order (MRO) for bases """ # Two essentially featureless objects, just inheriting stuff from # object. self.assertEqual(dir(NotImplemented), dir(Ellipsis)) - if support.check_impl_detail(): - # None differs in PyPy: it has a __nonzero__ - self.assertEqual(dir(None), dir(Ellipsis)) # Nasty test case for proxied objects class Wrapper(object): diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 3d9c06a..768ea8d 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -294,6 +294,15 @@ class Keywords_TestCase(unittest.TestCase): self.fail('TypeError should have been raised') class Bytes_TestCase(unittest.TestCase): + def test_c(self): + from _testcapi import getargs_c + self.assertRaises(TypeError, getargs_c, b'abc') # len > 1 + self.assertEqual(getargs_c(b'a'), b'a') + self.assertEqual(getargs_c(bytearray(b'a')), b'a') + self.assertRaises(TypeError, getargs_c, memoryview(b'a')) + self.assertRaises(TypeError, getargs_c, 's') + self.assertRaises(TypeError, getargs_c, None) + def test_s(self): from _testcapi import getargs_s self.assertEqual(getargs_s('abc\xe9'), b'abc\xc3\xa9') diff --git a/Lib/textwrap.py b/Lib/textwrap.py index f014cb0..0aeba3f 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -5,8 +5,6 @@ # Copyright (C) 2002, 2003 Python Software Foundation. # Written by Greg Ward <gward@python.net> -__revision__ = "$Id$" - import re __all__ = ['TextWrapper', 'wrap', 'fill', 'dedent'] diff --git a/Lib/timeit.py b/Lib/timeit.py index f2510ea..f45168b 100644 --- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -191,9 +191,11 @@ class Timer: it = [None] * number gcold = gc.isenabled() gc.disable() - timing = self.inner(it, self.timer) - if gcold: - gc.enable() + try: + timing = self.inner(it, self.timer) + finally: + if gcold: + gc.enable() return timing def repeat(self, repeat=default_repeat, number=default_number): @@ -771,6 +771,7 @@ Chris Rebert Marc Recht John Redford Terry Reedy +Gareth Rees Steve Reeves Lennart Regebro Ofir Reichenberg @@ -13,6 +13,10 @@ Core and Builtins - Verify the types of AST strings and identifiers provided by the user before compiling them. +- Issue #12647: The None object now has a __bool__() method that returns False. + Formerly, bool(None) returned False only because of special case logic + in PyObject_IsTrue(). + - Issue #12579: str.format_map() now raises a ValueError if used on a format string that contains positional fields. Initial patch by Julian Berman. @@ -234,6 +238,9 @@ Core and Builtins - Issue #11386: bytearray.pop() now throws IndexError when the bytearray is empty, instead of OverflowError. +- Issue #12380: The rjust, ljust and center methods of bytes and bytearray + now accept a bytearray argument. + Library ------- @@ -247,6 +254,11 @@ Library - Issue #9723: Add shlex.quote functions, to escape filenames and command lines. +- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime. + +- Issue #12514: Use try/finally to assure the timeit module restores garbage + collections when it is done. + - Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is given as a low fd, it gets overwritten. @@ -1286,6 +1298,8 @@ C-API - Issue #12173: The first argument of PyImport_ImportModuleLevel is now `const char *` instead of `char *`. +- Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format. + Documentation ------------- diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 35d25e6..51c79c9 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1003,6 +1003,15 @@ test_k_code(PyObject *self) } static PyObject * +getargs_c(PyObject *self, PyObject *args) +{ + char c; + if (!PyArg_ParseTuple(args, "c", &c)) + return NULL; + return PyBytes_FromStringAndSize(&c, 1); +} + +static PyObject * getargs_s(PyObject *self, PyObject *args) { char *str; @@ -2289,6 +2298,7 @@ static PyMethodDef TestMethods[] = { (PyCFunction)test_long_long_and_overflow, METH_NOARGS}, {"test_L_code", (PyCFunction)test_L_code, METH_NOARGS}, #endif + {"getargs_c", getargs_c, METH_VARARGS}, {"getargs_s", getargs_s, METH_VARARGS}, {"getargs_s_star", getargs_s_star, METH_VARARGS}, {"getargs_s_hash", getargs_s_hash, METH_VARARGS}, diff --git a/Objects/object.c b/Objects/object.c index 05c52f1..27d7089 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1255,7 +1255,7 @@ PyObject_Dir(PyObject *obj) } /* -None is as a non-NULL undefined value. +None is a non-NULL undefined value. There is (and should be!) no way to create other objects of this type, so there is exactly one (which is indestructible, by the way). */ @@ -1277,6 +1277,48 @@ none_dealloc(PyObject* ignore) Py_FatalError("deallocating None"); } +static int +none_bool(PyObject *v) +{ + return 0; +} + +static PyNumberMethods none_as_number = { + 0, /* nb_add */ + 0, /* nb_subtract */ + 0, /* nb_multiply */ + 0, /* nb_remainder */ + 0, /* nb_divmod */ + 0, /* nb_power */ + 0, /* nb_negative */ + 0, /* nb_positive */ + 0, /* nb_absolute */ + (inquiry)none_bool, /* nb_bool */ + 0, /* nb_invert */ + 0, /* nb_lshift */ + 0, /* nb_rshift */ + 0, /* nb_and */ + 0, /* nb_xor */ + 0, /* nb_or */ + 0, /* nb_int */ + 0, /* nb_reserved */ + 0, /* nb_float */ + 0, /* nb_inplace_add */ + 0, /* nb_inplace_subtract */ + 0, /* nb_inplace_multiply */ + 0, /* nb_inplace_remainder */ + 0, /* nb_inplace_power */ + 0, /* nb_inplace_lshift */ + 0, /* nb_inplace_rshift */ + 0, /* nb_inplace_and */ + 0, /* nb_inplace_xor */ + 0, /* nb_inplace_or */ + 0, /* nb_floor_divide */ + 0, /* nb_true_divide */ + 0, /* nb_inplace_floor_divide */ + 0, /* nb_inplace_true_divide */ + 0, /* nb_index */ +}; static PyTypeObject PyNone_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -1289,7 +1331,7 @@ static PyTypeObject PyNone_Type = { 0, /*tp_setattr*/ 0, /*tp_reserved*/ none_repr, /*tp_repr*/ - 0, /*tp_as_number*/ + &none_as_number, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ diff --git a/Python/getargs.c b/Python/getargs.c index 4b57153..c3da368 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -828,6 +828,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, char *p = va_arg(*p_va, char *); if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1) *p = PyBytes_AS_STRING(arg)[0]; + else if (PyByteArray_Check(arg) && PyByteArray_Size(arg) == 1) + *p = PyByteArray_AS_STRING(arg)[0]; else return converterr("a byte string of length 1", arg, msgbuf, bufsize); break; |
