From 4b47002198f2c0404e16d2f02786845d6d3a0d3b Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 31 Aug 2009 21:43:11 -0700 Subject: Update Python C extension for new upb_array API. --- lang_ext/python/cext.c | 1 + lang_ext/python/pb.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'lang_ext/python') diff --git a/lang_ext/python/cext.c b/lang_ext/python/cext.c index 5336f2d..c2199c4 100644 --- a/lang_ext/python/cext.c +++ b/lang_ext/python/cext.c @@ -11,6 +11,7 @@ PyMODINIT_FUNC initcext(void) { PyObject *mod = Py_InitModule("upb.cext", NULL); + (void)mod; initdefinition(); initpb(); } diff --git a/lang_ext/python/pb.c b/lang_ext/python/pb.c index 0f52bb8..634b397 100644 --- a/lang_ext/python/pb.c +++ b/lang_ext/python/pb.c @@ -316,7 +316,7 @@ PyObject* fieldop_call(PyObject *callable, PyObject *args, PyObject *kw) PyErr_SetString(PyExc_IndexError, "assignment to invalid index"); return NULL; } - p = upb_array_getelementptr(*p.arr, i, f->type); + p = upb_array_getelementptr(*p.arr, i); } else { /* obj.set_foo(val) */ if(!PyArg_ParseTuple(args, "O", &val)) return NULL; @@ -357,8 +357,8 @@ PyObject* fieldop_call(PyObject *callable, PyObject *args, PyObject *kw) } upb_arraylen_t len = (*p.arr)->len; - union upb_value_ptr elem_p = upb_array_getelementptr(*p.arr, len, f->type); - upb_array_resize(*p.arr, len + 1); + union upb_value_ptr elem_p = upb_array_getelementptr(*p.arr, len); + upb_array_append(*p.arr); if(upb_issubmsg(f)) { /* string or submsg. */ @@ -386,7 +386,7 @@ PyObject* fieldop_call(PyObject *callable, PyObject *args, PyObject *kw) PyErr_SetString(PyExc_IndexError, "get from invalid index"); return NULL; } - p = upb_array_getelementptr(*p.arr, i, f->type); + p = upb_array_getelementptr(*p.arr, i); } else { /* obj.foo() */ EXPECT_NO_ARGS; -- cgit v1.2.3