Merged revisions 77185-77188,77262,77313,77317,77331-77333,77337-77338 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77185 | andrew.kuchling | 2009-12-31 10:17:05 -0600 (Thu, 31 Dec 2009) | 1 line

  Add some items
........
  r77186 | benjamin.peterson | 2009-12-31 10:28:24 -0600 (Thu, 31 Dec 2009) | 1 line

  update expat comment
........
  r77187 | andrew.kuchling | 2009-12-31 10:38:53 -0600 (Thu, 31 Dec 2009) | 1 line

  Add various items
........
  r77188 | benjamin.peterson | 2009-12-31 10:49:37 -0600 (Thu, 31 Dec 2009) | 1 line

  add another advancement
........
  r77262 | andrew.kuchling | 2010-01-02 19:15:21 -0600 (Sat, 02 Jan 2010) | 1 line

  Add a few items
........
  r77313 | benjamin.peterson | 2010-01-04 18:04:19 -0600 (Mon, 04 Jan 2010) | 1 line

  add a test about hashing array.array
........
  r77317 | georg.brandl | 2010-01-05 12:14:52 -0600 (Tue, 05 Jan 2010) | 1 line

  Add Stefan.
........
  r77331 | georg.brandl | 2010-01-06 11:43:06 -0600 (Wed, 06 Jan 2010) | 1 line

  Small fixes to test_cmd: fix signature of do_shell, remove duplicate import, add option to run the custom Cmd class.
........
  r77332 | georg.brandl | 2010-01-06 12:02:16 -0600 (Wed, 06 Jan 2010) | 7 lines

  #5991: let completion for the "help" command include help topics.

  This also simplifies the Cmd.get_names() method implementation; it was written
  at a time where dir() didn't consider base class attributes.
........
  r77333 | georg.brandl | 2010-01-06 12:26:08 -0600 (Wed, 06 Jan 2010) | 1 line

  #5950: document that zip files with comments are unsupported in zipimport.
........
  r77337 | r.david.murray | 2010-01-06 21:09:08 -0600 (Wed, 06 Jan 2010) | 3 lines

  Add -W to the 'basics', 'opt', and 'all' test runs so that we get verbose
  information if a failure happens.
........
  r77338 | r.david.murray | 2010-01-06 22:04:28 -0600 (Wed, 06 Jan 2010) | 2 lines

  Fix inadvertent checkin of debug line.
........
This commit is contained in:
Benjamin Peterson 2010-01-09 18:53:06 +00:00
parent 46a9900e09
commit a28e7028f9
8 changed files with 111 additions and 45 deletions

View File

@ -26,6 +26,8 @@ Any files may be present in the ZIP archive, but only files :file:`.py` and
corresponding :file:`.pyc` or :file:`.pyo` file, meaning that if a ZIP archive
doesn't contain :file:`.pyc` files, importing may be rather slow.
ZIP archives with an archive comment are currently not supported.
.. seealso::
`PKZIP Application Note <http://www.pkware.com/documents/casestudies/APPNOTE.TXT>`_

View File

