From 9753b483e85c8cd2d3b3aff04f8d4bcb1aee8061 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Feb 2009 03:32:23 +0000 Subject: [PATCH] Merged revisions 69754,69794 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r69754 | benjamin.peterson | 2009-02-18 22:22:03 -0600 (Wed, 18 Feb 2009) | 54 lines Merged revisions 69576,69579-69580,69589,69619-69620,69633,69703-69704,69728-69730 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69576 | georg.brandl | 2009-02-13 04:56:50 -0600 (Fri, 13 Feb 2009) | 1 line #1661108: note that urlsafe encoded string can contain "=". ........ r69579 | georg.brandl | 2009-02-13 05:06:59 -0600 (Fri, 13 Feb 2009) | 2 lines Fix warnings GCC emits where the argument of PyErr_Format is a single variable. ........ r69580 | georg.brandl | 2009-02-13 05:10:04 -0600 (Fri, 13 Feb 2009) | 2 lines Fix warnings GCC emits where the argument of PyErr_Format is a single variable. ........ r69589 | martin.v.loewis | 2009-02-13 14:11:34 -0600 (Fri, 13 Feb 2009) | 2 lines Move amd64 properties further to the top, so that they override the linker options correctly. ........ r69619 | benjamin.peterson | 2009-02-14 11:00:51 -0600 (Sat, 14 Feb 2009) | 1 line this needn't be a shebang line ........ r69620 | georg.brandl | 2009-02-14 11:01:36 -0600 (Sat, 14 Feb 2009) | 1 line #5179: don't leak PIPE fds when child execution fails. ........ r69633 | hirokazu.yamamoto | 2009-02-15 03:19:48 -0600 (Sun, 15 Feb 2009) | 1 line Fixed typo. ........ r69703 | raymond.hettinger | 2009-02-16 16:42:54 -0600 (Mon, 16 Feb 2009) | 3 lines Issue 5229: Documentation for super() neglects to say what super() actually does ........ r69704 | raymond.hettinger | 2009-02-16 17:00:25 -0600 (Mon, 16 Feb 2009) | 1 line Add explanation for super(type1, type2). ........ r69728 | georg.brandl | 2009-02-17 18:22:55 -0600 (Tue, 17 Feb 2009) | 2 lines #5297: fix example. ........ r69729 | georg.brandl | 2009-02-17 18:25:13 -0600 (Tue, 17 Feb 2009) | 2 lines #5296: sequence -> iterable. ........ r69730 | georg.brandl | 2009-02-17 18:31:36 -0600 (Tue, 17 Feb 2009) | 2 lines #5268: mention VMSError. ........ ................ r69794 | benjamin.peterson | 2009-02-19 21:19:25 -0600 (Thu, 19 Feb 2009) | 1 line fix None errno #5312 ................ --- Doc/library/base64.rst | 3 ++- Doc/library/exceptions.rst | 5 +++++ Doc/library/functions.rst | 15 +++++++++------ Doc/library/socketserver.rst | 2 +- Doc/reference/simple_stmts.rst | 13 +++++++++---- Lib/os.py | 4 ++-- Lib/subprocess.py | 3 +++ Lib/test/test_pep263.py | 2 +- Lib/test/test_subprocess.py | 16 ++++++++++++++++ Modules/_ctypes/_ctypes.c | 14 ++++++++------ Objects/unicodeobject.c | 6 +++--- PCbuild/sqlite3.vcproj | 8 ++++---- 12 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst index 35b61aeab4ea..9818ea08bba9 100644 --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -62,7 +62,8 @@ The modern interface provides: .. function:: urlsafe_b64encode(s) Encode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of - ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. + ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. The result + can still contain ``=``. .. function:: urlsafe_b64decode(s) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 7129df50d687..b1626f26bafd 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -348,6 +348,11 @@ The following exceptions are the exceptions that are actually raised. more precise exception such as :exc:`IndexError`. +.. exception:: VMSError + + Only available on VMS. Raised when a VMS-specific error occurs. + + .. exception:: WindowsError Raised when a Windows-specific error occurs or when the error number does not diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 0cd1ce14e4ec..79fd4f4ecc31 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1039,16 +1039,19 @@ are always available. They are listed here in alphabetical order. .. function:: super([type[, object-or-type]]) - Return a *super* object that acts as a proxy to superclasses of *type*. + Return a proxy object that delegates method calls to a parent class of + *type*. This is useful for accessing inherited methods that have been + overriden in a child class. The search order for parent classes is + determined by the ``__mro__`` attribute of the *type* and can change + whenever the parent classes are updated. If the second argument is omitted the super object returned is unbound. If the second argument is an object, ``isinstance(obj, type)`` must be true. If - the second argument is a type, ``issubclass(type2, type)`` must be true. - Calling :func:`super` without arguments is equivalent to ``super(this_class, - first_arg)``. + the second argument is a type, ``issubclass(type2, type)`` must be true (this + is useful for classmethods). - There are two typical use cases for :func:`super`. In a class hierarchy with - single inheritance, :func:`super` can be used to refer to parent classes without + There are two typical use cases for "super". In a class hierarchy with + single inheritance, "super" can be used to refer to parent classes without naming them explicitly, thus making the code more maintainable. This use closely parallels the use of "super" in other programming languages. diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst index d827b9e713ff..f82f53881673 100644 --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -508,7 +508,7 @@ An example for the :class:`ThreadingMixIn` class:: # Exit the server thread when the main thread terminates server_thread.setDaemon(True) server_thread.start() - print("Server loop running in thread:", server_thread.getName()) + print("Server loop running in thread:", server_thread.name) client(ip, port, b"Hello World 1") client(ip, port, b"Hello World 2") diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index d54499081666..f12daf9e7274 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -116,7 +116,12 @@ square brackets, is recursively defined as follows. * If the target list is a single target: The object is assigned to that target. -* If the target list is a comma-separated list of targets: +* If the target list is a comma-separated list of targets: The object must be an + iterable with the same number of items as there are targets in the target list, + and the items are assigned, from left to right, to the corresponding targets. + (This rule is relaxed as of Python 1.5; in earlier versions, the object had to + be a tuple. Since strings are sequences, an assignment like ``a, b = "xy"`` is + now legal as long as the string has the right length.) * If the target list contains one target prefixed with an asterisk, called a "starred" target: The object must be a sequence with at least as many items @@ -152,9 +157,9 @@ Assignment of an object to a single target is recursively defined as follows. be deallocated and its destructor (if it has one) to be called. * If the target is a target list enclosed in parentheses or in square brackets: - The object must be a sequence with the same number of items as there are targets - in the target list, and its items are assigned, from left to right, to the - corresponding targets. + The object must be an iterable with the same number of items as there are + targets in the target list, and its items are assigned, from left to right, + to the corresponding targets. .. index:: pair: attribute; assignment diff --git a/Lib/os.py b/Lib/os.py index 5a020d322791..65f88ba1892b 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -372,8 +372,8 @@ def _execvpe(file, args, env=None): saved_exc = e saved_tb = tb if saved_exc: - raise error(saved_exc).with_traceback(saved_tb) - raise error(last_exc).with_traceback(tb) + raise saved_exc.with_traceback(saved_tb) + raise last_exc.with_traceback(tb) # Change environ to automatically call putenv(), unsetenv if they exist. diff --git a/Lib/subprocess.py b/Lib/subprocess.py index ac92185b6f5d..ad91bec60690 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1094,6 +1094,9 @@ class Popen(object): if data: os.waitpid(self.pid, 0) child_exception = pickle.loads(data) + for fd in (p2cwrite, c2pread, errread): + if fd is not None: + os.close(fd) raise child_exception diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py index 17abbd807a01..a594cc4c6c29 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -1,4 +1,4 @@ -#! -*- coding: koi8-r -*- +# -*- coding: koi8-r -*- # This file is marked as binary in the CVS, to prevent MacCVS from recoding it. import unittest diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index f4f1cd5a86d0..916ffb2215a6 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -487,6 +487,22 @@ class ProcessTestCase(unittest.TestCase): p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) self.assertEqual(p.wait(), 0) + def test_leaking_fds_on_error(self): + # see bug #5179: Popen leaks file descriptors to PIPEs if + # the child fails to execute; this will eventually exhaust + # the maximum number of open fds. 1024 seems a very common + # value for that limit, but Windows has 2048, so we loop + # 1024 times (each call leaked two fds). + for i in range(1024): + try: + subprocess.Popen(['nonexisting_i_hope'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # Windows raises IOError + except (IOError, OSError) as err: + if err.errno != 2: # ignore "no such file" + raise + # # POSIX tests # diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 9eb497538e3e..61d34ab1c3ce 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -566,13 +566,14 @@ CDataType_in_dll(PyObject *type, PyObject *args) #else address = (void *)ctypes_dlsym(handle, name); if (!address) { - PyErr_Format(PyExc_ValueError, #ifdef __CYGWIN__ /* dlerror() isn't very helpful on cygwin */ + PyErr_Format(PyExc_ValueError, "symbol '%s' not found (%s) ", - name, + name); +#else + PyErr_SetString(PyExc_ValueError, ctypes_dlerror()); #endif - ctypes_dlerror()); return NULL; } #endif @@ -3208,13 +3209,14 @@ CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) #else address = (PPROC)ctypes_dlsym(handle, name); if (!address) { - PyErr_Format(PyExc_AttributeError, #ifdef __CYGWIN__ /* dlerror() isn't very helpful on cygwin */ + PyErr_Format(PyExc_AttributeError, "function '%s' not found (%s) ", - name, + name); +#else + PyErr_SetString(PyExc_AttributeError, ctypes_dlerror()); #endif - ctypes_dlerror()); return NULL; } #endif diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index f099bd1904db..21917f2a6ed3 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1591,7 +1591,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { - PyErr_Format(PyExc_TypeError, &argparse[4]); + PyErr_SetString(PyExc_TypeError, &argparse[4]); goto onError; } if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type, &repunicode, &newpos)) @@ -3665,7 +3665,7 @@ static PyObject *unicode_encode_call_errorhandler(const char *errors, if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { - PyErr_Format(PyExc_TypeError, &argparse[4]); + PyErr_SetString(PyExc_TypeError, &argparse[4]); Py_DECREF(restuple); return NULL; } @@ -4929,7 +4929,7 @@ static PyObject *unicode_translate_call_errorhandler(const char *errors, if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { - PyErr_Format(PyExc_TypeError, &argparse[4]); + PyErr_SetString(PyExc_TypeError, &argparse[4]); Py_DECREF(restuple); return NULL; } diff --git a/PCbuild/sqlite3.vcproj b/PCbuild/sqlite3.vcproj index 0af1cdc07b72..70badf5fe2dc 100644 --- a/PCbuild/sqlite3.vcproj +++ b/PCbuild/sqlite3.vcproj @@ -82,7 +82,7 @@ @@ -327,7 +327,7 @@ @@ -449,7 +449,7 @@ -- 2.47.3