Message286780
> - maybe the bug is that python2 should not reject integers, making the upgrade path to python3 (or the backward compatibility with python2, same thing) easy.
It is too late for this.
You can use the helper that converts the argument to appropriate depending on the version.
if PY2:
def helper(arg):
if isinstance(ar, (int, long)):
return chr(arg)
return arg
else:
def helper(arg):
return arg
...
v[0] = helper(42)
Or just have different branches for performance critical code:
if PY2:
v[0] = b'\x2a'
else:
v[0] = 42
I don't think Python interpreter should be changed here. |
|
Date |
User |
Action |
Args |
2017-02-02 13:11:38 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, brett.cannon, benjamin.peterson, skrah, vpelletier |
2017-02-02 13:11:38 | serhiy.storchaka | set | messageid: <1486041098.84.0.635835543444.issue29404@psf.upfronthosting.co.za> |
2017-02-02 13:11:38 | serhiy.storchaka | link | issue29404 messages |
2017-02-02 13:11:38 | serhiy.storchaka | create | |
|