@ -264,7 +264,9 @@ Some smaller changes made to the core Python language are:
Windows, and on Unix platforms using the gcc, icc, or suncc
compilers. There may be a small number of platforms where correct
operation of this code cannot be guaranteed, so the code is not
used on such systems.
used on such systems. You can find out which code is being used
by checking :data:`sys.float_repr_style`, which will be ``short``
if the new code is in use and ``legacy`` if it isn't.
Implemented by Eric Smith and Mark Dickinson, using David Gay's
:file:`dtoa.c` library; :issue:`7117`.
@ -358,6 +360,11 @@ Some smaller changes made to the core Python language are:
on the :exc:`IOError` exception when trying to open a directory
on POSIX platforms. (Noted by Jan Kaliszewski; :issue:`4764`.)
* The Python tokenizer now translates line endings itself, so the
:func:`compile` built-in function can now accept code using any
line-ending convention. Additionally, it no longer requires that the
code end in a newline.
* Extra parentheses in function definitions are illegal in Python 3.x,
meaning that you get a syntax error from ``def f((x)): pass``. In
Python3-warning mode, Python 2.7 will now warn about this odd usage.
@ -433,6 +440,8 @@ Several performance enhancements have been added:
Various benchmarks show speedups of between 50% and 150% for long
integer divisions and modulo operations.
(Contributed by Mark Dickinson; :issue:`5512`.)
Bitwise operations are also significantly faster (initial patch by
Gregory Smith; :issue:`1087418`).
* The implementation of ``%`` checks for the left-side operand being
a Python string and special-cases it; this results in a 1-3%
@ -444,6 +453,16 @@ Several performance enhancements have been added:
faster bytecode. (Patch by Antoine Pitrou, back-ported to 2.7
by Jeffrey Yasskin; :issue:`4715`.)
* 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`.)
* The :meth:`rindex`, :meth:`rpartition`, and :meth:`rsplit` methods
of string objects now uses a fast reverse-search algorithm instead of
a character-by-character scan. This is often faster by a factor of 10.
(Added by Florent Xicluna; :issue:`7462`.)
* 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
@ -453,11 +472,6 @@ Several performance enhancements have been added:
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 and Improved Modules
@ -602,6 +616,10 @@ changes, or look through the Subversion logs for all the details.
XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
(Contributed by Tarek Ziade; :issue:`7457`.)
:file:`setup.py` files will now accept a :option:`--no-user-cfg` switch
to skip reading the :file:`~/.pydistutils.cfg` file. (Suggested by
by Michael Hoffman, and implemented by Paul Winkler; :issue:`1180`.)
* The :class:`Fraction` class now accepts two rational numbers
as arguments to its constructor.
(Implemented by Mark Dickinson; :issue:`5812`.)
@ -625,14 +643,6 @@ changes, or look through the Subversion logs for all the details.
recorded in a gzipped file by providing an optional timestamp to
the constructor. (Contributed by Jacques Frechet; :issue:`4272`.)
* 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`.)
@ -745,6 +755,10 @@ changes, or look through the Subversion logs for all the details.
to store data.
(Contributed by Tarek Ziade; :issue:`6693`.)
* The :mod:`socket` module's :class:`SSL` objects now support the
buffer API, which fixed a test suite failure. (Fixed by Antoine Pitrou;
:issue:`7133`.)
* 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,
@ -858,6 +872,10 @@ GvR worked on merging them into Python's version of :mod:`unittest`.
whether the two values evaluate to the same object or not.
(Added by Michael Foord; :issue:`2578`.)
* :meth:`assertIsInstance` and :meth:`assertNotIsInstance` check whether
the resulting object is an instance of a particular class, or of
one of a tuple of classes. (Added by Georg Brandl; :issue:`7031`.)
* :meth:`assertGreater`, :meth:`assertGreaterEqual`,
:meth:`assertLess`, and :meth:`assertLessEqual` compare
two quantities.
@ -1025,6 +1043,11 @@ Changes to Python's build process and to the C API include:
a :ctype:`long`, an *overflow* flag is set and returned to the caller.
(Contributed by Case Van Horsen; :issue:`7528`.)
* New function: stemming from the rewrite of string-to-float conversion,
a new :cfunc:`PyOS_string_to_double` function was added. The old
:cfunc:`PyOS_ascii_strtod` and :cfunc:`PyOS_ascii_atof` functions
are now deprecated.
* New macros: the Python header files now define the following macros:
:cmacro:`Py_ISALNUM`,
:cmacro:`Py_ISALPHA`,
@ -1067,10 +1090,30 @@ Changes to Python's build process and to the C API include:
(Fixed by Thomas Wouters; :issue:`1590864`.)
* The :cfunc:`Py_Finalize` function now calls the internal
:func:`threading._shutdown` function; this prevents some exceptions from
being raised when an interpreter shuts down.
(Patch by Adam Olsen; :issue:`1722344`.)
* Global symbols defined by the :mod:`ctypes` module are now prefixed
with ``Py``, or with ``_ctypes``. (Implemented by Thomas
Heller; :issue:`3102`.)
* New configure option: the :option:`--with-system-expat` switch allows
building the :mod:`pyexpat` module to use the system Expat library.
(Contributed by Arfrever Frehtes Taifersar Arahesis; :issue:`7609`.)
* New configure option: Compiling Python with the
:option:`--with-valgrind` option will now disable the pymalloc
allocator, which is difficult for the Valgrind to analyze correctly.
Valgrind will therefore be better at detecting memory leaks and
overruns. (Contributed by James Henstridge; :issue:`2422`.)
* New configure option: you can now supply no arguments to
:option:`--with-dbmliborder=` in order to build none of the various
DBM modules. (Added by Arfrever Frehtes Taifersar Arahesis;
:issue:`6491`.)
* The :program:`configure` script now checks for floating-point rounding bugs
on certain 32-bit Intel chips and defines a :cmacro:`X87_DOUBLE_ROUNDING`
preprocessor definition. No code currently uses this definition,
@ -1083,11 +1126,6 @@ Changes to Python's build process and to the C API include:
* The build process now supports Subversion 1.7. (Contributed by
Arfrever Frehtes Taifersar Arahesis; :issue:`6094`.)
* Compiling Python with the :option:`--with-valgrind` option will now
disable the pymalloc allocator, which is difficult for the Valgrind to
analyze correctly. Valgrind will therefore be better at detecting
memory leaks and overruns. (Contributed by James Henstridge; :issue:`2422`.)
.. ======================================================================
@ -1139,12 +1177,14 @@ Other Changes and Fixes
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
* Another :file:`regrtest.py` switch is :option:`-j`, which
takes an integer specifying how many tests run in parallel. This
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`.)
(Added by Antoine Pitrou, :issue:`6152`.) This can also be used
with a new :option:`-F` switch that runs selected tests in a loop
until they fail. (Added by Antoine Pitrou; :issue:`7312`.)
.. ======================================================================
@ -1175,6 +1215,17 @@ that may require changes to your code:
nothing when a negative length is requested, as other file-like
objects do. (:issue:`7348`).
For C extensions:
* C extensions that use integer format codes with the ``PyArg_Parse*``
family of functions will now raise a :exc:`TypeError` exception
instead of triggering a :exc:`DeprecationWarning` (:issue:`5080`).
* Use the new :cfunc:`PyOS_string_to_double` function instead of the old
:cfunc:`PyOS_ascii_strtod` and :cfunc:`PyOS_ascii_atof` functions,
which are now deprecated.
.. ======================================================================

View File

@ -278,19 +278,15 @@ class Cmd:
return None
def get_names(self):
# Inheritance says we have to look in class and
# base classes; order is not important.
names = []
classes = [self.__class__]
while classes:
aclass = classes.pop(0)
if aclass.__bases__:
classes = classes + list(aclass.__bases__)
names = names + dir(aclass)
return names
# This method used to pull in base class attributes
# at a time dir() didn't do it yet.
return dir(self.__class__)
def complete_help(self, *args):
return self.completenames(*args)
commands = set(self.completenames(*args))
topics = set(a[5:] for a in self.get_names()
if a.startswith('help_' + args[0]))
return list(commands | topics)
def do_help(self, arg):
if arg:

View File

@ -60,15 +60,17 @@ class samplecmdclass(cmd.Cmd):
>>> mycmd.completenames("12")
[]
>>> mycmd.completenames("help")
['help', 'help']
['help']
Test for the function complete_help():
>>> mycmd.complete_help("a")
['add']
>>> mycmd.complete_help("he")
['help', 'help']
['help']
>>> mycmd.complete_help("12")
[]
>>> sorted(mycmd.complete_help(""))
['add', 'exit', 'help', 'shell']
Test for the function do_help():
>>> mycmd.do_help("testet")
@ -144,7 +146,7 @@ class samplecmdclass(cmd.Cmd):
def complete_command(self):
print("complete command")
def do_shell(self):
def do_shell(self, s):
pass
def do_add(self, s):
@ -171,6 +173,7 @@ def test_main(verbose=None):
support.run_doctest(test_cmd, verbose)
def test_coverage(coverdir):
import trace
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
trace=0, count=1)
tracer.run('reload(cmd);test_main()')
@ -181,5 +184,7 @@ def test_coverage(coverdir):
if __name__ == "__main__":
if "-c" in sys.argv:
test_coverage('/tmp/cmd.cover')
elif "-i" in sys.argv:
samplecmdclass().cmdloop()
else:
test_main()

View File

@ -6,8 +6,10 @@
# Licensed to PSF under a Contributor Agreement.
#
import array
import hashlib
from io import StringIO
import itertools
import sys
try:
import threading
@ -93,6 +95,13 @@ class HashLibTestCase(unittest.TestCase):
super(HashLibTestCase, self).__init__(*args, **kwargs)
def test_hash_array(self):
a = array.array("b", range(10))
constructors = self.constructors_to_test.values()
for cons in itertools.chain.from_iterable(constructors):
c = cons(a)
c.hexdigest()
def test_unknown_hash(self):
try:
hashlib.new('spam spam spam spam spam')

View File

@ -214,7 +214,7 @@ if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
## make and run basic tests
F=make-test.out
start=`current_time`
$PYTHON $REGRTEST_ARGS -u urlfetch >& build/$F
$PYTHON $REGRTEST_ARGS -W -u urlfetch >& build/$F
NUM_FAILURES=`count_failures build/$F`
place_summary_first build/$F
update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
@ -222,7 +222,7 @@ if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
F=make-test-opt.out
start=`current_time`
$PYTHON -O $REGRTEST_ARGS -u urlfetch >& build/$F
$PYTHON -O $REGRTEST_ARGS -W -u urlfetch >& build/$F
NUM_FAILURES=`count_failures build/$F`
place_summary_first build/$F
update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
@ -245,7 +245,7 @@ if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
start=`current_time`
## skip curses when running from cron since there's no terminal
## skip sound since it's not setup on the PSF box (/dev/dsp)
$PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev $_ALWAYS_SKIP >& build/$F
$PYTHON $REGRTEST_ARGS -W -uall -x test_curses test_linuxaudiodev test_ossaudiodev &_ALWAYS_SKIP >& build/$F
NUM_FAILURES=`count_failures build/$F`
place_summary_first build/$F
update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start

View File

@ -20,6 +20,9 @@ for details. When the agreement is signed, please note it in this log.
Permissions History
-------------------
- Stefan Krah was given SVN access on January 5 2010 by GFB, at
suggestion of Mark Dickinson, for work on the decimal module.
- Doug Hellmann was given SVN access on September 19 2009 by GFB, at
suggestion of Jesse Noller, for documentation work.

View File

@ -1108,12 +1108,12 @@ class PyBuildExt(build_ext):
# Interface to the Expat XML parser
#
# Expat was written by James Clark and is now maintained by a
# group of developers on SourceForge; see www.libexpat.org for
# more information. The pyexpat module was written by Paul
# Prescod after a prototype by Jack Jansen. The Expat source
# is included in Modules/expat/. Usage of a system
# shared libexpat.so/expat.dll is not advised.
# Expat was written by James Clark and is now maintained by a group of
# developers on SourceForge; see www.libexpat.org for more information.
# The pyexpat module was written by Paul Prescod after a prototype by
# Jack Jansen. The Expat source is included in Modules/expat/. Usage
# of a system shared libexpat.so is possible with --with-system-expat
# cofigure option.
#
# More information on Expat can be found at www.libexpat.org.
#