summaryrefslogtreecommitdiff
path: root/src/zope/tal/xmlparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/zope/tal/xmlparser.py')
-rw-r--r--src/zope/tal/xmlparser.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/zope/tal/xmlparser.py b/src/zope/tal/xmlparser.py
index 7ebee73..f4891f9 100644
--- a/src/zope/tal/xmlparser.py
+++ b/src/zope/tal/xmlparser.py
@@ -16,22 +16,10 @@
This creates a parser with namespace processing enabled.
"""
import logging
+from urllib.request import urlopen
-try:
- # Python 2.x
- from urllib import urlopen
-except ImportError:
- # Python 3.x
- from urllib.request import urlopen
-
-try:
- unicode
-except NameError:
- unicode = str # Python 3.x
-
-
-class XMLParser(object):
+class XMLParser:
"""
Parse XML using :mod:`xml.parsers.expat`.
"""
@@ -91,9 +79,9 @@ class XMLParser(object):
def parseString(self, s):
"""Parse the given string."""
- if isinstance(s, unicode):
- # Expat cannot deal with unicode strings, only with
- # encoded ones. Also, its range of encodings is rather
+ if isinstance(s, str):
+ # Expat cannot deal with str, only with
+ # bytes. Also, its range of encodings is rather
# limited, UTF-8 is the safest bet here.
s = s.encode('utf-8')
self.parser.Parse(s, 1)