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.
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::
* 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
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::
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
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))
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*')
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]
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.
#undef KQ_OFF
static PyObject *
+
kqueue_event_repr(kqueue_event_Object *s)
{
char buf[1024];
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;
}
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) {
evl = PyMem_New(struct kevent, nevents);
if (evl == NULL) {
PyErr_NoMemory();
- return NULL;
+ goto error;
}
}