Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f47ed4a

Browse files
committed
Merged revisions 70912,70944,70968,71033,71041,71208,71263,71286,71395-71396,71405-71406,71485,71492,71494 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r70912 | georg.brandl | 2009-03-31 17:35:46 -0500 (Tue, 31 Mar 2009) | 1 line #5617: add a handy function to print a unicode string to gdbinit. ........ r70944 | georg.brandl | 2009-03-31 23:32:39 -0500 (Tue, 31 Mar 2009) | 1 line #5631: add upload to list of possible commands, which is presented in --help-commands. ........ r70968 | michael.foord | 2009-04-01 13:25:38 -0500 (Wed, 01 Apr 2009) | 1 line Adding Wing project file ........ r71033 | brett.cannon | 2009-04-01 22:34:53 -0500 (Wed, 01 Apr 2009) | 3 lines Fix two issues introduced by issue #71031 by changing the signature of PyImport_AppendInittab() to take a const char *. ........ r71041 | jesse.noller | 2009-04-02 00:17:26 -0500 (Thu, 02 Apr 2009) | 1 line Add custom initializer argument to multiprocess.Manager*, courtesy of lekma ........ r71208 | michael.foord | 2009-04-04 20:15:01 -0500 (Sat, 04 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 ........ r71263 | michael.foord | 2009-04-05 14:19:28 -0500 (Sun, 05 Apr 2009) | 4 lines Adding assertIs and assertIsNot methods to unittest.TestCase Issue #2578 ........ r71286 | tarek.ziade | 2009-04-05 17:04:38 -0500 (Sun, 05 Apr 2009) | 1 line added a simplest test to distutils.spawn._nt_quote_args ........ r71395 | benjamin.peterson | 2009-04-08 08:27:29 -0500 (Wed, 08 Apr 2009) | 1 line these must be installed to correctly run tests ........ r71396 | benjamin.peterson | 2009-04-08 08:29:41 -0500 (Wed, 08 Apr 2009) | 1 line fix syntax ........ r71405 | andrew.kuchling | 2009-04-09 06:22:47 -0500 (Thu, 09 Apr 2009) | 1 line Add items ........ r71406 | andrew.kuchling | 2009-04-09 06:23:36 -0500 (Thu, 09 Apr 2009) | 1 line Typo fixes ........ r71485 | andrew.kuchling | 2009-04-11 11:12:23 -0500 (Sat, 11 Apr 2009) | 1 line Add various items ........ r71492 | georg.brandl | 2009-04-11 13:19:27 -0500 (Sat, 11 Apr 2009) | 1 line Take credit for a patch of mine. ........ r71494 | benjamin.peterson | 2009-04-11 14:31:00 -0500 (Sat, 11 Apr 2009) | 1 line ignore py3_test_grammar when compiling the library ........
1 parent a0a7faa commit f47ed4a

15 files changed

Lines changed: 320 additions & 34 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,10 @@ their parent process exits. The manager classes are defined in the
11281128
``current_process().authkey``. Otherwise *authkey* is used and it
11291129
must be a string.
11301130

1131-
.. method:: start()
1131+
.. method:: start([initializer[, initargs]])
11321132

1133-
Start a subprocess to start the manager.
1133+
Start a subprocess to start the manager. If *initializer* is not ``None``
1134+
then the subprocess will call ``initializer(*initargs)`` when it starts.
11341135

11351136
.. method:: serve_forever()
11361137

Doc/library/unittest.rst

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ Test cases
689689
assertLessEqual(first, second, msg=None)
690690

691691
Test that *first* is respectively >, >=, < or <= than *second* depending
692-
on the method name. If not, the test will fail with the nice explanation
692+
on the method name. If not, the test will fail with an explanation
693693
or with the explanation given by *msg*::
694694

695695
>>> self.assertGreaterEqual(3, 4)
@@ -722,7 +722,7 @@ Test cases
722722
.. method:: assertIn(first, second, msg=None)
723723
assertNotIn(first, second, msg=None)
724724

725-
Tests that *first* is or is not in *second* with a nice explanitory error
725+
Tests that *first* is or is not in *second* with an explanatory error
726726
message as appropriate.
727727

