diff options
Diffstat (limited to 'Modules/_pickle.c')
| -rw-r--r-- | Modules/_pickle.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 79113e0..b1e1d49 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -346,7 +346,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj) { PyObject *result; - result = _PyObject_CallArg1(func, obj); + result = PyObject_CallFunctionObjArgs(func, obj, NULL); Py_DECREF(obj); return result; } @@ -1941,7 +1941,7 @@ save_long(PicklerObject *self, PyObject *obj) goto error; } else { - char *string; + const char *string; /* proto < 2: write the repr and newline. This is quadratic-time (in the number of digits), in both directions. We add a trailing 'L' @@ -2218,7 +2218,7 @@ write_unicode_binary(PicklerObject *self, PyObject *obj) { PyObject *encoded = NULL; Py_ssize_t size; - char *data; + const char *data; int r; if (PyUnicode_READY(obj)) @@ -2787,10 +2787,10 @@ batch_dict_exact(PicklerObject *self, PyObject *obj) const char setitem_op = SETITEM; const char setitems_op = SETITEMS; - assert(obj != NULL); + assert(obj != NULL && PyDict_CheckExact(obj)); assert(self->proto > 0); - dict_size = PyDict_Size(obj); + dict_size = PyDict_GET_SIZE(obj); /* Special-case len(d) == 1 to save space. */ if (dict_size == 1) { @@ -2819,7 +2819,7 @@ batch_dict_exact(PicklerObject *self, PyObject *obj) } if (_Pickler_Write(self, &setitems_op, 1) < 0) return -1; - if (PyDict_Size(obj) != dict_size) { + if (PyDict_GET_SIZE(obj) != dict_size) { PyErr_Format( PyExc_RuntimeError, "dictionary changed size during iteration"); @@ -2837,6 +2837,7 @@ save_dict(PicklerObject *self, PyObject *obj) char header[3]; Py_ssize_t len; int status = 0; + assert(PyDict_Check(obj)); if (self->fast && !fast_save_enter(self, obj)) goto error; @@ -2855,14 +2856,10 @@ save_dict(PicklerObject *self, PyObject *obj) if (_Pickler_Write(self, header, len) < 0) goto error; - /* Get dict size, and bow out early if empty. */ - if ((len = PyDict_Size(obj)) < 0) - goto error; - if (memo_put(self, obj) < 0) goto error; - if (len != 0) { + if (PyDict_GET_SIZE(obj)) { /* Save the dict items. */ if (PyDict_CheckExact(obj) && self->proto > 0) { /* We can take certain shortcuts if we know this is a dict and @@ -4571,8 +4568,8 @@ find_class(UnpicklerObject *self, PyObject *module_name, PyObject *global_name) { _Py_IDENTIFIER(find_class); - return _PyObject_CallMethodId((PyObject *)self, &PyId_find_class, "OO", - module_name, global_name); + return _PyObject_CallMethodIdObjArgs((PyObject *)self, &PyId_find_class, + module_name, global_name, NULL); } static Py_ssize_t @@ -4762,7 +4759,7 @@ static int load_long(UnpicklerObject *self) { PyObject *value; - char *s; + char *s = NULL; Py_ssize_t len; if ((len = _Unpickler_Readline(self, &s)) < 0) @@ -4993,7 +4990,7 @@ load_unicode(UnpicklerObject *self) { PyObject *str; Py_ssize_t len; - char *s; + char *s = NULL; if ((len = _Unpickler_Readline(self, &s)) < 0) return -1; @@ -5184,7 +5181,7 @@ instantiate(PyObject *cls, PyObject *args) else { _Py_IDENTIFIER(__new__); - result = _PyObject_CallMethodId(cls, &PyId___new__, "O", cls); + result = _PyObject_CallMethodIdObjArgs(cls, &PyId___new__, cls, NULL); } return result; } @@ -5732,7 +5729,7 @@ load_put(UnpicklerObject *self) PyObject *key, *value; Py_ssize_t idx; Py_ssize_t len; - char *s; + char *s = NULL; if ((len = _Unpickler_Readline(self, &s)) < 0) return -1; @@ -6878,7 +6875,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj) Py_ssize_t i = 0; PyObject *key, *value; - new_memo_size = PyDict_Size(obj); + new_memo_size = PyDict_GET_SIZE(obj); new_memo = _Unpickler_NewMemo(new_memo_size); if (new_memo == NULL) return -1; |
