Bdanilko / EdPy

A compiler for a subset of python2 to be used on the Microbric Edison robot
GNU General Public License v2.0
18 stars 12 forks source link

Made the code running both in Python 2.7 and 3.5 #1

Closed aivarannamaa closed 7 years ago

aivarannamaa commented 7 years ago

I think I was able to solve most Python 3 compatibility issues (changed signatures, changed AST nodes and bytes vs str issues).

So far I've tested it only with follow_torch and sumo_wrestle demo programs. The assembly listings when run with Python 2.7 vs 3.5 look almost the same. Some sections have switched places, though (are you using some dict-s or set-s in your code? These could bring nondeterminism). Generated waw files are about the same size.

I'm not suggesting you should accept the PR at the moment -- I hope to find time to do some more testing soon. I mostly just wanted to share the optimism, that Py3 support is feasible.

aivarannamaa commented 7 years ago

I forgot to add, that I feel confident that I didn't break anything in Python 2 support. The wav files generated for sumo_wrestle with Python 2.7 before vs after my modifications, were identical.

Bdanilko commented 7 years ago

Hi,

This looks great! I'm really happy that the 2.7 to the 3.x parser changes were so minimal. I won't be able to do good testing for a couple of weeks, but this is looking really good. I like your refactors. One small thing, the io.Out.xxxx functions are meant for future translations so the text in them should be the same. Only the values in the format should change and should be kept minimal as they won't be translated. Running the program - TransStrings.py will check that all strings are the same. I prefer having the text where it is used. Great looking work -- Thanks! Brian

Bdanilko commented 7 years ago

Sorry didn't mean to close anything!

aivarannamaa commented 7 years ago

I think now my changes are ready to be merged.

I reverted two translatable strings as they were in original code and merged your updates.

I also tested the code with actual Edison using my IDE plug-in (https://bitbucket.org/plas/thonny-edison). I successfully programmed clap_controlled_driving and test_program demos to Edison both with Python 2.7 and 3.6.

Bdanilko commented 7 years ago

This looks great -- I'll merge and add a document talking about python versions. It's the parser that worries me the most -- as it uses knowledge of the AST produced by the version of python that it is run under. Still I did diffs of the 2.7 vs. 3.6 AST and your changes seemed to address everything that EdPy uses. Thanks for your work on this -- I'm looking forward to having a look at thonny!