728728
If specified *msg* will be used as the error message on failure.
@@ -766,7 +766,7 @@ Test cases
766766

767767
.. method:: assertDictContainsSubset(expected, actual, msg=None)
768768

769-
Tests whether the key value pairs in dictionary *actual* are a
769+
Tests whether the key/value pairs in dictionary *actual* are a
770770
superset of those in *expected*. If not, an error message listing
771771
the missing keys and mismatched values is generated.
772772

@@ -858,6 +858,23 @@ Test cases
858858
.. versionadded:: 3.1
859859

860860

861+
.. method:: assertIs(expr1, expr2[, msg])
862+
863+
This signals a test failure if *expr1* and *expr2* don't evaluate to the same
864+
object.
865+
866+
.. versionadded:: 2.7
867+
868+
869+
.. method:: assertIsNot(expr1, expr2[, msg])
870+
871+
The inverse of the :meth:`assertIs` method.
872+
This signals a test failure if *expr1* and *expr2* evaluate to the same
873+
object.
874+
875+
.. versionadded:: 2.7
876+
877+
861878
.. method:: assertFalse(expr[, msg])
862879
failIf(expr[, msg])
863880

@@ -951,12 +968,12 @@ Test cases
951968
been asked to compare are exactly *typeobj* (not subclasses).
952969
*function* must take two positional arguments and a third msg=None
953970
keyword argument just as :meth:`assertEqual` does. It must raise
954-
self.failureException when inequality between the first two
971+
``self.failureException`` when inequality between the first two
955972
parameters is detected.
956973

957974
One good use of custom equality checking functions for a type
958-
is to raise self.failureException with an error message useful
959-
for debugging the by explaining the inequalities in detail.
975+
is to raise ``self.failureException`` with an error message useful
976+
for debugging the problem by explaining the inequalities in detail.
960977

961978
.. versionadded:: 3.1
962979

Doc/whatsnew/2.7.rst

Lines changed: 155 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ Other Language Changes
8888

8989
Some smaller changes made to the core Python language are:
9090

