[Python-checkins] python/dist/src/Objects typeobject.c,2.181,2.182

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
2002年10月14日 17:57:31 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv9333
Modified Files:
	typeobject.c 
Log Message:
For some reason (probably cut and paste), __ipow__ for new-style
classes was called with three arguments. This makes no sense, there's
no way to pass in the "modulo" 3rd argument as for __pow__, and
classic classes don't do this. [SF bug 620179]
I don't want to backport this to 2.2.2, because it could break
existing code that has developed a work-around. Code in 2.2.2 that
wants to use __ipow__ and wants to be forward compatible with 2.3
should be written like this:
 def __ipow__(self, exponent, modulo=None):
 ...
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.181
retrieving revision 2.182
diff -C2 -d -r2.181 -r2.182
*** typeobject.c	14 Oct 2002 21:11:34 -0000	2.181
--- typeobject.c	15 Oct 2002 00:57:28 -0000	2.182
***************
*** 3400,3404 ****
 SLOT1(slot_nb_inplace_divide, "__idiv__", PyObject *, "O")
 SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O")
! SLOT2(slot_nb_inplace_power, "__ipow__", PyObject *, PyObject *, "OO")
 SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *, "O")
 SLOT1(slot_nb_inplace_rshift, "__irshift__", PyObject *, "O")
--- 3400,3404 ----
 SLOT1(slot_nb_inplace_divide, "__idiv__", PyObject *, "O")
 SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O")
! SLOT1(slot_nb_inplace_power, "__ipow__", PyObject *, "O")
 SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *, "O")
 SLOT1(slot_nb_inplace_rshift, "__irshift__", PyObject *, "O")
***************
*** 4039,4043 ****
 	 wrap_binaryfunc, "%"),
 	IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power,
! 	 wrap_ternaryfunc, "**"),
 	IBSLOT("__ilshift__", nb_inplace_lshift, slot_nb_inplace_lshift,
 	 wrap_binaryfunc, "<<"),
--- 4039,4043 ----
 	 wrap_binaryfunc, "%"),
 	IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power,
! 	 wrap_binaryfunc, "**"),
 	IBSLOT("__ilshift__", nb_inplace_lshift, slot_nb_inplace_lshift,
 	 wrap_binaryfunc, "<<"),

AltStyle によって変換されたページ (->オリジナル) /