News for hackers. Stuff that matters.

Show HN: Python 3 with backwards compatibility features

Porting Python code from version 2.x to 3.x is not a simple task. To help, I built a version of Python 3.6 that includes backwards compatibility features. Most important is the mixing of bytes and str objects and comparisons. For example, in vanilla Python 3:

  >>> b'foo' + 'bar'
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: can't concat bytes to str
  >>> None < 'hi'
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: unorderable types: NoneType() < str()

In my Python 3:

  >>> b'foo' + 'bar'
  sys:1: DeprecationWarning: encoding bytes to str
  'foobar'
  >>> None < 'hi'
  __main__:1: DeprecationWarning: default compare is depreciated
  True
Certain changes are easy to fix with code converters like 2to3. For example, changing print statements into functions is trivial. I don't bother trying to handle those. There is still a lot of things that could be added. However, when porting a large code base to Python 3, I found it useful.

I hope other people might use it and submit improvements. If someone need pre-built binaries (e.g. Windows), I would be willing to do it.

https://github.com/nascheme/ppython

( 2 comments | 7 points | on HN )
Re:Show HN: Python 3 with backwards compatibility features by GroSacASacs on Tuesday December 13, 2016 @10:30AM (#13167469)
Good work, have you put it on PIP and Python Mailing list ?
Re:Show HN: Python 3 with backwards compatibility features by lulzman206 on Saturday December 10, 2016 @08:28PM (#13149061)
This is what Python devs should have done...