docs: def hook_wrapper_23(stdin, stdout, prompt):
      u'''Wrap a Python readline so it behaves like GNU readline.'''
      try:
          # call the Python hook
          res = ensure_str(readline_hook(prompt))
          # make sure it returned the right sort of thing
          if res and not isinstance(res, str):
              raise TypeError, u'readline must return a string.'
      except KeyboardInterrupt:
          # GNU readline returns 0 on keyboard interrupt
          return 0
      except EOFError:
          # It returns an empty string on EOF
          res = u''
      except:
          print >>sys.stderr, u'Readline internal error'
          traceback.print_exc()
          res = u'\n'
      # we have to make a copy because the caller expects to free the result
      n = len(res)
      p = Console.PyMem_Malloc(n + 1)
      _strncpy(cast(p, c_char_p), res, n + 1)
      return p