Skip to content

Commit e8731e1

Browse files
committed
Some DeprecationWarning fixes
1 parent df42934 commit e8731e1

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.6.6.6"
23+
VERSION = "1.6.6.7"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/sqlalchemy.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8-
import imp
8+
import importlib
99
import logging
1010
import os
1111
import re
1212
import sys
1313
import traceback
1414
import warnings
1515

16+
_path = list(sys.path)
1617
_sqlalchemy = None
1718
try:
18-
f, pathname, desc = imp.find_module("sqlalchemy", sys.path[1:])
19-
_ = imp.load_module("sqlalchemy", f, pathname, desc)
20-
if hasattr(_, "dialects"):
21-
_sqlalchemy = _
19+
sys.path = sys.path[1:]
20+
module = importlib.import_module("sqlalchemy")
21+
if hasattr(module, "dialects"):
22+
_sqlalchemy = module
2223
warnings.simplefilter(action="ignore", category=_sqlalchemy.exc.SAWarning)
2324
except ImportError:
2425
pass
26+
finally:
27+
sys.path = _path
2528

2629
try:
2730
import MySQLdb # used by SQLAlchemy in case of MySQL

sqlmap.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
3737
else:
3838
warnings.resetwarnings()
39-
warnings.simplefilter("ignore", category=ResourceWarning, append=1)
39+
warnings.filterwarnings(action="ignore", message="'crypt'", category=DeprecationWarning)
40+
warnings.simplefilter("ignore", category=ImportWarning)
41+
if sys.version_info >= (3, 0):
42+
warnings.simplefilter("ignore", category=ResourceWarning)
4043

4144
warnings.filterwarnings(action="ignore", message="Python 2 is no longer supported")
4245
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)

0 commit comments

Comments
 (0)