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
PyInt_FromSsize_t LONG_MIN and LONG_MAX typecasts needed #49130
Comments
there's probably a better way to do this (or a better reason), but PyObject *
PyInt_FromSsize_t(Py_ssize_t ival)
{
if ((long)ival >= (long)LONG_MIN && (long)ival <= (long)LONG_MAX)
{
return PyInt_FromLong((long)ival);
}
return _PyLong_FromSsize_t(ival);
} |
Interesting. How many of those casts are actually necessary to make It seems to me that a better fix would be to fix LONG_MIN and LONG_MAX P.S. Looking at your python-dev messages, does len([1, 2]) really return |
oh, duh - 2L not 1L yes you're right :) yeh i believe it's likely to be because in PC/pyconfig.h LONG_MAX is you're right that would make life a looot easier. |
.... hmmm... noo, it's already #defined to 0x7fffffffL in so .... this works (Include/pyports.h) #ifdef __WINE__ /* weird: you have to typecast 0x7fffffffL to long */
#undef LONG_MAX
#undef LONG_MIN
#define LONG_MAX ((long)0x7FFFFFFFL)
#define LONG_MIN ((long)(-LONG_MAX-1))
#else
#ifndef LONG_MAX
#if SIZEOF_LONG == 4
#define LONG_MAX 0X7FFFFFFFL
#elif SIZEOF_LONG == 8
#define LONG_MAX 0X7FFFFFFFFFFFFFFFL
#else
#error "could not set LONG_MAX in pyport.h"
#endif
#endif
#ifndef LONG_MIN
#define LONG_MIN (-LONG_MAX-1)
#endif #endif /* __WINE__ */ |
I think you should study the preprocessor output to find out what In any case, I'm tempted to close this as "works for me" - 0x7FFFFFFFL |
It seems likely that this is a wine bug rather than a Python bug. |
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: