Message80052
the assumption is made that the result will fit into a PyInt.
obviously, on a 32-bit system, where SIZEOF_LONG is 4 bytes,
that ain't happening.
a complex test would be something like this:
if len <= 9: it's an int, definitely.
if len > 10: it's a long, definitely.
if len == 10, and first char is a "-", it's an int, definitely
if len == 10, and first char is 5,6,7,8,9, it's a long, definitely.
if len == 10, and first char is 0,1,2,3, it's an int, definitely.
if len == 10, and first char is 4, it _might_ be a long, but it might
also be an int, so... uh... let's assume it's a long!
and you know what? xxxx that for a game of soldiers: just use
"if len >= 10" assume it's a long :)
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 537276c..e56f8e5 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -3143,7 +3143,15 @@ load_int(Unpicklerobject *self)
errno = 0;
l = strtol(s, &endptr, 0);
- if (errno || (*endptr != '\n') || (endptr[1] != '\0')) {
+ if (errno || (*endptr != '\n') || (endptr[1] != '\0')
+#if SIZEOF_LONG == 4
+ /* integers of 10 chars or over could be bigger than 32-bit.
+ * just keep it simple: 10 or more chars, it goes into
+ * a PyLong.
+ */
+ || (len >= 10)
+#endif
+ ) {
/* Hm, maybe we've got something long. Let's try reading
it as a Python long object. */
errno = 0; |
|
Date |
User |
Action |
Args |
2009-01-17 22:01:00 | lkcl | set | recipients:
+ lkcl |
2009-01-17 22:01:00 | lkcl | set | messageid: <1232229660.32.0.518084727508.issue4977@psf.upfronthosting.co.za> |
2009-01-17 22:00:59 | lkcl | link | issue4977 messages |
2009-01-17 22:00:56 | lkcl | create | |
|