This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients gregory.p.smith, kristjan.jonsson, meador.inge, pitrou, trent, vstinner
Date 2013-06-13.21:22:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I just found the readline/GIL issue while working on #18203. I created #18205 but then I found this issue. I just closed #18205 as a duplicate. Here is a patch for Python 3.4.


Copy of the initial message (msg191089):

The callback PyOS_ReadlineFunctionPointer (used to read a line from the standard input) must return a buffer allocated by PyMem_Malloc(), but PyOS_Readline() releases the GIL before calling PyOS_ReadlineFunctionPointer.

Simplified extract of PyOS_Readline():

    if (!isatty (fileno (sys_stdin)) || !isatty (fileno (sys_stdout)))
        rv = PyOS_StdioReadline (sys_stdin, sys_stdout, prompt);
        rv = (*PyOS_ReadlineFunctionPointer)(sys_stdin, sys_stdout,

tok_nextc() calls PyOS_Readline() and calls PyMem_FREE() to release its result.

PyOS_ReadlineFunctionPointer should allocate memory using malloc(), not using PyMem_Malloc(). But PyOS_Readline() should copy the line into a buffer allocated by PyMem_Malloc() to keep backward compatibility.

See also issue #18203 and #3329.
Date User Action Args
2013-06-13 21:22:30vstinnersetrecipients: + vstinner, gregory.p.smith, pitrou, kristjan.jonsson, trent, meador.inge
2013-06-13 21:22:30vstinnersetmessageid: <>
2013-06-13 21:22:30vstinnerlinkissue16742 messages
2013-06-13 21:22:30vstinnercreate