[Python-checkins] r68619 - in python/branches/py3k: 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

mark.dickinson python-checkins at python.org
Thu Jan 15 20:32:24 CET 2009


Author: mark.dickinson
Date: Thu Jan 15 20:32:23 2009
New Revision: 68619
Log:
Issue 4910, patch 2 of (probably) 3: pave the way for renaming of
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.
Modified:
 python/branches/py3k/Lib/test/test_binop.py
 python/branches/py3k/Lib/test/test_cmath.py
 python/branches/py3k/Modules/_struct.c
 python/branches/py3k/Objects/complexobject.c
 python/branches/py3k/Objects/floatobject.c
 python/branches/py3k/Objects/longobject.c
 python/branches/py3k/Objects/weakrefobject.c
 python/branches/py3k/PC/winreg.c
Modified: python/branches/py3k/Lib/test/test_binop.py
==============================================================================
--- python/branches/py3k/Lib/test/test_binop.py	(original)
+++ python/branches/py3k/Lib/test/test_binop.py	Thu Jan 15 20:32:23 2009
@@ -77,12 +77,6 @@
 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):
Modified: python/branches/py3k/Lib/test/test_cmath.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cmath.py	(original)
+++ python/branches/py3k/Lib/test/test_cmath.py	Thu Jan 15 20:32:23 2009
@@ -182,11 +182,9 @@
 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 @@
 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())
Modified: python/branches/py3k/Modules/_struct.c
==============================================================================
--- python/branches/py3k/Modules/_struct.c	(original)
+++ python/branches/py3k/Modules/_struct.c	Thu Jan 15 20:32:23 2009
@@ -127,8 +127,8 @@
 		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))
Modified: python/branches/py3k/Objects/complexobject.c
==============================================================================
--- python/branches/py3k/Objects/complexobject.c	(original)
+++ python/branches/py3k/Objects/complexobject.c	Thu Jan 15 20:32:23 2009
@@ -661,14 +661,6 @@
 }
 
 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)
 {
 	PyErr_SetString(PyExc_TypeError,
@@ -1068,7 +1060,7 @@
 	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 */
Modified: python/branches/py3k/Objects/floatobject.c
==============================================================================
--- python/branches/py3k/Objects/floatobject.c	(original)
+++ python/branches/py3k/Objects/floatobject.c	Thu Jan 15 20:32:23 2009
@@ -1798,7 +1798,7 @@
 	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 */
Modified: python/branches/py3k/Objects/longobject.c
==============================================================================
--- python/branches/py3k/Objects/longobject.c	(original)
+++ python/branches/py3k/Objects/longobject.c	Thu Jan 15 20:32:23 2009
@@ -3830,7 +3830,7 @@
 			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 */
Modified: python/branches/py3k/Objects/weakrefobject.c
==============================================================================
--- python/branches/py3k/Objects/weakrefobject.c	(original)
+++ python/branches/py3k/Objects/weakrefobject.c	Thu Jan 15 20:32:23 2009
@@ -489,7 +489,6 @@
 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 @@
 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*/
Modified: python/branches/py3k/PC/winreg.c
==============================================================================
--- python/branches/py3k/PC/winreg.c	(original)
+++ python/branches/py3k/PC/winreg.c	Thu Jan 15 20:32:23 2009
@@ -451,7 +451,7 @@
 	PyHKEY_binaryFailureFunc,	/* nb_xor */
 	PyHKEY_binaryFailureFunc,	/* nb_or */
 	PyHKEY_intFunc,			/* nb_int */
-	PyHKEY_unaryFailureFunc,	/* nb_long */
+	0,				/* nb_long */
 	PyHKEY_unaryFailureFunc,	/* nb_float */
 };
 


More information about the Python-checkins mailing list

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