mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
Make sure LineAndFileWrapper gets bytes() as its first argument.
This change fixes a test in test_urllib.
This commit is contained in:
parent
4e7855d7fd
commit
04319c78d6
1 changed files with 5 additions and 3 deletions
|
|
@ -340,7 +340,7 @@ class HTTPResponse:
|
||||||
self.will_close = _UNKNOWN # conn will close at end of response
|
self.will_close = _UNKNOWN # conn will close at end of response
|
||||||
|
|
||||||
def _read_status(self):
|
def _read_status(self):
|
||||||
# Initialize with Simple-Response defaults
|
# Initialize with Simple-Response defaults.
|
||||||
line = str(self.fp.readline(), "iso-8859-1")
|
line = str(self.fp.readline(), "iso-8859-1")
|
||||||
if self.debuglevel > 0:
|
if self.debuglevel > 0:
|
||||||
print("reply:", repr(line))
|
print("reply:", repr(line))
|
||||||
|
|
@ -363,8 +363,10 @@ class HTTPResponse:
|
||||||
self.close()
|
self.close()
|
||||||
raise BadStatusLine(line)
|
raise BadStatusLine(line)
|
||||||
else:
|
else:
|
||||||
# assume it's a Simple-Response from an 0.9 server
|
# Assume it's a Simple-Response from an 0.9 server.
|
||||||
self.fp = LineAndFileWrapper(line, self.fp)
|
# We have to convert the first line back to raw bytes
|
||||||
|
# because self.fp.readline() needs to return bytes.
|
||||||
|
self.fp = LineAndFileWrapper(bytes(line), self.fp)
|
||||||
return "HTTP/0.9", 200, ""
|
return "HTTP/0.9", 200, ""
|
||||||
|
|
||||||
# The status code is a three-digit number
|
# The status code is a three-digit number
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue