diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2023-03-07 18:30:55 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2023-03-07 18:30:55 +0100 |
commit | 56586c925d30dbac177fe756687f619c454c702c (patch) | |
tree | a833d481d82165991008bfd1a44b49bd8c39128a | |
parent | bea3cf2d16899251b4b5f6b2609db9881645ea2d (diff) | |
download | psutil-56586c925d30dbac177fe756687f619c454c702c.tar.gz |
fix exec() compatibility with PYPY (closes #2198)
-rw-r--r-- | psutil/_common.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/psutil/_common.py b/psutil/_common.py index da8a96e5..90e76c6c 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -369,7 +369,12 @@ class TimeoutExpired(Error): # This should be in _compat.py rather than here, but does not work well # with setup.py importing this module via a sys.path trick. if PY3: - __builtins__["exec"]("""def raise_from(value, from_value): + if isinstance(__builtins__, dict): # cpython + exec_ = __builtins__["exec"] + else: # pypy + exec_ = getattr(__builtins__, "exec") + + exec_("""def raise_from(value, from_value): try: raise value from from_value finally: |