示例#1
0
def strerror(space, errno):
    """Translate an error code to a message string."""
    try:
        return space.wrap(_strerror(errno))
    except ValueError:
        raise OperationError(space.w_ValueError,
                             space.wrap("strerror() argument out of range"))
示例#2
0
def strerror(space, errno):
    """Translate an error code to a message string."""
    try:
        return space.wrap(_strerror(errno))
    except ValueError:
        raise OperationError(space.w_ValueError,
                             space.wrap("strerror() argument out of range"))
示例#3
0
def PyErr_SetFromErrnoWithFilenameObject(space, w_type, w_value):
    """Similar to PyErr_SetFromErrno(), with the additional behavior that if
    w_value is not NULL, it is passed to the constructor of type as a
    third parameter.  In the case of exceptions such as IOError and OSError,
    this is used to define the filename attribute of the exception instance.
    Return value: always NULL."""
    # XXX Doesn't actually do anything with PyErr_CheckSignals.
    errno = rffi.cast(lltype.Signed, rposix._get_errno())
    msg, lgt = _strerror(errno)
    if w_value:
        w_error = space.call_function(w_type, space.newint(errno),
                                      space.newtext(msg, lgt), w_value)
    else:
        w_error = space.call_function(w_type, space.newint(errno),
                                      space.newtext(msg, lgt))
    raise OperationError(w_type, w_error)
示例#4
0
文件: pyerrors.py 项目: Qointum/pypy
def PyErr_SetFromErrnoWithFilenameObject(space, w_type, w_value):
    """Similar to PyErr_SetFromErrno(), with the additional behavior that if
    w_value is not NULL, it is passed to the constructor of type as a
    third parameter.  In the case of exceptions such as IOError and OSError,
    this is used to define the filename attribute of the exception instance.
    Return value: always NULL."""
    # XXX Doesn't actually do anything with PyErr_CheckSignals.
    errno = rffi.cast(lltype.Signed, rposix._get_errno())
    msg = _strerror(errno)
    if w_value:
        w_error = space.call_function(w_type,
                                      space.wrap(errno),
                                      space.wrap(msg),
                                      w_value)
    else:
        w_error = space.call_function(w_type,
                                      space.wrap(errno),
                                      space.wrap(msg))
    raise OperationError(w_type, w_error)
示例#5
0
def _get_error_msg():
    errno = rposix.get_saved_errno()
    return _strerror(errno)
def _get_error_msg():
    errno = rposix.get_saved_errno()
    return _strerror(errno)
示例#7
0
def _errmsg(what):
    from rpython.rlib import rposix
    errmsg = _strerror(rposix.get_errno())
    return u"%s failed" % what if errmsg is None else errmsg
示例#8
0
文件: locale.py 项目: Qointum/pypy
def _errmsg(what):
    from rpython.rlib import rposix
    errmsg = _strerror(rposix.get_errno())
    return u"%s failed" % what if errmsg is None else errmsg