コード例 #1
0
def getWindowsError(space):
    errno = geterrno()
    message = rwin32.FormatErrorW(errno)
    w_errcode = space.newint(errno)
    return OperationError(space.w_WindowsError,
                         space.newtuple([w_errcode, space.newtext(*message),
                        space.w_None, w_errcode]))
コード例 #2
0
def raiseWindowsError(space, errcode, context):
    message = rwin32.FormatErrorW(errcode)
    w_errcode = space.newint(errcode)
    w_t = space.newtuple(
        [w_errcode,
         space.newtext(*message), space.w_None, w_errcode])
    raise OperationError(space.w_WindowsError, w_t)
コード例 #3
0
 def dlopenex(name):
     res = rwin32.LoadLibraryExA(name)
     if not res:
         err = rwin32.GetLastError_saved()
         ustr, lgt = rwin32.FormatErrorW(err)
         raise DLOpenError(ustr)
     return res
コード例 #4
0
 def dlopenU(name, mode=-1):
     # mode is unused on windows, but a consistant signature
     res = rwin32.LoadLibraryW(name)
     if not res:
         err = rwin32.GetLastError_saved()
         ustr, lgt = rwin32.FormatErrorW(err)
         raise DLOpenError(ustr)
     return res
コード例 #5
0
 def dlopenex(name):
     res = rwin32.LoadLibraryExA(name)
     if not res:
         err = rwin32.GetLastError_saved()
         ustr = rwin32.FormatErrorW(err)
         # DLOpenError unicode msg breaks translation of cpyext create_extension_module
         raise DLOpenError(ustr.encode('utf-8'))
     return res
コード例 #6
0
 def dlopenU(name, mode=-1):
     # mode is unused on windows, but a consistant signature
     res = rwin32.LoadLibraryW(name)
     if not res:
         err = rwin32.GetLastError_saved()
         ustr = rwin32.FormatErrorW(err)
         # DLOpenError unicode msg breaks translation of cpyext create_extension_module
         raise DLOpenError(ustr.encode('utf-8'))
     return res
コード例 #7
0
 def dlopenex(name, flags=rwin32.LOAD_WITH_ALTERED_SEARCH_PATH):
     # Don't display a message box when Python can't load a DLL */
     old_mode = rwin32.SetErrorMode(rwin32.SEM_FAILCRITICALERRORS)
     res = rwin32.LoadLibraryExA(name, flags)
     rwin32.SetErrorMode(old_mode)
     if not res:
         err = rwin32.GetLastError_saved()
         ustr, lgt = rwin32.FormatErrorW(err)
         raise DLOpenError(ustr)
     return res
コード例 #8
0
def _wrap_oserror2_impl(space, e, w_filename, w_filename2, w_exc, eintr_retry):
    # move the common logic in its own function, instead of having it
    # duplicated 4 times in all 4 specialized versions of wrap_oserror2()

    if rwin32.WIN32 and isinstance(e, WindowsError):
        winerror = e.winerror
        try:
            msg, lgt = rwin32.FormatErrorW(winerror)
        except ValueError:
            msg = 'Windows Error %d' % winerror
            lgt = len(msg)
        w_errno = space.w_None
        w_winerror = space.newint(winerror)
        w_msg = space.newtext(msg, lgt)
        w_exc = space.w_WindowsError
    else:
        errno = e.errno
        if errno == EINTR:
            space.getexecutioncontext().checksignals()
            if eintr_retry:
                return None

        try:
            msg, lgt = strerror(errno)
        except ValueError:
            msg = 'error %d' % errno
            lgt = len(msg)
        w_errno = space.newint(errno)
        w_winerror = space.w_None
        w_msg = space.newtext(msg, lgt)

    if w_filename is None:
        w_filename = space.w_None
    if w_filename2 is None:
        w_filename2 = space.w_None
    w_error = space.call_function(w_exc, w_errno, w_msg, w_filename,
                                  w_winerror, w_filename2)
    operror = OperationError(w_exc, w_error)
    if eintr_retry:
        raise operror
    return operror
コード例 #9
0
def test_formaterror_unicode():
    msg = rwin32.FormatErrorW(34)
    assert type(msg) is unicode
    assert u'%2' in msg
コード例 #10
0
ファイル: test_rwin32.py プロジェクト: soIu/rpython
def test_formaterror_unicode():
    msg, lgt = rwin32.FormatErrorW(34)
    assert type(msg) is str
    assert '%2' in msg
コード例 #11
0
 def FormatError(space, code):
     return space.newtext(*rwin32.FormatErrorW(code))
コード例 #12
0
 def FormatError(space, code):
     return space.newunicode(rwin32.FormatErrorW(code))