(fun)
return wrapper
Call callable into a try/except clause and translate ENOENT,
    EACCES and EPERM in NoSuchProcess or AccessDenied exceptions.
Call callable into a try/except clause and translate ENOENT,
    EACCES and EPERM in NoSuchProcess or AccessDenied exceptions.
Call callable into a try / except clause and translate ENOENT EACCES and EPERM in NoSuchProcess or AccessDenied exceptions .
def wrap_exceptions(fun):
    """Call callable into a try/except clause and translate ENOENT,
    EACCES and EPERM in NoSuchProcess or AccessDenied exceptions.
    """
    def wrapper(self, *args, **kwargs):
        try:
            return fun(self, *args, **kwargs)
        except EnvironmentError as err:
            # support for private module import
            if (NoSuchProcess is None or AccessDenied is None or
                    ZombieProcess is None):
                raise
            # ENOENT (no such file or directory) gets raised on open().
            # ESRCH (no such process) can get raised on read() if
            # process is gone in meantime.
            if err.errno in (errno.ENOENT, errno.ESRCH):
                if not pid_exists(self.pid):
                    raise NoSuchProcess(self.pid, self._name)
                else:
                    raise ZombieProcess(self.pid, self._name, self._ppid)
            if err.errno in (errno.EPERM, errno.EACCES):
                raise AccessDenied(self.pid, self._name)
            raise
    return wrapper
def wrap_exceptions ( fun ) : def wrapper ( self , * args , * * kwargs ) : try : return fun ( self , * args , * * kwargs ) except EnvironmentError as err : # support for private module import if ( NoSuchProcess is None or AccessDenied is None or ZombieProcess is None ) : raise # ENOENT (no such file or directory) gets raised on open(). # ESRCH (no such process) can get raised on read() if # process is gone in meantime. if err . errno in ( errno . ENOENT , errno . ESRCH ) : if not pid_exists ( self . pid ) : raise NoSuchProcess ( self . pid , self . _name ) else : raise ZombieProcess ( self . pid , self . _name , self . _ppid ) if err . errno in ( errno . EPERM , errno . EACCES ) : raise AccessDenied ( self . pid , self . _name ) raise return wrapper