[Patches] Cannot upload a patch, will someone do it for me?

Moshe Zadka moshez@zadka.site.co.il
Wed, 10 Jan 2001 18:20:11 +0200 (IST)


The comment should be:
Patch to implement PEP 217.
No documentation yet.

Please assign it to Guido.

Thanks in advance.
(If you want to know what the problem is, I think it's that lynx
doesn't support multipart/form-data, and I haven't any other browser.
I'll install X over the weekend to solve that...:( )

Index: Python/ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.215
diff -c -r2.215 ceval.c
*** Python/ceval.c	2001/01/04 22:33:01	2.215
--- Python/ceval.c	2001/01/10 08:03:53
***************
*** 1245,1280 ****
  
  		case PRINT_EXPR:
  			v = POP();
! 			/* Print value except if None */
! 			/* After printing, also assign to '_' */
! 			/* Before, set '_' to None to avoid recursion */
! 			if (v != Py_None &&
! 			    (err = PyDict_SetItemString(
! 				    f->f_builtins, "_", Py_None)) == 0) {
! 				err = Py_FlushLine();
! 				if (err == 0) {
! 					x = PySys_GetObject("stdout");
! 					if (x == NULL) {
! 						PyErr_SetString(
! 							PyExc_RuntimeError,
! 							"lost sys.stdout");
! 						err = -1;
! 					}
! 				}
! 				if (err == 0)
! 					err = PyFile_WriteObject(v, x, 0);
! 				if (err == 0) {
! 					PyFile_SoftSpace(x, 1);
! 					err = Py_FlushLine();
! 				}
! 				if (err == 0) {
! 					err = PyDict_SetItemString(
! 						f->f_builtins, "_", v);
! 				}
  			}
  			Py_DECREF(v);
  			break;
! 		
  		case PRINT_ITEM_TO:
  			w = stream = POP();
  			/* fall through to PRINT_ITEM */
--- 1245,1270 ----
  
  		case PRINT_EXPR:
  			v = POP();
! 			w = PySys_GetObject("displayhook");
! 			if (w == NULL) {
! 				PyErr_SetString(PyExc_RuntimeError,
! 						"lost sys.displayhook");
! 				err = -1;
  			}
+ 			if (err == 0) {
+ 				x = Py_BuildValue("(O)", v);
+ 				if (x == NULL)
+ 					err = -1;
+ 			}
+ 			if (err == 0) {
+ 				w = PyEval_CallObject(w, x);
+ 				if (w == NULL)
+ 					err = -1;
+ 			}
  			Py_DECREF(v);
+ 			Py_XDECREF(x);
  			break;
! 
  		case PRINT_ITEM_TO:
  			w = stream = POP();
  			/* fall through to PRINT_ITEM */
Index: Python/sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.80
diff -c -r2.80 sysmodule.c
*** Python/sysmodule.c	2000/12/15 22:02:05	2.80
--- Python/sysmodule.c	2001/01/10 08:05:44
***************
*** 68,73 ****
--- 68,117 ----
  }
  
  static PyObject *
+ sys_displayhook(PyObject *self, PyObject *args)
+ {
+ 	PyObject *o, *stdout;
+ 	PyInterpreterState *interp = PyThreadState_Get()->interp;
+ 	PyObject *modules = interp->modules;
+ 	PyObject *builtins = PyDict_GetItemString(modules, "__builtin__");
+ 
+ 	/* parse arguments */
+ 	if (!PyArg_ParseTuple(args, "O:displayhook", &o))
+ 		return NULL;
+ 
+ 	/* Print value except if None */
+ 	/* After printing, also assign to '_' */
+ 	/* Before, set '_' to None to avoid recursion */
+ 	if (o == Py_None) {
+ 		Py_INCREF(Py_None);
+ 		return Py_None;
+ 	}
+ 	if (PyObject_SetAttrString(builtins, "_", Py_None) != 0)
+ 		return NULL;
+ 	if (Py_FlushLine() != 0)
+ 		return NULL;
+ 	stdout = PySys_GetObject("stdout");
+ 	if (stdout == NULL) {
+ 		PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
+ 		return NULL;
+ 	}
+ 	if (PyFile_WriteObject(o, stdout, 0) != 0)
+ 		return NULL;
+ 	PyFile_SoftSpace(stdout, 1);
+ 	if (Py_FlushLine() != 0)
+ 		return NULL;
+ 	if (PyObject_SetAttrString(builtins, "_", o) != 0)
+ 		return NULL;
+ 	Py_INCREF(Py_None);
+ 	return Py_None;
+ }
+ 
+ static char displayhook_doc[] =
+ "displayhook(o) -> None\n"
+ "\n"
+ "Print o to the stdout, and save it in __builtin__._\n";
+ 
+ static PyObject *
  sys_exc_info(PyObject *self, PyObject *args)
  {
  	PyThreadState *tstate;
***************
*** 332,337 ****
--- 376,382 ----
  
  static PyMethodDef sys_methods[] = {
  	/* Might as well keep this in alphabetic order */
+ 	{"disp