This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: self.length shield exception in httplib
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: bsder, euske, georg.brandl, georg.brandl
Priority: normal Keywords:

Created on 2005-03-03 07:22 by bsder, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg24436 - (view) Author: Andrew P. Lentvorski, Jr. (bsder) Date: 2005-03-03 07:22
Under certain conditions (I'm trying to open a
Shoutcast stream), I wind up with the following
exception from httplib:

 Traceback (most recent call last):
  File "/home/devel/lib/python2.4/threading.py", line
442, in __bootstrap
    self.run()
  File "avalanche.py", line 86, in run
    streamData = streamResponse.read(256)
  File "/home/devel/lib/python2.4/httplib.py", line
478, in read
    self.length -= len(s)
TypeError: unsupported operand type(s) for -=: 'str'
and 'int'

Normally, self.length has many shields of the form "if
self.length is None:"; however, self.length gets
initialize to _UNKNOWN which is the string "UNKNOWN"
rather than None.  As such, all of the shields are useless.

Am I using a deprecated library or something?  I'm
really surprised no one else has bumped into this.
msg24437 - (view) Author: Yusuke Shinyama (euske) Date: 2005-05-10 02:46
Logged In: YES 
user_id=385990

I did bump into the same problem.
Apparently when I got HTTP/0.9 connection, self.length is
not initialized.
Inserting a line into l.362 at httplib.py (v2.4) seems to
solve this problem. I will also post a patch:

        if self.version == 9:
            self.chunked = 0
            self.will_close = 1
            self.msg = HTTPMessage(StringIO())
+            self.length = None
            return
msg24438 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-26 22:07
Logged In: YES 
user_id=1188172

Thanks for the report! This is fixed as of Lib/httplib.py
r1.95, r1.94.2.1.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41644
2005-03-03 07:22:23bsdercreate