[Python-3000-checkins] r58226 - in python/branches/py3k: Demo/classes/Rat.py Demo/classes/bitvec.py Doc/c-api/newtypes.rst Doc/glossary.rst Doc/library/decimal.rst Include/object.h Modules/datetimemodule.c Objects/boolobject.c Objects/complexobject.c Objects/floatobject.c Objects/longobject.c Objects/setobject.c Objects/weakrefobject.c PC/_winreg.c Tools/modulator/Templates/object_tp_as_number

neil.schemenauer python-3000-checkins at python.org
Fri Sep 21 22:19:23 CEST 2007


Author: neil.schemenauer
Date: Fri Sep 21 22:19:23 2007
New Revision: 58226

Modified:
   python/branches/py3k/Demo/classes/Rat.py
   python/branches/py3k/Demo/classes/bitvec.py
   python/branches/py3k/Doc/c-api/newtypes.rst
   python/branches/py3k/Doc/glossary.rst
   python/branches/py3k/Doc/library/decimal.rst
   python/branches/py3k/Include/object.h
   python/branches/py3k/Modules/datetimemodule.c
   python/branches/py3k/Objects/boolobject.c
   python/branches/py3k/Objects/complexobject.c
   python/branches/py3k/Objects/floatobject.c
   python/branches/py3k/Objects/longobject.c
   python/branches/py3k/Objects/setobject.c
   python/branches/py3k/Objects/weakrefobject.c
   python/branches/py3k/PC/_winreg.c
   python/branches/py3k/Tools/modulator/Templates/object_tp_as_number
Log:
Remove more cruft leftover from nb_coerce.  Rename nb_coerce to
nb_reserved.


Modified: python/branches/py3k/Demo/classes/Rat.py
==============================================================================
--- python/branches/py3k/Demo/classes/Rat.py	(original)
+++ python/branches/py3k/Demo/classes/Rat.py	Fri Sep 21 22:19:23 2007
@@ -226,10 +226,6 @@
     def __bool__(a):
         return a.__num != 0
 
