[Python-checkins] python/dist/src/Lib/test test_b1.py,1.42.4.2,1.42.4.3

nnorwitz@sourceforge.net nnorwitz@sourceforge.net
Thu, 23 May 2002 06:02:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv12391/Lib/test

Modified Files:
      Tag: release22-maint
	test_b1.py 
Log Message:
Closes: #556025 seg fault when doing list(xrange(1e9))

A MemoryError is now raised when the list cannot be created.
There is a test, but as the comment says, it really only
works for 32 bit systems.  I don't know how to improve
the test for other systems (ie, 64 bit or systems
where the data size != addressable size,
e.g. 64 bit data, but 48 bit addressable memory)


Index: test_b1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.42.4.2
retrieving revision 1.42.4.3
diff -C2 -d -r1.42.4.2 -r1.42.4.3
*** test_b1.py	18 Apr 2002 02:19:36 -0000	1.42.4.2
--- test_b1.py	23 May 2002 13:02:37 -0000	1.42.4.3
***************
*** 500,503 ****
--- 500,514 ----
  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)'