diff options
-rw-r--r-- | psutil/_common.py | 2 | ||||
-rw-r--r-- | psutil/_pslinux.py | 6 | ||||
-rw-r--r-- | psutil/tests/__init__.py | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/psutil/_common.py b/psutil/_common.py index 90e76c6c..74ae2557 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -372,7 +372,7 @@ if PY3: if isinstance(__builtins__, dict): # cpython exec_ = __builtins__["exec"] else: # pypy - exec_ = getattr(__builtins__, "exec") + exec_ = getattr(__builtins__, "exec") # noqa exec_("""def raise_from(value, from_value): try: diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 33ee1b14..11e62944 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -510,7 +510,7 @@ def virtual_memory(): msg = "%s memory stats couldn't be determined and %s set to 0" % ( ", ".join(missing_fields), "was" if len(missing_fields) == 1 else "were") - warnings.warn(msg, RuntimeWarning) + warnings.warn(msg, RuntimeWarning, stacklevel=2) return svmem(total, avail, percent, used, free, active, inactive, buffers, cached, shared, slab) @@ -544,7 +544,7 @@ def swap_memory(): # see https://github.com/giampaolo/psutil/issues/722 msg = "'sin' and 'sout' swap memory stats couldn't " \ "be determined and were set to 0 (%s)" % str(err) - warnings.warn(msg, RuntimeWarning) + warnings.warn(msg, RuntimeWarning, stacklevel=2) sin = sout = 0 else: with f: @@ -564,7 +564,7 @@ def swap_memory(): # https://github.com/giampaolo/psutil/issues/313 msg = "'sin' and 'sout' swap memory stats couldn't " \ "be determined and were set to 0" - warnings.warn(msg, RuntimeWarning) + warnings.warn(msg, RuntimeWarning, stacklevel=2) sin = sout = 0 return _common.sswap(total, used, free, percent, sin, sout) diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index e3766eea..cdc8b671 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -248,7 +248,7 @@ def _get_py_exe(): # Let's use the base python in this case. base = getattr(sys, "_base_executable", None) if WINDOWS and sys.version_info >= (3, 7) and base is not None: - # We need to set __PYVENV_LAUNCHER__ to sys.executable for the + # We need to set __PYVENV_LAUNCHER__ to sys.executable for the # base python executable to know about the environment. env["__PYVENV_LAUNCHER__"] = sys.executable return base, env @@ -1737,7 +1737,7 @@ def import_module_by_path(path): def warn(msg): """Raise a warning msg.""" - warnings.warn(msg, UserWarning) + warnings.warn(msg, UserWarning, stacklevel=2) def is_namedtuple(x): |