[Python-checkins] cpython (merge default -> default): merge

christian.heimes python-checkins at python.org
Sat Oct 6 17:14:18 CEST 2012


http://hg.python.org/cpython/rev/654eb8c3a82e
changeset:   79523:654eb8c3a82e
parent:      79522:f56a49e74178
parent:      79520:7fd068d4ded8
user:        Christian Heimes <christian at cheimes.de>
date:        Sat Oct 06 17:14:02 2012 +0200
summary:
  merge

files:
  Doc/library/zipfile.rst     |  24 ++++++++++++------------
  Lib/lib2to3/btm_utils.py    |   6 ++----
  Lib/lib2to3/pytree.py       |   9 +++------
  Lib/test/test_subprocess.py |  22 ++++++++++++++++++++++
  Lib/unittest/loader.py      |   3 +--
  5 files changed, 40 insertions(+), 24 deletions(-)


diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -61,7 +61,7 @@
 .. class:: ZipInfo(filename='NoName', date_time=(1980,1,1,0,0,0))
 
    Class used to represent information about a member of an archive. Instances
-   of this class are returned by the :meth:`getinfo` and :meth:`infolist`
+   of this class are returned by the :meth:`.getinfo` and :meth:`.infolist`
    methods of :class:`ZipFile` objects.  Most users of the :mod:`zipfile` module
    will not need to create these, but only use those created by this
    module. *filename* should be the full name of the archive member, and
@@ -87,20 +87,20 @@
 .. data:: ZIP_DEFLATED
 
    The numeric constant for the usual ZIP compression method.  This requires the
-   zlib module.
+   :mod:`zlib` module.
 
 
 .. data:: ZIP_BZIP2
 
    The numeric constant for the BZIP2 compression method.  This requires the
-   bz2 module.
+   :mod:`bz2` module.
 
    .. versionadded:: 3.3
 
 .. data:: ZIP_LZMA
 
    The numeric constant for the LZMA compression method.  This requires the
-   lzma module.
+   :mod:`lzma` module.
 
    .. versionadded:: 3.3
 
@@ -155,7 +155,7 @@
    these extensions.
 
    If the file is created with mode ``'a'`` or ``'w'`` and then
-   :meth:`close`\ d without adding any files to the archive, the appropriate
+   :meth:`closed <close>` without adding any files to the archive, the appropriate
    ZIP structures for an empty archive will be written to the file.
 
    ZipFile is also a context manager and therefore supports the
@@ -169,7 +169,7 @@
       Added the ability to use :class:`ZipFile` as a context manager.
 
    .. versionchanged:: 3.3
-      Added support for :mod:`bzip2` and :mod:`lzma` compression.
+      Added support for :mod:`bzip2 <bz2>` and :mod:`lzma` compression.
 
 
 .. method:: ZipFile.close()
@@ -207,7 +207,7 @@
    *mode* parameter, if included, must be one of the following: ``'r'`` (the
    default), ``'U'``, or ``'rU'``. Choosing ``'U'`` or  ``'rU'`` will enable
    :term:`universal newlines` support in the read-only object.  *pwd* is the
-   password used for encrypted files.  Calling  :meth:`open` on a closed
+   password used for encrypted files.  Calling  :meth:`.open` on a closed
    ZipFile will raise a  :exc:`RuntimeError`.
 
    .. note::
@@ -229,7 +229,7 @@
 
    .. note::
 
-      The :meth:`open`, :meth:`read` and :meth:`extract` methods can take a filename
+      The :meth:`.open`, :meth:`read` and :meth:`extract` methods can take a filename
       or a :class:`ZipInfo` object.  You will appreciate this when trying to read a
       ZIP file that contains members with duplicate names.
 
