Mercurial > cpython-lru_cache-weakref
changeset 57675:087fe5fa113c
Merged revisions 76534,76538,76628,76701,76774 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76534 | martin.v.loewis | 2009-11-26 02:42:05 -0600 (Thu, 26 Nov 2009) | 2 lines
Fix typo.
........
r76538 | georg.brandl | 2009-11-26 14:48:25 -0600 (Thu, 26 Nov 2009) | 1 line
#7400: typo.
........
r76628 | andrew.kuchling | 2009-12-02 08:27:11 -0600 (Wed, 02 Dec 2009) | 1 line
Markup fixes
........
r76701 | andrew.kuchling | 2009-12-07 20:37:05 -0600 (Mon, 07 Dec 2009) | 1 line
Typo fix; grammar fix
........
r76774 | benjamin.peterson | 2009-12-12 18:54:15 -0600 (Sat, 12 Dec 2009) | 1 line
account for PyObject_IsInstance's new ability to fail
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 13 Dec 2009 01:23:39 +0000 |
| parents | 8048569eb53f |
| children | d8c5e38515b6 |
| files | Doc/library/functions.rst Doc/whatsnew/2.7.rst Parser/asdl_c.py Python/bltinmodule.c |
| diffstat | 4 files changed, 30 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Doc/library/functions.rst Sun Dec 13 00:38:59 2009 +0000 +++ b/Doc/library/functions.rst Sun Dec 13 01:23:39 2009 +0000 @@ -973,7 +973,7 @@ .. function:: set([iterable]) :noindex: - Return a new set, optionally with elements are taken from *iterable*. + Return a new set, optionally with elements taken from *iterable*. The set type is described in :ref:`types-set`.
--- a/Doc/whatsnew/2.7.rst Sun Dec 13 00:38:59 2009 +0000 +++ b/Doc/whatsnew/2.7.rst Sun Dec 13 01:23:39 2009 +0000 @@ -70,7 +70,7 @@ * 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>`__. @@ -515,7 +515,7 @@ 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`). @@ -587,14 +587,14 @@ 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:: @@ -1080,5 +1080,5 @@ 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.
--- a/Parser/asdl_c.py Sun Dec 13 00:38:59 2009 +0000 +++ b/Parser/asdl_c.py Sun Dec 13 01:23:39 2009 +0000 @@ -366,6 +366,7 @@ 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): @@ -385,7 +386,13 @@ 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) @@ -407,7 +414,12 @@ 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) @@ -1077,11 +1089,15 @@ 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;
--- a/Python/bltinmodule.c Sun Dec 13 00:38:59 2009 +0000 +++ b/Python/bltinmodule.c Sun Dec 13 01:23:39 2009 +0000 @@ -529,6 +529,7 @@ int mode = -1; int dont_inherit = 0; int supplied_flags = 0; + int is_ast; PyCompilerFlags cf; PyObject *cmd; static char *kwlist[] = {"source", "filename", "mode", "flags", @@ -567,7 +568,10 @@ return NULL; } - if (PyAST_Check(cmd)) { + is_ast = PyAST_Check(cmd); + if (is_ast == -1) + return NULL; + if (is_ast) { PyObject *result; if (supplied_flags & PyCF_ONLY_AST) { Py_INCREF(cmd);
