Repository: django-wiki/django-wiki

Issue:
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
Deprecated in 3.2 and removed in 3.9.

```
Internal Server Error: /wiki/
Traceback (most recent call last):
  File "$VENV/lib/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "$VENV/lib/python3.9/site-packages/django/core/handlers/base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "$VENV/lib/python3.9/site-packages/django/core/handlers/base.py", line 143, in _get_response
    response = response.render()
  File "$VENV/lib/python3.9/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "$VENV/lib/python3.9/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "$VENV/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/classytags/core.py", line 151, in render
    return self.render_tag(context, **kwargs)
  File "$VENV/lib/python3.9/site-packages/sekizai/templatetags/sekizai_tags.py", line 87, in render_tag
    rendered_contents = nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 936, in render
    bit = node.render_annotated(context)
  File "$VENV/lib/python3.9/site-packages/django/template/base.py", line 903, in render_annotated
    return self.render(context)
  File "$VENV/lib/python3.9/site-packages/django/template/library.py", line 214, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "$VENV/lib/python3.9/site-packages/wiki/templatetags/wiki_tags.py", line 53, in wiki_render
    content = article.get_cached_content(user=context.get("user"))
  File "$VENV/lib/python3.9/site-packages/wiki/models/article.py", line 250, in get_cached_content
    cached_content = self.render(user=user)
  File "$VENV/lib/python3.9/site-packages/wiki/models/article.py", line 211, in render
    article_markdown(
  File "$VENV/lib/python3.9/site-packages/wiki/core/markdown/__init__.py", line 49, in article_markdown
    return md.convert(text)
  File "$VENV/lib/python3.9/site-packages/wiki/core/markdown/__init__.py", line 31, in convert
    html = super().convert(text, *args, **kwargs)
  File "$VENV/lib/python3.9/site-packages/markdown/core.py", line 267, in convert
    newRoot = treeprocessor.run(root)
  File "$VENV/lib/python3.9/site-packages/wiki/core/markdown/mdx/responsivetable.py", line 15, in run
    for table_wrapper in list(root.getiterator("table")):
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
```


Discussion:
Hi @AstraLuma - is this more broadly associated with Python 3.9 support?
Probably.
Alright, it probably needs to add Python 3.9 to the test matrix of `tox.ini` and `.travis.yml`. Then, replacing the use of `getiterator` in a way that is backwards-compatible.

@AstraLuma - is it something you would be interested in fixing?
Possibly. I've got other things going on, but if I have time to dig into django-wiki this is should be an easy fix.
@AstraLuma @benjaoming 

I have installed python 3.9 and got the same error.

I leave you a solution.

```python              
import sys
```

```python
class ResponsiveTableTree(Treeprocessor):
    def run(self, root):
        if sys.version_info >= (3, 9):
            root_iter = root.iter('table')
        else:
            root_iter = root.getiterator('table') 

        for table_wrapper in list(root_iter):
            table_new = self.create_table_element()
            self.convert_to_wrapper(table_wrapper)
            self.move_children(table_wrapper, table_new)
            table_wrapper.append(table_new)
        return root
```

- I'm using the 0.4.x from django-wiki and it's a bit modified


https://github.com/Python-Markdown/markdown/issues/953

Resolving patch:
diff --git a/src/wiki/__init__.py b/src/wiki/__init__.py
--- a/src/wiki/__init__.py
+++ b/src/wiki/__init__.py
@@ -17,5 +17,5 @@
 
 default_app_config = "wiki.apps.WikiConfig"
 
-VERSION = (0, 7, 1, "final", 0)
+VERSION = (0, 7, 2, "alpha", 0)
 __version__ = get_version(VERSION)
diff --git a/src/wiki/core/markdown/mdx/responsivetable.py b/src/wiki/core/markdown/mdx/responsivetable.py
--- a/src/wiki/core/markdown/mdx/responsivetable.py
+++ b/src/wiki/core/markdown/mdx/responsivetable.py
@@ -11,8 +11,14 @@ def extendMarkdown(self, md):
 
 
 class ResponsiveTableTree(Treeprocessor):
+    """
+    NOTE: If you allow inputting of raw <table> tags rather than Markdown code
+    for tables, this tree processor will not affect the table, as it gets
+    stashed and not managed by a Treeprocessor type extension.
+    """
+
     def run(self, root):
-        for table_wrapper in list(root.getiterator("table")):
+        for table_wrapper in list(root.iter("table")):
             table_new = self.create_table_element()
             self.convert_to_wrapper(table_wrapper)
             self.move_children(table_wrapper, table_new)


Test patch: