if list('') != []: raise TestFailed, 'list('')'
if list('spam') != ['s', 'p', 'a', 'm']: raise TestFailed, "list('spam')"
+try:
+ # Verify clearing of bug #556025
+ # this assumes that the max data size (sys.maxint) == max address size
+ # this also assumes that the address size is at least 4 bytes
+ # with 8 byte addresses, the bug is not well tested
+ list(xrange(sys.maxint / 4))
+except MemoryError:
+ pass
+else:
+ raise TestFailed, 'list(xrange(sys.maxint / 4))'
+
print 'long'
if long(314) != 314L: raise TestFailed, 'long(314)'
if long(3.14) != 3L: raise TestFailed, 'long(3.14)'
return ((n >> nbits) + 1) << nbits;
}
-#define NRESIZE(var, type, nitems) PyMem_RESIZE(var, type, roundupsize(nitems))
+#define NRESIZE(var, type, nitems) \
+do { \
+ size_t _new_size = roundupsize(nitems); \
+ if (_new_size <= ((~(size_t)0) / sizeof(type))) \
+ PyMem_RESIZE(var, type, _new_size); \
+ else \
+ var = NULL; \
+} while (0)
PyObject *
PyList_New(int size)
if (n < 0)
n = 8; /* arbitrary */
NRESIZE(result->ob_item, PyObject*, n);
- if (result->ob_item == NULL)
+ if (result->ob_item == NULL) {
+ PyErr_NoMemory();
goto error;
+ }
for (i = 0; i < n; i++)
result->ob_item[i] = NULL;
result->ob_size = n;