You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by "ssteiner@idc" <ss...@integrateddevcorp.com> on 2010/07/18 03:31:45 UTC

[libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

With Python 2.7, Rackspace driver

Works fine under 2.6.5, fails on Python 2.7

Traceback:
    images = self.list_images()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 193, in list_images
    return self._to_images(self.connection.request('/images/detail').object)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 147, in request
    method=method, headers=headers
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/base.py", line 433, in request
    headers=headers)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 946, in request
    self._send_request(method, url, body, headers)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 986, in _send_request
    self.putheader(hdr, value)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 924, in putheader
    str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, int found

Haven't explored too much, I'm busy on a time-critical deployment, working on switching to 2.7 to run deployment scripts, fell down right here...

Anyone have any ideas?

Thanks,

Stephen F. Steiner
Integrated Development Corporation
ssteiner@integrateddevcorp.com
www.integrateddevcorp.com
(603)433-1232




Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteiner@idc" <ss...@integrateddevcorp.com>.
And, since I'm busy talking to myself:

http://docs.python.org/library/httplib.html

	"The header Content-Length is automatically set to the correct value. The headers argument should be a mapping of extra HTTP headers to send with the request."

So setting the header is redundant anyway.

S

On Jul 18, 2010, at 8:44 AM, ssteiner@idc wrote:

> Oh, and if anyone with commit access is listening, changing line 426 in base.py to:
> 
>        headers.update({'Content-Length': str(len(data))})
> 
> Solves the problem.
> 
> S
> 
> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
> 
>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>> 
>> Of course, I reserve the right to be totally off-base here ;)
>> 
>> On Jul 17, 2010, at 9:31 PM, "ssteiner@idc" <ss...@integrateddevcorp.com> wrote:
>> 
>>> With Python 2.7, Rackspace driver
>>> 
>>> Works fine under 2.6.5, fails on Python 2.7
>>> 
>>> Traceback:
>>>  images = self.list_images()
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 193, in list_images
>>>  return self._to_images(self.connection.request('/images/detail').object)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 147, in request
>>>  method=method, headers=headers
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/base.py", line 433, in request
>>>  headers=headers)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 946, in request
>>>  self._send_request(method, url, body, headers)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 986, in _send_request
>>>  self.putheader(hdr, value)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 924, in putheader
>>>  str = '%s: %s' % (header, '\r\n\t'.join(values))
>>> TypeError: sequence item 0: expected string, int found
>>> 
>>> Haven't explored too much, I'm busy on a time-critical deployment, working on switching to 2.7 to run deployment scripts, fell down right here...
>>> 
>>> Anyone have any ideas?
>>> 
>>> Thanks,
>>> 
>>> Stephen F. Steiner
>>> Integrated Development Corporation
>>> ssteiner@integrateddevcorp.com
>>> www.integrateddevcorp.com
>>> (603)433-1232
>>> 
>>> 
>>> 
> 
> Stephen F. Steiner
> Integrated Development Corporation
> ssteiner@integrateddevcorp.com
> www.integrateddevcorp.com 
> (603)433-1232
> 
> 
> 
> 

Stephen F. Steiner
Integrated Development Corporation
ssteiner@integrateddevcorp.com
www.integrateddevcorp.com 
(603)433-1232





Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteiner@idc" <ss...@integrateddevcorp.com>.
Oh, and if anyone with commit access is listening, changing line 426 in base.py to:

        headers.update({'Content-Length': str(len(data))})

Solves the problem.

S

On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:

> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
> 
> Of course, I reserve the right to be totally off-base here ;)
> 
> On Jul 17, 2010, at 9:31 PM, "ssteiner@idc" <ss...@integrateddevcorp.com> wrote:
> 
>> With Python 2.7, Rackspace driver
>> 
>> Works fine under 2.6.5, fails on Python 2.7
>> 
>> Traceback:
>>   images = self.list_images()
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 193, in list_images
>>   return self._to_images(self.connection.request('/images/detail').object)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 147, in request
>>   method=method, headers=headers
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/base.py", line 433, in request
>>   headers=headers)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 946, in request
>>   self._send_request(method, url, body, headers)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 986, in _send_request
>>   self.putheader(hdr, value)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 924, in putheader
>>   str = '%s: %s' % (header, '\r\n\t'.join(values))
>> TypeError: sequence item 0: expected string, int found
>> 
>> Haven't explored too much, I'm busy on a time-critical deployment, working on switching to 2.7 to run deployment scripts, fell down right here...
>> 
>> Anyone have any ideas?
>> 
>> Thanks,
>> 
>> Stephen F. Steiner
>> Integrated Development Corporation
>> ssteiner@integrateddevcorp.com
>> www.integrateddevcorp.com
>> (603)433-1232
>> 
>> 
>> 

Stephen F. Steiner
Integrated Development Corporation
ssteiner@integrateddevcorp.com
www.integrateddevcorp.com 
(603)433-1232





Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteiner@idc" <ss...@integrateddevcorp.com>.
Just before base.py calls httplib on line 433, it sets this header.

