Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79cddc5

Browse files
author
Skip Montanaro
committed
stupid, stupid, stupid... raw_input() already supports readline() if the
readline module is loaded.
1 parent b98a8ba commit 79cddc5

3 files changed

Lines changed: 1 addition & 39 deletions

File tree

Doc/lib/libreadline.tex

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ \section{\module{readline} ---
1515
The \module{readline} module defines the following functions:
1616

1717

18-
\begin{funcdesc}{readline}{\optional{prompt}}
19-
Get a single line of input from the user.
20-
\end{funcdesc}
21-
2218
\begin{funcdesc}{parse_and_bind}{string}
2319
Parse and execute single line of a readline init file.
2420
\end{funcdesc}
@@ -160,7 +156,7 @@ \subsection{Example \label{readline-example}}
160156
\end{verbatim}
161157

162158
The following example extends the \class{code.InteractiveConsole} class to
163-
support command line editing and history save/restore.
159+
support history save/restore.
164160

165161
\begin{verbatim}
166162
import code
@@ -183,12 +179,6 @@ \subsection{Example \label{readline-example}}
183179
pass
184180
atexit.register(self.save_history, histfile)
185181
186-
def raw_input(self, prompt=""):
187-
line = readline.readline(prompt)
188-
if line:
189-
readline.add_history(line)
190-
return line
191-
192182
def save_history(self, histfile):
193183
readline.write_history_file(histfile)
194184
\end{verbatim}

Misc/NEWS

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,6 @@ Core and builtins
207207
Extension modules
208208
-----------------
209209

210-
- The readline module now exposes the readline() function to the Python
211-
programmer. readline.readline() should be a drop-in replacement for
212-
raw_input() but coupled with the other readline module functionality allow
213-
programmers to offer history and input recall to their users.
214-
215210
- operator.isMappingType() and operator.isSequenceType() now give
216211
fewer false positives.
217212

Modules/readline.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@
3232
#endif
3333

3434

35-
/* Exported function to get a line from the user */
36-
37-
static PyObject *
38-
py_readline(PyObject *self, PyObject *args)
39-
{
40-
char *s = NULL;
41-
char *line = NULL;
42-
if (!PyArg_ParseTuple(args, "|s:readline", &s))
43-
return NULL;
44-
line = readline(s);
45-
if (line == NULL) {
46-
PyErr_SetString(PyExc_EOFError, "End of file on input");
47-
return NULL;
48-
}
49-
return PyString_FromString(line);
50-
}
51-
52-
PyDoc_STRVAR(doc_py_readline,
53-
"readline([prompt]) -> line\n\
54-
Prompt for and read a line of text. Raise EOFError on EOF.");
55-
56-
5735
/* Exported function to send one line to readline's init file parser */
5836

5937
static PyObject *
@@ -490,7 +468,6 @@ contents of the line buffer.");
490468

491469
static struct PyMethodDef readline_methods[] =
492470
{
493-
{"readline", py_readline, METH_VARARGS, doc_py_readline},
494471
{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
495472
{"get_line_buffer", get_line_buffer, METH_NOARGS, doc_get_line_buffer},
496473
{"insert_text", insert_text, METH_VARARGS, doc_insert_text},

0 commit comments

Comments
 (0)