def raise_os_error ( _errno , path = None ) : msg = "%s: '%s'" % ( strerror ( _errno ) , path ) if path else strerror ( _errno ) raise OSError ( _errno , msg )
raise errpr in a function python
Helper for raising the correct exception under Python 3 while still being able to raise the same common exception class in Python 2 . 7 .
def raise_os_error(_errno, path=None):
    """
    Helper for raising the correct exception under Python 3 while still
    being able to raise the same common exception class in Python 2.7.
    """

    msg = "%s: '%s'" % (strerror(_errno), path) if path else strerror(_errno)
    raise OSError(_errno, msg)