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.

Author serhiy.storchaka
Recipients benjamin.peterson, brett.cannon, serhiy.storchaka, skrah, vpelletier
Date 2017-02-02.13:11:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486041098.84.0.635835543444.issue29404@psf.upfronthosting.co.za>
In-reply-to
Content
> - 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.
History
Date User Action Args
2017-02-02 13:11:38serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, benjamin.peterson, skrah, vpelletier
2017-02-02 13:11:38serhiy.storchakasetmessageid: <1486041098.84.0.635835543444.issue29404@psf.upfronthosting.co.za>
2017-02-02 13:11:38serhiy.storchakalinkissue29404 messages
2017-02-02 13:11:38serhiy.storchakacreate