@@ -889,6 +889,8 @@ def __init__(self, host='', port=None, key_file=None, cert_file=None,
889889
890890
891891class HTTPException (Exception ):
892+ # Subclasses that define an __init__ must call Exception.__init__
893+ # or define self.args. Otherwise, str() will fail.
892894 pass
893895
894896class NotConnected (HTTPException ):
@@ -899,6 +901,7 @@ class InvalidURL(HTTPException):
899901
900902class UnknownProtocol (HTTPException ):
901903 def __init__ (self , version ):
904+ self .args = version ,
902905 self .version = version
903906
904907class UnknownTransferEncoding (HTTPException ):
@@ -909,6 +912,7 @@ class UnimplementedFileMode(HTTPException):
909912
910913class IncompleteRead (HTTPException ):
911914 def __init__ (self , partial ):
915+ self .args = partial ,
912916 self .partial = partial
913917
914918class ImproperConnectionState (HTTPException ):
@@ -925,6 +929,7 @@ class ResponseNotReady(ImproperConnectionState):
925929
926930class 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