Some DeprecationWarning fixes

This commit is contained in:
Miroslav Stampar 2022-06-22 13:05:41 +02:00
parent df4293473d
commit e8731e1af5
3 changed files with 13 additions and 7 deletions

View File

@ -20,7 +20,7 @@ from thirdparty import six
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.6.6.6" VERSION = "1.6.6.7"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -5,7 +5,7 @@ Copyright (c) 2006-2022 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission See the file 'LICENSE' for copying permission
""" """
import imp import importlib
import logging import logging
import os import os
import re import re
@ -13,15 +13,18 @@ import sys
import traceback import traceback
import warnings import warnings
_path = list(sys.path)
_sqlalchemy = None _sqlalchemy = None
try: try:
f, pathname, desc = imp.find_module("sqlalchemy", sys.path[1:]) sys.path = sys.path[1:]
_ = imp.load_module("sqlalchemy", f, pathname, desc) module = importlib.import_module("sqlalchemy")
if hasattr(_, "dialects"): if hasattr(module, "dialects"):
_sqlalchemy = _ _sqlalchemy = module
warnings.simplefilter(action="ignore", category=_sqlalchemy.exc.SAWarning) warnings.simplefilter(action="ignore", category=_sqlalchemy.exc.SAWarning)
except ImportError: except ImportError:
pass pass
finally:
sys.path = _path
try: try:
import MySQLdb # used by SQLAlchemy in case of MySQL import MySQLdb # used by SQLAlchemy in case of MySQL

View File

@ -36,7 +36,10 @@ try:
warnings.filterwarnings(action="ignore", category=DeprecationWarning) warnings.filterwarnings(action="ignore", category=DeprecationWarning)
else: else:
warnings.resetwarnings() warnings.resetwarnings()
warnings.simplefilter("ignore", category=ResourceWarning, append=1) warnings.filterwarnings(action="ignore", message="'crypt'", category=DeprecationWarning)
warnings.simplefilter("ignore", category=ImportWarning)
if sys.version_info >= (3, 0):
warnings.simplefilter("ignore", category=ResourceWarning)
warnings.filterwarnings(action="ignore", message="Python 2 is no longer supported") warnings.filterwarnings(action="ignore", message="Python 2 is no longer supported")
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning) warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)