diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-01 09:11:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-01 09:11:43 (GMT) |
commit | eb8974616bc58f44b2a3c3e4ca2326894ae42c8f (patch) | |
tree | 8b33d94a0ca263a5260703d1299fe54ab90d48c2 /Lib/xml | |
parent | 41c57b335330ff48af098d47e379e0f9ba09d233 (diff) | |
download | cpython-eb8974616bc58f44b2a3c3e4ca2326894ae42c8f.zip cpython-eb8974616bc58f44b2a3c3e4ca2326894ae42c8f.tar.gz cpython-eb8974616bc58f44b2a3c3e4ca2326894ae42c8f.tar.bz2 |
bpo-15999: Always pass bool instead of int to the expat parser. (GH-15622)
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/expatbuilder.py | 8 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 4 | ||||
-rw-r--r-- | Lib/xml/sax/expatreader.py | 14 |
3 files changed, 13 insertions, 13 deletions
diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py index 2bd835b..199c22d 100644 --- a/Lib/xml/dom/expatbuilder.py +++ b/Lib/xml/dom/expatbuilder.py @@ -204,11 +204,11 @@ class ExpatBuilder: buffer = file.read(16*1024) if not buffer: break - parser.Parse(buffer, 0) + parser.Parse(buffer, False) if first_buffer and self.document.documentElement: self._setup_subset(buffer) first_buffer = False - parser.Parse("", True) + parser.Parse(b"", True) except ParseEscape: pass doc = self.document @@ -637,7 +637,7 @@ class FragmentBuilder(ExpatBuilder): nsattrs = self._getNSattrs() # get ns decls from node's ancestors document = _FRAGMENT_BUILDER_TEMPLATE % (ident, subset, nsattrs) try: - parser.Parse(document, 1) + parser.Parse(document, True) except: self.reset() raise @@ -697,7 +697,7 @@ class FragmentBuilder(ExpatBuilder): self.fragment = self.document.createDocumentFragment() self.curNode = self.fragment try: - parser.Parse(self._source, 1) + parser.Parse(self._source, True) finally: self.curNode = old_cur_node self.document = old_document diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index beb2d68..e75200a 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1710,14 +1710,14 @@ class XMLParser: def feed(self, data): """Feed encoded data to parser.""" try: - self.parser.Parse(data, 0) + self.parser.Parse(data, False) except self._error as v: self._raiseerror(v) def close(self): """Finish feeding data to parser and return element structure.""" try: - self.parser.Parse("", 1) # end of data + self.parser.Parse(b"", True) # end of data except self._error as v: self._raiseerror(v) try: diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py index 5066ffc..e334ac9 100644 --- a/Lib/xml/sax/expatreader.py +++ b/Lib/xml/sax/expatreader.py @@ -93,7 +93,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): self._parser = None self._namespaces = namespaceHandling self._lex_handler_prop = None - self._parsing = 0 + self._parsing = False self._entity_stack = [] self._external_ges = 0 self._interning = None @@ -203,10 +203,10 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): # IncrementalParser methods - def feed(self, data, isFinal = 0): + def feed(self, data, isFinal=False): if not self._parsing: self.reset() - self._parsing = 1 + self._parsing = True self._cont_handler.startDocument() try: @@ -237,13 +237,13 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): # If we are completing an external entity, do nothing here return try: - self.feed("", isFinal = 1) + self.feed(b"", isFinal=True) self._cont_handler.endDocument() - self._parsing = 0 + self._parsing = False # break cycle created by expat handlers pointing to our methods self._parser = None finally: - self._parsing = 0 + self._parsing = False if self._parser is not None: # Keep ErrorColumnNumber and ErrorLineNumber after closing. parser = _ClosedParser() @@ -307,7 +307,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): self._parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) - self._parsing = 0 + self._parsing = False self._entity_stack = [] # Locator methods |