You have a serious migration issue. If you want to switch to Python 2.7 and even Python 3, there is basically no easy way around refactoring the existing (user) code base eventually. IMHO, you have the following options.
Provide a permanent (non-optional) 2.6 compatible interface to your users. That means they do not have to change anything, but it kind of defeats the purpose of upgrading to Python 2.7 since the users still have to satisfy Python 2.6 semantics. Verdict: Not recommended.
Provide a temporary (non-optional) 2.6 compatible interface for a limited amount of time. In that case the existing code needs to be refactored eventually. Verdict: Not recommended.
Make users include a flag in their code (e.g. a magic comment that can be identified safely without executing the file like # *$$ supertool-pythonversion: 2.7 $$*), which Python version the code expects to be run with and use 2.6 compatibility only for the files that have not been flagged with Python 2.7. That way, you can do whatever compatibility hacks are needed to run old files and run new files the way they are. Verdict: Increases complexity, but helps you doing the migration. Recommended.
However, you are in the convenient position of calling Python from C++. So you can control the environment that scripts are run with via the globals and locals dictionary passed to PyEval_EvalCode. In order to implement scenario 3, after checking the compatibility flag from the file, you can put a custom range function which supports float arguments into the gloabls dictionary before calling PyEval_EvalCode to "enable" the compatibility mode.
I am not proficient with Python's C API, but in Python this would look like this (and it is possible to do the same via the C API):
range27 = range
def range26(start=None, stop=None, step=None):
if start is not None and not isinstance(start, int):
start = int(start)
if stop is not None and not isinstance(stop, int):
stop = int(stop)
if step is not None and not isinstance(step, int):
step = int(step)
return range27(start, stop, step)
def execute_user_code(user_file):
...
src = read(user_file)
global_dict = {}
local_dict = {}
...
if check_magic_version_comment(src) in (None, '2.6'):
global_dict['range'] = range26
global_dict['range27'] = range27
# the last line is needed because the call
# of range27 will be resolved against global_dict
# when the user code is executed
eval_code(src, global_dict, local_dict)
...