curl-and-python

Re: postfields and unicode objects

From: <johansen_at_sun.com>
Date: Thu, 13 Aug 2009 13:38:53 -0700

On Thu, Aug 13, 2009 at 11:41:55AM -0700, Toshio Kuratomi wrote:
> On 08/13/2009 09:27 AM, johansen_at_sun.com wrote:
> > It looks like unicode should work.
> >
> > Based upon this description, either the object isn't a unicode object
> > that's a subclass of string, or you've found a bug in the Python C API.
> >
> > Here's the relevant bit of pycurl.c (1635-1647):
> >
> > case CURLOPT_POSTFIELDS:
> > if (PyString_AsStringAndSize(obj, &str, &len) != 0)
> > return NULL;
> > /* automatically set POSTFIELDSIZE */
> > if (len <= INT_MAX) {
> > res = curl_easy_setopt(self->handle, CURLOPT_POSTFIELDSIZE, (lon
> > } else {
> > res = curl_easy_setopt(self->handle, CURLOPT_POSTFIELDSIZE_LARGE
> > }
> > if (res != CURLE_OK) {
> > CURLERROR_RETVAL();
> > }
> > break;
> >
> > The only place this code is checking types is in the if statement.
> >
>
> The code that's causing this is earlier around line 1587:
>
>
> /* Handle the case of string arguments */
> if (PyString_Check(obj)) {
> [...]

Thanks for the clarification. I did see that line, but got confused by
the documentation.

        int PyString_Check(PyObject *o)
            Return true if the object o is a string object or an
            instance of a subtype of the string type. Changed in version
            2.2: Allowed subtypes to be accepted.

I assumed this meant all subtypes of any kind of string, since there's
no BaseString API method. It sounds like I had that wrong.

-j
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2009-08-13