@@ -943,7 +943,7 @@ def dataToTrafficFile(data):
943943 try :
944944 conf .trafficFP .write (data )
945945 conf .trafficFP .flush ()
946- except IOError , ex :
946+ except IOError as ex :
947947 errMsg = "something went wrong while trying "
948948 errMsg += "to write to the traffic file '%s' ('%s')" % (conf .trafficFile , getSafeExString (ex ))
949949 raise SqlmapSystemException (errMsg )
@@ -952,7 +952,7 @@ def dataToDumpFile(dumpFile, data):
952952 try :
953953 dumpFile .write (data )
954954 dumpFile .flush ()
955- except IOError , ex :
955+ except IOError as ex :
956956 if "No space left" in getUnicode (ex ):
957957 errMsg = "no space left on output device"
958958 logger .error (errMsg )
@@ -972,15 +972,15 @@ def dataToOutFile(filename, data):
972972 try :
973973 with open (retVal , "w+b" ) as f : # has to stay as non-codecs because data is raw ASCII encoded data
974974 f .write (unicodeencode (data ))
975- except UnicodeEncodeError , ex :
975+ except UnicodeEncodeError as ex :
976976 _ = normalizeUnicode (filename )
977977 if filename != _ :
978978 filename = _
979979 else :
980980 errMsg = "couldn't write to the "
981981 errMsg += "output file ('%s')" % getSafeExString (ex )
982982 raise SqlmapGenericException (errMsg )
983- except IOError , ex :
983+ except IOError as ex :
984984 errMsg = "something went wrong while trying to write "
985985 errMsg += "to the output file ('%s')" % getSafeExString (ex )
986986 raise SqlmapGenericException (errMsg )
@@ -1446,7 +1446,7 @@ def parseTargetUrl():
14461446
14471447 try :
14481448 urlSplit = urlparse .urlsplit (conf .url )
1449- except ValueError , ex :
1449+ except ValueError as ex :
14501450 errMsg = "invalid URL '%s' has been given ('%s'). " % (conf .url , getSafeExString (ex ))
14511451 errMsg += "Please be sure that you don't have any leftover characters (e.g. '[' or ']') "
14521452 errMsg += "in the hostname part"
@@ -2038,7 +2038,7 @@ def parseXmlFile(xmlFile, handler):
20382038 try :
20392039 with contextlib .closing (StringIO (readCachedFileContent (xmlFile ))) as stream :
20402040 parse (stream , handler )
2041- except (SAXParseException , UnicodeError ), ex :
2041+ except (SAXParseException , UnicodeError ) as ex :
20422042 errMsg = "something appears to be wrong with "
20432043 errMsg += "the file '%s' ('%s'). Please make " % (xmlFile , getSafeExString (ex ))
20442044 errMsg += "sure that you haven't made any changes to it"
@@ -2104,7 +2104,7 @@ def readCachedFileContent(filename, mode="rb"):
21042104 try :
21052105 with openFile (filename , mode ) as f :
21062106 kb .cache .content [filename ] = f .read ()
2107- except (IOError , OSError , MemoryError ), ex :
2107+ except (IOError , OSError , MemoryError ) as ex :
21082108 errMsg = "something went wrong while trying "
21092109 errMsg += "to read the content of file '%s' ('%s')" % (filename , getSafeExString (ex ))
21102110 raise SqlmapSystemException (errMsg )
@@ -2218,7 +2218,7 @@ def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, un
22182218 retVal [line ] = True
22192219 else :
22202220 retVal .append (line )
2221- except (IOError , OSError , MemoryError ), ex :
2221+ except (IOError , OSError , MemoryError ) as ex :
22222222 errMsg = "something went wrong while trying "
22232223 errMsg += "to read the content of file '%s' ('%s')" % (filename , getSafeExString (ex ))
22242224 raise SqlmapSystemException (errMsg )
@@ -2351,7 +2351,7 @@ def getUnicode(value, encoding=None, noneToNull=False):
23512351 while True :
23522352 try :
23532353 return unicode (value , encoding or (kb .get ("pageEncoding" ) if kb .get ("originalPage" ) else None ) or UNICODE_ENCODING )
2354- except UnicodeDecodeError , ex :
2354+ except UnicodeDecodeError as ex :
23552355 try :
23562356 return unicode (value , UNICODE_ENCODING )
23572357 except :
@@ -2407,7 +2407,7 @@ def pushValue(value):
24072407 getCurrentThreadData ().valueStack .append (copy .deepcopy (value ))
24082408 success = True
24092409 break
2410- except Exception , ex :
2410+ except Exception as ex :
24112411 _ = ex
24122412
24132413 if not success :
@@ -3095,7 +3095,7 @@ def saveConfig(conf, filename):
30953095 with openFile (filename , "wb" ) as f :
30963096 try :
30973097 config .write (f )
3098- except IOError , ex :
3098+ except IOError as ex :
30993099 errMsg = "something went wrong while trying "
31003100 errMsg += "to write to the configuration file '%s' ('%s')" % (filename , getSafeExString (ex ))
31013101 raise SqlmapSystemException (errMsg )
@@ -3442,7 +3442,7 @@ def createGithubIssue(errMsg, excMsg):
34423442
34433443 try :
34443444 content = urllib2 .urlopen (req ).read ()
3445- except Exception , ex :
3445+ except Exception as ex :
34463446 content = None
34473447
34483448 issueUrl = re .search (r"https://github.com/sqlmapproject/sqlmap/issues/\d+" , content or "" )
@@ -4063,7 +4063,7 @@ def geturl(self):
40634063 continue
40644064
40654065 request = form .click ()
4066- except (ValueError , TypeError ), ex :
4066+ except (ValueError , TypeError ) as ex :
40674067 errMsg = "there has been a problem while "
40684068 errMsg += "processing page forms ('%s')" % getSafeExString (ex )
40694069 if raise_ :
@@ -4193,7 +4193,7 @@ def evaluateCode(code, variables=None):
41934193 exec (code , variables )
41944194 except KeyboardInterrupt :
41954195 raise
4196- except Exception , ex :
4196+ except Exception as ex :
41974197 errMsg = "an error occurred while evaluating provided code ('%s') " % getSafeExString (ex )
41984198 raise SqlmapGenericException (errMsg )
41994199
@@ -4715,7 +4715,7 @@ def _parseBurpLog(content):
47154715 try :
47164716 with openFile (reqFile , "rb" ) as f :
47174717 content = f .read ()
4718- except (IOError , OSError , MemoryError ), ex :
4718+ except (IOError , OSError , MemoryError ) as ex :
47194719 errMsg = "something went wrong while trying "
47204720 errMsg += "to read the content of file '%s' ('%s')" % (reqFile , getSafeExString (ex ))
47214721 raise SqlmapSystemException (errMsg )
0 commit comments