base.py: 426:
        headers.update({'Content-Length': len(data)})

Why that worked before, I don't know, but it shouldn't have and now doesn't.

S


On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:

> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
> 
> Of course, I reserve the right to be totally off-base here ;)
> 
> On Jul 17, 2010, at 9:31 PM, "ssteiner@idc" <ss...@integrateddevcorp.com> wrote:
> 
>> With Python 2.7, Rackspace driver
>> 
>> Works fine under 2.6.5, fails on Python 2.7
>> 
>> Traceback:
>>   images = self.list_images()
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 193, in list_images
>>   return self._to_images(self.connection.request('/images/detail').object)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 147, in request
>>   method=method, headers=headers
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/base.py", line 433, in request
>>   headers=headers)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 946, in request
>>   self._send_request(method, url, body, headers)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 986, in _send_request
>>   self.putheader(hdr, value)
>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 924, in putheader
>>   str = '%s: %s' % (header, '\r\n\t'.join(values))
>> TypeError: sequence item 0: expected string, int found
>> 
>> Haven't explored too much, I'm busy on a time-critical deployment, working on switching to 2.7 to run deployment scripts, fell down right here...
>> 
>> Anyone have any ideas?
>> 
>> Thanks,
>> 
>> Stephen F. Steiner
>> Integrated Development Corporation
>> ssteiner@integrateddevcorp.com
>> www.integrateddevcorp.com
>> (603)433-1232
>> 
>> 
>> 

Stephen F. Steiner
Integrated Development Corporation
ssteiner@integrateddevcorp.com
www.integrateddevcorp.com 
(603)433-1232





Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Jul 19, 2010, at 11:52 AM, Jed Smith wrote:

> On Jul 19, 2010, at 10:35 AM, ssteinerX@gmail.com wrote:
> 
>> 
>> On Jul 19, 2010, at 10:18 AM, Jed Smith wrote:
>> 
>>> On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:
>>> 
>>>> 
>>>> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
>>>> 
>>>>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>>>>> 
>>>>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>>>>> 
>>>>> That's eye-opening.
>>>>> 
>>>>> I always thought %s called str() on the arguments in question if they weren't
>>>>> strings already.  If they did indeed change that, half of my code (not only
>>>>> in libcloud) is going to break.  I'd hope that's a regression and not
>>>>> intentional...
>>>> 
>>>> Please see my previous message about the redundant header that's being explicitly set as an integer.
>>> 
>>> Oh, it's in the .join(values).  That makes more sense, and has never worked.
>>> 
>>> My apologies, read the exception wrong.
>> 
>> No problem, now, the question is who is going to remove the setting of the redundant header and get it committed?
> 
> I cast it to string as opposed to removing it.  There may be a reason it is set
> that both of us are unaware of.  LIBCLOUD-43 created for tracking.
> 
> Fixed in r965538 = 04f1f94f1fe26d2ac36f29d7b7a57ea786fed070

As per a previous e-mail, it's set by httplib by default but I guess without testing, this is safer.

Thanks,

S


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by Jerry Chen <je...@apache.org>.
On Jul 19, 2010, at 10:52 AM, Jed Smith wrote:

> On Jul 19, 2010, at 10:35 AM, ssteinerX@gmail.com wrote:
> 
>> 
>> On Jul 19, 2010, at 10:18 AM, Jed Smith wrote:
>> 
>>> On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:
>>> 
>>>> 
>>>> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
>>>> 
>>>>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>>>>> 
>>>>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>>>>> 
>>>>> That's eye-opening.
>>>>> 
>>>>> I always thought %s called str() on the arguments in question if they weren't
>>>>> strings already.  If they did indeed change that, half of my code (not only
>>>>> in libcloud) is going to break.  I'd hope that's a regression and not
>>>>> intentional...
>>>> 
>>>> Please see my previous message about the redundant header that's being explicitly set as an integer.
>>> 
>>> Oh, it's in the .join(values).  That makes more sense, and has never worked.
>>> 
>>> My apologies, read the exception wrong.
>> 
>> No problem, now, the question is who is going to remove the setting of the redundant header and get it committed?
> 
> I cast it to string as opposed to removing it.  There may be a reason it is set
> that both of us are unaware of.  LIBCLOUD-43 created for tracking.
> 
> Fixed in r965538 = 04f1f94f1fe26d2ac36f29d7b7a57ea786fed070

Thanks Jed.


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by Jed Smith <je...@jedsmith.org>.
On Jul 19, 2010, at 10:35 AM, ssteinerX@gmail.com wrote:

> 
> On Jul 19, 2010, at 10:18 AM, Jed Smith wrote:
> 
>> On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:
>> 
>>> 
>>> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
>>> 
>>>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>>>> 
>>>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>>>> 
>>>> That's eye-opening.
>>>> 
>>>> I always thought %s called str() on the arguments in question if they weren't
>>>> strings already.  If they did indeed change that, half of my code (not only
>>>> in libcloud) is going to break.  I'd hope that's a regression and not
>>>> intentional...
>>> 
>>> Please see my previous message about the redundant header that's being explicitly set as an integer.
>> 
>> Oh, it's in the .join(values).  That makes more sense, and has never worked.
>> 
>> My apologies, read the exception wrong.
> 
> No problem, now, the question is who is going to remove the setting of the redundant header and get it committed?

