code: def _readline_windows():
      
  
      try:
          fileno = sys.stdin.fileno()
      except (EnvironmentError, AttributeError):
          fileno = -1
  
      # In case stdin is replaced, read from that
      if fileno != 0:
          return _readline_windows_fallback()
  
      h = winapi.GetStdHandle(winapi.STD_INPUT_HANDLE)
      if h == winapi.INVALID_HANDLE_VALUE:
          return _readline_windows_fallback()
  
      buf_size = 1024
      buf = ctypes.create_string_buffer(buf_size * ctypes.sizeof(winapi.WCHAR))
      read = winapi.DWORD()
  
      text = u""
      while True:
          if winapi.ReadConsoleW(
                  h, buf, buf_size, ctypes.byref(read), None) == 0:
              if not text:
                  return _readline_windows_fallback()
              raise ctypes.WinError()
          data = buf[:read.value * ctypes.sizeof(winapi.WCHAR)]
          text += data.decode("utf-16-le", _surrogatepass)
          if text.endswith(u"\r\n"):
              return text[:-2]
docs: Raises OSError