Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatible with python-2.6 #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kylezh
Copy link
Contributor

@kylezh kylezh commented Dec 11, 2014

Fixes two issues in generators/xml.py when using python-2.6.

The main problem is caused by incompatible between xml.etree.ElementTree-1.2
(used by pyhton-2.6) and xml.etree.ElementTree-1.3 (used by python-2.7).

  • ElementTree.register_namespace(prefix, uri)
    Workaround by:
    ElementTree._namespace_map[uri] = prefix

    This solution is based on http://goo.gl/Z4Sjtq

  • ElementTree.write(file, encoding='utf-8', xml_declaration=True)
    Workaround by:
    ElementTree.write(file, encoding='UTF-8')

    This solution is based on http://goo.gl/8K88ow (pls check Olli's answer)

Also replaces unittest by unittest2 which is compitable with python-2.6 and
fixes the tests.
Signed-off-by: Kai Zhang [email protected]

@kylezh kylezh force-pushed the compatible-with-pyhton-2.6 branch 2 times, most recently from 9e32999 to a5044c6 Compare December 11, 2014 08:37
Fixes two issues in generators/xml.py when using python-2.6.

The main problem is caused by incompatible between xml.etree.ElementTree-1.2
(used by pyhton-2.6) and xml.etree.ElementTree-1.3 (used by python-2.7).

+ ElementTree.register_namespace(prefix, uri)
  Workaround by:
  ElementTree._namespace_map[uri] = prefix

  This solution is based on http://goo.gl/Z4Sjtq

+ ElementTree.write(file, encoding='utf-8', xml_declaration=True)
  Workaround by:
  ElementTree.write(file, encoding='UTF-8')

  This solution is based on http://goo.gl/8K88ow (pls check Olli's answer)

Also replaces unittest by unittest2 which is compitable with python-2.6 and
fixes the tests.

Signed-off-by: Kai Zhang <[email protected]>
@kylezh kylezh force-pushed the compatible-with-pyhton-2.6 branch from a5044c6 to a13225e Compare December 11, 2014 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant