From 605a0af598c49650ab7a4a2c0ae111a0d5eff4aa Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Sun, 9 Aug 2020 07:17:51 +0000 Subject: [PATCH 1/2] Use ElementTree instead of deprecated cElementTree. --- textblob/_text.py | 5 ++--- textblob/compat.py | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/textblob/_text.py b/textblob/_text.py index 152d0e12..26d0cef1 100644 --- a/textblob/_text.py +++ b/textblob/_text.py @@ -11,9 +11,8 @@ import types import os import re -from xml.etree import cElementTree -from .compat import text_type, basestring, imap, unicode, binary_type, PY2 +from .compat import text_type, basestring, imap, unicode, binary_type, PY2, ET try: MODULE = os.path.dirname(os.path.abspath(__file__)) @@ -740,7 +739,7 @@ def load(self, path=None): if not os.path.exists(path): return words, synsets, labels = {}, {}, {} - xml = cElementTree.parse(path) + xml = ET.parse(path) xml = xml.getroot() for w in xml.findall("word"): if self._confidence is None \ diff --git a/textblob/compat.py b/textblob/compat.py index bf384dd1..8aa60747 100644 --- a/textblob/compat.py +++ b/textblob/compat.py @@ -16,6 +16,7 @@ imap = imap izip = izip import unicodecsv as csv + import xml.etree.cElementTree as ET def implements_to_string(cls): """Class decorator that renames __str__ to __unicode__ and @@ -36,6 +37,7 @@ def implements_to_string(cls): imap = map izip = zip import csv + import xml.etree.ElementTree as ET implements_to_string = lambda x: x From 9042d22413cfa2610744d2e66bfa87d5fbae57a5 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Thu, 15 Feb 2024 15:26:27 -0500 Subject: [PATCH 2/2] Add @tirkarthi to AUTHORS; update changelog --- AUTHORS.rst | 1 + CHANGELOG.rst | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index a00d4c6e..86aebc45 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -33,3 +33,4 @@ Contributors (chronological) - Ram Rachum `@cool-RR `_ - Romain Casati `@casatir `_ - Evgeny Kemerov `@sudoguy `_ +- Karthikeyan Singaravelan `@tirkarthi `_ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a6195d4e..dabf01ca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,13 @@ Changelog 0.18.0 (unreleased) ------------------- +Bug fixes: + +- Remove usage of deprecated cElementTree (:issue:`339`). + Thanks :user:`tirkarthi` for reporting and for the PR. +- Address ``SyntaxWarning`` on Python 3.12 (:pr:`418`). + Thanks :user:`smontanaro` for the PR. + Removals: - ``TextBlob.translate()`` and ``TextBlob.detect_language``, and ``textblob.translate``