Commit 4e0486b7 by Mikhail Korobov

Python 3.3 compatibility for nltk.internals.ElementWrapper. Thanks @achimnol. Fixes #350.

parent 8ffb0884
...@@ -647,13 +647,18 @@ class ElementWrapper(object): ...@@ -647,13 +647,18 @@ class ElementWrapper(object):
if isinstance(etree, ElementWrapper): if isinstance(etree, ElementWrapper):
return etree return etree
else: else:
return object.__new__(ElementWrapper, etree) return object.__new__(ElementWrapper)
def __init__(self, etree): def __init__(self, etree):
""" r"""
Initialize a new Element wrapper for ``etree``. If Initialize a new Element wrapper for ``etree``.
``etree`` is a string, then it will be converted to an
Element object using ``ElementTree.fromstring()`` first. If ``etree`` is a string, then it will be converted to an
Element object using ``ElementTree.fromstring()`` first:
>>> ElementWrapper("<test></test>")
<Element "<?xml version='1.0' encoding='utf8'?>\n<test />">
""" """
if isinstance(etree, compat.string_types): if isinstance(etree, compat.string_types):
etree = ElementTree.fromstring(etree) etree = ElementTree.fromstring(etree)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment