summaryrefslogtreecommitdiff
path: root/Modules/_ctypes/callproc.c
diff options
context:
space:
mode:
authorMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:18:39 -0800
committerMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:18:39 -0800
commit731cca110f376cdbaffb536e42d6c9d6da574fa8 (patch)
tree9cb95caf6f8b933115820bf699725d9cd600d2df /Modules/_ctypes/callproc.c
parentda79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (diff)
parentc8102f4d974669f4c5e4ca7bcd73292a1ac5bcbf (diff)
downloadcpython-731cca110f376cdbaffb536e42d6c9d6da574fa8.tar.gz
Issue #29371: merge with 3.6
Diffstat (limited to 'Modules/_ctypes/callproc.c')
-rw-r--r--Modules/_ctypes/callproc.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 7d542fb50d..9b368caf65 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -892,8 +892,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
return PyLong_FromLong(*(int *)result);
if (restype == Py_None) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
dict = PyType_stgdict(restype);
@@ -1263,8 +1262,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
return NULL;
if (!FreeLibrary((HMODULE)hMod))
return PyErr_SetFromWindowsErr(GetLastError());
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static const char copy_com_pointer_doc[] =
@@ -1349,8 +1347,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args)
ctypes_dlerror());
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *py_dl_sym(PyObject *self, PyObject *args)
@@ -1624,32 +1621,39 @@ resize(PyObject *self, PyObject *args)
obj->b_size = size;
}
done:
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
unpickle(PyObject *self, PyObject *args)
{
- PyObject *typ;
- PyObject *state;
- PyObject *result;
- PyObject *tmp;
+ PyObject *typ, *state, *meth, *obj, *result;
_Py_IDENTIFIER(__new__);
_Py_IDENTIFIER(__setstate__);
- if (!PyArg_ParseTuple(args, "OO", &typ, &state))
+ if (!PyArg_ParseTuple(args, "OO!", &typ, &PyTuple_Type, &state))
return NULL;
- result = _PyObject_CallMethodId(typ, &PyId___new__, "O", typ);
- if (result == NULL)
- return NULL;
- tmp = _PyObject_CallMethodId(result, &PyId___setstate__, "O", state);
- if (tmp == NULL) {
- Py_DECREF(result);
+ obj = _PyObject_CallMethodIdObjArgs(typ, &PyId___new__, typ, NULL);
+ if (obj == NULL)
return NULL;
+
+ meth = _PyObject_GetAttrId(obj, &PyId___setstate__);
+ if (meth == NULL) {
+ goto error;
}
- Py_DECREF(tmp);
- return result;
+
+ result = PyObject_Call(meth, state, NULL);
+ Py_DECREF(meth);
+ if (result == NULL) {
+ goto error;
+ }
+ Py_DECREF(result);
+
+ return obj;
+
+error:
+ Py_DECREF(obj);
+ return NULL;
}
static PyObject *