jpadilla / django-rest-framework-xml

XML support for Django REST Framework

Home Page:http://jpadilla.github.io/django-rest-framework-xml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaks in Python3.6

cnobile2012 opened this issue · comments

This may not be a big issue yet, but when I tried to run my tests in Travis it broke in DRF on Python3.6.

  The command "(cd inventory/settings/; ln -s travis.py local.py)" exited with 0.
  1.07s$ python manage.py makemigrations accounts categories invoices locations projects regions suppliers
  Traceback (most recent call last):
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/site-packages/rest_framework/settings.py", line 177, in import_from_string module = importlib.import_module(module_path)
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 978, in _gcd_import
    File "<frozen importlib._bootstrap>", line 961, in _find_and_load
    File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 678, in exec_module
    File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/site-packages/rest_framework_xml/parsers.py", line 13, in <module>
      from .compat import etree
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/site-packages/rest_framework_xml/compat.py", line 9, in <module>
      import defusedxml.ElementTree as etree
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/site-packages/defusedxml/ElementTree.py", line 62, in <module>
      _XMLParser, _iterparse, _IterParseIterator, ParseError = _get_py3_cls()
    File "/home/travis/virtualenv/python3.6.0/lib/python3.6/site-packages/defusedxml/ElementTree.py", line 56, in _get_py3_cls
      _IterParseIterator = pure_pymod._IterParseIterator
  AttributeError: module 'xml.etree.ElementTree' has no attribute '_IterParseIterator'

This seems to be an issue with defusedxml tiran/defusedxml#4

This issue will be fixed in the next version of defusedxml. You can try temporary adding defusedxml==0.5.0.rc1 to your requirements.txt until the final release. Support for Python 2.6, 3.1, 3.2 and 3.3 will be dropped however.

@jpadilla - since there is no deliverable here, should we close this? Or leave it open and rerun travis tests when the next version of defusedxml is released?

defusedxml==0.5.0 was released but like @yennicks they're dropping support for a couple of Python versions. We still care about Python 3.3

We might be able to get around this by installing defusedxml<0.5 by default and defusedxml>=0.5 for Python 3.6.

Django 1.11 will drop support for python 3.3 in a month and python 3.3 is EOL in September 2017. You could also bump to this lib to 1.4 with defusedxml==0.5.0 and drop support for 3.3.
Potentially at the same time than the support for Django 1.10 and maybe 1.11 (see issue #19 )

Looking for some clarification: if I use defusedxml5.0, can I use REST Framework XML with Python 3.6? Documentation explicitly states 3.4 not 3.6 as a requirement (https://jpadilla.github.io/django-rest-framework-xml/).

Looks like this can be closed off. The support matrix was updated in #32 and this no longer appears to be an issue.