This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inconsistent acceptance of floats for range()
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, docwatson
Priority: low Keywords:

Created on 2004-08-08 00:13 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg22008 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-08-08 00:13
``range(1.0)`` will raise a DeprecationWarning (thanks to 
PyArg_ParseTuple() warning when a float is passed when an 
integer is expected), but if you do ``range(1e100)`` it raises a 
TypeError saying that an "integer end argument expected, got 
float".  Obviously not consistent.
msg22009 - (view) Author: Dave Watson (docwatson) Date: 2004-08-14 03:49
Logged In: YES 
user_id=1094771

I've looked into it, and 1e100 is of type 'long float'
internally, which uses a different range function
(handle_range_long) instead of 1.0 which is a normal float,
which uses the standard range function (bltin_range).

It seems the long version was written after the standard
one, and once the deprecation warning (which happens in both
versions, but it will only print once per session, restart
python to test each) is turned into an error, things will be
consistent.
msg22010 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-08-17 02:17
Logged In: YES 
user_id=357491

OK, works for me.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40713
2004-08-08 00:13:29brett.cannoncreate