-    # coercion
-    def __coerce__(a, b):
-        return a, Rat(b)
-
 def test():
     '''\
     Test function for rat module.

Modified: python/branches/py3k/Demo/classes/bitvec.py
==============================================================================
--- python/branches/py3k/Demo/classes/bitvec.py	(original)
+++ python/branches/py3k/Demo/classes/bitvec.py	Fri Sep 21 22:19:23 2007
@@ -311,13 +311,6 @@
         return BitVec(~self._data & ((1 << self._len) - 1), \
                   self._len)
 
-    def __coerce__(self, otherseq, *rest):
-        #needed for *some* of the arithmetic operations
-        #rprt('%r.__coerce__%r\n' % (self, (otherseq,) + rest))
-        if type(otherseq) != type(self):
-            otherseq = bitvec(otherseq, *rest)
-        return self, otherseq
-
     def __int__(self):
         return int(self._data)
 

Modified: python/branches/py3k/Doc/c-api/newtypes.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/newtypes.rst	(original)
+++ python/branches/py3k/Doc/c-api/newtypes.rst	Fri Sep 21 22:19:23 2007
@@ -330,7 +330,7 @@
 section.  The fields will be described in the order in which they occur in the
 structure.
 
-Typedefs: unaryfunc, binaryfunc, ternaryfunc, inquiry, coercion, intargfunc,
+Typedefs: unaryfunc, binaryfunc, ternaryfunc, inquiry, intargfunc,
 intintargfunc, intobjargproc, intintobjargproc, objobjargproc, destructor,
 freefunc, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc,
 cmpfunc, reprfunc, hashfunc
@@ -751,19 +751,6 @@
       :attr:`sq_inplace_repeat`.
 
 
-   .. data:: Py_TPFLAGS_CHECKTYPES
-
-      If this bit is set, the binary and ternary operations in the
-      :ctype:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept
-      arguments of arbitrary object types, and do their own type conversions if
-      needed.  If this bit is clear, those operations require that all arguments have
-      the current type as their type, and the caller is supposed to perform a coercion
-      operation first.  This applies to :attr:`nb_add`, :attr:`nb_subtract`,
-      :attr:`nb_multiply`, :attr:`nb_divide`, :attr:`nb_remainder`, :attr:`nb_divmod`,
-      :attr:`nb_power`, :attr:`nb_lshift`, :attr:`nb_rshift`, :attr:`nb_and`,
-      :attr:`nb_xor`, and :attr:`nb_or`.
-
-
    .. data:: Py_TPFLAGS_HAVE_RICHCOMPARE
 
       If this bit is set, the type object has the :attr:`tp_richcompare` field, as

Modified: python/branches/py3k/Doc/glossary.rst
==============================================================================
--- python/branches/py3k/Doc/glossary.rst	(original)
+++ python/branches/py3k/Doc/glossary.rst	Fri Sep 21 22:19:23 2007
@@ -32,19 +32,6 @@
       One of the two flavors of classes in earlier Python versions.  Since
       Python 3.0, there are no classic classes anymore.
     
-   coercion
-      The implicit conversion of an instance of one type to another during an
-      operation which involves two arguments of the same type.  For example,
-      ``int(3.15)`` converts the floating point number to the integer ``3``, but
-      in ``3+4.5``, each argument is of a different type (one int, one float),
-      and both must be converted to the same type before they can be added or it
-      will raise a ``TypeError``.  Coercion between two operands can be
-      performed with the ``coerce`` builtin function; thus, ``3+4.5`` is
-      equivalent to calling ``operator.add(*coerce(3, 4.5))`` and results in
-      ``operator.add(3.0, 4.5)``.  Without coercion, all arguments of even
-      compatible types would have to be normalized to the same value by the
-      programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``.
-    
    complex number
       An extension of the familiar real number system in which all numbers are
       expressed as a sum of a real part and an imaginary part.  Imaginary
@@ -168,14 +155,14 @@
    integer division
       Mathematical division discarding any remainder.  For example, the
       expression ``11/4`` currently evaluates to ``2`` in contrast to the
-      ``2.75`` returned by float division.  Also called *floor division*.
-      When dividing two integers the outcome will always be another integer
-      (having the floor function applied to it). However, if one of the operands
-      is another numeric type (such as a :class:`float`), the result will be
-      coerced (see :term:`coercion`) to a common type.  For example, an integer
-      divided by a float will result in a float value, possibly with a decimal
-      fraction.  Integer division can be forced by using the ``//`` operator
-      instead of the ``/`` operator.  See also :term:`__future__`.
+      ``2.75`` returned by float division.  Also called *floor division*.  When
+      dividing two integers the outcome will always be another integer (having
+      the floor function applied to it). However, if the operands types are
+      different, one of them will be converted to the other's type.  For
+      example, an integer divided by a float will result in a float value,
+      possibly with a decimal fraction.  Integer division can be forced by using
+      the ``//`` operator instead of the ``/`` operator.  See also
+      :term:`__future__`.
     
    interactive
       Python has an interactive interpreter which means that you can try out

Modified: python/branches/py3k/Doc/library/decimal.rst
==============================================================================
--- python/branches/py3k/Doc/library/decimal.rst	(original)
+++ python/branches/py3k/Doc/library/decimal.rst	Fri Sep 21 22:19:23 2007
@@ -312,7 +312,7 @@
 numeric types such as :class:`float` and :class:`int`.  All of the usual math
 operations and special methods apply.  Likewise, decimal objects can be copied,
 pickled, printed, used as dictionary keys, used as set elements, compared,
-sorted, and coerced to another type (such as :class:`float` or :class:`long`).
+sorted, and converted to another type (such as :class:`float` or :class:`int`).
 
 In addition to the standard numeric properties, decimal floating point objects
 also have a number of specialized methods:

Modified: python/branches/py3k/Include/object.h
==============================================================================
--- python/branches/py3k/Include/object.h	(original)
+++ python/branches/py3k/Include/object.h	Fri Sep 21 22:19:23 2007
@@ -133,7 +133,6 @@
 typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
 typedef int (*inquiry)(PyObject *);
 typedef Py_ssize_t (*lenfunc)(PyObject *);
-typedef int (*coercion)(PyObject **, PyObject **);
 typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
 typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
 typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
@@ -222,7 +221,7 @@
 	binaryfunc nb_and;
 	binaryfunc nb_xor;
 	binaryfunc nb_or;
-	coercion nb_coerce;
+	int nb_reserved; /* unused, used to be nb_coerce */
 	unaryfunc nb_int;
 	unaryfunc nb_long;
 	unaryfunc nb_float;

Modified: python/branches/py3k/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k/Modules/datetimemodule.c	(original)
+++ python/branches/py3k/Modules/datetimemodule.c	Fri Sep 21 22:19:23 2007
@@ -2082,7 +2082,7 @@
 	0,					/*nb_and*/
 	0,					/*nb_xor*/
 	0,					/*nb_or*/
-	0,					/*nb_coerce*/
+	0,					/*nb_reserved*/
 	0,					/*nb_int*/
 	0,					/*nb_long*/
 	0,					/*nb_float*/

Modified: python/branches/py3k/Objects/boolobject.c
==============================================================================
--- python/branches/py3k/Objects/boolobject.c	(original)
+++ python/branches/py3k/Objects/boolobject.c	Fri Sep 21 22:19:23 2007
@@ -108,7 +108,7 @@
 	bool_and,		/* nb_and */
 	bool_xor,		/* nb_xor */
 	bool_or,		/* nb_or */
-	0,			/* nb_coerce */
+	0,			/* nb_reserved */
 	0,			/* nb_int */
 	0,			/* nb_long */
 	0,			/* nb_float */

Modified: python/branches/py3k/Objects/complexobject.c
==============================================================================
--- python/branches/py3k/Objects/complexobject.c	(original)
+++ python/branches/py3k/Objects/complexobject.c	Fri Sep 21 22:19:23 2007
@@ -963,7 +963,7 @@
 	0,					/* nb_and */
 	0,					/* nb_xor */
 	0,					/* nb_or */
-	(coercion)0,				/* nb_coerce */
+	0,					/* nb_reserved */
 	complex_int,				/* nb_int */
 	complex_long,				/* nb_long */
 	complex_float,				/* nb_float */

Modified: python/branches/py3k/Objects/floatobject.c
==============================================================================
--- python/branches/py3k/Objects/floatobject.c	(original)
+++ python/branches/py3k/Objects/floatobject.c	Fri Sep 21 22:19:23 2007
@@ -235,8 +235,7 @@
 }
 
 /* Macro and helper that convert PyObject obj to a C double and store
-   the value in dbl; this replaces the functionality of the coercion
-   slot function.  If conversion to double raises an exception, obj is
+   the value in dbl.  If conversion to double raises an exception, obj is
    set to NULL, and the function invoking this macro returns NULL.  If
    obj is not of float, int or long type, Py_NotImplemented is incref'ed,
    stored in obj, and returned from the function invoking this macro.
@@ -1069,7 +1068,7 @@
 	0,		/*nb_and*/
 	0,		/*nb_xor*/
 	0,		/*nb_or*/
-	(coercion)0,	/*nb_coerce*/
+	0,		/*nb_reserved*/
 	float_trunc,	/*nb_int*/
 	float_trunc,	/*nb_long*/
 	float_float,	/*nb_float*/

Modified: python/branches/py3k/Objects/longobject.c
==============================================================================
--- python/branches/py3k/Objects/longobject.c	(original)
+++ python/branches/py3k/Objects/longobject.c	Fri Sep 21 22:19:23 2007
@@ -3631,7 +3631,7 @@
 			long_and,	/*nb_and*/
 			long_xor,	/*nb_xor*/
 			long_or,	/*nb_or*/
-			0,		/*nb_coerce*/
+			0,		/*nb_reserved*/
 			long_long,	/*nb_int*/
 			long_long,	/*nb_long*/
 			long_float,	/*nb_float*/

Modified: python/branches/py3k/Objects/setobject.c
==============================================================================
--- python/branches/py3k/Objects/setobject.c	(original)
+++ python/branches/py3k/Objects/setobject.c	Fri Sep 21 22:19:23 2007
@@ -1881,7 +1881,7 @@
 	(binaryfunc)set_and,		/*nb_and*/
 	(binaryfunc)set_xor,		/*nb_xor*/
 	(binaryfunc)set_or,		/*nb_or*/
-	0,				/*nb_coerce*/
+	0,				/*nb_reserved*/
 	0,				/*nb_int*/
 	0,				/*nb_long*/
 	0,				/*nb_float*/

Modified: python/branches/py3k/Objects/weakrefobject.c
==============================================================================
--- python/branches/py3k/Objects/weakrefobject.c	(original)
+++ python/branches/py3k/Objects/weakrefobject.c	Fri Sep 21 22:19:23 2007
@@ -589,7 +589,7 @@
     proxy_and,              /*nb_and*/
     proxy_xor,              /*nb_xor*/
     proxy_or,               /*nb_or*/
-    0,                      /*nb_coerce*/
+    0,                      /*nb_reserved*/
     proxy_int,              /*nb_int*/
     proxy_long,             /*nb_long*/
     proxy_float,            /*nb_float*/

Modified: python/branches/py3k/PC/_winreg.c
==============================================================================
--- python/branches/py3k/PC/_winreg.c	(original)
+++ python/branches/py3k/PC/_winreg.c	Fri Sep 21 22:19:23 2007
@@ -430,7 +430,7 @@
 	PyHKEY_binaryFailureFunc,	/* nb_and */
 	PyHKEY_binaryFailureFunc,	/* nb_xor */
 	PyHKEY_binaryFailureFunc,	/* nb_or */
-	NULL,				/* nb_coerce */
+	0,				/* nb_reserved */
 	PyHKEY_intFunc,			/* nb_int */
 	PyHKEY_unaryFailureFunc,	/* nb_long */
 	PyHKEY_unaryFailureFunc,	/* nb_float */

Modified: python/branches/py3k/Tools/modulator/Templates/object_tp_as_number
==============================================================================
--- python/branches/py3k/Tools/modulator/Templates/object_tp_as_number	(original)
+++ python/branches/py3k/Tools/modulator/Templates/object_tp_as_number	Fri Sep 21 22:19:23 2007
@@ -103,13 +103,6 @@
 	/* XXXX */
 }
 
-static int
-$abbrev$_coerce(PyObject **pv, PyObject **pw)
-{
-	/* XXXX I haven't a clue... */
-	return 1;
-}
-
 static PyObject *
 $abbrev$_int($abbrev$object *v)
 {


More information about the Python-3000-checkins mailing list