mzsk / tinypy

Automatically exported from code.google.com/p/tinypy
Other
0 stars 0 forks source link

range(n) return an empty list for n > MAX_INT #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

 run the following code :

  print(len(range(2**32 + 1)))

What is the expected output? What do you see instead?

  I think we should get an overflow error (list can't be longer than the
max int value), instead we get '0'

What version of the product are you using? On what operating system?

  svn version : trunk@157, on ubuntu using a 64bit computer

Please provide any additional information below.

  in the code of tp_range (builtins.c), we convert the arguments from
double to int without any check.

Original issue reported on code.google.com by charlie...@gmail.com on 5 Feb 2010 at 9:25

GoogleCodeExporter commented 9 years ago
I think the problem might not be so much in max list size as in the computer 
memory
(although I don't actively participate in the dev -- yet -- so I can't tell) - I
agree that tinypy should raise an error though (perhaps an out of memory error?)

Original comment by darkuran...@gmail.com on 5 Feb 2010 at 10:35

GoogleCodeExporter commented 9 years ago
I attach a patch that should fix the problem.  We should add a test case before
landing it though.

Original comment by charlie...@gmail.com on 5 Feb 2010 at 3:01

Attachments: