[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-16 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Thanks, Antoine. I'll investigate. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298 ___

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-16 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Looks like Benjamin already fixed the refleak in r76319, r76320. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298 ___

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-15 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: The fix was applied to py3k in r76292, but I bodged the commit and committed some extra (non-working) code by mistake. That was removed in r76293, so all should be well now. Merged to release31-maint in r76294. trunk and the 2.6

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-15 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Backported the tests and some of the fixes to 2.x in r76295 (trunk) and r76296 (release26-maint). 2.x seems to have been producing correct results in all cases on my machine. The only problem on 2.x was that the code depended on signed

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-15 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Not sure whether it's related, but there is now a sizeable refleak: test_range beginning 6 repetitions 123456 .. test_range leaked [150, 150, 150] references, sum=450 -- nosy: +pitrou ___ Python

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-14 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: It looks like the PyLong version of reverse is broken too: list(range(10**100, 10**100-2, -2)) [1 ] list(reversed(range(10**100, 10**100-2,

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-14 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: I've updated to patch to improve the tests, and fix the problems with the PyLong version of range.__reversed__. (Also updated on Rietveld.) -- Added file: http://bugs.python.org/file15329/issue7298_v2.patch

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-13 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Thanks for reviewing, Eric. I'll work a bit more on the tests. I'm also not sure what to do about 2.x: here reversed(xrange(start, stop, step)) has some of the same problems for large numbers. (E.g., if step == LONG_MIN.) The options

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-13 Thread Eric Smith
Eric Smith e...@trueblade.com added the comment: For 2.x, I'd just raise an exception. No one is going to be using a step of LONG_MIN. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-11 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: and here's a patch (includes the earlier tests). -- Added file: http://bugs.python.org/file15310/issue7298.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-11 Thread Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298 ___ ___

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-11 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: I've uploaded this patch to Rietveld to make it easier to review: http://codereview.appspot.com/154060/show -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-11 Thread Eric Smith
Eric Smith e...@trueblade.com added the comment: I reviewed the issue on Rietveld, and it looks fine to me with the exception of my comment about the tests. The comment is mostly a nit, so if you don't agree don't worry about it. I tested it with and without pydebug and the tests pass. I think

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread ledave123
New submission from ledave123 ledave...@yahoo.fr: On python 2.4.4, reversed(range()) is correct : list(reversed(range(12,-1,-1))) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] However, on python 3.1.1 : list(reversed(range(12,-1,-1))) [] which is obviously wrong. When step is positive, the

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Nice catch! Thanks for reporting this. get_len_of_range in Objects/rangeobject.c only works for positive steps, but is being called with a negative step here. I think get_len_of_range should be changed to work with both positive and

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: There's another problem with range_reverse: it uses a short range (all fields longs) if start, stop and step fit into a C long. But it doesn't check whether the length fits into a C long. This leads to the following:

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Further investigations show that range_iter has the same problem. :-( for x in range(-1, 2**63-1): print(x) ... (no output) This really needs to be fixed. Upgrading to release blocker, and removing the easy flag. -- keywords:

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread Eric Smith
Changes by Eric Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7298 ___ ___ Python-bugs-list mailing

[issue7298] reversed(range(x, -1, -1)) is empty when x 1

2009-11-10 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Here are some tests. -- keywords: +patch stage: - needs patch Added file: http://bugs.python.org/file15306/issue7298_test.patch ___ Python tracker rep...@bugs.python.org