(fun)
return wrapper
Decorator which translates bare OSError and IOError exceptions
    into NoSuchProcess and AccessDenied.
Decorator which translates bare OSError and IOError exceptions
    into NoSuchProcess and AccessDenied.
Decorator which translates bare OSError and IOError exceptions into NoSuchProcess and AccessDenied .
def wrap_exceptions(fun):
    """Decorator which translates bare OSError and IOError exceptions
    into NoSuchProcess and AccessDenied.
    """
    @functools.wraps(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:
                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):
                raise NoSuchProcess(self.pid, self._name)
            if err.errno in (errno.EPERM, errno.EACCES):
                raise AccessDenied(self.pid, self._name)
            raise
    return wrapper
def wrap_exceptions ( fun ) : @ functools . wraps ( 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 : 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 ) : raise NoSuchProcess ( self . pid , self . _name ) if err . errno in ( errno . EPERM , errno . EACCES ) : raise AccessDenied ( self . pid , self . _name ) raise return wrapper