diff --git a/.python-pycurl.metadata b/.python-pycurl.metadata new file mode 100644 index 0000000..1720bf2 --- /dev/null +++ b/.python-pycurl.metadata @@ -0,0 +1 @@ +3fb59eca1461331bb9e9e8d6fe3b23eda961a416 SOURCES/pycurl-7.19.0.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/0001-No-longer-keep-copies-of-string-options-since-this-i.patch b/SOURCES/0001-No-longer-keep-copies-of-string-options-since-this-i.patch new file mode 100644 index 0000000..bfbe215 --- /dev/null +++ b/SOURCES/0001-No-longer-keep-copies-of-string-options-since-this-i.patch @@ -0,0 +1,200 @@ +From 05433632fb1ccdabc1d29d78f32bc35de0a8638b Mon Sep 17 00:00:00 2001 +From: kjetilja +Date: Mon, 29 Sep 2008 10:56:57 +0000 +Subject: [PATCH 1/5] No longer keep copies of string options since this is managed by libcurl + +Signed-off-by: Kamil Dudka +--- + ChangeLog | 12 +++++++++- + src/pycurl.c | 60 +-------------------------------------------------------- + 2 files changed, 12 insertions(+), 60 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index 0fb7f8c..618654d 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,7 +1,15 @@ +-Version 7.19.0 [requires libcurl-7.19.0 or better] ++Version 7.19.1 [requires libcurl-7.19.0 or better] + -------------- + +- * Added CURLFILE, ADDRESS_SCOPE and ISSUERCERT options, ++ * No longer keep string options copies in the ++ Curl Python objects, since string options are ++ now managed by libcurl. ++ ++ ++Version 7.19.0 ++-------------- ++ ++ * Added CURLFILE, ADDRESS_SCOPE and ISSUERCERT options, + as well as the APPCONNECT_TIME info. + + * Added PRIMARY_IP info (patch by +diff --git a/src/pycurl.c b/src/pycurl.c +index a17a23b..6de1514 100644 +--- a/src/pycurl.c ++++ b/src/pycurl.c +@@ -1,4 +1,4 @@ +-/* $Id: pycurl.c,v 1.147 2008/09/09 17:40:34 kjetilja Exp $ */ ++/* $Id: pycurl.c,v 1.148 2008/09/29 10:56:57 kjetilja Exp $ */ + + /* PycURL -- cURL Python module + * +@@ -97,12 +97,6 @@ static void pycurl_ssl_cleanup(void); + /* Calculate the number of OBJECTPOINT options we need to store */ + #define OPTIONS_SIZE ((int)CURLOPT_LASTENTRY % 10000) + #define MOPTIONS_SIZE ((int)CURLMOPT_LASTENTRY % 10000) +-static int OPT_INDEX(int o) +-{ +- assert(o >= CURLOPTTYPE_OBJECTPOINT); +- assert(o < CURLOPTTYPE_OBJECTPOINT + OPTIONS_SIZE); +- return o - CURLOPTTYPE_OBJECTPOINT; +-} + + /* Type objects */ + static PyObject *ErrorObject = NULL; +@@ -161,7 +155,6 @@ typedef struct { + PyObject *writedata_fp; + PyObject *writeheader_fp; + /* misc */ +- void *options[OPTIONS_SIZE]; /* for OBJECTPOINT options */ + char error[CURL_ERROR_SIZE+1]; + } CurlObject; + +@@ -741,7 +734,6 @@ util_curl_new(void) + self->writeheader_fp = NULL; + + /* Zero string pointer memory buffer used by setopt */ +- memset(self->options, 0, sizeof(self->options)); + memset(self->error, 0, sizeof(self->error)); + + return self; +@@ -804,7 +796,6 @@ do_curl_new(PyObject *dummy) + free(s); + goto error; + } +- self->options[ OPT_INDEX(CURLOPT_USERAGENT) ] = s; s = NULL; + + /* Success - return new object */ + return self; +@@ -872,7 +863,6 @@ static void + util_curl_close(CurlObject *self) + { + CURL *handle; +- int i; + + /* Zero handle and thread-state to disallow any operations to be run + * from now on */ +@@ -916,16 +906,6 @@ util_curl_close(CurlObject *self) + SFREE(self->postquote); + SFREE(self->prequote); + #undef SFREE +- +- /* Last, free the options. This must be done after the curl handle +- * is closed since libcurl assumes that some options are valid when +- * invoking curl_easy_cleanup(). */ +- for (i = 0; i < OPTIONS_SIZE; i++) { +- if (self->options[i] != NULL) { +- free(self->options[i]); +- self->options[i] = NULL; +- } +- } + } + + +@@ -1424,8 +1404,6 @@ verbose_error: + static PyObject* + do_curl_reset(CurlObject *self) + { +- unsigned int i; +- + curl_easy_reset(self->handle); + + /* Decref callbacks and file handles */ +@@ -1443,15 +1421,6 @@ do_curl_reset(CurlObject *self) + SFREE(self->postquote); + SFREE(self->prequote); + #undef SFREE +- +- /* Last, free the options */ +- for (i = 0; i < OPTIONS_SIZE; i++) { +- if (self->options[i] != NULL) { +- free(self->options[i]); +- self->options[i] = NULL; +- } +- } +- + return Py_None; + } + +@@ -1461,7 +1430,6 @@ static PyObject * + util_curl_unsetopt(CurlObject *self, int option) + { + int res; +- int opt_index = -1; + + #define SETOPT2(o,x) \ + if ((res = curl_easy_setopt(self->handle, (o), (x))) != CURLE_OK) goto error +@@ -1502,7 +1470,6 @@ util_curl_unsetopt(CurlObject *self, int option) + case CURLOPT_SSL_CIPHER_LIST: + case CURLOPT_USERPWD: + SETOPT((char *) 0); +- opt_index = OPT_INDEX(option); + break; + + /* info: we explicitly list unsupported options here */ +@@ -1512,11 +1479,6 @@ util_curl_unsetopt(CurlObject *self, int option) + return NULL; + } + +- if (opt_index >= 0 && self->options[opt_index] != NULL) { +- free(self->options[opt_index]); +- self->options[opt_index] = NULL; +- } +- + Py_INCREF(Py_None); + return Py_None; + +@@ -1587,8 +1549,6 @@ do_curl_setopt(CurlObject *self, PyObject *args) + if (PyString_Check(obj)) { + char *str = NULL; + Py_ssize_t len = -1; +- char *buf; +- int opt_index; + + /* Check that the option specified a string as well as the input */ + switch (option) { +@@ -1651,28 +1611,12 @@ do_curl_setopt(CurlObject *self, PyObject *args) + } + /* Allocate memory to hold the string */ + assert(str != NULL); +- if (len <= 0) +- buf = strdup(str); +- else { +- buf = (char *) malloc(len); +- if (buf) memcpy(buf, str, len); +- } +- if (buf == NULL) +- return PyErr_NoMemory(); + /* Call setopt */ +- res = curl_easy_setopt(self->handle, (CURLoption)option, buf); ++ res = curl_easy_setopt(self->handle, (CURLoption)option, str); + /* Check for errors */ + if (res != CURLE_OK) { +- free(buf); + CURLERROR_RETVAL(); + } +- /* Save allocated option buffer */ +- opt_index = OPT_INDEX(option); +- if (self->options[opt_index] != NULL) { +- free(self->options[opt_index]); +- self->options[opt_index] = NULL; +- } +- self->options[opt_index] = buf; + Py_INCREF(Py_None); + return Py_None; + } +-- +1.7.1 + diff --git a/SOURCES/0002-Fixes-https-sourceforge.net-tracker-func-detail-aid-.patch b/SOURCES/0002-Fixes-https-sourceforge.net-tracker-func-detail-aid-.patch new file mode 100644 index 0000000..522087c --- /dev/null +++ b/SOURCES/0002-Fixes-https-sourceforge.net-tracker-func-detail-aid-.patch @@ -0,0 +1,61 @@ +From 009e170d2838346461ff0b31b0afa44f3d6278f3 Mon Sep 17 00:00:00 2001 +From: zanee +Date: Fri, 23 Apr 2010 16:06:41 +0000 +Subject: [PATCH 2/5] Fixes https://sourceforge.net/tracker/?func=detail&aid=2812016&group_id=28236&atid=392777 with applied patch from sourceforge user dbprice1. + +Signed-off-by: Kamil Dudka +--- + setup.py | 23 ++++++++++++++++++----- + 1 files changed, 18 insertions(+), 5 deletions(-) + +diff --git a/setup.py b/setup.py +index 0ffd9d2..76b9d58 100644 +--- a/setup.py ++++ b/setup.py +@@ -1,7 +1,7 @@ + #! /usr/bin/env python + # -*- coding: iso-8859-1 -*- + # vi:ts=4:et +-# $Id: setup.py,v 1.150 2008/09/09 17:40:34 kjetilja Exp $ ++# $Id: setup.py,v 1.151 2010/04/23 16:06:41 zanee Exp $ + + """Setup script for the PycURL module distribution.""" + +@@ -9,7 +9,7 @@ PACKAGE = "pycurl" + PY_PACKAGE = "curl" + VERSION = "7.19.0" + +-import glob, os, re, sys, string ++import glob, os, re, sys, string, subprocess + import distutils + from distutils.core import setup + from distutils.extension import Extension +@@ -96,9 +96,22 @@ else: + include_dirs.append(e[2:]) + else: + extra_compile_args.append(e) +- libs = split_quoted( +- os.popen("'%s' --libs" % CURL_CONFIG).read()+\ +- os.popen("'%s' --static-libs" % CURL_CONFIG).read()) ++ ++ # Run curl-config --libs and --static-libs. Some platforms may not ++ # support one or the other of these curl-config options, so gracefully ++ # tolerate failure of either, but not both. ++ optbuf = "" ++ for option in ["--libs", "--static-libs"]: ++ p = subprocess.Popen("'%s' %s" % (CURL_CONFIG, option), shell=True, ++ stdout=subprocess.PIPE) ++ (stdout, stderr) = p.communicate() ++ if p.wait() == 0: ++ optbuf += stdout ++ if optbuf == "": ++ raise Exception, ("Neither of curl-config --libs or --static-libs" + ++ "produced output") ++ libs = split_quoted(optbuf) ++ + for e in libs: + if e[:2] == "-l": + libraries.append(e[2:]) +-- +1.7.1 + diff --git a/SOURCES/0003-Fixes-refcount-bug-and-provides-better-organization-.patch b/SOURCES/0003-Fixes-refcount-bug-and-provides-better-organization-.patch new file mode 100644 index 0000000..80c600e --- /dev/null +++ b/SOURCES/0003-Fixes-refcount-bug-and-provides-better-organization-.patch @@ -0,0 +1,160 @@ +From 4a377e2d60fb903e91a370595a6ea22cb7ee0e0e Mon Sep 17 00:00:00 2001 +From: zanee +Date: Wed, 28 Apr 2010 16:02:41 +0000 +Subject: [PATCH 3/5 v2] Fixes refcount bug and provides better organization of PyCurl object. Submitted by dbprice1. + +https://sourceforge.net/tracker/?func=detail&aid=2893665&group_id=28236&atid=392777 + +Signed-off-by: Kamil Dudka +--- + src/pycurl.c | 88 +++++++++++++++++++++++++++++++++++++-------------------- + 1 files changed, 57 insertions(+), 31 deletions(-) + +diff --git a/src/pycurl.c b/src/pycurl.c +index 6de1514..32c7ca5 100644 +--- a/src/pycurl.c ++++ b/src/pycurl.c +@@ -1,4 +1,4 @@ +-/* $Id: pycurl.c,v 1.148 2008/09/29 10:56:57 kjetilja Exp $ */ ++/* $Id: pycurl.c,v 1.149 2010/04/28 16:02:41 zanee Exp $ */ + + /* PycURL -- cURL Python module + * +@@ -739,64 +739,80 @@ util_curl_new(void) + return self; + } + +- +-/* constructor - this is a module-level function returning a new instance */ +-static CurlObject * +-do_curl_new(PyObject *dummy) ++/* initializer - used to intialize curl easy handles for use with pycurl */ ++static int ++util_curl_init(CurlObject *self) + { +- CurlObject *self = NULL; + int res; + char *s = NULL; + +- UNUSED(dummy); +- +- /* Allocate python curl object */ +- self = util_curl_new(); +- if (self == NULL) +- return NULL; +- +- /* Initialize curl handle */ +- self->handle = curl_easy_init(); +- if (self->handle == NULL) +- goto error; +- + /* Set curl error buffer and zero it */ + res = curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->error); +- if (res != CURLE_OK) +- goto error; ++ if (res != CURLE_OK) { ++ return (-1); ++ } + memset(self->error, 0, sizeof(self->error)); + + /* Set backreference */ + res = curl_easy_setopt(self->handle, CURLOPT_PRIVATE, (char *) self); +- if (res != CURLE_OK) +- goto error; ++ if (res != CURLE_OK) { ++ return (-1); ++ } + + /* Enable NOPROGRESS by default, i.e. no progress output */ + res = curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, (long)1); +- if (res != CURLE_OK) +- goto error; ++ if (res != CURLE_OK) { ++ return (-1); ++ } + + /* Disable VERBOSE by default, i.e. no verbose output */ + res = curl_easy_setopt(self->handle, CURLOPT_VERBOSE, (long)0); +- if (res != CURLE_OK) +- goto error; ++ if (res != CURLE_OK) { ++ return (-1); ++ } + + /* Set FTP_ACCOUNT to NULL by default */ + res = curl_easy_setopt(self->handle, CURLOPT_FTP_ACCOUNT, NULL); +- if (res != CURLE_OK) +- goto error; ++ if (res != CURLE_OK) { ++ return (-1); ++ } + + /* Set default USERAGENT */ + s = (char *) malloc(7 + strlen(LIBCURL_VERSION) + 1); +- if (s == NULL) +- goto error; ++ if (s == NULL) { ++ return (-1); ++ } + strcpy(s, "PycURL/"); strcpy(s+7, LIBCURL_VERSION); + res = curl_easy_setopt(self->handle, CURLOPT_USERAGENT, (char *) s); + if (res != CURLE_OK) { + free(s); +- goto error; ++ return (-1); + } ++ return (0); ++} ++ ++/* constructor - this is a module-level function returning a new instance */ ++static CurlObject * ++do_curl_new(PyObject *dummy) ++{ ++ CurlObject *self = NULL; ++ int res; ++ ++ UNUSED(dummy); ++ ++ /* Allocate python curl object */ ++ self = util_curl_new(); ++ if (self == NULL) ++ return NULL; ++ ++ /* Initialize curl handle */ ++ self->handle = curl_easy_init(); ++ if (self->handle == NULL) ++ goto error; + ++ res = util_curl_init(self); ++ if (res < 0) ++ goto error; + /* Success - return new object */ + return self; + +@@ -1404,6 +1420,8 @@ verbose_error: + static PyObject* + do_curl_reset(CurlObject *self) + { ++ int res; ++ + curl_easy_reset(self->handle); + + /* Decref callbacks and file handles */ +@@ -1421,6 +1439,14 @@ do_curl_reset(CurlObject *self) + SFREE(self->postquote); + SFREE(self->prequote); + #undef SFREE ++ res = util_curl_init(self); ++ if (res < 0) { ++ Py_DECREF(self); /* this also closes self->handle */ ++ PyErr_SetString(ErrorObject, "resetting curl failed"); ++ return NULL; ++ } ++ ++ Py_INCREF(Py_None); + return Py_None; + } + +-- +1.7.1 + diff --git a/SOURCES/0004-Test-for-reset-fixes-refcount-bug.patch b/SOURCES/0004-Test-for-reset-fixes-refcount-bug.patch new file mode 100644 index 0000000..6144842 --- /dev/null +++ b/SOURCES/0004-Test-for-reset-fixes-refcount-bug.patch @@ -0,0 +1,94 @@ +From 206c15ea32e05ae98827d00626a101e33a7bec70 Mon Sep 17 00:00:00 2001 +From: zanee +Date: Wed, 28 Apr 2010 16:03:40 +0000 +Subject: [PATCH 4/5] Test for reset fixes refcount bug + +Signed-off-by: Kamil Dudka +--- + tests/test_reset.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 74 insertions(+), 0 deletions(-) + create mode 100644 tests/test_reset.py + +diff --git a/tests/test_reset.py b/tests/test_reset.py +new file mode 100644 +index 0000000..c350d17 +--- /dev/null ++++ b/tests/test_reset.py +@@ -0,0 +1,74 @@ ++#!/usr/bin/python ++ ++import sys ++import pycurl ++ ++saw_error = 1 ++ ++def main(): ++ global saw_error ++ ++ pycurl.global_init(pycurl.GLOBAL_DEFAULT) ++ ++ outf = file("/dev/null", "rb+") ++ cm = pycurl.CurlMulti() ++ ++ # Set multi handle's options ++ cm.setopt(pycurl.M_PIPELINING, 1) ++ ++ eh = pycurl.Curl() ++ ++ for x in range(1, 20): ++ ++ eh.setopt(pycurl.WRITEDATA, outf) ++ eh.setopt(pycurl.URL, sys.argv[1]) ++ cm.add_handle(eh) ++ ++ while 1: ++ ret, active_handles = cm.perform() ++ if ret != pycurl.E_CALL_MULTI_PERFORM: ++ break ++ ++ while active_handles: ++ ret = cm.select(1.0) ++ if ret == -1: ++ continue ++ while 1: ++ ret, active_handles = cm.perform() ++ if ret != pycurl.E_CALL_MULTI_PERFORM: ++ break ++ ++ count, good, bad = cm.info_read() ++ ++ for h, en, em in bad: ++ print "Transfer to %s failed with %d, %s\n" % \ ++ (h.getinfo(pycurl.EFFECTIVE_URL), en, em) ++ raise RuntimeError ++ ++ for h in good: ++ httpcode = h.getinfo(pycurl.RESPONSE_CODE) ++ if httpcode != 200: ++ print "Transfer to %s failed with code %d\n" %\ ++ (h.getinfo(pycurl.EFFECTIVE_URL), httpcode) ++ raise RuntimeError ++ ++ else: ++ print "Recd %d bytes from %s" % \ ++ (h.getinfo(pycurl.SIZE_DOWNLOAD), ++ h.getinfo(pycurl.EFFECTIVE_URL)) ++ ++ cm.remove_handle(eh) ++ eh.reset() ++ ++ eh.close() ++ cm.close() ++ outf.close() ++ ++ pycurl.global_cleanup() ++ ++ ++if __name__ == '__main__': ++ if len(sys.argv) != 2: ++ print "Usage: %s " % sys.argv[0] ++ sys.exit(2) ++ main() +-- +1.7.1 + diff --git a/SOURCES/0005-Updating-ChangeLog-with-relevant-changes.patch b/SOURCES/0005-Updating-ChangeLog-with-relevant-changes.patch new file mode 100644 index 0000000..dd8d803 --- /dev/null +++ b/SOURCES/0005-Updating-ChangeLog-with-relevant-changes.patch @@ -0,0 +1,32 @@ +From d075bfb8a5207f933a5a704becd7f64e8521dc28 Mon Sep 17 00:00:00 2001 +From: zanee +Date: Tue, 4 May 2010 18:47:08 +0000 +Subject: [PATCH 5/5] Updating ChangeLog with relevant changes + +Signed-off-by: Kamil Dudka +--- + ChangeLog | 11 +++++++++++ + 1 files changed, 11 insertions(+), 0 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index 618654d..885c8b0 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,14 @@ ++Version 7.19.2 ++-------------- ++ ++ * Cleaned up website ++ ++ * Fix pycurl.reset() (patch by ). ++ ++ * Fix install routine in setup.py where ++ certain platforms (Solaris, Mac OSX, etc) ++ would search for a static copy of libcurl (dbp) ++ + Version 7.19.1 [requires libcurl-7.19.0 or better] + -------------- + +-- +1.7.1 + diff --git a/SOURCES/0101-test_internals.py-add-a-test-for-ref-counting-of-res.patch b/SOURCES/0101-test_internals.py-add-a-test-for-ref-counting-of-res.patch new file mode 100644 index 0000000..5e889ca --- /dev/null +++ b/SOURCES/0101-test_internals.py-add-a-test-for-ref-counting-of-res.patch @@ -0,0 +1,28 @@ +From 593cf090dacc230cd28aee1993d86b2b83b414f9 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Mon, 25 Feb 2013 19:50:18 +0100 +Subject: [PATCH 1/4] test_internals.py: add a test for ref-counting of reset() + +--- + tests/test_internals.py | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/tests/test_internals.py b/tests/test_internals.py +index afcc53d..d026952 100644 +--- a/tests/test_internals.py ++++ b/tests/test_internals.py +@@ -245,6 +245,11 @@ if 1 and gc: + if opts.verbose >= 1: + print "Tracked objects:", len(gc.get_objects()) + ++if 1: ++ # Ensure that the refcounting error in "reset" is fixed: ++ for i in xrange(100000): ++ c = Curl() ++ c.reset() + + # /*********************************************************************** + # // done +-- +1.7.1 + diff --git a/SOURCES/0102-pycurl.c-eliminate-duplicated-code-in-util_write_cal.patch b/SOURCES/0102-pycurl.c-eliminate-duplicated-code-in-util_write_cal.patch new file mode 100644 index 0000000..b707a61 --- /dev/null +++ b/SOURCES/0102-pycurl.c-eliminate-duplicated-code-in-util_write_cal.patch @@ -0,0 +1,34 @@ +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 + diff --git a/SOURCES/0103-pycurl.c-allow-to-return-1-from-write-callback.patch b/SOURCES/0103-pycurl.c-allow-to-return-1-from-write-callback.patch new file mode 100644 index 0000000..d3d7a3e --- /dev/null +++ b/SOURCES/0103-pycurl.c-allow-to-return-1-from-write-callback.patch @@ -0,0 +1,45 @@ +From ca4705dab05371c40f398b97277024332ed44651 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Tue, 26 Feb 2013 16:58:55 +0100 +Subject: [PATCH 3/4] pycurl.c: allow to return -1 from write callback + +... to abort the transfer and WRITEFUNC_PAUSE to pause the transfer + +Reported By: Zdenek Pavlas +Bug: https://bugzilla.redhat.com/857875 +--- + src/pycurl.c | 11 +++++------ + 1 files changed, 5 insertions(+), 6 deletions(-) + +diff --git a/src/pycurl.c b/src/pycurl.c +index f197145..b59eeb8 100644 +--- a/src/pycurl.c ++++ b/src/pycurl.c +@@ -1081,12 +1081,8 @@ util_write_callback(int flags, char *ptr, size_t size, size_t nmemb, void *strea + ret = total_size; /* None means success */ + } + 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); +- goto verbose_error; +- } +- ret = (size_t) obj_size; /* success */ ++ /* if the cast to long fails, PyLong_AsLong() returns -1L */ ++ ret = (size_t) PyLong_AsLong(result); + } + else { + PyErr_SetString(ErrorObject, "write callback must return int or None"); +@@ -3423,6 +3419,9 @@ initpycurl(void) + /* Abort curl_read_callback(). */ + insint_c(d, "READFUNC_ABORT", CURL_READFUNC_ABORT); + ++ /* Pause curl_write_callback(). */ ++ insint_c(d, "WRITEFUNC_PAUSE", CURL_WRITEFUNC_PAUSE); ++ + /* constants for ioctl callback return values */ + insint_c(d, "IOE_OK", CURLIOE_OK); + insint_c(d, "IOE_UNKNOWNCMD", CURLIOE_UNKNOWNCMD); +-- +1.7.1 + diff --git a/SOURCES/0104-test_write_abort.py-test-returning-1-from-write-call.patch b/SOURCES/0104-test_write_abort.py-test-returning-1-from-write-call.patch new file mode 100644 index 0000000..b6d4168 --- /dev/null +++ b/SOURCES/0104-test_write_abort.py-test-returning-1-from-write-call.patch @@ -0,0 +1,59 @@ +From d8e4390da96d19a322a6fd3512ccac0200f15ddb Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Wed, 6 Mar 2013 14:38:01 +0100 +Subject: [PATCH 4/4] test_write_abort.py: test returning -1 from write callback + +--- + Makefile | 1 + + tests/test_write_abort.py | 27 +++++++++++++++++++++++++++ + 2 files changed, 28 insertions(+), 0 deletions(-) + create mode 100755 tests/test_write_abort.py + +diff --git a/Makefile b/Makefile +index 9b2369d..10b95a7 100644 +--- a/Makefile ++++ b/Makefile +@@ -16,6 +16,7 @@ build-7.10.8: + + test: build + $(PYTHON) tests/test_internals.py -q ++ $(PYTHON) tests/test_write_abort.py -q + + # (needs GNU binutils) + strip: build +diff --git a/tests/test_write_abort.py b/tests/test_write_abort.py +new file mode 100755 +index 0000000..28e7d1f +--- /dev/null ++++ b/tests/test_write_abort.py +@@ -0,0 +1,27 @@ ++#!/usr/bin/python ++import os.path ++import pycurl ++import sys ++ ++pycurl.global_init(pycurl.GLOBAL_DEFAULT) ++ ++def write_cb(_): ++ # this should cause pycurl.WRITEFUNCTION (without any range errors) ++ return -1 ++ ++# download the script itself through the file:// protocol into write_cb ++c = pycurl.Curl() ++c.setopt(pycurl.URL, 'file://' + os.path.abspath(sys.argv[0])) ++c.setopt(pycurl.WRITEFUNCTION, write_cb) ++try: ++ c.perform() ++except pycurl.error, (err, msg): ++ # we expect pycurl.E_WRITE_ERROR as the response ++ assert pycurl.E_WRITE_ERROR == err ++ ++# no additional errors should be reported ++assert not hasattr(sys, 'last_value') ++ ++c.close() ++ ++pycurl.global_cleanup() +-- +1.7.1 + diff --git a/SOURCES/0105-add-the-GLOBAL_ACK_EINTR-constant-to-the-list-of-exp.patch b/SOURCES/0105-add-the-GLOBAL_ACK_EINTR-constant-to-the-list-of-exp.patch new file mode 100644 index 0000000..2731893 --- /dev/null +++ b/SOURCES/0105-add-the-GLOBAL_ACK_EINTR-constant-to-the-list-of-exp.patch @@ -0,0 +1,61 @@ +From cf4104369f5716a6904152435713ec81358c0102 Mon Sep 17 00:00:00 2001 +From: Zdenek Pavlas +Date: Wed, 13 Mar 2013 16:55:58 +0100 +Subject: [PATCH] add the GLOBAL_ACK_EINTR constant to the list of exported symbols + +... if built against a new enough version of libcurl + +Bug: https://bugzilla.redhat.com/920589 + +Signed-off-by: Kamil Dudka +--- + src/pycurl.c | 19 +++++++++++++++---- + 1 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/src/pycurl.c b/src/pycurl.c +index b59eeb8..9a7135c 100644 +--- a/src/pycurl.c ++++ b/src/pycurl.c +@@ -3125,6 +3125,16 @@ static PyTypeObject CurlMulti_Type = { + */ + }; + ++static int ++are_global_init_flags_valid(int flags) ++{ ++#ifdef CURL_GLOBAL_ACK_EINTR ++ /* CURL_GLOBAL_ACK_EINTR was introduced in libcurl-7.30.0 */ ++ return !(flags & ~(CURL_GLOBAL_ALL | CURL_GLOBAL_ACK_EINTR)); ++#else ++ return !(flags & ~(CURL_GLOBAL_ALL)); ++#endif ++} + + /************************************************************************* + // module level +@@ -3142,10 +3152,7 @@ do_global_init(PyObject *dummy, PyObject *args) + return NULL; + } + +- if (!(option == CURL_GLOBAL_SSL || +- option == CURL_GLOBAL_WIN32 || +- option == CURL_GLOBAL_ALL || +- option == CURL_GLOBAL_NOTHING)) { ++ if (!are_global_init_flags_valid(option)) { + PyErr_SetString(PyExc_ValueError, "invalid option to global_init"); + return NULL; + } +@@ -3780,6 +3787,10 @@ initpycurl(void) + insint(d, "GLOBAL_ALL", CURL_GLOBAL_ALL); + insint(d, "GLOBAL_NOTHING", CURL_GLOBAL_NOTHING); + insint(d, "GLOBAL_DEFAULT", CURL_GLOBAL_DEFAULT); ++#ifdef CURL_GLOBAL_ACK_EINTR ++ /* CURL_GLOBAL_ACK_EINTR was introduced in libcurl-7.30.0 */ ++ insint(d, "GLOBAL_ACK_EINTR", CURL_GLOBAL_ACK_EINTR); ++#endif + + + /* constants for curl_multi_socket interface */ +-- +1.7.1 + diff --git a/SPECS/python-pycurl.spec b/SPECS/python-pycurl.spec new file mode 100644 index 0000000..a5e0c55 --- /dev/null +++ b/SPECS/python-pycurl.spec @@ -0,0 +1,174 @@ +%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + +Name: python-pycurl +Version: 7.19.0 +Release: 15.1%{?dist} +Summary: A Python interface to libcurl + +Group: Development/Languages +License: LGPLv2+ or MIT +URL: http://pycurl.sourceforge.net/ +Source0: http://pycurl.sourceforge.net/download/pycurl-%{version}.tar.gz + +# upstream patches +Patch1: 0001-No-longer-keep-copies-of-string-options-since-this-i.patch +Patch2: 0002-Fixes-https-sourceforge.net-tracker-func-detail-aid-.patch +Patch3: 0003-Fixes-refcount-bug-and-provides-better-organization-.patch +Patch4: 0004-Test-for-reset-fixes-refcount-bug.patch +Patch5: 0005-Updating-ChangeLog-with-relevant-changes.patch + +# downstream patches +Patch101: 0101-test_internals.py-add-a-test-for-ref-counting-of-res.patch +Patch102: 0102-pycurl.c-eliminate-duplicated-code-in-util_write_cal.patch +Patch103: 0103-pycurl.c-allow-to-return-1-from-write-callback.patch +Patch104: 0104-test_write_abort.py-test-returning-1-from-write-call.patch +Patch105: 0105-add-the-GLOBAL_ACK_EINTR-constant-to-the-list-of-exp.patch + +Requires: keyutils-libs +BuildRequires: python-devel +BuildRequires: curl-devel >= 7.19.0 +BuildRequires: openssl-devel + +# During its initialization, PycURL checks that the actual libcurl version +# is not lower than the one used when PycURL was built. +# Yes, that should be handled by library versioning (which would then get +# automatically reflected by rpm). +# For now, we have to reflect that dependency. +%global libcurl_sed '/^#define LIBCURL_VERSION "/!d;s/"[^"]*$//;s/.*"//;q' +%global curlver_h /usr/include/curl/curlver.h +%global libcurl_ver %(sed %{libcurl_sed} %{curlver_h} 2>/dev/null || echo 0) +Requires: libcurl >= %{libcurl_ver} + +Provides: pycurl = %{version}-%{release} + +%description +PycURL is a Python interface to libcurl. PycURL can be used to fetch +objects identified by a URL from a Python program, similar to the +urllib Python module. PycURL is mature, very fast, and supports a lot +of features. + +%prep +%setup0 -q -n pycurl-%{version} +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch101 -p1 +%patch102 -p1 +%patch103 -p1 +%patch104 -p1 +%patch105 -p1 +chmod a-x examples/* + +%build +CFLAGS="$RPM_OPT_FLAGS -DHAVE_CURL_OPENSSL" %{__python} setup.py build + +%check +export PYTHONPATH=$RPM_BUILD_ROOT%{python_sitearch} +make test PYTHON=%{__python} + +%install +%{__python} setup.py install -O1 --skip-build --root %{buildroot} +rm -rf %{buildroot}%{_datadir}/doc/pycurl + +%files +%doc COPYING COPYING2 ChangeLog README TODO examples doc tests +%{python_sitearch}/* + +%changelog +* Tue Apr 09 2013 Kamil Dudka - 7.19.0-15.1 +- add the GLOBAL_ACK_EINTR constant to the list of exported symbols (#920589) + +* Wed Mar 06 2013 Kamil Dudka - 7.19.0-15 +- allow to return -1 from the write callback (#857875) +- remove the patch for curl-config --static-libs no longer needed +- run the tests against the just built pycurl, not the system one + +* Mon Feb 25 2013 Kamil Dudka - 7.19.0-14 +- apply bug-fixes committed to upstream CVS since 7.19.0 (fixes #896025) + +* Thu Feb 14 2013 Fedora Release Engineering - 7.19.0-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Aug 22 2012 Jan Synáček - 7.19.0-12 +- Improve spec + +* Sat Jul 21 2012 Fedora Release Engineering - 7.19.0-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Jan 14 2012 Fedora Release Engineering - 7.19.0-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Feb 08 2011 Fedora Release Engineering - 7.19.0-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Dec 20 2010 Dennis Gilmore - 7.19.0-8 +- add Missing Requires on keyutils-libs + +* Tue Aug 17 2010 Jeffrey C. Ollie - 7.19.0-7 +- Add patch developed by David Malcolm to fix segfaults caused by a missing incref + +* Thu Jul 22 2010 David Malcolm - 7.19.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Tue Mar 2 2010 Karel Klic - 7.19.0-5 +- Package COPYING2 file +- Added MIT as a package license + +* Sun Jul 26 2009 Fedora Release Engineering - 7.19.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri Apr 17 2009 Stepan Kasal - 7.19.0-3 +- fix typo in the previous change + +* Fri Apr 17 2009 Stepan Kasal - 7.19.0-2 +- add a require to reflect a dependency on libcurl version (#496308) + +* Thu Mar 5 2009 Jeffrey C. Ollie - 7.19.0-1 +- Update to 7.19.0 + +* Thu Feb 26 2009 Fedora Release Engineering - 7.18.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sat Nov 29 2008 Ignacio Vazquez-Abrams - 7.18.2-2 +- Rebuild for Python 2.6 + +* Thu Jul 3 2008 Jeffrey C. Ollie - 7.18.2-1 +- Update to 7.18.2 +- Thanks to Ville Skyttä re-enable the tests and fix a minor problem + with the setup.py. (Bug # 45400) + +* Thu Jun 5 2008 Jeffrey C. Ollie - 7.18.1-1 +- Update to 7.18.1 +- Disable tests because it's not testing the built library, it's trying to + test an installed library. + +* Tue Feb 19 2008 Fedora Release Engineering - 7.16.4-3 +- Autorebuild for GCC 4.3 + +* Thu Jan 3 2008 Jeffrey C. Ollie - 7.16.4-2 +- BR openssl-devel + +* Wed Aug 29 2007 Jeffrey C. Ollie - 7.16.4-1 +- Update to 7.16.4 +- Update license tag. + +* Sat Jun 9 2007 Jeffrey C. Ollie - 7.16.2.1-1 +- Update to released version. + +* Thu Dec 7 2006 Jeffrey C. Ollie - 7.16.0-0.1.20061207 +- Update to a CVS snapshot since development has a newer version of curl than is in FC <= 6 + +* Thu Dec 7 2006 Jeffrey C. Ollie - 7.15.5.1-4 +- Add -DHAVE_CURL_OPENSSL to fix PPC build problem. + +* Thu Dec 7 2006 Jeffrey C. Ollie - 7.15.5.1-3 +- Don't forget to Provide: pycurl!!! + +* Thu Dec 7 2006 Jeffrey C. Ollie - 7.15.5.1-2 +- Remove INSTALL from the list of documentation +- Use python_sitearch for all of the files + +* Thu Dec 7 2006 Jeffrey C. Ollie - 7.15.5.1-1 +- First version for Fedora Extras