91+
* The string :method:`format` method now supports automatic numbering
92+
of the replacement fields. This makes using :meth:`format`
93+
more closely resemble using ``%s`` formatting::
94+
95+
>>> '{}:{}:{}'.format(2009, 04, 'Sunday')
96+
'2009:4:Sunday'
97+
>>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
98+
'2009:4:Sunday'
99+
100+
The auto-numbering takes the fields from left to right, so the first
101+
``{...}`` specifier will use the first argument to :meth:`format`,
102+
the next specifier will use the next argument, and so on. You can't
103+
mix auto-numbering and explicit numbering -- either number all of
104+
your specifier fields or none of them -- but you can mix
105+
auto-numbering and named fields, as in the second example above.
106+
(Contributed by XXX; :issue`5237`.)
107+
91108
* The :func:`int` and :func:`long` types gained a ``bit_length``
92109
method that returns the number of bits necessary to represent
93110
its argument in binary::
@@ -106,7 +123,7 @@ Some smaller changes made to the core Python language are:
106123
(Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
107124

108125
* The :class:`bytearray` type's :meth:`translate` method will
109-
now accept None as its first argument. (Fixed by Georg Brandl;
126+
now accept ``None`` as its first argument. (Fixed by Georg Brandl;
110127
:issue:`4759`.)
111128

112129
.. ======================================================================
@@ -201,7 +218,7 @@ changes, or look through the Subversion logs for all the details.
201218
management protocol, so you can write ``with bz2.BZ2File(...) as f: ...``.
202219
(Contributed by Hagen Fuerstenau; :issue:`3860`.)
203220

204-
* A new :class:`Counter` class in the :mod:`collections` module is
221+
* New class: the :class:`Counter` class in the :mod:`collections` module is
205222
useful for tallying data. :class:`Counter` instances behave mostly
206223
like dictionaries but return zero for missing keys instead of
207224
raising a :exc:`KeyError`::
@@ -236,7 +253,7 @@ changes, or look through the Subversion logs for all the details.
236253
Contributed by Raymond Hettinger; :issue:`1696199`.
237254

238255
The :class:`namedtuple` class now has an optional *rename* parameter.
239-
If *rename* is True, field names that are invalid because they've
256+
If *rename* is true, field names that are invalid because they've
240257
been repeated or that aren't legal Python identifiers will be
241258
renamed to legal names that are derived from the field's
242259
position within the list of fields:
@@ -247,15 +264,26 @@ changes, or look through the Subversion logs for all the details.
247264

248265
(Added by Raymond Hettinger; :issue:`1818`.)
249266

267+
The :class:`deque` data type now exposes its maximum length as the
268+
read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.)
269+
250270
* In Distutils, :func:`distutils.sdist.add_defaults` now uses
251271
*package_dir* and *data_files* to create the MANIFEST file.
272+
:mod:`distutils.sysconfig` will now read the :envvar:`AR`
273+
environment variable.
252274

253275
It is no longer mandatory to store clear-text passwords in the
254276
:file:`.pypirc` file when registering and uploading packages to PyPI. As long
255277
as the username is present in that file, the :mod:`distutils` package will
256278
prompt for the password if not present. (Added by Tarek Ziade,
257279
based on an initial contribution by Nathan Van Gheem; :issue:`4394`.)
258280

281+
A Distutils setup can now specify that a C extension is optional by
282+
setting the *optional* option setting to true. If this optional is
283+
supplied, failure to build the extension will not abort the build
284+
process, but instead simply not install the failing extension.
285+
(Contributed by Georg Brandl; :issue:`5583`.)
286+
259287
* New method: the :class:`Decimal` class gained a
260288
:meth:`from_float` class method that performs an exact conversion
261289
of a floating-point number to a :class:`Decimal`.
@@ -267,8 +295,8 @@ changes, or look through the Subversion logs for all the details.
267295
``Decimal('0.1000000000000000055511151231257827021181583404541015625')``.
268296
(Implemented by Raymond Hettinger; :issue:`4796`.)
269297

270-
* A new function in the :mod:`gc` module, :func:`is_tracked`, returns
271-
True if a given instance is tracked by the garbage collector, False
298+
* New function: the :mod:`gc` module's :func:`is_tracked` returns
299+
true if a given instance is tracked by the garbage collector, false
272300
otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.)
273301

274302
* The :mod:`gzip` module's :class:`GzipFile` now supports the context
@@ -284,7 +312,7 @@ changes, or look through the Subversion logs for all the details.
284312

285313
* New function: ``itertools.compress(*data*, *selectors*)`` takes two
286314
iterators. Elements of *data* are returned if the corresponding
287-
value in *selectors* is True::
315+
value in *selectors* is true::
288316

289317
itertools.compress('ABCDEF', [1,0,1,0,1,1]) =>
290318
A, C, E, F
@@ -322,12 +350,22 @@ changes, or look through the Subversion logs for all the details.
322350
with any object literal that decodes to a list of pairs.
323351
(Contributed by Raymond Hettinger; :issue:`5381`.)
324352

353+
* The :mod:`multiprocessing` module's :class:`Manager*` classes
354+
can now be passed a callable that will be called whenever
355+
a subprocess is started, along with a set of arguments that will be
356+
passed to the callable.
357+
(Contributed by lekma; :issue:`5585`.)
358+
325359
* The :mod:`pydoc` module now has help for the various symbols that Python
326360
uses. You can now do ``help('<<')`` or ``help('@')``, for example.
327361
(Contributed by David Laban; :issue:`4739`.)
328362

329-
* A new function in the :mod:`subprocess` module,
330-
:func:`check_output`, runs a command with a specified set of arguments
363+
* The :mod:`re` module's :func:`split`, :func:`sub`, and :func:`subn`
364+
now accept an optional *flags* argument, for consistency with the
365+
other functions in the module. (Added by Gregory P. Smith.)
366+
367+
* New function: the :mod:`subprocess` module's
368+
:func:`check_output` runs a command with a specified set of arguments
331369
and returns the command's output as a string when the command runs without
332370
error, or raises a :exc:`CalledProcessError` exception otherwise.
333371

