diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-11-20 01:48:38 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-11-20 01:48:38 (GMT) |
commit | aab9585130d1143f2b734ba67d0676fd874040d8 (patch) | |
tree | 9c40c21af0d2b0f41be2c1fdda8efdb5ea1e3d44 /Parser | |
parent | c9a9417f487beeddbf0af4e253fab3c1545207f4 (diff) | |
download | cpython-aab9585130d1143f2b734ba67d0676fd874040d8.zip cpython-aab9585130d1143f2b734ba67d0676fd874040d8.tar.gz cpython-aab9585130d1143f2b734ba67d0676fd874040d8.tar.bz2 |
Merged revisions 86538 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86538 | benjamin.peterson | 2010-11-19 19:38:49 -0600 (Fri, 19 Nov 2010) | 1 line
use %R format code; fixes invalid dereferencing #10391
........
Diffstat (limited to 'Parser')
-rwxr-xr-x | Parser/asdl_c.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index c1e07d2..087f95a 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -366,19 +366,19 @@ class Obj2ModVisitor(PickleVisitor): self.emit("obj2ast_%s(PyObject* obj, %s* out, PyArena* arena)" % (name, ctype), 0) self.emit("{", 0) self.emit("PyObject* tmp = NULL;", 1) + # Prevent compiler warnings about unused variable. + self.emit("tmp = tmp;", 1) self.emit("int isinstance;", 1) self.emit("", 0) - def sumTrailer(self, name): + def sumTrailer(self, name, add_label=False): self.emit("", 0) - self.emit("tmp = PyObject_Repr(obj);", 1) # there's really nothing more we can do if this fails ... - self.emit("if (tmp == NULL) goto failed;", 1) - error = "expected some sort of %s, but got %%.400s" % name - format = "PyErr_Format(PyExc_TypeError, \"%s\", PyBytes_AS_STRING(tmp));" + error = "expected some sort of %s, but got %%R" % name + format = "PyErr_Format(PyExc_TypeError, \"%s\", obj);" self.emit(format % error, 1, reflow=False) - self.emit("failed:", 0) - self.emit("Py_XDECREF(tmp);", 1) + if add_label: + self.emit("failed:", 1) self.emit("return 1;", 1) self.emit("}", 0) self.emit("", 0) @@ -430,7 +430,7 @@ class Obj2ModVisitor(PickleVisitor): self.emit("if (*out == NULL) goto failed;", 2) self.emit("return 0;", 2) self.emit("}", 1) - self.sumTrailer(name) + self.sumTrailer(name, True) def visitAttributeDeclaration(self, a, name, sum=sum): ctype = get_c_type(a.type) |