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

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 22 Jan 2001 07:59:36 -0800


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

Modified Files:
	object.c 
Log Message:
Once again, numeric-smelling objects compare smaller than non-numeric
ones.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.112
retrieving revision 2.113
diff -C2 -r2.112 -r2.113
*** object.c	2001/01/21 16:25:18	2.112
--- object.c	2001/01/22 15:59:32	2.113
***************
*** 523,526 ****
--- 523,527 ----
  {
  	int c;
+ 	char *vname, *wname;
  
  	if (v->ob_type == w->ob_type) {
***************
*** 551,556 ****
  
  	/* different type: compare type names */
! 	c = strcmp(v->ob_type->tp_name, w->ob_type->tp_name);
! 	return (c < 0) ? -1 : (c > 0) ? 1 : 0;
  }
  
--- 552,571 ----
  
  	/* different type: compare type names */
! 	if (v->ob_type->tp_as_number)
! 		vname = "";
! 	else
! 		vname = v->ob_type->tp_name;
! 	if (w->ob_type->tp_as_number)
! 		wname = "";
! 	else
! 		wname = w->ob_type->tp_name;
! 	c = strcmp(vname, wname);
! 	if (c < 0)
! 		return -1;
! 	if (c > 0)
! 		return 1;
! 	/* Same type name, or (more likely) incomparable numeric types */
! 	return ((Py_uintptr_t)(v->ob_type) < (
! 		Py_uintptr_t)(w->ob_type)) ? -1 : 1;
  }