@@ -343,26 +381,99 @@ changes, or look through the Subversion logs for all the details.
343381

344382
(Contributed by Gregory P. Smith.)
345383

384+
* New function: :func:`is_declared_global` in the :mod:`symtable` module
385+
returns true for variables that are explicitly declared to be global,
386+
false for ones that are implicitly global.
387+
(Contributed by Jeremy Hylton.)
388+
346389
* The ``sys.version_info`` value is now a named tuple, with attributes
347390
named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``.
348391
(Contributed by Ross Light; :issue:`4285`.)
349392

393+
* The :mod:`threading` module's :meth:`Event.wait` method now returns
394+
the internal flag on exit. This means the method will usually
395+
return true because :meth:`wait` is supposed to block until the
396+
internal flag becomes true. The return value will only be false if
397+
a timeout was provided and the operation timed out.
398+
(Contributed by XXX; :issue:`1674032`.)
399+
350400
* The :mod:`unittest` module was enhanced in several ways.
401+
The progress messages will now show 'x' for expected failures
402+
and 'u' for unexpected successes when run in verbose mode.
403+
(Contributed by Benjamin Peterson.)
351404
Test cases can raise the :exc:`SkipTest` exception to skip a test.
352405
(:issue:`1034053`.)
353-
It will now use 'x' for expected failures
354-
and 'u' for unexpected successes when run in its verbose mode.
355-
(Contributed by Benjamin Peterson.)
406+
407+
The error messages for :meth:`assertEqual`,
408+
:meth:`assertTrue`, and :meth:`assertFalse`
409+
failures now provide more information. If you set the
410+
:attr:`longMessage` attribute of your :class:`TestCase` classes to
411+
true, both the standard error message and any additional message you
412+
provide will be printed for failures. (Added by Michael Foord; :issue:`5663`.)
356413

357414
The :meth:`assertRaises` and :meth:`failUnlessRaises` methods now
358415
return a context handler when called without providing a callable
359416
object to run. For example, you can write this::
360417

361-
with self.assertRaises(KeyError):
362-
raise ValueError
418+
with self.assertRaises(KeyError):
419+
raise ValueError
363420

364421
(Implemented by Antoine Pitrou; :issue:`4444`.)
365422

