[Python-checkins] python/dist/src/Objects longobject.c,1.164,1.165

loewis at users.sourceforge.net loewis at users.sourceforge.net
Mon Sep 20 08:14:58 CEST 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11191/Objects

Modified Files:
	longobject.c 
Log Message:
Patch #1024670: Support int objects in PyLong_AsUnsignedLong[Mask].


Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -d -r1.164 -r1.165
--- longobject.c	30 Aug 2004 02:58:59 -0000	1.164
+++ longobject.c	20 Sep 2004 06:14:54 -0000	1.165
@@ -245,6 +245,15 @@
 	int i;
 
 	if (vv == NULL || !PyLong_Check(vv)) {
+		if (vv != NULL && PyInt_Check(vv)) {
+			long val = PyInt_AsLong(vv);
+			if (val < 0) {
+				PyErr_SetString(PyExc_OverflowError,
+				"can't convert negative value to unsigned long");
+				return (unsigned long) -1;
+			}
+			return val;
+		}
 		PyErr_BadInternalCall();
 		return (unsigned long) -1;
 	}
@@ -279,6 +288,8 @@
 	int i, sign;
 
 	if (vv == NULL || !PyLong_Check(vv)) {
+		if (vv != NULL && PyInt_Check(vv))
+			return PyInt_AsUnsignedLongMask(vv);
 		PyErr_BadInternalCall();
 		return (unsigned long) -1;
 	}



More information about the Python-checkins mailing list