Closed suizokukan closed 9 years ago
It seems that there are compatible errors with Python 2 reported by Travis CI (https://travis-ci.org/caesar0301/treelib). Could you please fix it and let me merge this feature directly?
Yes, I'm working on it. I hope to fix the problem as soon as possible.
Everything's fine but I'm not very proud of the way I fixed the problem.
Since I think it's convenient that every Python object may be introspected with its str() method, I suggest adding such a method to the Tree class. The suggested Tree.str() method simply returns what is "drawn" by Tree._print_backend(). The code seems ok with Python2/3; the tests are ok with Python3.
o added Tree.str() method, by simply returning the value returned by Tree._print_backend(). o since str() in Python2 doesn't have to return non-unicode characters, I used a trick found in Django's code, a decorator above the Tree class. (see http://django.readthedocs.org/en/latest/_modules/django/utils/encoding.html) o modified TestCase.test_print_backend() by using the str() method.