-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
32 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# defusedxml | ||
# | ||
# Copyright (c) 2013 by Christian Heimes <[email protected]> | ||
# Copyright (c) 2013-2020 by Christian Heimes <[email protected]> | ||
# Licensed to PSF under a Contributor Agreement. | ||
# See https://www.python.org/psf/license for licensing details. | ||
"""Defused xml.etree.ElementTree facade | ||
|
@@ -13,14 +13,7 @@ | |
from xml.etree.ElementTree import parse as _parse | ||
from xml.etree.ElementTree import tostring | ||
|
||
from .common import PY3 | ||
|
||
if PY3: | ||
import importlib | ||
else: | ||
from xml.etree.ElementTree import XMLParser as _XMLParser | ||
from xml.etree.ElementTree import iterparse as _iterparse | ||
from xml.etree.ElementTree import ParseError | ||
import importlib | ||
|
||
|
||
from .common import ( | ||
|
@@ -68,8 +61,7 @@ def _get_py3_cls(): | |
return _XMLParser, _iterparse, ParseError | ||
|
||
|
||
if PY3: | ||
_XMLParser, _iterparse, ParseError = _get_py3_cls() | ||
_XMLParser, _iterparse, ParseError = _get_py3_cls() | ||
|
||
_sentinel = object() | ||
|
||
|
@@ -84,8 +76,7 @@ def __init__( | |
forbid_entities=True, | ||
forbid_external=True, | ||
): | ||
# Python 2.x old style class | ||
_XMLParser.__init__(self, target=target, encoding=encoding) | ||
super().__init__(target=target, encoding=encoding) | ||
if html is not _sentinel: | ||
# the 'html' argument has been deprecated and ignored in all | ||
# supported versions of Python. Python 3.8 finally removed it. | ||
|
@@ -101,10 +92,7 @@ def __init__( | |
self.forbid_dtd = forbid_dtd | ||
self.forbid_entities = forbid_entities | ||
self.forbid_external = forbid_external | ||
if PY3: | ||
parser = self.parser | ||
else: | ||
parser = self._parser | ||
parser = self.parser | ||
if self.forbid_dtd: | ||
parser.StartDoctypeDeclHandler = self.defused_start_doctype_decl | ||
if self.forbid_entities: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# defusedxml | ||
# | ||
# Copyright (c) 2013 by Christian Heimes <[email protected]> | ||
# Copyright (c) 2013-2020 by Christian Heimes <[email protected]> | ||
# Licensed to PSF under a Contributor Agreement. | ||
# See https://www.python.org/psf/license for licensing details. | ||
"""Common constants, exceptions and helpe functions | ||
""" | ||
import sys | ||
import xml.parsers.expat | ||
|
||
PY3 = sys.version_info[0] == 3 | ||
PY3 = True | ||
|
||
# Fail early when pyexpat is not installed correctly | ||
if not hasattr(xml.parsers.expat, "ParserCreate"): | ||
|
@@ -26,7 +26,7 @@ class DTDForbidden(DefusedXmlException): | |
"""Document type definition is forbidden""" | ||
|
||
def __init__(self, name, sysid, pubid): | ||
super(DTDForbidden, self).__init__() | ||
super().__init__() | ||
self.name = name | ||
self.sysid = sysid | ||
self.pubid = pubid | ||
|
@@ -40,7 +40,7 @@ class EntitiesForbidden(DefusedXmlException): | |
"""Entity definition is forbidden""" | ||
|
||
def __init__(self, name, value, base, sysid, pubid, notation_name): | ||
super(EntitiesForbidden, self).__init__() | ||
super().__init__() | ||
self.name = name | ||
self.value = value | ||
self.base = base | ||
|
@@ -57,7 +57,7 @@ class ExternalReferenceForbidden(DefusedXmlException): | |
"""Resolving an external reference is forbidden""" | ||
|
||
def __init__(self, context, base, sysid, pubid): | ||
super(ExternalReferenceForbidden, self).__init__() | ||
super().__init__() | ||
self.context = context | ||
self.base = base | ||
self.sysid = sysid | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
[tool.black] | ||
line-length = 98 | ||
# black does not yet support py39 | ||
target-version = ['py27', 'py35', 'py36', 'py37', 'py38'] | ||
target-version = ['py36', 'py37', 'py38'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters