Issue 48 in tinypy: range(n) return an empty list for n > MAX_INT

3 views
Skip to first unread message

codesite...@google.com

unread,
Feb 5, 2010, 4:25:56 AM2/5/10
to tin...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 48 by charlie137: range(n) return an empty list for n > MAX_INT
http://code.google.com/p/tinypy/issues/detail?id=48

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.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Feb 5, 2010, 5:36:09 AM2/5/10
to tin...@googlegroups.com

Comment #1 on issue 48 by darkuranium: range(n) return an empty list for n
> MAX_INT
http://code.google.com/p/tinypy/issues/detail?id=48

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?)

codesite...@google.com

unread,
Feb 5, 2010, 10:02:31 AM2/5/10
to tin...@googlegroups.com

Comment #2 on issue 48 by charlie137: range(n) return an empty list for n >
MAX_INT
http://code.google.com/p/tinypy/issues/detail?id=48

I attach a patch that should fix the problem. We should add a test case
before
landing it though.


Attachments:
0001-range-raises-an-error-if-N-is-too-high.patch 1.3 KB

Reply all
Reply to author
Forward
0 new messages