Skip to content

Commit

Permalink
address _psosx.py
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 21, 2024
1 parent e91c404 commit bbd2c5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,8 @@ def _send_signal(self, sig):
else:
self._gone = True
raise NoSuchProcess(self.pid, self._name) from e
except PermissionError:
raise AccessDenied(self.pid, self._name)
except PermissionError as e:
raise AccessDenied(self.pid, self._name) from e

def send_signal(self, sig):
"""Send a signal *sig* to process pre-emptively checking
Expand Down
4 changes: 2 additions & 2 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def decode_address(addr, family):
socket.AF_INET6,
struct.pack('<4I', *struct.unpack('<4I', ip)),
)
except ValueError as err:
except ValueError:
# see: https://github.com/giampaolo/psutil/issues/623
if not supports_ipv6():
raise _Ipv6UnsupportedError from None
Expand All @@ -892,7 +892,7 @@ def process_inet(file, family, type_, inodes, filter_pid=None):
f"error while parsing {file}; malformed line"
f" {lineno} {line!r}"
)
raise RuntimeError(msg)
raise RuntimeError(msg) from None
if inode in inodes:
# # We assume inet sockets are unique, so we error
# # out if there are multiple references to the
Expand Down
10 changes: 5 additions & 5 deletions psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,13 @@ def wrap_exceptions(fun):
def wrapper(self, *args, **kwargs):
try:
return fun(self, *args, **kwargs)
except ProcessLookupError:
except ProcessLookupError as e:
if is_zombie(self.pid):
raise ZombieProcess(self.pid, self._name, self._ppid)
raise ZombieProcess(self.pid, self._name, self._ppid) from e
else:
raise NoSuchProcess(self.pid, self._name)
except PermissionError:
raise AccessDenied(self.pid, self._name)
raise NoSuchProcess(self.pid, self._name) from e
except PermissionError as e:
raise AccessDenied(self.pid, self._name) from e

return wrapper

Expand Down

0 comments on commit bbd2c5b

Please sign in to comment.