[Python-checkins] CVS: python/dist/src/Objects object.c,2.124.4.2,2.124.4.3

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 27 Apr 2001 14:32:13 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5972

Modified Files:
      Tag: descr-branch
	object.c 
Log Message:
Fix a very old flaw in PyObject_Print().  Amazing!  When an object
type defines tp_str but not tp_repr, 'print x' to a real file
object would not call the tp_str slot but rather print a default style
representation: <foo object at 0x....>.  This even though 'print x' to
a file-like-object would correctly call the tp_str slot.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.124.4.2
retrieving revision 2.124.4.3
diff -C2 -r2.124.4.2 -r2.124.4.3
*** object.c	2001/04/27 18:04:51	2.124.4.2
--- object.c	2001/04/27 21:32:11	2.124.4.3
***************
*** 197,201 ****
  				op->ob_refcnt, op);
  		else if (op->ob_type->tp_print == NULL) {
! 			if (op->ob_type->tp_repr == NULL) {
  				fprintf(fp, "<%s object at %p>",
  					op->ob_type->tp_name, op);
--- 197,204 ----
  				op->ob_refcnt, op);
  		else if (op->ob_type->tp_print == NULL) {
! 			if ((flags & Py_PRINT_RAW)
! 			    ? (op->ob_type->tp_str == NULL)
! 			    : (op->ob_type->tp_repr == NULL))
! 			{
  				fprintf(fp, "<%s object at %p>",
  					op->ob_type->tp_name, op);