diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-04 10:30:49 -0700 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-04 10:30:49 -0700 |
commit | e8a7c6da1a97921bd44793b7af9ce6d9752d24ea (patch) | |
tree | 6cada7f0d1772f76d4e0fa6074414a994eaeebcd | |
parent | f6d6fe1f959ebc93fe0284311dc1441f0a47aef5 (diff) | |
download | psutil-e8a7c6da1a97921bd44793b7af9ce6d9752d24ea.tar.gz |
fix error on py 2.7 where OSError doesn't always have winerror attribute
-rw-r--r-- | psutil/_pswindows.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 260651d1..32b9f576 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -656,8 +656,11 @@ ppid_map = cext.ppid_map # used internally by Process.children() def is_permission_err(exc): """Return True if this is a permission error.""" assert isinstance(exc, OSError), exc + # On Python 2 OSError doesn't always have 'winerror'. Sometimes + # it does, in which case the original exception was WindowsError + # (which is a subclass of OSError). return exc.errno in (errno.EPERM, errno.EACCES) or \ - exc.winerror == cext.ERROR_ACCESS_DENIED + getattr(exc, "winerror", -1) == cext.ERROR_ACCESS_DENIED def convert_oserror(exc, pid=None, name=None): |