423+
A number of new methods were added that provide more specialized
424+
tests. Many of these methods were written by Google engineers
425+
for use in their test suites; Gregory P. Smith, Michael Foord, and
426+
GvR worked on merging them into Python's version of :mod:`unittest`.
427+
428+
* :meth:`assertIsNone` and :meth:`assertIsNotNone` take one
429+
expression and verify that the result is or is not ``None``.
430+
431+
* :meth:`assertIs` and :meth:`assertIsNot` take two values and check
432+
whether the two values evaluate to the same object or not.
433+
(Added by Michael Foord; :issue:`2578`.)
434+
435+
* :meth:`assertGreater`, :meth:`assertGreaterEqual`,
436+
:meth:`assertLess`, and :meth:`assertLessEqual` compare
437+
two quantities.
438+
439+
* :meth:`assertMultiLineEqual` compares two strings, and if they're
440+
not equal, displays a helpful comparison that highlights the
441+
differences in the two strings.
442+
443+
* :meth:`assertRegexpMatches` checks whether its first argument is a
444+
string matching a regular expression provided as its second argument.
445+
446+
* :meth:`assertRaisesRegexp` checks whether a particular exception
447+
is raised, and then also checks that the string representation of
448+
the exception matches the provided regular expression.
449+
450+
* :meth:`assertIn` and :meth:`assertNotIn` tests whether
451+
*first* is or is not in *second*.
452+
453+
* :meth:`assertSameElements` tests whether two provided sequences
454+
contain the same elements.
455+
456+
* :meth:`assertSetEqual` compares whether two sets are equal, and
457+
only reports the differences between the sets in case of error.
458+
459+
* Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual`
460+
compare the specified types and explain the differences.
461+
More generally, :meth:`assertSequenceEqual` compares two sequences
462+
and can optionally check whether both sequences are of a
463+
particular type.
464+
465+
* :meth:`assertDictEqual` compares two dictionaries and reports the
466+
differences. :meth:`assertDictContainsSubset` checks whether
467+
all of the key/value pairs in *first* are found in *second*.
468+
469+
* A new hook, :meth:`addTypeEqualityFunc` takes a type object and a
470+
function. The :meth:`assertEqual` method will use the function
471+
when both of the objects being compared are of the specified type.
472+
This function should compare the two objects and raise an
473+
exception if they don't match; it's a good idea for the function
474+
to provide additional information about why the two objects are
475+
matching, much as the new sequence comparison methods do.
476+
366477
* The :func:`is_zipfile` function in the :mod:`zipfile` module will now
367478
accept a file object, in addition to the path names accepted in earlier
368479
versions. (Contributed by Gabriel Genellina; :issue:`4756`.)
@@ -376,7 +487,37 @@ changes, or look through the Subversion logs for all the details.
376487
importlib: Importing Modules
377488
------------------------------
378489

379-
XXX write this
490+
Python 3.1 includes the :mod:`importlib` package, a re-implementation
491+
of the logic underlying Python's :keyword:`import` statement.
492+
:mod:`importlib` is useful for implementors of Python interpreters and
493+
to user who wish to write new importers that can participate in the
494+
import process. Python 2.7 doesn't contain the complete
495+
:mod:`importlib` package, but instead has a tiny subset that contains
496+
a single function, :func:`import_module`.
497+
498+
``import_module(*name*, *package*=None)`` imports a module. *name* is
499+
a string containing the module or package's name. It's possible to do
500+
relative imports by providing a string that begins with a ``.``
501+
character, such as ``..utils.errors``. For relative imports, the
502+
*package* argument must be provided and is the name of the package that
503+
will be used as the anchor for
504+
the relative import. :func:`import_module` both inserts the imported
505+
module into ``sys.modules`` and returns the module object.
506+
507+
Here are some examples::
508+
509+
>>> from importlib import import_module
510+
>>> anydbm = import_module('anydbm') # Standard absolute import
511+
>>> anydbm
512+
<module 'anydbm' from '/p/python/Lib/anydbm.py'>
513+
>>> # Relative import
514+
>>> sysconfig = import_module('..sysconfig', 'distutils.command')
515+
>>> sysconfig
516+
<module 'distutils.sysconfig' from '/p/python/Lib/distutils/sysconfig.pyc'>
517+
518+
:mod:`importlib` was implemented by Brett Cannon and introduced in
519+
Python 3.1.
520+
380521

381522
ttk: Themed Widgets for Tk
382523
--------------------------

Lib/distutils/command/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'bdist_rpm',
2424
'bdist_wininst',
2525
'check',
26+
'upload',
2627
# These two are reserved for future use:
2728
#'bdist_sdux',
2829
#'bdist_pkgtool',

Lib/distutils/command/check.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def system_message(self, level, message, *children, **kwargs):
2727
self.messages.append((level, message, children, kwargs))
2828

2929
HAS_DOCUTILS = True
30-
except ImportError:
31-
# docutils is not installed
30+
except Exception:
31+
# Catch all exceptions because exceptions besides ImportError probably
32+
# indicate that docutils is not ported to Py3k.
3233
HAS_DOCUTILS = False
3334

3435
class check(Command):

Lib/distutils/tests/test_spawn.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Tests for distutils.spawn."""
2+
import unittest
3+
from distutils.spawn import _nt_quote_args
4+
5+
class SpawnTestCase(unittest.TestCase):
6+
7+
def test_nt_quote_args(self):
8+
9+
for (args, wanted) in ((['with space', 'nospace'],
10+
['"with space"', 'nospace']),
11+
(['nochange', 'nospace'],
12+
['nochange', 'nospace'])):
13+
res = _nt_quote_args(args)
14+
self.assertEquals(res, wanted)
15+
16+
def test_suite():
17+
return unittest.makeSuite(SpawnTestCase)
18+
19+
if __name__ == "__main__":
20+
unittest.main(defaultTest="test_suite")

0 commit comments

Comments
 (0)