Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. [translation:ERROR] UnionError:
  2.  
  3. Offending annotations:
  4. SomeInstance(can_be_None=False, classdef=pypy.objspace.std.unicodeobject.W_UnicodeObject)
  5. SomeUnicodeString(no_nul=True)
  6.  
  7. In <FunctionGraph of (pypy.module._io.interp_win32consoleio:33)read_console_w at 0x2a74d110>:
  8. <return block>
  9. Processing block:
  10. block@781[buf_0...] is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
  11. in (pypy.module._io.interp_win32consoleio:33)read_console_w
  12. containing the following operations:
  13. v951 = simple_call((function charp2str), buf_0)
  14. --end--
  15. [translation] start debugger...
  16. > c:\pypy\pypy\rpython\annotator\binaryop.py(93)union()
  17. -> raise UnionError(obj1, obj2)
  18.  
  19.  
  20. def read_console_w(space, handle, maxlen):
  21. err = 0
  22. sig = 0
  23. buf = lltype.malloc(rffi.CWCHARP.TO, maxlen, flavor='raw')
  24. readlen = 0
  25. try:
  26. if not buf:
  27. # Should return some kind of
  28. # null here but this results in a union error.
  29. return space.newutf8("",0)
  30.  
  31. off = 0
  32. while off < maxlen:
  33. with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as n:
  34. n[0] = rffi.cast(rffi.UINT, -1)
  35. len = min(rffi.cast(rffi.INT, maxlen - off),rffi.cast(rffi.INT, BUFSIZ))
  36. rwin32.SetLastError_saved(0)
  37. res = rwin32.ReadConsoleW(handle, buf[off], len, n, rffi.NULL)
  38.  
  39. err = rwin32.GetLastError_saved()
  40.  
  41. if not res:
  42. break
  43.  
  44. if n[0] == -1 and err == rwin32.ERROR_OPERATION_ABORTED:
  45. break
  46.  
  47. if n[0] == 0:
  48. if err != rwin32.ERROR_OPERATION_ABORTED:
  49. break
  50. err = 0
  51. hInterruptEvent = sigintevent()
  52. if rwin32.WaitForSingleObjectEx(hInterruptEvent, 100, False) == rwin32.WAIT_OBJECT_0:
  53. rwin32.ResetEvent(hInterruptEvent)
  54. space.getexecutioncontext().checksignals()
  55.  
  56. readlen += n[0]
  57.  
  58. # We didn't manage to read the whole buffer
  59. # don't try again as it will just block
  60. if n[0] < len:
  61. break
  62.  
  63. # We read a new line
  64. if buf[readlen -1] == u'\n':
  65. break
  66.  
  67. with lltype.scoped_alloc(rwin32.LPWORD.TO, 1) as char_type:
  68. if (off + BUFSIZ) >= maxlen and \
  69. rwin32.GetStringTypeW(rwin32.CT_CTYPE3, buf[readlen[0] - 1], 1, char_type) and \
  70. char_type == rwin32.C3_HIGHSURROGATE:
  71. maxlen += 1
  72. newbuf = lltype.malloc(rffi.CWCHARP.TO, maxlen, flavor='raw')
  73. lltype.free(buf, flavor='raw')
  74. buf = newbuf
  75. off += n[0]
  76. continue
  77. off += BUFSIZ
  78. if err:
  79. lltype.free(buf, flavor='raw')
  80. return space.newutf8("",0)
  81.  
  82. if readlen > 0 and buf == u'\x1a':
  83. lltype.free(buf, flavor='raw')
  84. buf = lltype.malloc(rffi.CWCHARP.TO, 1, flavor='raw')
  85. buf[0] = '\0'
  86. readlen = 0
  87. return rffi.wcharp2unicode(buf)
  88. except:
  89. lltype.free(buf, flavor='raw')
  90. return space.newutf8("",0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement