parameters: (stdin, stdout, prompt)
return_statement: return p
docstring: Wrap a Python readline so it behaves like GNU readline.
docstring_summary: Wrap a Python readline so it behaves like GNU readline.
docstring_tokens: Wrap a Python readline so it behaves like GNU readline .
function: def hook_wrapper_23(stdin, stdout, prompt):
      '''Wrap a Python readline so it behaves like GNU readline.'''
      try:
          # call the Python hook
          res = readline_hook(prompt)
          # make sure it returned the right sort of thing
          if res and not isinstance(res, str):
              raise TypeError, '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 = ''
      except:
          print >>sys.stderr, 'Readline internal error'
          traceback.print_exc()
          res = '\n'
      # we have to make a copy because the caller expects to free the result
      n = len(res)
      p = Console.PyMem_Malloc(n+1)
      cdll.msvcrt.strncpy(p, res, n+1)
      return p
function_tokens: def hook_wrapper_23 ( stdin , stdout , prompt ) : try : # call the Python hook res = readline_hook ( prompt ) # make sure it returned the right sort of thing if res and not isinstance ( res , str ) : raise TypeError , '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 = '' except : print >> sys . stderr , 'Readline internal error' traceback . print_exc ( ) res = '\n' # we have to make a copy because the caller expects to free the result n = len ( res ) p = Console . PyMem_Malloc ( n + 1 ) cdll . msvcrt . strncpy ( p , res , n + 1 ) return p