Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [translation:ERROR] UnionError:
- Offending annotations:
- SomeInstance(can_be_None=False, classdef=pypy.objspace.std.unicodeobject.W_UnicodeObject)
- SomeUnicodeString(no_nul=True)
- In <FunctionGraph of (pypy.module._io.interp_win32consoleio:33)read_console_w at 0x2a74d110>:
- <return block>
- Processing block:
- block@781[buf_0...] is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
- in (pypy.module._io.interp_win32consoleio:33)read_console_w
- containing the following operations:
- v951 = simple_call((function charp2str), buf_0)
- --end--
- [translation] start debugger...
- > c:\pypy\pypy\rpython\annotator\binaryop.py(93)union()
- -> raise UnionError(obj1, obj2)
- def read_console_w(space, handle, maxlen):
- err = 0
- sig = 0
- buf = lltype.malloc(rffi.CWCHARP.TO, maxlen, flavor='raw')
- readlen = 0
- try:
- if not buf:
- # Should return some kind of
- # null here but this results in a union error.
- return space.newutf8("",0)
- off = 0
- while off < maxlen:
- with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as n:
- n[0] = rffi.cast(rffi.UINT, -1)
- len = min(rffi.cast(rffi.INT, maxlen - off),rffi.cast(rffi.INT, BUFSIZ))
- rwin32.SetLastError_saved(0)
- res = rwin32.ReadConsoleW(handle, buf[off], len, n, rffi.NULL)
- err = rwin32.GetLastError_saved()
- if not res:
- break
- if n[0] == -1 and err == rwin32.ERROR_OPERATION_ABORTED:
- break
- if n[0] == 0:
- if err != rwin32.ERROR_OPERATION_ABORTED:
- break
- err = 0
- hInterruptEvent = sigintevent()
- if rwin32.WaitForSingleObjectEx(hInterruptEvent, 100, False) == rwin32.WAIT_OBJECT_0:
- rwin32.ResetEvent(hInterruptEvent)
- space.getexecutioncontext().checksignals()
- readlen += n[0]
- # We didn't manage to read the whole buffer
- # don't try again as it will just block
- if n[0] < len:
- break
- # We read a new line
- if buf[readlen -1] == u'\n':
- break
- with lltype.scoped_alloc(rwin32.LPWORD.TO, 1) as char_type:
- if (off + BUFSIZ) >= maxlen and \
- rwin32.GetStringTypeW(rwin32.CT_CTYPE3, buf[readlen[0] - 1], 1, char_type) and \
- char_type == rwin32.C3_HIGHSURROGATE:
- maxlen += 1
- newbuf = lltype.malloc(rffi.CWCHARP.TO, maxlen, flavor='raw')
- lltype.free(buf, flavor='raw')
- buf = newbuf
- off += n[0]
- continue
- off += BUFSIZ
- if err:
- lltype.free(buf, flavor='raw')
- return space.newutf8("",0)
- if readlen > 0 and buf == u'\x1a':
- lltype.free(buf, flavor='raw')
- buf = lltype.malloc(rffi.CWCHARP.TO, 1, flavor='raw')
- buf[0] = '\0'
- readlen = 0
- return rffi.wcharp2unicode(buf)
- except:
- lltype.free(buf, flavor='raw')
- return space.newutf8("",0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement