]> granicus.if.org Git - python/commitdiff
Issue 4910, patch 2 of (probably) 3: pave the way for renaming of
authorMark Dickinson <dickinsm@gmail.com>
Thu, 15 Jan 2009 19:32:23 +0000 (19:32 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 15 Jan 2009 19:32:23 +0000 (19:32 +0000)
nb_long:  remove last remaining use of nb_long
(in the struct module) from the core, set nb_long slots on all builtin
and extension types to 0, and remove uses of __long__ in test_complex
and test_binop.

Reviewed by Benjamin Peterson.

Lib/test/test_binop.py
Lib/test/test_cmath.py
Modules/_struct.c
Objects/complexobject.c
Objects/floatobject.c
Objects/longobject.c
Objects/weakrefobject.c
PC/winreg.c

index f60fe3f070905fedb3492020ff91bba8558484b8..0dc18dd93aa6ee63d728189a096fde87ac33565e 100644 (file)
@@ -77,12 +77,6 @@ class Rat(object):
                                       repr(self))
         raise ValueError("can't convert %s to int" % repr(self))
 
-    def __long__(self):
-        """Convert a Rat to an long; self.den must be 1."""
-        if self.__den == 1:
-            return int(self.__num)
-        raise ValueError("can't convert %s to long" % repr(self))
-
     def __add__(self, other):
         """Add two Rats, or a Rat and a number."""
         if isint(other):
index 3c34fecd90492b58d764e65bb7c3db23f4ae3e76..17cb56689fba55baf58457d74b3dc9ba1690a7e4 100755 (executable)
@@ -182,11 +182,9 @@ class CMathTests(unittest.TestCase):
             pass
         class MyInt(object):
             def __int__(self): return 2
-            def __long__(self): return 2
             def __index__(self): return 2
         class MyIntOS:
             def __int__(self): return 2
-            def __long__(self): return 2
             def __index__(self): return 2
 
         # other possible combinations of __float__ and __complex__
@@ -219,7 +217,7 @@ class CMathTests(unittest.TestCase):
             self.assertEqual(f(JustFloatOS()), f(flt_arg))
             # TypeError should be raised for classes not providing
             # either __complex__ or __float__, even if they provide
-            # __int__, __long__ or __index__.  An old-style class
+            # __int__ or __index__.  An old-style class
             # currently raises AttributeError instead of a TypeError;
             # this could be considered a bug.
             self.assertRaises(TypeError, f, NeitherComplexNorFloat())
index a9b1ffac5314bc7593c2086d1e3191df3a803233..a99e7f227eb6620030c645c890dce0d83d3cdc4e 100644 (file)
@@ -127,8 +127,8 @@ get_pylong(PyObject *v)
                return v;
        }
        m = Py_TYPE(v)->tp_as_number;
-       if (m != NULL && m->nb_long != NULL) {
-               v = m->nb_long(v);
+       if (m != NULL && m->nb_int != NULL) {
+               v = m->nb_int(v);
                if (v == NULL)
                        return NULL;
                if (PyLong_Check(v))
index 75283a0236f8245b493e49343c447a1331ca3e87..a7fd7dc558358e6ba7e6a47bf59f24b1881a836a 100644 (file)
@@ -660,14 +660,6 @@ complex_int(PyObject *v)
        return NULL;
 }
 
-static PyObject *
-complex_long(PyObject *v)
-{
-       PyErr_SetString(PyExc_TypeError,
-                  "can't convert complex to long; use long(abs(z))");
-       return NULL;
-}
-
 static PyObject *
 complex_float(PyObject *v)
 {
@@ -1068,7 +1060,7 @@ static PyNumberMethods complex_as_number = {
        0,                                      /* nb_xor */
        0,                                      /* nb_or */
        complex_int,                            /* nb_int */
-       complex_long,                           /* nb_long */
+       0,                                      /* nb_long */
        complex_float,                          /* nb_float */
        0,                                      /* nb_inplace_add */
        0,                                      /* nb_inplace_subtract */
index 20c1eef01468480d41629054b472c56f7af863d6..7292ca568977ee1a244e99c6ef07fd97731d22b3 100644 (file)
@@ -1798,7 +1798,7 @@ static PyNumberMethods float_as_number = {
        0,              /*nb_xor*/
        0,              /*nb_or*/
        float_trunc,    /*nb_int*/
-       float_trunc,    /*nb_long*/
+       0,              /*nb_long*/
        float_float,    /*nb_float*/
        0,              /* nb_inplace_add */
        0,              /* nb_inplace_subtract */
index 9993d103ea24644bc2e5f858d7305e3af27ab28d..259f7c57a04f1f91226638b6702e99fbc9b11c32 100644 (file)
@@ -3830,7 +3830,7 @@ static PyNumberMethods long_as_number = {
                        long_xor,       /*nb_xor*/
                        long_or,        /*nb_or*/
                        long_long,      /*nb_int*/
-                       long_long,      /*nb_long*/
+       0,                              /*nb_long*/
                        long_float,     /*nb_float*/
        0,                              /* nb_inplace_add */
        0,                              /* nb_inplace_subtract */
index faa0f86f99e0f56000861afb73e04f18a7f6c1d8..538b21cbf49b200e56ce122cc316b4bad68e785c 100644 (file)
@@ -489,7 +489,6 @@ WRAP_BINARY(proxy_and, PyNumber_And)
 WRAP_BINARY(proxy_xor, PyNumber_Xor)
 WRAP_BINARY(proxy_or, PyNumber_Or)
 WRAP_UNARY(proxy_int, PyNumber_Int)
-WRAP_UNARY(proxy_long, PyNumber_Long)
 WRAP_UNARY(proxy_float, PyNumber_Float)
 WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd)
 WRAP_BINARY(proxy_isub, PyNumber_InPlaceSubtract)
@@ -595,7 +594,7 @@ static PyNumberMethods proxy_as_number = {
     proxy_xor,              /*nb_xor*/
     proxy_or,               /*nb_or*/
     proxy_int,              /*nb_int*/
-    proxy_long,             /*nb_long*/
+    0,                      /*nb_long*/
     proxy_float,            /*nb_float*/
     proxy_iadd,             /*nb_inplace_add*/
     proxy_isub,             /*nb_inplace_subtract*/
index 7d1d8164e8f4c2c70bfd40108e7c036800c98e79..7316fcd94e55bf6393e53b7e65affb65b99948ec 100644 (file)
@@ -451,7 +451,7 @@ static PyNumberMethods PyHKEY_NumberMethods =
        PyHKEY_binaryFailureFunc,       /* nb_xor */
        PyHKEY_binaryFailureFunc,       /* nb_or */
        PyHKEY_intFunc,                 /* nb_int */
-       PyHKEY_unaryFailureFunc,        /* nb_long */
+       0,                              /* nb_long */
        PyHKEY_unaryFailureFunc,        /* nb_float */
 };