Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12f4f35

Browse files
committed
Fix SF bug #575360
Subclasses of Exception that define an __init__ must call Exception.__init__ or define self.args. Otherwise, str() will fail. Bug fix candidate.
1 parent d46aa37 commit 12f4f35

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/httplib.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ def __init__(self, host='', port=None, key_file=None, cert_file=None,
889889

890890

891891
class HTTPException(Exception):
892+
# Subclasses that define an __init__ must call Exception.__init__
893+
# or define self.args. Otherwise, str() will fail.
892894
pass
893895

894896
class NotConnected(HTTPException):
@@ -899,6 +901,7 @@ class InvalidURL(HTTPException):
899901

900902
class UnknownProtocol(HTTPException):
901903
def __init__(self, version):
904+
self.args = version,
902905
self.version = version
903906

904907
class UnknownTransferEncoding(HTTPException):
@@ -909,6 +912,7 @@ class UnimplementedFileMode(HTTPException):
909912

910913
class IncompleteRead(HTTPException):
911914
def __init__(self, partial):
915+
self.args = partial,
912916
self.partial = partial
913917

914918
class ImproperConnectionState(HTTPException):
@@ -925,6 +929,7 @@ class ResponseNotReady(ImproperConnectionState):
925929

926930
class BadStatusLine(HTTPException):
927931
def __init__(self, line):
932+
self.args = line,
928933
self.line = line
929934

930935
# for backwards compatibility
@@ -1073,6 +1078,7 @@ class HTTP11(HTTP):
10731078
r = c.getresponse()
10741079
except BadStatusLine, err:
10751080
print "strict mode failed as expected"
1081+
print err
10761082
else:
10771083
print "XXX strict mode should have failed"
10781084

0 commit comments

Comments
 (0)