From c84c2a02a34031a951edeb5d3f81676d05e2765f Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 26 Feb 2013 14:49:47 +0100 Subject: [PATCH 2/4] pycurl.c: eliminate duplicated code in util_write_callback() Suggested by Zdenek Pavlas . --- src/pycurl.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) diff --git a/src/pycurl.c b/src/pycurl.c index 74f5248..f197145 100644 --- a/src/pycurl.c +++ b/src/pycurl.c @@ -1080,15 +1080,7 @@ util_write_callback(int flags, char *ptr, size_t size, size_t nmemb, void *strea if (result == Py_None) { ret = total_size; /* None means success */ } - else if (PyInt_Check(result)) { - long obj_size = PyInt_AsLong(result); - if (obj_size < 0 || obj_size > total_size) { - PyErr_Format(ErrorObject, "invalid return value for write callback %ld %ld", (long)obj_size, (long)total_size); - goto verbose_error; - } - ret = (size_t) obj_size; /* success */ - } - else if (PyLong_Check(result)) { + else if (PyInt_Check(result) || PyLong_Check(result)) { long obj_size = PyLong_AsLong(result); if (obj_size < 0 || obj_size > total_size) { PyErr_Format(ErrorObject, "invalid return value for write callback %ld %ld", (long)obj_size, (long)total_size); -- 1.7.1