summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/xml
diff options
context:
space:
mode:
authorshadchin <[email protected]>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <[email protected]>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Lib/xml
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/xml')
-rw-r--r--contrib/tools/python3/src/Lib/xml/dom/expatbuilder.py5
-rw-r--r--contrib/tools/python3/src/Lib/xml/etree/ElementTree.py23
-rw-r--r--contrib/tools/python3/src/Lib/xml/sax/__init__.py21
-rw-r--r--contrib/tools/python3/src/Lib/xml/sax/_exceptions.py4
-rw-r--r--contrib/tools/python3/src/Lib/xml/sax/expatreader.py6
-rw-r--r--contrib/tools/python3/src/Lib/xml/sax/xmlreader.py4
6 files changed, 10 insertions, 53 deletions
diff --git a/contrib/tools/python3/src/Lib/xml/dom/expatbuilder.py b/contrib/tools/python3/src/Lib/xml/dom/expatbuilder.py
index 199c22d0af3..7dd667bf3fb 100644
--- a/contrib/tools/python3/src/Lib/xml/dom/expatbuilder.py
+++ b/contrib/tools/python3/src/Lib/xml/dom/expatbuilder.py
@@ -200,10 +200,7 @@ class ExpatBuilder:
parser = self.getParser()
first_buffer = True
try:
- while 1:
- buffer = file.read(16*1024)
- if not buffer:
- break
+ while buffer := file.read(16*1024):
parser.Parse(buffer, False)
if first_buffer and self.document.documentElement:
self._setup_subset(buffer)
diff --git a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
index fce0c2963a2..bb7362d1634 100644
--- a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
+++ b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
@@ -189,19 +189,6 @@ class Element:
"""
return self.__class__(tag, attrib)
- def copy(self):
- """Return copy of current element.
-
- This creates a shallow copy. Subelements will be shared with the
- original tree.
-
- """
- warnings.warn(
- "elem.copy() is deprecated. Use copy.copy(elem) instead.",
- DeprecationWarning
- )
- return self.__copy__()
-
def __copy__(self):
elem = self.makeelement(self.tag, self.attrib)
elem.text = self.text
@@ -214,9 +201,10 @@ class Element:
def __bool__(self):
warnings.warn(
- "The behavior of this method will change in future versions. "
+ "Testing an element's truth value will raise an exception in "
+ "future versions. "
"Use specific 'len(elem)' or 'elem is not None' test instead.",
- FutureWarning, stacklevel=2
+ DeprecationWarning, stacklevel=2
)
return len(self._children) != 0 # emulate old behaviour, for now
@@ -580,10 +568,7 @@ class ElementTree:
# it with chunks.
self._root = parser._parse_whole(source)
return self._root
- while True:
- data = source.read(65536)
- if not data:
- break
+ while data := source.read(65536):
parser.feed(data)
self._root = parser.close()
return self._root
diff --git a/contrib/tools/python3/src/Lib/xml/sax/__init__.py b/contrib/tools/python3/src/Lib/xml/sax/__init__.py
index 17b75879eba..b657310207c 100644
--- a/contrib/tools/python3/src/Lib/xml/sax/__init__.py
+++ b/contrib/tools/python3/src/Lib/xml/sax/__init__.py
@@ -60,11 +60,7 @@ if _false:
import os, sys
if not sys.flags.ignore_environment and "PY_SAX_PARSER" in os.environ:
default_parser_list = os.environ["PY_SAX_PARSER"].split(",")
-del os
-
-_key = "python.xml.sax.parser"
-if sys.platform[:4] == "java" and sys.registry.containsKey(_key):
- default_parser_list = sys.registry.getProperty(_key).split(",")
+del os, sys
def make_parser(parser_list=()):
@@ -93,15 +89,6 @@ def make_parser(parser_list=()):
# --- Internal utility methods used by make_parser
-if sys.platform[ : 4] == "java":
- def _create_parser(parser_name):
- from org.python.core import imp
- drv_module = imp.importName(parser_name, 0, globals())
- return drv_module.create_parser()
-
-else:
- def _create_parser(parser_name):
- drv_module = __import__(parser_name,{},{},['create_parser'])
- return drv_module.create_parser()
-
-del sys
+def _create_parser(parser_name):
+ drv_module = __import__(parser_name,{},{},['create_parser'])
+ return drv_module.create_parser()
diff --git a/contrib/tools/python3/src/Lib/xml/sax/_exceptions.py b/contrib/tools/python3/src/Lib/xml/sax/_exceptions.py
index a9b2ba35c6a..f292dc3a8e5 100644
--- a/contrib/tools/python3/src/Lib/xml/sax/_exceptions.py
+++ b/contrib/tools/python3/src/Lib/xml/sax/_exceptions.py
@@ -1,8 +1,4 @@
"""Different kinds of SAX Exceptions"""
-import sys
-if sys.platform[:4] == "java":
- from java.lang import Exception
-del sys
# ===== SAXEXCEPTION =====
diff --git a/contrib/tools/python3/src/Lib/xml/sax/expatreader.py b/contrib/tools/python3/src/Lib/xml/sax/expatreader.py
index e334ac9fea0..b9ad52692db 100644
--- a/contrib/tools/python3/src/Lib/xml/sax/expatreader.py
+++ b/contrib/tools/python3/src/Lib/xml/sax/expatreader.py
@@ -12,12 +12,6 @@ from xml.sax.handler import feature_external_ges, feature_external_pes
from xml.sax.handler import feature_string_interning
from xml.sax.handler import property_xml_string, property_interning_dict
-# xml.parsers.expat does not raise ImportError in Jython
-import sys
-if sys.platform[:4] == "java":
- raise SAXReaderNotAvailable("expat not available in Java", None)
-del sys
-
try:
from xml.parsers import expat
except ImportError:
diff --git a/contrib/tools/python3/src/Lib/xml/sax/xmlreader.py b/contrib/tools/python3/src/Lib/xml/sax/xmlreader.py
index 716f2284041..e906121d23b 100644
--- a/contrib/tools/python3/src/Lib/xml/sax/xmlreader.py
+++ b/contrib/tools/python3/src/Lib/xml/sax/xmlreader.py
@@ -120,10 +120,8 @@ class IncrementalParser(XMLReader):
file = source.getCharacterStream()
if file is None:
file = source.getByteStream()
- buffer = file.read(self._bufsize)
- while buffer:
+ while buffer := file.read(self._bufsize):
self.feed(buffer)
- buffer = file.read(self._bufsize)
self.close()
def feed(self, data):