diff options
author | Andrew Kuchling <amk@amk.ca> | 2013-05-29 01:48:28 (GMT) |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2013-05-29 01:48:28 (GMT) |
commit | 1e170bae71bce4191fcda87a9aa2b4cbfeed0a56 (patch) | |
tree | a41324663bea2679a6ed53b4ed87ab711dcffbbd /Doc/c-api | |
parent | 6750282007f3444fe7b500ae9cf6172921ffd5f4 (diff) | |
download | cpython-1e170bae71bce4191fcda87a9aa2b4cbfeed0a56.zip cpython-1e170bae71bce4191fcda87a9aa2b4cbfeed0a56.tar.gz cpython-1e170bae71bce4191fcda87a9aa2b4cbfeed0a56.tar.bz2 |
#1554133: Document PyOS_InputHook, PyOS_ReadlineFunctionPointer
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/veryhigh.rst | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 499eb3e..284eee8 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -144,6 +144,29 @@ the same library that the Python runtime is using. (:func:`sys.getfilesystemencoding`). Returns ``0`` at EOF. +.. c:var:: int (*PyOS_InputHook)(void) + + Can be set to point to a function with the prototype + ``int func(void)``. The function will be called when Python's + interpreter prompt is about to become idle and wait for user input + from the terminal. The return value is ignored. Overriding this + hook can be used to integrate the interpreter's prompt with other + event loops, as done in the :file:`Modules/_tkinter.c` in the + Python source code. + + +.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *) + + Can be set to point to a function with the prototype + ``char *func(FILE *stdin, FILE *stdout, char *prompt)``, + overriding the default function used to read a single line of input + at the interpreter's prompt. The function is expected to output + the string *prompt* if it's not *NULL*, and then read a line of + input from the provided standard input file, returning the + resulting string. For example, The :mod:`readline` module sets + this hook to provide line-editing and tab-completion features. + + .. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start) This is a simplified interface to @@ -338,4 +361,3 @@ the same library that the Python runtime is using. This bit can be set in *flags* to cause division operator ``/`` to be interpreted as "true division" according to :pep:`238`. - |