1. Christian Heimes
  2. defusedxml

Commits

Brett Cannon  committed 32024df

No need to clutter the code with super() calls for Python 3; it's just a nicety and not required

  • Participants
  • Parent commits f32529d
  • Branches default

Comments (0)

Files changed (2)

File defusedxml/expatbuilder.py

View file
  • Ignore whitespace
 
 class DefusedExpatBuilder(_ExpatBuilder):
     def __init__(self, options=None, forbid_dtd=False, forbid_entities=True):
-        if PY3:
-            super().__init__(options)
-        else:
-            # Python 2.x old style class
-            _ExpatBuilder.__init__(self, options)
+        _ExpatBuilder.__init__(self, options)
         self.forbid_dtd = forbid_dtd
         self.forbid_entities = forbid_entities
 
         raise ExternalEntitiesForbidden(systemId, publicId)
 
     def install(self, parser):
-        if PY3:
-            super().install(parser)
-        else:
-            # Python 2.x old style class
-            _ExpatBuilder.install(self, parser)
+        _ExpatBuilder.install(self, parser)
 
         if self.forbid_dtd:
             parser.StartDoctypeDeclHandler = self.start_doctype_decl
     """Document builder that supports namespaces."""
 
     def install(self, parser):
-        # Python 3.x code doesn't use super() :(
         DefusedExpatBuilder.install(self, parser)
         if self._options.namespace_declarations:
             parser.StartNamespaceDeclHandler = (
                 self.start_namespace_decl_handler)
 
     def reset(self):
-        if PY3:
-            super().reset()
-        else:
-            DefusedExpatBuilder.reset(self)
+        DefusedExpatBuilder.reset(self)
         self._initNamespaces()
 
 
     Document node.
     """
     if namespaces:
-        builder = DefusedExpatBuilderNS(forbid_dtd=forbid_dtd,
-                                        forbid_entities=forbid_entities)
+        build_builder = DefusedExpatBuilderNS
     else:
-        builder = DefusedExpatBuilder(forbid_dtd=forbid_dtd,
-                                      forbid_entities=forbid_entities)
+        build_builder = DefusedExpatBuilder
+    builder = build_builder(forbid_dtd=forbid_dtd,
+                            forbid_entities=forbid_entities)
     return builder.parseString(string)

File defusedxml/expatreader.py

View file
  • Ignore whitespace
 
     def __init__(self, forbid_dtd=False, forbid_entities=True,
                  *args, **kwargs):
-        if PY3:
-            super().__init__(*args, **kwargs)
-        else:
-            # Python 2.x old style class
-            _ExpatParser.__init__(self, *args, **kwargs)
+        _ExpatParser.__init__(self, *args, **kwargs)
         self.forbid_dtd = forbid_dtd
         self.forbid_entities = forbid_entities
 
         raise ExternalEntitiesForbidden(systemId, publicId)
 
     def reset(self):
-        if PY3:
-            super().reset()
-        else:
-            # Python 2.x old style class
-            _ExpatParser.reset(self)
+        _ExpatParser.reset(self)
         parser = self._parser
         if self.forbid_dtd:
             parser.StartDoctypeDeclHandler = self.start_doctype_decl