Old exception handling format to new one

This commit is contained in:
Miroslav Stampar 2019-01-22 14:09:13 +01:00
parent ba356baab0
commit bdc4457f34
11 changed files with 26 additions and 27 deletions

View File

@ -61,8 +61,8 @@ def main():
if not args.inputFile:
parser.error('Missing the input file, -h for help')
except (OptionError, TypeError), e:
parser.error(e)
except (OptionError, TypeError) as ex:
parser.error(ex)
if not os.path.isfile(args.inputFile):
print('ERROR: the provided input file \'%s\' is non existent' % args.inputFile)

View File

@ -88,8 +88,8 @@ if __name__ == "__main__":
if not args.inputFile:
parser.error("Missing the input file, -h for help")
except (OptionError, TypeError), e:
parser.error(e)
except (OptionError, TypeError) as ex:
parser.error(ex)
inputFile = args.inputFile
outputFile = args.outputFile

View File

@ -110,8 +110,8 @@ def main():
if not args.inputFile:
parser.error('Missing the input file, -h for help')
except (OptionError, TypeError), e:
parser.error(e)
except (OptionError, TypeError) as ex:
parser.error(ex)
if not os.path.isfile(args.inputFile):
print('ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile)

View File

@ -10,7 +10,6 @@ import os
import cProfile
from lib.core.common import getSafeExString
from lib.core.common import getUnicode
from lib.core.data import logger
from lib.core.data import paths
from lib.core.settings import UNICODE_ENCODING

View File

@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
from lib.core.enums import OS
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.1.71"
VERSION = "1.3.1.72"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -1836,7 +1836,7 @@ class UnicodeDammit:
u = self._toUnicode(markup, proposed)
self.markup = u
self.originalEncoding = proposed
except Exception, e:
except Exception as e:
# print "That didn't work!"
# print e
return None

View File

@ -1100,7 +1100,7 @@ def _ParseFileEx(file, base_uri,
data = file.read(CHUNK)
try:
fp.feed(data)
except ParseError, e:
except ParseError as e:
e.base_uri = base_uri
raise
if len(data) != CHUNK: break
@ -2902,7 +2902,7 @@ class HTMLForm:
control = self.find_control(name)
try:
control.value = value
except AttributeError, e:
except AttributeError as e:
raise ValueError(str(e))
def get_value(self,

View File

@ -180,7 +180,7 @@ class AnsiToWin32(object):
def _write(self, text, retry=5):
try:
self.wrapped.write(text)
except IOError, err:
except IOError as err:
if not (err.errno == 0 and retry > 0):
raise
self._write(text, retry-1)

View File

@ -695,7 +695,7 @@ class XmlTokenizer:
self.final = len(data) < size
try:
self.parser.Parse(data, self.final)
except xml.parsers.expat.ExpatError, e:
except xml.parsers.expat.ExpatError as e:
#if e.code == xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS:
if e.code == 3:
pass

View File

@ -238,7 +238,7 @@ class KeepAliveHandler:
self._cm.add(host, h, 0)
self._start_transaction(h, req)
r = h.getresponse()
except (socket.error, httplib.HTTPException), err:
except (socket.error, httplib.HTTPException) as err:
raise urllib2.URLError(err)
if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason)
@ -323,7 +323,7 @@ class KeepAliveHandler:
h.putrequest(req.get_method() or 'GET', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
else:
h.putrequest(req.get_method() or 'GET', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
except (socket.error, httplib.HTTPException), err:
except (socket.error, httplib.HTTPException) as err:
raise urllib2.URLError(err)
if not req.headers.has_key('Connection'):
@ -495,7 +495,7 @@ def error_handler(url):
fo.close()
try: status, reason = fo.status, fo.reason
except AttributeError: status, reason = None, None
except IOError, e:
except IOError as e:
print " EXCEPTION: %s" % e
raise
else:
@ -613,7 +613,7 @@ def test_timeout(url):
def test(url, N=10):
print "checking error hander (do this on a non-200)"
try: error_handler(url)
except IOError, e:
except IOError as e:
print "exiting - exception will prevent further tests"
sys.exit()
print

View File

@ -1,8 +1,8 @@
3d37032b2bd62ee37bd61c5b7ad31ab4 extra/beep/beep.py
fb6be55d21a70765e35549af2484f762 extra/beep/__init__.py
03e8129f9ef4aea150266255a0cd06f4 extra/cloak/cloak.py
8b4237aae3b82c325e0b34f6adfa0bc3 extra/cloak/cloak.py
fb6be55d21a70765e35549af2484f762 extra/cloak/__init__.py
c7da22bb04f5c42a523d04baebe8088c extra/dbgtool/dbgtool.py
1046e46c8923ec5afe4f6f1ca3ee55bb extra/dbgtool/dbgtool.py
fb6be55d21a70765e35549af2484f762 extra/dbgtool/__init__.py
acba8b5dc93db0fe6b2b04ff0138c33c extra/icmpsh/icmpsh.exe_
216a0e04bef7053e6aa35ca98907007e extra/icmpsh/icmpsh_m.py
@ -10,7 +10,7 @@ acba8b5dc93db0fe6b2b04ff0138c33c extra/icmpsh/icmpsh.exe_
fb6be55d21a70765e35549af2484f762 extra/__init__.py
ff90cb0366f7cefbdd6e573e27e6238c extra/runcmd/runcmd.exe_
fb6be55d21a70765e35549af2484f762 extra/safe2bin/__init__.py
db2b5fce6e92d3a13cb62aea5ffcae2d extra/safe2bin/safe2bin.py
c26cfad6b77b44a1317cd058b4477ce0 extra/safe2bin/safe2bin.py
d229479d02d21b29f209143cb0547780 extra/shellcodeexec/linux/shellcodeexec.x32_
2fe2f94eebc62f7614f0391a8a90104f extra/shellcodeexec/linux/shellcodeexec.x64_
c55b400b72acc43e0e59c87dd8bb8d75 extra/shellcodeexec/windows/shellcodeexec.x32.exe_
@ -44,12 +44,12 @@ fb6be55d21a70765e35549af2484f762 lib/core/__init__.py
fa9f24e88c81a6cef52da3dd5e637010 lib/core/optiondict.py
b56df9d9426027f3450432c2b6428485 lib/core/option.py
fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py
4cfda3735871cd59b213470a0bbc8c3a lib/core/profiling.py
4b12aa67fbf6c973d12e54cf9cb54ea0 lib/core/profiling.py
5e2c16a8e2daee22dd545df13386e7a3 lib/core/readlineng.py
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
77e8b3de0d19deb37e87cf34bdf18a1a lib/core/settings.py
568792efda46b66327bb5e42ee5f136f lib/core/settings.py
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
9c7b5c6397fb3da33e7a4d7876d159c6 lib/core/target.py
@ -294,7 +294,7 @@ fc571c746951a5306591e04f70ddc46e tamper/versionedmorekeywords.py
d39ce1f99e268dc7f92b602656f49461 tamper/xforwardedfor.py
b1c02296b4e3b0ebaa58b9dcd914cbf4 thirdparty/ansistrm/ansistrm.py
d41d8cd98f00b204e9800998ecf8427e thirdparty/ansistrm/__init__.py
4dd01a6ac22e44e445330500e2a7fb1a thirdparty/beautifulsoup/beautifulsoup.py
7abd52c4381afd8ac07d5978c8897c2b thirdparty/beautifulsoup/beautifulsoup.py
cb2e1fe7c404dff41a2ae9132828f532 thirdparty/beautifulsoup/__init__.py
ff54a1d98f0ab01ba7b58b068d2ebd26 thirdparty/bottle/bottle.py
4528e6a7bb9341c36c425faf40ef32c3 thirdparty/bottle/__init__.py
@ -336,21 +336,21 @@ ee25f2a03587e2c283eab0b36c9e5783 thirdparty/chardet/sbcsgroupprober.py
c9349824f2647962175d321cc0c52134 thirdparty/chardet/sjisprober.py
bcae4c645a737d3f0e7c96a66528ca4a thirdparty/chardet/universaldetector.py
6f8b3e25472c02fb45a75215a175991f thirdparty/chardet/utf8prober.py
9df18debb6b5c5c0caff3d126958c8d7 thirdparty/clientform/clientform.py
1dd9a97cef4c8e7da7082c1f0518a19b thirdparty/clientform/clientform.py
722281d87fb13ec22555480f8f4c715b thirdparty/clientform/__init__.py
0b625ccefa6b066f79d3cbb3639267e6 thirdparty/colorama/ansi.py
93bb7f06c8300a91b533ea55e8aead43 thirdparty/colorama/ansitowin32.py
7ec474bef2432a1b45001bb87f2ab25f thirdparty/colorama/ansitowin32.py
ed4d76c08741d34ac79f6488663345f7 thirdparty/colorama/initialise.py
c0707ca77ccb4a2c0f12b4085057193c thirdparty/colorama/__init__.py
ad3d022d4591aee80f7391248d722413 thirdparty/colorama/win32.py
cdd682cbf77137ef4253b77a95ed9bd8 thirdparty/colorama/winterm.py
be7eac2e6cfb45c5e297ec5eee66e747 thirdparty/fcrypt/fcrypt.py
e00542d22ffa8d8ac894c210f38454be thirdparty/fcrypt/__init__.py
f495039e29b2ebe431fa0a31d3c564fa thirdparty/gprof2dot/gprof2dot.py
5bf76c1e6f4674cec65d89814d989304 thirdparty/gprof2dot/gprof2dot.py
855372c870a23d46683f8aa39d75f6a1 thirdparty/gprof2dot/__init__.py
d41d8cd98f00b204e9800998ecf8427e thirdparty/__init__.py
e3b18f925d125bd17c7e7a7ec0b4b85f thirdparty/keepalive/__init__.py
e0c6a936506bffeed53ce106ec15942d thirdparty/keepalive/keepalive.py
c7e8085d9db7a798540b3bad4546dd4a thirdparty/keepalive/keepalive.py
d41d8cd98f00b204e9800998ecf8427e thirdparty/magic/__init__.py
bf318e0abbe6b2e1a167a233db7f744f thirdparty/magic/magic.py
d41d8cd98f00b204e9800998ecf8427e thirdparty/multipart/__init__.py