Skip to content

Python 3 support#10

Closed
drmfinlay wants to merge 5 commits intomasterfrom
feat/py3-support
Closed

Python 3 support#10
drmfinlay wants to merge 5 commits intomasterfrom
feat/py3-support

Conversation

@drmfinlay
Copy link
Member

@drmfinlay drmfinlay commented Apr 18, 2018

I've selectively merged changes from pull request t4ngo/dragonfly#56 to make dragonfly compatible with both Python 2.7 and 3+, plus fixes for more recent commits. 2to3 and six have been used to do this. I had originally thought to use setuptools and 2to3 to do this (see #5), but that approach had a few quirks.

You should be able to use 2to3 to convert grammar modules to work with both Python versions.

I've tested this using Python versions 2.7.13 and 3.5.3 on Debian, but not as much on Windows, so more testing is required before merging this.

Some notes/issues:

  • The natlink dragonfly engine won't work with Python 3 until natlink itself supports Python 3.
  • The Keyboard class is now broken for Python 3, despite commit c48aec9 (fixed)
  • I'm not sure if I've done the windows-1252 encoding correctly for both Python versions.
  • The test_int_ref test for dragonfly2jsgf seems to fail only for Python 3. I suspect this is (yet another) pyjsgf issue.
  • The new relative import statements seem to be causing docstring tests to break.
  • I screwed up the merge from @sathishkottravel's master branch, so I need to fix that. Never mind, it just can't be automatically rebased.

sathishkottravel and others added 5 commits October 2, 2016 07:16
1) 2to3 has been used initially
2) string.letter -> string.ascii_letters
3) c_char(char)  -> c_char(ord(char)) , similar c_wchar
4) __str__(self) modified in action_base.py and state.py  ( #http://stackoverflow.com/questions/6812031/how-to-make-unicode-string-with-python3)
…eat/py3-support

I've reverted the Unicode changes in favour of using 2to3 from
setuptools to translate for Python 3 with only a few fixes
enabled. The same has been done for basestring, str and long->int
changes. There are also still a few newer issues to be resolved
with 2to3.

There are also a few unrelated changes in apps/family and some
typo fixes.
- 2to3 was mostly used to unify syntactic differences between
  versions. E.g. 'except Exception, e' -> 'except Exception as e'
  and 'print "text"' -> 'print("text")'. It was also used for
  generator function changes and relative imports.
- The 'six' package has been used for semantic differences between
  versions. E.g. unicode -> str conversion. That package has been
  added to install_requires in setup.py.
- Not sure if I've done the windows-1252 encoding correctly across
  Python versions
drmfinlay added a commit that referenced this pull request Jun 8, 2018
Closes #10.

- Not everything is working yet for Python 3.
- There may be still be some issues with Python 2 (a lot of code
  changes), so this is being merged into 'develop' first. Any
  issues will probably be related to encoding between
  windows-1252, utf-8 and/or ascii.
@drmfinlay
Copy link
Member Author

This has been merged into develop instead. More testing needs to be done on Windows for both Python versions. The parser tests and doctests pass for both versions.

The bug with Keyboard has been resolved.

@drmfinlay drmfinlay closed this Jun 9, 2018
@drmfinlay drmfinlay deleted the feat/py3-support branch June 9, 2018 03:31
@LexiconCode LexiconCode added the Enhancement Enhancement existing feature label Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Enhancement existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants