Issue 1472639: make range be xrange (original) (raw)
As discussed (in private email), make range an alias for xrange and see howmuch breaks ;)
Aside from Python/bltinmodule.c, 31 files had to be changed: 3 modules (but one of them was a doctest in doctest), 2 test output files (for profile and cProfile), and 26 tests. The predominant breakage in tests was due to tests using range() to express expected-test-output, and comparing it with the output list. Another fair sized portion (particularly of doctests, and including the doctest in doctest itself that had to be updated) broke because of reliance on the repr of range(). Only a few tests broke because of xrange() being immutable (mostly tests that were actually testing list-behaviour, like item- and slice-assignment, on a list created by range()), but that were all two real breakages in actual modules. The only place that broke because xrange can't handle longs was the test for range() that tested whether it'd take longs. Overall, ~185 lines had to be changed.
The patch still breaks a test: the test to see if range() does proper checks on its arguments (using the 'badint' class in test_builtin.) I didn't fix it to remind myself that xrange() should be made to operate on longs :) (It currently fails because xrange() will turn all its arguments into C long integers before it does any checks.)