curl-and-python

Re: Problems with OPT_CAINFO

From: Dario Meloni via curl-and-python <curl-and-python_at_cool.haxx.se>
Date: Thu, 6 Aug 2015 12:21:48 +0200

Yes, you are right,
I just finished some more testing and noticed I had a mess in the python
libraries. I cleared everything and now I can make everything work on
python2, but not on python3 due to that different behaviour in the call to
libcurl.
Disregard the previous patch. I can reproduce it in every case in python3
running the example script

$ ltrace -e curl_easy_setopt python3 certinfo_example.py
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x271a,
0x7fc931d12ee8, 116) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x2777,
0x7fc931d12e10, 0) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 43, 1,
0x7ffecd69d730) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 41, 0,
0x7ffecd69d730) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x2796,
0, 0x7ffecd69d730) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x2722,
0x26eb380, 0x7ffecd69d730) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x2712,
0x7fc931c170f8, 8) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x4e2b,
0x7fc9308715c0, 0) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 0x2711,
0x7fc931d12e10, 0x7ffecd69d610) = 0
pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0x276b9e0, 172, 1,
0) = 48
Traceback (most recent call last):
  File "certinfo_example.py", line 20, in <module>
    elements = certinfo_demo()[0]
  File "certinfo_example.py", line 13, in certinfo_demo
    c.setopt(pycurl.OPT_CERTINFO, True)
pycurl.error: (48, '')
+++ exited (status 1) +++

Dario Meloni

2015-08-06 11:49 GMT+02:00 Kamil Dudka <kdudka_at_redhat.com>:

> On Thursday 06 August 2015 11:31:00 Dario Meloni via curl-and-python wrote:
> > I am sorry, I created the patch backward...
> >
> >
> > --- easy.c.orig 2015-08-06 11:12:33.070837025 +0200
> > +++ easy.c 2015-08-06 11:12:41.334837007 +0200
> > @@ -1,5 +1,6 @@
> > #include "pycurl.h"
> > #include "docstrings.h"
> > +#include <curl/curl.h>
>
> This looks strange. <curl/curl.h> is already included by src/pycurl.h so
> including it once again should be a no-op. Could you please attach the
> preprocessed source code of src/easy.c with/without your patch?
>
> Kamil
>
> >
> /*************************************************************************
> > // static utility functions
> >
> >
> > Dario Meloni
> >
> > 2015-08-06 11:17 GMT+02:00 Dario Meloni <mellon85_at_gmail.com>:
> > > While developing some automated test in python I noticed I couldn't get
> > > OPT_CAINFO to work, it was always returning error 48 (UNKNOWN OPTION).
> > > The error is raised also while trying the example script from
> > >
> http://curl.haxx.se/mail/curlpython-2010-02/att-0017/certinfo_example.py
> > >
> > > This is happening on Ubuntu 14.04LTS. I tested with both pycurl 7.19.3
> > > (ubuntu package), installing the latest 7.19.5.1 in python 2 and 3 with
> > > pip/pip3 and also manually installing it.
> > >
> > >
> > > I checked with ltrace what's the difference wrt a simple C program that
> > > was instead working and noticed these diferences:
> > >
> > > a.out->curl_easy_setopt(0x801510, 172, 1, 172) = 0
> > >
> > > pycurl.cpython-34m-x86_64-linux-gnu.so->curl_easy_setopt(0xfa4c30,
> 172, 1,
> > > 0) = 48
> > >
> > > the pycurl version was sending a different value as the last argument
> > >
> > > Applying this incredibly small patch fixes it for me
> > >
> > >
> > > --- easy.c 2015-08-06 11:12:41.334837007 +0200
> > > +++ easy.c.orig 2015-08-06 11:12:33.070837025 +0200
> > > @@ -1,6 +1,5 @@
> > >
> > > #include "pycurl.h"
> > > #include "docstrings.h"
> > >
> > > -#include <curl/curl.h>
> > >
> > >
> /************************************************************************
> > > *
> > > // static utility functions
> > >
> > > Dario Meloni
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2015-08-06