I cast it to string as opposed to removing it.  There may be a reason it is set
that both of us are unaware of.  LIBCLOUD-43 created for tracking.

Fixed in r965538 = 04f1f94f1fe26d2ac36f29d7b7a57ea786fed070

JS


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Jul 19, 2010, at 10:18 AM, Jed Smith wrote:

> On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:
> 
>> 
>> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
>> 
>>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>>> 
>>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>>> 
>>> That's eye-opening.
>>> 
>>> I always thought %s called str() on the arguments in question if they weren't
>>> strings already.  If they did indeed change that, half of my code (not only
>>> in libcloud) is going to break.  I'd hope that's a regression and not
>>> intentional...
>> 
>> Please see my previous message about the redundant header that's being explicitly set as an integer.
> 
> Oh, it's in the .join(values).  That makes more sense, and has never worked.
> 
> My apologies, read the exception wrong.

No problem, now, the question is who is going to remove the setting of the redundant header and get it committed?

S



Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by Jed Smith <je...@jedsmith.org>.
On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:

> 
> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
> 
>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>> 
>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>> 
>> That's eye-opening.
>> 
>> I always thought %s called str() on the arguments in question if they weren't
>> strings already.  If they did indeed change that, half of my code (not only
>> in libcloud) is going to break.  I'd hope that's a regression and not
>> intentional...
> 
> Please see my previous message about the redundant header that's being explicitly set as an integer.

Oh, it's in the .join(values).  That makes more sense, and has never worked.

My apologies, read the exception wrong.

JS


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Jul 19, 2010, at 10:13 AM, ssteinerX@gmail.com wrote:

> 
> On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:
> 
>> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
>> 
>>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
>> 
>> That's eye-opening.
>> 
>> I always thought %s called str() on the arguments in question if they weren't
>> strings already.  If they did indeed change that, half of my code (not only
>> in libcloud) is going to break.  I'd hope that's a regression and not
>> intentional...
> 
> Please see my previous message about the redundant header that's being explicitly set as an integer.
> 
> The chances of an error like the one you're talking about getting through the Python release process is incredibly unlikely.

Sometimes gluing two sentences together doesn't work:

> The chance of an error like the one you're talking about getting through the Python release process is incredibly slim.


S


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Jul 19, 2010, at 10:04 AM, Jed Smith wrote:

> On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:
> 
>> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.
> 
> That's eye-opening.
> 
> I always thought %s called str() on the arguments in question if they weren't
> strings already.  If they did indeed change that, half of my code (not only
> in libcloud) is going to break.  I'd hope that's a regression and not
> intentional...

Please see my previous message about the redundant header that's being explicitly set as an integer.

The chances of an error like the one you're talking about getting through the Python release process is incredibly unlikely.

S


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by Jed Smith <je...@jedsmith.org>.
On Jul 18, 2010, at 12:25 AM, Tom Davis wrote:

> Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.

That's eye-opening.

I always thought %s called str() on the arguments in question if they weren't
strings already.  If they did indeed change that, half of my code (not only
in libcloud) is going to break.  I'd hope that's a regression and not
intentional...

JS


Re: [libcloud] Python 2.7 _to_images putheader failure, works on Python 2.6

Posted by Tom Davis <to...@dislocatedday.com>.
Judging by the exception, I guess they stopped implicitly casting variables used in format strings? That's not something I remember reading about in What's New, but it makes sense in that context. What header we're sending that isn't a string is another question.

Of course, I reserve the right to be totally off-base here ;)

On Jul 17, 2010, at 9:31 PM, "ssteiner@idc" <ss...@integrateddevcorp.com> wrote:

> With Python 2.7, Rackspace driver
> 
> Works fine under 2.6.5, fails on Python 2.7
> 
> Traceback:
>    images = self.list_images()
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 193, in list_images
>    return self._to_images(self.connection.request('/images/detail').object)
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/drivers/rackspace.py", line 147, in request
>    method=method, headers=headers
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/apache_libcloud-0.4.0-py2.7.egg/libcloud/base.py", line 433, in request
>    headers=headers)
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 946, in request
>    self._send_request(method, url, body, headers)
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 986, in _send_request
>    self.putheader(hdr, value)
>  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 924, in putheader
>    str = '%s: %s' % (header, '\r\n\t'.join(values))
> TypeError: sequence item 0: expected string, int found
> 
> Haven't explored too much, I'm busy on a time-critical deployment, working on switching to 2.7 to run deployment scripts, fell down right here...
> 
> Anyone have any ideas?
> 
> Thanks,
> 
> Stephen F. Steiner
> Integrated Development Corporation
> ssteiner@integrateddevcorp.com
> www.integrateddevcorp.com
> (603)433-1232
> 
> 
>