Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.length shield exception in httplib #41644

Closed
bsder mannequin opened this issue Mar 3, 2005 · 3 comments
Closed

self.length shield exception in httplib #41644

bsder mannequin opened this issue Mar 3, 2005 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@bsder
Copy link
Mannequin

bsder mannequin commented Mar 3, 2005

BPO 1155638
Nosy @birkenfeld, @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2005-06-26.22:07:34.000>
created_at = <Date 2005-03-03.07:22:23.000>
labels = ['library']
title = 'self.length shield exception in httplib'
updated_at = <Date 2005-06-26.22:07:34.000>
user = 'https://bugs.python.org/bsder'

bugs.python.org fields:

activity = <Date 2005-06-26.22:07:34.000>
actor = 'georg.brandl'
assignee = 'georg.brandl'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-03-03.07:22:23.000>
creator = 'bsder'
dependencies = []
files = []
hgrepos = []
issue_num = 1155638
keywords = []
message_count = 3.0
messages = ['24436', '24437', '24438']
nosy_count = 4.0
nosy_names = ['georg.brandl', 'georg.brandl', 'bsder', 'euske']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1155638'
versions = ['Python 2.4']

@bsder
Copy link
Mannequin Author

bsder mannequin commented Mar 3, 2005

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.

@bsder bsder mannequin closed this as completed Mar 3, 2005
@bsder bsder mannequin assigned birkenfeld Mar 3, 2005
@bsder bsder mannequin added the stdlib Python modules in the Lib dir label Mar 3, 2005
@bsder bsder mannequin closed this as completed Mar 3, 2005
@bsder bsder mannequin assigned birkenfeld Mar 3, 2005
@bsder bsder mannequin added the stdlib Python modules in the Lib dir label Mar 3, 2005
@euske
Copy link
Mannequin

euske mannequin commented May 10, 2005

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

@birkenfeld
Copy link
Member

Logged In: YES
user_id=1188172

Thanks for the report! This is fixed as of Lib/httplib.py
r1.95, r1.94.2.1.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant