@@ -79,8 +79,7 @@ def open_without_clobber(name, *args):
7979 while fd is None :
8080 try :
8181 fd = os .open (name , os .O_CREAT | os .O_EXCL , 0o666 )
82- except OSError :
83- err = sys .exc_info ()[1 ]
82+ except OSError as err :
8483 if err .errno == os .errno .EEXIST :
8584 name = "%s.%i" % (orig_name , count )
8685 count += 1
@@ -1008,8 +1007,8 @@ def _handle_login(opt, parser, args, action, bz):
10081007 print ("Logging into %s" % urlparse (bz .url )[1 ])
10091008 bz .interactive_login (
10101009 opt .username , opt .password )
1011- except bugzilla .BugzillaError :
1012- print (str (sys . exc_info ()[ 1 ] ))
1010+ except bugzilla .BugzillaError as e :
1011+ print (str (e ))
10131012 sys .exit (1 )
10141013
10151014 if opt .ensure_logged_in and not bz .logged_in :
@@ -1120,13 +1119,11 @@ if __name__ == '__main__':
11201119 log .debug ("" , exc_info = True )
11211120 print ("\n Exited at user request." )
11221121 sys .exit (1 )
1123- except (Fault , bugzilla .BugzillaError ):
1124- e = sys .exc_info ()[1 ]
1122+ except (Fault , bugzilla .BugzillaError ) as e :
11251123 log .debug ("" , exc_info = True )
11261124 print ("\n Server error: %s" % str (e ))
11271125 sys .exit (3 )
1128- except ProtocolError :
1129- e = sys .exc_info ()[1 ]
1126+ except ProtocolError as e :
11301127 log .debug ("" , exc_info = True )
11311128 print ("\n Invalid server response: %d %s" % (e .errcode , e .errmsg ))
11321129 # Detect redirect
@@ -1135,8 +1132,7 @@ if __name__ == '__main__':
11351132 print ("\n Server was attempting a redirect. Try: "
11361133 " bugzilla --bugzilla %s ..." % redir )
11371134 sys .exit (4 )
1138- except requests .exceptions .SSLError :
1139- e = sys .exc_info ()[1 ]
1135+ except requests .exceptions .SSLError as e :
11401136 log .debug ("" , exc_info = True )
11411137
11421138 # Give SSL recommendations
@@ -1147,8 +1143,7 @@ if __name__ == '__main__':
11471143 sys .exit (4 )
11481144 except (socket .error ,
11491145 requests .exceptions .HTTPError ,
1150- requests .exceptions .ConnectionError ):
1151- e = sys .exc_info ()[1 ]
1146+ requests .exceptions .ConnectionError ) as e :
11521147 log .debug ("" , exc_info = True )
11531148 print ("\n Connection lost/failed: %s" % str (e ))
11541149 sys .exit (2 )
0 commit comments