On Wed, Apr 24, 2013 at 10:40 AM, Edward K. Ream <[email protected]>wrote:

> Two major discoveries:
>

Alas, neither python-modernize, nor six, nor the "unicode_escape" encoding
is a magic bullet.

1.  six.u can fail for unicode input.  Sheesh.  This looks safer::

def u(s):
    if sys.version_info < (3,):
        return s if isinstance(s,unicode) else unicode(s,"unicode_escape")
    else:
        return s if isinstance(s,str) else str(s,"unicode_escape")

2. python-modernize is pretty disappointing.  It doesn't automatically
convert imports!  And the print fixer inserts a 'from __future__ import
print_function' for every print statement contains one of the new keywords.

Furthermore, python-modernize always wraps u literals in calls to six.u.
(There are actually other unicode literal options, but they are useless.)
Otoh, it's easy to convert calls to six.u to just u and convert 'import
six' to 'from docutils.utils.u import u'.

The bottom line is that unicode issues are still causing subtle problems.
The strategy remains:

- start with the original docutils sources,
- make *small* changes to the code,
- run all of docutils' unit tests
- figure out what went wrong :-)

The goal: create a relatively simple recipe for converting docutils to a
common code base *automatically*.
 Not there yet.  I had hoped to avoid writing my own fixers, but it looks
like that is not really an option.

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.


Reply via email to