w_byte((char)((x>>24) & 0xff), p);
}
-#if SIZEOF_LONG > 4
-static void
-w_long64(long x, WFILE *p)
-{
- w_long(x, p);
- w_long(x>>32, p);
-}
-#endif
-
+ #define SIZE32_MAX 0x7FFFFFFF
+
+ #if SIZEOF_SIZE_T > 4
+ # define W_SIZE(n, p) do { \
+ if ((n) > SIZE32_MAX) { \
+ (p)->depth--; \
+ (p)->error = WFERR_UNMARSHALLABLE; \
+ return; \
+ } \
+ w_long((long)(n), p); \
+ } while(0)
+ #else
+ # define W_SIZE w_long
+ #endif
+
/* We assume that Python longs are stored internally in base some power of
2**15; for the sake of portability we'll always read and write them in base
exactly 2**15. */
}
}
else {
- PyObject *data = PyObject_CallMethod(p->readable, "read", "n", n);
+ _Py_IDENTIFIER(read);
+
- PyObject *data = _PyObject_CallMethodId(p->readable, &PyId_read, "i", n);
++ PyObject *data = _PyObject_CallMethodId(p->readable, &PyId_read, "n", n);
read = 0;
if (data != NULL) {
if (!PyBytes_Check(data)) {