* A version of the :mod:`io` library, rewritten in C for performance.
* The ordered-dictionary type described in :ref:`pep-0372`.
-* The new format specified described in :ref:`pep-0378`.
+* The new format specifier described in :ref:`pep-0378`.
* The :class:`memoryview` object.
* A small subset of the :mod:`importlib` module `described below <#importlib-section>`__.
more sensible for numeric types. (Changed by Mark Dickinson; :issue:`6857`.)
* Distutils is being more actively developed, thanks to Tarek Ziade
- has taken over maintenance of the package. A new
+ who has taken over maintenance of the package. A new
:file:`setup.py` subcommand, ``check``, will
check that the arguments being passed to the :func:`setup` function
are complete and correct (:issue:`5732`).
an invalid file descriptor. (Implemented by Benjamin Peterson;
:issue:`4991`.)
-* New function: ``itertools.compress(*data*, *selectors*)`` takes two
+* New function: ``itertools.compress(data, selectors)`` takes two
iterators. Elements of *data* are returned if the corresponding
value in *selectors* is true::
itertools.compress('ABCDEF', [1,0,1,0,1,1]) =>
A, C, E, F
- New function: ``itertools.combinations_with_replacement(*iter*, *r*)``
+ New function: ``itertools.combinations_with_replacement(iter, r)``
returns all the possible *r*-length combinations of elements from the
iterable *iter*. Unlike :func:`combinations`, individual elements
can be repeated in the generated combinations::
The author would like to thank the following people for offering
suggestions, corrections and assistance with various drafts of this
-article: no one yet.
+article: Ryan Lovett, Hugh Secker-Walker.
self.emit("obj2ast_%s(PyObject* obj, %s* out, PyArena* arena)" % (name, ctype), 0)
self.emit("{", 0)
self.emit("PyObject* tmp = NULL;", 1)
+ self.emit("int isinstance;", 1)
self.emit("", 0)
def sumTrailer(self, name):
def simpleSum(self, sum, name):
self.funcHeader(name)
for t in sum.types:
- self.emit("if (PyObject_IsInstance(obj, (PyObject*)%s_type)) {" % t.name, 1)
+ line = ("isinstance = PyObject_IsInstance(obj, "
+ "(PyObject *)%s_type);")
+ self.emit(line % (t.name,), 1)
+ self.emit("if (isinstance == -1) {", 1)
+ self.emit("return 1;", 2)
+ self.emit("}", 1)
+ self.emit("if (isinstance) {", 1)
self.emit("*out = %s;" % t.name, 2)
self.emit("return 0;", 2)
self.emit("}", 1)
for a in sum.attributes:
self.visitField(a, name, sum=sum, depth=1)
for t in sum.types:
- self.emit("if (PyObject_IsInstance(obj, (PyObject*)%s_type)) {" % t.name, 1)
+ line = "isinstance = PyObject_IsInstance(obj, (PyObject*)%s_type);"
+ self.emit(line % (t.name,), 1)
+ self.emit("if (isinstance == -1) {", 1)
+ self.emit("return 1;", 2)
+ self.emit("}", 1)
+ self.emit("if (isinstance) {", 1)
for f in t.fields:
self.visitFieldDeclaration(f, t.name, sum=sum, depth=2)
self.emit("", 0)
PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
(PyObject*)Interactive_type};
char *req_name[] = {"Module", "Expression", "Interactive"};
+ int isinstance;
assert(0 <= mode && mode <= 2);
init_types();
- if (!PyObject_IsInstance(ast, req_type[mode])) {
+ isinstance = PyObject_IsInstance(ast, req_type[mode]);
+ if (isinstance == -1)
+ return NULL;
+ if (!isinstance) {
PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
req_name[mode], Py_TYPE(ast)->tp_name);
return NULL;