[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.74,2.75

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 25 Sep 2001 14:16:35 -0700


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

Modified Files:
	typeobject.c 
Log Message:
add_operators(): the __floordiv__ and __truediv__ descriptors (and
their 'i' and 'r' variants) were not being generated if the
corresponding nb_ slots were present in the type object.  I bet this
is because floor and true division were introduced after I last
looked at that part of the code.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.74
retrieving revision 2.75
diff -C2 -d -r2.74 -r2.75
*** typeobject.c	2001/09/25 16:25:58	2.74
--- typeobject.c	2001/09/25 21:16:33	2.75
***************
*** 1838,1841 ****
--- 1838,1843 ----
  BINARY(xor, "x^y");
  BINARY(or, "x|y");
+ BINARY(floordiv, "x//y");
+ BINARY(truediv, "x/y # true division");
  
  static PyObject *
***************
*** 1916,1919 ****
--- 1918,1923 ----
  IBINARY(ixor, "x^=y");
  IBINARY(ior, "x|=y");
+ IBINARY(ifloordiv, "x//=y");
+ IBINARY(itruediv, "x/=y # true division");
  
  #undef ITERNARY
***************
*** 2587,2590 ****
--- 2591,2600 ----
  		ADD(nb->nb_inplace_xor, tab_ixor);
  		ADD(nb->nb_inplace_or, tab_ior);
+ 		if (type->tp_flags & Py_TPFLAGS_CHECKTYPES) {
+ 			ADD(nb->nb_floor_divide, tab_floordiv);
+ 			ADD(nb->nb_true_divide, tab_truediv);
+ 			ADD(nb->nb_inplace_floor_divide, tab_ifloordiv);
+ 			ADD(nb->nb_inplace_true_divide, tab_itruediv);
+ 		}
  	}