]> granicus.if.org Git - python/commitdiff
Merged revisions 78101,78115,78117,78182,78188,78245,78386,78496 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sun, 14 Mar 2010 10:51:01 +0000 (10:51 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 14 Mar 2010 10:51:01 +0000 (10:51 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78101 | georg.brandl | 2010-02-08 01:04:54 +0100 (Mo, 08 Feb 2010) | 1 line

  Fix test_fnmatch.
........
  r78115 | georg.brandl | 2010-02-08 23:40:51 +0100 (Mo, 08 Feb 2010) | 1 line

  Fix missing string formatting placeholder.
........
  r78117 | georg.brandl | 2010-02-08 23:48:37 +0100 (Mo, 08 Feb 2010) | 1 line

  Convert test failure from output-producing to self.fail().
........
  r78182 | georg.brandl | 2010-02-14 09:18:23 +0100 (So, 14 Feb 2010) | 1 line

  #7926: fix stray parens.
........
  r78188 | georg.brandl | 2010-02-14 14:38:12 +0100 (So, 14 Feb 2010) | 1 line

  #7926: fix-up wording.
........
  r78245 | georg.brandl | 2010-02-19 20:36:08 +0100 (Fr, 19 Feb 2010) | 1 line

  #7967: PyXML is no more.
........
  r78386 | georg.brandl | 2010-02-23 22:48:57 +0100 (Di, 23 Feb 2010) | 1 line

  #6544: fix refleak in kqueue, occurring in certain error conditions.
........
  r78496 | georg.brandl | 2010-02-27 15:58:08 +0100 (Sa, 27 Feb 2010) | 1 line

  Link to http://www.python.org/dev/workflow/ from bugs page.
........

Doc/bugs.rst
Doc/whatsnew/2.6.rst
Lib/test/test_fnmatch.py
Lib/test/test_strftime.py
Misc/NEWS
Modules/selectmodule.c

index dc7d388bcc3d74c3cb62b9bbcc2395522d0d4fd2..4db2433a1d6685430c06dc49b6db828a156fa99e 100644 (file)
@@ -23,10 +23,9 @@ In the case of documentation bugs, look at the most recent development docs at
 http://docs.python.org/dev to see if the bug has been fixed.
 
 If the problem you're reporting is not already in the bug tracker, go back to
-the Python Bug Tracker.  If you don't already have a tracker account, select the
-"Register" link in the sidebar and undergo the registration procedure.
-Otherwise, if you're not logged in, enter your credentials and select "Login".
-It is not possible to submit a bug report anonymously.
+the Python Bug Tracker and log in.  If you don't already have a tracker account,
+select the "Register" link or, if you use OpenID, one of the OpenID provider
+logos in the sidebar.  It is not possible to submit a bug report anonymously.
 
 Being now logged in, you can submit a bug.  Select the "Create New" link in the
 sidebar to open the bug reporting form.
@@ -43,7 +42,8 @@ were using (including version information as appropriate).
 
 Each bug report will be assigned to a developer who will determine what needs to
 be done to correct the problem.  You will receive an update each time action is
-taken on the bug.
+taken on the bug.  See http://www.python.org/dev/workflow/ for a detailed
+description of the issue workflow.
 
 
 .. seealso::
index 7c5902274d26edbb4c5388dea6aab3e3d491a240..1952032025915e7216407092d006702223f0e3ea 100644 (file)
@@ -350,9 +350,10 @@ A high-level explanation of the context management protocol is:
 
 * The code in *BLOCK* is executed.
 
-* If *BLOCK* raises an exception, the :meth:`__exit__(type, value, traceback)`
-  is called with the exception details, the same values returned by
-  :func:`sys.exc_info`.  The method's return value controls whether the exception
+* If *BLOCK* raises an exception, the context manager's :meth:`__exit__` method
+  is called with three arguments, the exception details (``type, value, traceback``,
+  the same values returned by :func:`sys.exc_info`, which can also be ``None``
+  if no exception occurred).  The method's return value controls whether an exception
   is re-raised: any false value re-raises the exception, and ``True`` will result
   in suppressing it.  You'll only rarely want to suppress the exception, because
   if you do the author of the code containing the ':keyword:`with`' statement will
@@ -463,7 +464,7 @@ could be written as::
    with db_transaction(db) as cursor:
        ...
 
-The :mod:`contextlib` module also has a :func:`nested(mgr1, mgr2, ...)` function
+The :mod:`contextlib` module also has a ``nested(mgr1, mgr2, ...)`` function
 that combines a number of context managers so you don't need to write nested
 ':keyword:`with`' statements.  In this example, the single ':keyword:`with`'
 statement both starts a database transaction and acquires a thread lock::
@@ -472,8 +473,9 @@ statement both starts a database transaction and acquires a thread lock::
    with nested (db_transaction(db), lock) as (cursor, locked):
        ...
 
-Finally, the :func:`closing(object)` function returns *object* so that it can be
-bound to a variable, and calls ``object.close`` at the end of the block. ::
+Finally, the :func:`closing` function returns its argument so that it can be
+bound to a variable, and calls the argument's ``.close()`` method at the end
+of the block. ::
 
    import urllib, sys
    from contextlib import closing
index 2b510995796f1e4507a4767264b428879253fd11..6d2f9ada561619c47e4c996d2000a556b66157b9 100644 (file)
@@ -7,13 +7,13 @@ from fnmatch import fnmatch, fnmatchcase
 
 
 class FnmatchTestCase(unittest.TestCase):
-    def check_match(self, filename, pattern, should_match=1):
+    def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
         if should_match:
-            self.assertTrue(fnmatch(filename, pattern),
+            self.assertTrue(fn(filename, pattern),
                          "expected %r to match pattern %r"
                          % (filename, pattern))
         else:
-            self.assertTrue(not fnmatch(filename, pattern),
+            self.assertTrue(not fn(filename, pattern),
                          "expected %r not to match pattern %r"
                          % (filename, pattern))
 
@@ -52,8 +52,8 @@ class FnmatchTestCase(unittest.TestCase):
 
     def test_fnmatchcase(self):
         check = self.check_match
-        check('AbC', 'abc', 0)
-        check('abc', 'AbC', 0)
+        check('AbC', 'abc', 0, fnmatchcase)
+        check('abc', 'AbC', 0, fnmatchcase)
 
     def test_bytes(self):
         self.check_match(b'test', b'te*')
index 41144b720be862ff730b1f13a18c3d8e97b0327b..14057eb34acbb0ca03189d61e4953cb0e8d3abdb 100644 (file)
@@ -116,16 +116,15 @@ class StrftimeTest(unittest.TestCase):
             try:
                 result = time.strftime(e[0], now)
             except ValueError as error:
-                print("Standard '%s' format gaver error:" % (e[0], error))
-                continue
+                self.fail("strftime '%s' format gave error: %s" % (e[0], error))
             if re.match(escapestr(e[1], self.ampm), result):
                 continue
             if not result or result[0] == '%':
-                print("Does not support standard '%s' format (%s)" % \
-                       (e[0], e[2]))
+                self.fail("strftime does not support standard '%s' format (%s)"
+                          % (e[0], e[2]))
             else:
-                print("Conflict for %s (%s):" % (e[0], e[2]))
-                print("  Expected %s, but got %s" % (e[1], result))
+                self.fail("Conflict for %s (%s): expected %s, but got %s"
+                          % (e[0], e[2], e[1], result))
 
     def strftest2(self, now):
         nowsecs = str(int(now))[:-1]
index 8651d1fb63d15809714c5fbc2e8fcb5ce2b3a27b..b8c098c353e9a7e9fab5b26a6cd4508d5580ed57 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -781,6 +781,9 @@ Library
 Extension Modules
 -----------------
 
+- Issue #6544: fix a reference leak in the kqueue implementation's error
+  handling.
+
 - Stop providing crtassem.h symbols when compiling with Visual Studio 2010, as
   msvcr100.dll is not a platform assembly anymore.
 
index 9f1b96825e8beabdadb1f5eb66ae344395ec911b..c13bab91fc3e938ea20d0267d974e24125cc29bb 100644 (file)
@@ -1241,6 +1241,7 @@ static struct PyMemberDef kqueue_event_members[] = {
 #undef KQ_OFF
 
 static PyObject *
+
 kqueue_event_repr(kqueue_event_Object *s)
 {
        char buf[1024];
@@ -1526,19 +1527,6 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                return NULL;
        }
 
-       if (ch != NULL && ch != Py_None) {
-               it = PyObject_GetIter(ch);
-               if (it == NULL) {
-                       PyErr_SetString(PyExc_TypeError,
-                                       "changelist is not iterable");
-                       return NULL;
-               }
-               nchanges = PyObject_Size(ch);
-               if (nchanges < 0) {
-                       return NULL;
-               }
-       }
-
        if (otimeout == Py_None || otimeout == NULL) {
                ptimeoutspec = NULL;
        }
@@ -1574,11 +1562,22 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                return NULL;
        }
 
-       if (nchanges) {
+       if (ch != NULL && ch != Py_None) {
+               it = PyObject_GetIter(ch);
+               if (it == NULL) {
+                       PyErr_SetString(PyExc_TypeError,
+                                       "changelist is not iterable");
+                       return NULL;
+               }
+               nchanges = PyObject_Size(ch);
+               if (nchanges < 0) {
+                       goto error;
+               }
+
                chl = PyMem_New(struct kevent, nchanges);
                if (chl == NULL) {
                        PyErr_NoMemory();
-                       return NULL;
+                       goto error;
                }
                i = 0;
                while ((ei = PyIter_Next(it)) != NULL) {
@@ -1601,7 +1600,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                evl = PyMem_New(struct kevent, nevents);
                if (evl == NULL) {
                        PyErr_NoMemory();
-                       return NULL;
+                       goto error;
                }
        }