@@ -335,7 +335,7 @@
       :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`.
 
    .. versionchanged:: 3.2
-      The *compression_type* argument.
+      The *compress_type* argument.
 
 The following data attributes are also available:
 
@@ -351,7 +351,7 @@
    The comment text associated with the ZIP file.  If assigning a comment to a
    :class:`ZipFile` instance created with mode 'a' or 'w', this should be a
    string no longer than 65535 bytes.  Comments longer than this will be
-   truncated in the written archive when :meth:`ZipFile.close` is called.
+   truncated in the written archive when :meth:`close` is called.
 
 
 .. _pyzipfile-objects:
@@ -407,8 +407,8 @@
 ZipInfo Objects
 ---------------
 
-Instances of the :class:`ZipInfo` class are returned by the :meth:`getinfo` and
-:meth:`infolist` methods of :class:`ZipFile` objects.  Each object stores
+Instances of the :class:`ZipInfo` class are returned by the :meth:`.getinfo` and
+:meth:`.infolist` methods of :class:`ZipFile` objects.  Each object stores
 information about a single member of the ZIP archive.
 
 Instances have the following attributes:
diff --git a/Lib/lib2to3/btm_utils.py b/Lib/lib2to3/btm_utils.py
--- a/Lib/lib2to3/btm_utils.py
+++ b/Lib/lib2to3/btm_utils.py
@@ -96,8 +96,7 @@
     def leaves(self):
         "Generator that returns the leaves of the tree"
         for child in self.children:
-            for x in child.leaves():
-                yield x
+            yield from child.leaves()
         if not self.children:
             yield self
 
@@ -277,7 +276,6 @@
     sub-iterables"""
     for x in sequence:
         if isinstance(x, (list, tuple)):
-            for y in rec_test(x, test_func):
-                yield y
+            yield from rec_test(x, test_func)
         else:
             yield test_func(x)
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py
--- a/Lib/lib2to3/pytree.py
+++ b/Lib/lib2to3/pytree.py
@@ -194,8 +194,7 @@
 
     def leaves(self):
         for child in self.children:
-            for x in child.leaves():
-                yield x
+            yield from child.leaves()
 
     def depth(self):
         if self.parent is None:
@@ -274,16 +273,14 @@
     def post_order(self):
         """Return a post-order iterator for the tree."""
         for child in self.children:
-            for node in child.post_order():
-                yield node
+            yield from child.post_order()
         yield self
 
     def pre_order(self):
         """Return a pre-order iterator for the tree."""
         yield self
         for child in self.children:
-            for node in child.pre_order():
-                yield node
+            yield from child.pre_order()
 
     def _prefix_getter(self):
         """
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -192,6 +192,28 @@
         p.wait()
         self.assertEqual(p.stderr, None)
 
+    @unittest.skipIf(mswindows, "path not included in Windows message")
+    def test_path_in_arg_not_found_message(self):
+        # Check that the error message displays the path not found when
+        # args[0] is not found.
+        self.assertRaisesRegex(FileNotFoundError, "notfound_blahblah",
+                               subprocess.Popen, ["notfound_blahblah"])
+
+    @unittest.skipIf(mswindows, "path not displayed in Windows message")
+    def test_path_in_executable_not_found_message(self):
+        # Check that the error message displays the executable argument (and
+        # not args[0]) when the executable argument is not found
+        # (issue #16114).
+        #     We call sys.exit() inside the code to prevent the test runner
+        # from hanging if the test fails and finds python.
+        self.assertRaisesRegex(FileNotFoundError, "notfound_blahblah",
+                               subprocess.Popen, [sys.executable, "-c",
+                               "import sys; sys.exit(47)"],
+                               executable="notfound_blahblah")
+        self.assertRaisesRegex(FileNotFoundError, "exenotfound_blahblah",
+                               subprocess.Popen, ["argnotfound_blahblah"],
+                               executable="exenotfound_blahblah")
+
     # For use in the test_cwd* tests below.
     def _normalize_cwd(self, cwd):
         # Normalize an expected cwd (for Tru64 support).
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -291,8 +291,7 @@
                         # tests loaded from package file
                         yield tests
                     # recurse into the package
-                    for test in self._find_tests(full_path, pattern):
-                        yield test
+                    yield from self._find_tests(full_path, pattern)
                 else:
                     try:
                         yield load_tests(self, tests, pattern)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list