Two major discoveries: 1. The python-modernize project, https://github.com/mitsuhiko/python-modernize, creates a code base that will run on all "modern" Pythons, that is, Python 2.6+ and Python 3.0+. It adds and replaces some 2to3 fixers. Several fixers, especially the new unicode fixer, rely on the six project, https://pypi.python.org/pypi/six.
2. The six project shows the one and *only* proper way to convert u constants!!! The trick is to use unicode(s,"unicode_escape"), **not** unicode(s,"utf-8"). The "unicode_escape" encoding is buried deeply in the docs. For example: this is buried in a table in http://docs.python.org/2/library/codecs.html:: "unicode_escape": Produce a string that is suitable as Unicode literal in Python source code. I would never have discovered this without looking at the code for six.u. It looks like the "unicode_escape" encoding is a hidden part of Python lore. The way forward is now clear: - Run python-modernize on all the docutils sources. - Put six.py in leo/extensions. - Ensure that sys.path contains leo/extensions when Leo starts up. It may already be there. Summary Recent work has (laboriously!) created a common code base that passes all docutils unit tests when run with Python 2.7. This work showed how important it is to get unicode issues *exactly* right. Using python-modernize, I can throw away all my previous work--I should be able to create a common code base in one step. This has several important consequences: - It should be easy to upgrade leo\extensions\docutils when never versions of docutils come out. - Unlike this last week's work, the likelihood of subtle errors is greatly diminished. - It may be possible to convince the docutils folks to freeze their ancient code base, and do all future work on a modernized code base, created automatically from the old base. I'll be lobbying for that approach on docutils-dev, but there are no guarantees. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
