New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_maxint64 fails on 32-bit systems due to assumption that 64-bit fits into "long" #49227
Comments
the assumption is made that the result will fit into a PyInt. 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 diff --git a/Modules/cPickle.c b/Modules/cPickle.c - 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; |
From the included patch, I assume you're talking about a failure of I'm not seeing any such failure on my (32-bit) system, and the code in |
You might try replacing the strtol call with a call to PyOS_strtol. |
Closing as invalid. |
Reopening at OP's request. |
Two comments:
|
Luke, I closed this as invalid because it's not a Python bug: your system's |
Antoine, I leave it to you to decide what to do with this. As far as I can see, the only action that one might want to take I recommend against this though, for a few reasons:
It's true that Python has code to work around problems with standards BTW, Luke, note that you can still add comments to an issue even after |
hiya folks, lots of comments here. in no particular order:
on balance, i'd very much appreciate this being kept open so that i |
Please understand that the purpose of the bug tracker is not to keep I'm tempted to close this report immediately as completely confused and a) what action you are performing Please be *EXTREMELY* cautious when using the bug tracker, as any |
Closing since I haven't seen any sign of such failures on a 64-bit build. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: