[Python-checkins] r42023 - python/branches/ssize_t/Objects/object.c

martin.v.loewis python-checkins at python.org
Thu Jan 12 18:12:37 CET 2006


Author: martin.v.loewis
Date: Thu Jan 12 18:12:36 2006
New Revision: 42023

Modified:
   python/branches/ssize_t/Objects/object.c
Log:
Add SAFE_CAST

Modified: python/branches/ssize_t/Objects/object.c
==============================================================================
--- python/branches/ssize_t/Objects/object.c	(original)
+++ python/branches/ssize_t/Objects/object.c	Thu Jan 12 18:12:36 2006
@@ -1432,7 +1432,8 @@
 		res = (*v->ob_type->tp_as_sequence->sq_length)(v);
 	else
 		return 1;
-	return (res > 0) ? 1 : (int)res;
+	/* if it is negative, it should be either -1 or -2 */
+	return (res > 0) ? 1 : Py_SAFE_DOWNCAST(res, Py_ssize_t, int);
 }
 
 /* equivalent of 'not v'


More information about the Python-checkins mailing list