sync with upstream 9b8f4e38 (fixes #928370)
This commit is contained in:
parent
2423e9dab2
commit
9e1f88391f
9416
0000-pycurl-7.19.7-9b8f4e38.patch
Normal file
9416
0000-pycurl-7.19.7-9b8f4e38.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,200 +0,0 @@
|
|||||||
From 05433632fb1ccdabc1d29d78f32bc35de0a8638b Mon Sep 17 00:00:00 2001
|
|
||||||
From: kjetilja <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 <kdudka@redhat.com>
|
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
From 009e170d2838346461ff0b31b0afa44f3d6278f3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: zanee <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 <kdudka@redhat.com>
|
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,160 +0,0 @@
|
|||||||
From 4a377e2d60fb903e91a370595a6ea22cb7ee0e0e Mon Sep 17 00:00:00 2001
|
|
||||||
From: zanee <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 <kdudka@redhat.com>
|
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,94 +0,0 @@
|
|||||||
From 206c15ea32e05ae98827d00626a101e33a7bec70 Mon Sep 17 00:00:00 2001
|
|
||||||
From: zanee <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 <kdudka@redhat.com>
|
|
||||||
---
|
|
||||||
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 <url>" % sys.argv[0]
|
|
||||||
+ sys.exit(2)
|
|
||||||
+ main()
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
From d075bfb8a5207f933a5a704becd7f64e8521dc28 Mon Sep 17 00:00:00 2001
|
|
||||||
From: zanee <zanee>
|
|
||||||
Date: Tue, 4 May 2010 18:47:08 +0000
|
|
||||||
Subject: [PATCH 5/5] Updating ChangeLog with relevant changes
|
|
||||||
|
|
||||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
---
|
|
||||||
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 <johansen at sun.com>).
|
|
||||||
+
|
|
||||||
+ * 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
|
|
||||||
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From 593cf090dacc230cd28aee1993d86b2b83b414f9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
From c84c2a02a34031a951edeb5d3f81676d05e2765f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
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 <https://bugzilla.redhat.com/857875#c8>.
|
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
From ca4705dab05371c40f398b97277024332ed44651 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
From d8e4390da96d19a322a6fd3512ccac0200f15ddb Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kamil Dudka <kdudka@redhat.com>
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: python-pycurl
|
Name: python-pycurl
|
||||||
Version: 7.19.0
|
Version: 7.19.0
|
||||||
Release: 15%{?dist}
|
Release: 16.20120408git9b8f4e38%{?dist}
|
||||||
Summary: A Python interface to libcurl
|
Summary: A Python interface to libcurl
|
||||||
|
|
||||||
Group: Development/Languages
|
Group: Development/Languages
|
||||||
@ -10,23 +10,16 @@ License: LGPLv2+ or MIT
|
|||||||
URL: http://pycurl.sourceforge.net/
|
URL: http://pycurl.sourceforge.net/
|
||||||
Source0: http://pycurl.sourceforge.net/download/pycurl-%{version}.tar.gz
|
Source0: http://pycurl.sourceforge.net/download/pycurl-%{version}.tar.gz
|
||||||
|
|
||||||
# upstream patches
|
# sync with upstream's 9b8f4e38
|
||||||
Patch1: 0001-No-longer-keep-copies-of-string-options-since-this-i.patch
|
Patch0: 0000-pycurl-7.19.7-9b8f4e38.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
|
|
||||||
|
|
||||||
Requires: keyutils-libs
|
Requires: keyutils-libs
|
||||||
BuildRequires: python-devel
|
BuildRequires: python-devel
|
||||||
BuildRequires: curl-devel >= 7.19.0
|
BuildRequires: curl-devel >= 7.19.0
|
||||||
BuildRequires: openssl-devel
|
BuildRequires: openssl-devel
|
||||||
|
BuildRequires: python-bottle
|
||||||
|
BuildRequires: python-nose
|
||||||
|
BuildRequires: vsftpd
|
||||||
|
|
||||||
# During its initialization, PycURL checks that the actual libcurl version
|
# During its initialization, PycURL checks that the actual libcurl version
|
||||||
# is not lower than the one used when PycURL was built.
|
# is not lower than the one used when PycURL was built.
|
||||||
@ -48,16 +41,12 @@ of features.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup0 -q -n pycurl-%{version}
|
%setup0 -q -n pycurl-%{version}
|
||||||
%patch1 -p1
|
|
||||||
%patch2 -p1
|
# drop CVS stuff that would prevent git patches from being applied
|
||||||
%patch3 -p1
|
find -type f | xargs sed -i 's/\$Id: [^$]*\$/$Id$/'
|
||||||
%patch4 -p1
|
|
||||||
%patch5 -p1
|
# upstream patches
|
||||||
%patch101 -p1
|
%patch0 -p1
|
||||||
%patch102 -p1
|
|
||||||
%patch103 -p1
|
|
||||||
%patch104 -p1
|
|
||||||
chmod a-x examples/*
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
CFLAGS="$RPM_OPT_FLAGS -DHAVE_CURL_OPENSSL" %{__python} setup.py build
|
CFLAGS="$RPM_OPT_FLAGS -DHAVE_CURL_OPENSSL" %{__python} setup.py build
|
||||||
@ -71,10 +60,13 @@ make test PYTHON=%{__python}
|
|||||||
rm -rf %{buildroot}%{_datadir}/doc/pycurl
|
rm -rf %{buildroot}%{_datadir}/doc/pycurl
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%doc COPYING COPYING2 ChangeLog README TODO examples doc tests
|
%doc COPYING COPYING2 ChangeLog README.rst TODO examples doc tests
|
||||||
%{python_sitearch}/*
|
%{python_sitearch}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 09 2013 Kamil Dudka <kdudka@redhat.com> - 7.19.0-16.20120408git9b8f4e38
|
||||||
|
- sync with upstream 9b8f4e38 (fixes #928370)
|
||||||
|
|
||||||
* Wed Mar 06 2013 Kamil Dudka <kdudka@redhat.com> - 7.19.0-15
|
* Wed Mar 06 2013 Kamil Dudka <kdudka@redhat.com> - 7.19.0-15
|
||||||
- allow to return -1 from the write callback (#857875)
|
- allow to return -1 from the write callback (#857875)
|
||||||
- remove the patch for curl-config --static-libs no longer needed
|
- remove the patch for curl-config --static-libs no longer needed
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user