diff options
author | Christian Heimes <christian@cheimes.de> | 2013-11-14 00:48:32 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-11-14 00:48:32 (GMT) |
commit | c6ae813011bc588dd78f0f2fbbff61d789fe2c19 (patch) | |
tree | 024daed2375675e91272f4ffefb0d93ca12774b9 | |
parent | 6a3db25c70965790893e51febe139215b22b40c5 (diff) | |
parent | 541067a64077998b486be183fdaffec42fe3fae8 (diff) | |
download | cpython-c6ae813011bc588dd78f0f2fbbff61d789fe2c19.zip cpython-c6ae813011bc588dd78f0f2fbbff61d789fe2c19.tar.gz cpython-c6ae813011bc588dd78f0f2fbbff61d789fe2c19.tar.bz2 |
merge
-rw-r--r-- | Modules/_pickle.c | 17 | ||||
-rw-r--r-- | Modules/arraymodule.c | 18 | ||||
-rw-r--r-- | Python/peephole.c | 1 |
3 files changed, 21 insertions, 15 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 75b0441..9852cd3 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -136,6 +136,7 @@ static PyObject *empty_tuple = NULL; /* For looking up name pairs in copyreg._extension_registry. */ static PyObject *two_tuple = NULL; +_Py_IDENTIFIER(__name__); _Py_IDENTIFIER(modules); static int @@ -2599,7 +2600,6 @@ save_dict(PicklerObject *self, PyObject *obj) static int save_global(PicklerObject *self, PyObject *obj, PyObject *name) { - static PyObject *name_str = NULL; PyObject *global_name = NULL; PyObject *module_name = NULL; PyObject *module = NULL; @@ -2608,18 +2608,12 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name) const char global_op = GLOBAL; - if (name_str == NULL) { - name_str = PyUnicode_InternFromString("__name__"); - if (name_str == NULL) - goto error; - } - if (name) { global_name = name; Py_INCREF(global_name); } else { - global_name = PyObject_GetAttr(obj, name_str); + global_name = _PyObject_GetAttrId(obj, &PyId___name__); if (global_name == NULL) goto error; } @@ -3016,17 +3010,16 @@ save_reduce(PicklerObject *self, PyObject *args, PyObject *obj) /* Protocol 2 special case: if callable's name is __newobj__, use NEWOBJ. */ if (use_newobj) { - static PyObject *newobj_str = NULL, *name_str = NULL; + static PyObject *newobj_str = NULL; PyObject *name; if (newobj_str == NULL) { newobj_str = PyUnicode_InternFromString("__newobj__"); - name_str = PyUnicode_InternFromString("__name__"); - if (newobj_str == NULL || name_str == NULL) + if (newobj_str == NULL) return -1; } - name = PyObject_GetAttr(callable, name_str); + name = _PyObject_GetAttrId(callable, &PyId___name__); if (name == NULL) { if (PyErr_ExceptionMatches(PyExc_AttributeError)) PyErr_Clear(); diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 75b31f5..3466064 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1133,13 +1133,25 @@ Insert a new item x into the array before position i."); static PyObject * array_buffer_info(arrayobject *self, PyObject *unused) { - PyObject* retval = NULL; + PyObject *retval = NULL, *v; + retval = PyTuple_New(2); if (!retval) return NULL; - PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_SIZE(self)))); + v = PyLong_FromVoidPtr(self->ob_item); + if (v == NULL) { + Py_DECREF(retval); + return NULL; + } + PyTuple_SET_ITEM(retval, 0, v); + + v = PyLong_FromLong((long)(Py_SIZE(self))); + if (v == NULL) { + Py_DECREF(retval); + return NULL; + } + PyTuple_SET_ITEM(retval, 1, v); return retval; } diff --git a/Python/peephole.c b/Python/peephole.c index a49790a..4185462 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -275,6 +275,7 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts, PyObject *v len_consts = PyList_GET_SIZE(consts); if (PyList_Append(consts, newconst)) { Py_DECREF(newconst); + PyErr_Clear(); return 0; } Py_DECREF(newconst); |