[Python-checkins] python/dist/src/Modules readline.c,2.68,2.69

montanaro at users.sourceforge.net montanaro at users.sourceforge.net
Sun May 23 13:46:53 EDT 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6098/Modules

Modified Files:
	readline.c 
Log Message:
Exposed readline() function from the readline module.


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.68
retrieving revision 2.69
diff -C2 -d -r2.68 -r2.69
*** readline.c	25 Mar 2004 02:16:22 -0000	2.68
--- readline.c	23 May 2004 17:46:49 -0000	2.69
***************
*** 33,36 ****
--- 33,58 ----
  
  
+ /* Exported function to get a line from the user */
+ 
+ static PyObject *
+ py_readline(PyObject *self, PyObject *args)
+ {
+ 	char *s = NULL;
+ 	char *line = NULL;
+ 	if (!PyArg_ParseTuple(args, "|s:readline", &s))
+ 		return NULL;
+ 	line = readline(s);
+ 	if (line == NULL) {
+ 		PyErr_SetString(PyExc_EOFError, "End of file on input");
+ 		return NULL;
+ 	}
+ 	return PyString_FromString(line);
+ }
+ 
+ PyDoc_STRVAR(doc_py_readline,
+ "readline([prompt]) -> line\n\
+ Prompt for and read a line of text.  Raise EOFError on EOF.");
+ 
+ 
  /* Exported function to send one line to readline's init file parser */
  
***************
*** 469,472 ****
--- 491,495 ----
  static struct PyMethodDef readline_methods[] =
  {
+ 	{"readline", py_readline, METH_VARARGS, doc_py_readline},
  	{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
  	{"get_line_buffer", get_line_buffer, METH_NOARGS, doc_get_line_buffer},




More information about the Python-checkins mailing list