ericastor/RandomSources — pull request #4 by toffer (2013-03-05 06:26:04+00:00)
Title: Fix randrange() when called with start only.

The randrange() method for RandomDotOrg works fine when called with both start and stop args. But, when randrange() is called with just a start arg (no stop), it returns a value outside of the range. (Way outside!)

$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import randomSources
>>> rng = randomSources.RandomDotOrg()
>>> rng.randrange(1, 7)
5
>>> rng.randrange(7)
-999999995

Looking through the other paths through the randrange method, I see that the response from randrange is usually "shifted" before returning the value.

When it's called with just a start arg, no shifting happens.

I've added what I believe to be the correct shift, but I'm not 100% confident I've got it right.