lxml 5.3.2__cp313-cp313-win32.whl → 6.0.0__cp313-cp313-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lxml/__init__.py +1 -1
- lxml/_elementpath.cp313-win32.pyd +0 -0
- lxml/_elementpath.py +3 -1
- lxml/apihelpers.pxi +25 -17
- lxml/builder.cp313-win32.pyd +0 -0
- lxml/builder.py +11 -0
- lxml/debug.pxi +0 -54
- lxml/etree.cp313-win32.pyd +0 -0
- lxml/etree.h +244 -248
- lxml/etree.pyx +154 -33
- lxml/etree_api.h +204 -195
- lxml/extensions.pxi +3 -6
- lxml/html/__init__.py +7 -3
- lxml/html/_difflib.cp313-win32.pyd +0 -0
- lxml/html/_difflib.py +2106 -0
- lxml/html/builder.py +40 -0
- lxml/html/defs.py +3 -3
- lxml/html/diff.cp313-win32.pyd +0 -0
- lxml/html/diff.py +406 -312
- lxml/includes/etree_defs.h +6 -6
- lxml/includes/lxml-version.h +1 -1
- lxml/includes/tree.pxd +10 -12
- lxml/includes/xmlparser.pxd +46 -8
- lxml/lxml.etree.h +24 -28
- lxml/lxml.etree_api.h +59 -50
- lxml/objectify.cp313-win32.pyd +0 -0
- lxml/objectify.pyx +11 -7
- lxml/parser.pxi +106 -47
- lxml/sax.cp313-win32.pyd +0 -0
- lxml/sax.py +11 -0
- lxml/saxparser.pxi +14 -14
- lxml/schematron.pxi +8 -3
- lxml/serializer.pxi +71 -3
- lxml/xslt.pxi +10 -3
- lxml-6.0.0.dist-info/METADATA +163 -0
- {lxml-5.3.2.dist-info → lxml-6.0.0.dist-info}/RECORD +40 -38
- {lxml-5.3.2.dist-info → lxml-6.0.0.dist-info}/WHEEL +1 -1
- {lxml-5.3.2.dist-info → lxml-6.0.0.dist-info}/licenses/LICENSE.txt +3 -1
- lxml-5.3.2.dist-info/METADATA +0 -100
- {lxml-5.3.2.dist-info → lxml-6.0.0.dist-info}/licenses/LICENSES.txt +0 -0
- {lxml-5.3.2.dist-info → lxml-6.0.0.dist-info}/top_level.txt +0 -0
lxml/__init__.py
CHANGED
Binary file
|
lxml/_elementpath.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# cython: language_level=
|
1
|
+
# cython: language_level=3
|
2
2
|
|
3
3
|
#
|
4
4
|
# ElementTree
|
@@ -85,6 +85,8 @@ def xpath_tokenizer(pattern, namespaces=None, with_prefixes=True):
|
|
85
85
|
yield ttype, "{%s}%s" % (namespaces[prefix], uri)
|
86
86
|
except KeyError:
|
87
87
|
raise SyntaxError("prefix %r not found in prefix map" % prefix)
|
88
|
+
elif tag.isdecimal():
|
89
|
+
yield token # index
|
88
90
|
elif default_namespace and not parsing_attribute:
|
89
91
|
yield ttype, "{%s}%s" % (default_namespace, tag)
|
90
92
|
else:
|
lxml/apihelpers.pxi
CHANGED
@@ -439,7 +439,7 @@ cdef int _removeUnusedNamespaceDeclarations(xmlNode* c_element, set prefixes_to_
|
|
439
439
|
c_nsdef = c_nsdef.next
|
440
440
|
c_nsdef.next = c_nsdef.next.next
|
441
441
|
tree.xmlFreeNs(c_ns_list[i].ns)
|
442
|
-
|
442
|
+
|
443
443
|
if c_ns_list is not NULL:
|
444
444
|
python.lxml_free(c_ns_list)
|
445
445
|
return 0
|
@@ -685,7 +685,7 @@ cdef unicode _collectText(xmlNode* c_node):
|
|
685
685
|
"""Collect all text nodes and return them as a unicode string.
|
686
686
|
|
687
687
|
Start collecting at c_node.
|
688
|
-
|
688
|
+
|
689
689
|
If there was no text to collect, return None
|
690
690
|
"""
|
691
691
|
cdef Py_ssize_t scount
|
@@ -845,7 +845,7 @@ cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index) noexcept:
|
|
845
845
|
return _findChildBackwards(c_node, -index - 1)
|
846
846
|
else:
|
847
847
|
return _findChildForwards(c_node, index)
|
848
|
-
|
848
|
+
|
849
849
|
cdef inline xmlNode* _findChildForwards(xmlNode* c_node, Py_ssize_t index) noexcept:
|
850
850
|
"""Return child element of c_node with index, or return NULL if not found.
|
851
851
|
"""
|
@@ -876,7 +876,7 @@ cdef inline xmlNode* _findChildBackwards(xmlNode* c_node, Py_ssize_t index) noex
|
|
876
876
|
c += 1
|
877
877
|
c_child = c_child.prev
|
878
878
|
return NULL
|
879
|
-
|
879
|
+
|
880
880
|
cdef inline xmlNode* _textNodeOrSkip(xmlNode* c_node) noexcept nogil:
|
881
881
|
"""Return the node if it's a text node. Skip over ignorable nodes in a
|
882
882
|
series of text nodes. Return NULL if a non-ignorable node is found.
|
@@ -1031,23 +1031,31 @@ cdef Py_ssize_t _mapTagsToQnameMatchArray(xmlDoc* c_doc, list ns_tags,
|
|
1031
1031
|
Note that each qname struct in the array owns its href byte string object
|
1032
1032
|
if it is not NULL.
|
1033
1033
|
"""
|
1034
|
-
cdef Py_ssize_t count = 0, i
|
1034
|
+
cdef Py_ssize_t count = 0, i, c_tag_len
|
1035
1035
|
cdef bytes ns, tag
|
1036
|
+
cdef const_xmlChar* c_tag
|
1037
|
+
|
1036
1038
|
for ns, tag in ns_tags:
|
1037
1039
|
if tag is None:
|
1038
|
-
c_tag = <const_xmlChar*>NULL
|
1039
|
-
elif force_into_dict:
|
1040
|
-
c_tag = tree.xmlDictLookup(c_doc.dict, _xcstr(tag), len(tag))
|
1041
|
-
if c_tag is NULL:
|
1042
|
-
# clean up before raising the error
|
1043
|
-
for i in xrange(count):
|
1044
|
-
cpython.ref.Py_XDECREF(c_ns_tags[i].href)
|
1045
|
-
raise MemoryError()
|
1040
|
+
c_tag = <const_xmlChar*> NULL
|
1046
1041
|
else:
|
1047
|
-
|
1048
|
-
if
|
1049
|
-
# not in the dict => not in the document
|
1042
|
+
c_tag_len = len(tag)
|
1043
|
+
if c_tag_len > limits.INT_MAX:
|
1044
|
+
# too long, not in the dict => not in the document
|
1050
1045
|
continue
|
1046
|
+
elif force_into_dict:
|
1047
|
+
c_tag = tree.xmlDictLookup(c_doc.dict, _xcstr(tag), <int> c_tag_len)
|
1048
|
+
if c_tag is NULL:
|
1049
|
+
# clean up before raising the error
|
1050
|
+
for i in xrange(count):
|
1051
|
+
cpython.ref.Py_XDECREF(c_ns_tags[i].href)
|
1052
|
+
raise MemoryError()
|
1053
|
+
else:
|
1054
|
+
c_tag = tree.xmlDictExists(c_doc.dict, _xcstr(tag), <int> c_tag_len)
|
1055
|
+
if c_tag is NULL:
|
1056
|
+
# not in the dict => not in the document
|
1057
|
+
continue
|
1058
|
+
|
1051
1059
|
c_ns_tags[count].c_name = c_tag
|
1052
1060
|
if ns is None:
|
1053
1061
|
c_ns_tags[count].href = NULL
|
@@ -1095,7 +1103,7 @@ cdef int _removeSiblings(xmlNode* c_element, tree.xmlElementType node_type, bint
|
|
1095
1103
|
|
1096
1104
|
cdef void _moveTail(xmlNode* c_tail, xmlNode* c_target) noexcept:
|
1097
1105
|
cdef xmlNode* c_next
|
1098
|
-
# tail support: look for any text nodes trailing this node and
|
1106
|
+
# tail support: look for any text nodes trailing this node and
|
1099
1107
|
# move them too
|
1100
1108
|
c_tail = _textNodeOrSkip(c_tail)
|
1101
1109
|
while c_tail is not NULL:
|
lxml/builder.cp313-win32.pyd
CHANGED
Binary file
|
lxml/builder.py
CHANGED
@@ -45,6 +45,13 @@ _QName = ET.QName
|
|
45
45
|
|
46
46
|
from functools import partial
|
47
47
|
|
48
|
+
try:
|
49
|
+
from types import GenericAlias as _GenericAlias
|
50
|
+
except ImportError:
|
51
|
+
# Python 3.8 - we only need this as return value from "__class_getitem__"
|
52
|
+
def _GenericAlias(cls, item):
|
53
|
+
return f"{cls.__name__}[{item.__name__}]"
|
54
|
+
|
48
55
|
try:
|
49
56
|
basestring
|
50
57
|
except NameError:
|
@@ -227,6 +234,10 @@ class ElementMaker:
|
|
227
234
|
def __getattr__(self, tag):
|
228
235
|
return partial(self, tag)
|
229
236
|
|
237
|
+
# Allow subscripting ElementMaker in type annotions (PEP 560)
|
238
|
+
def __class_getitem__(cls, item):
|
239
|
+
return _GenericAlias(cls, item)
|
240
|
+
|
230
241
|
|
231
242
|
# create factory object
|
232
243
|
E = ElementMaker()
|
lxml/debug.pxi
CHANGED
@@ -32,59 +32,5 @@ cdef class _MemDebug:
|
|
32
32
|
raise MemoryError()
|
33
33
|
return tree.xmlDictSize(c_dict)
|
34
34
|
|
35
|
-
def dump(self, output_file=None, byte_count=None):
|
36
|
-
"""dump(self, output_file=None, byte_count=None)
|
37
|
-
|
38
|
-
Dumps the current memory blocks allocated by libxml2 to a file.
|
39
|
-
|
40
|
-
The optional parameter 'output_file' specifies the file path. It defaults
|
41
|
-
to the file ".memorylist" in the current directory.
|
42
|
-
|
43
|
-
The optional parameter 'byte_count' limits the number of bytes in the dump.
|
44
|
-
Note that this parameter is ignored when lxml is compiled against a libxml2
|
45
|
-
version before 2.7.0.
|
46
|
-
"""
|
47
|
-
cdef Py_ssize_t c_count
|
48
|
-
if output_file is None:
|
49
|
-
output_file = b'.memorylist'
|
50
|
-
elif isinstance(output_file, unicode):
|
51
|
-
output_file.encode(sys.getfilesystemencoding())
|
52
|
-
|
53
|
-
f = stdio.fopen(output_file, "w")
|
54
|
-
if f is NULL:
|
55
|
-
raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
|
56
|
-
try:
|
57
|
-
if byte_count is None:
|
58
|
-
tree.xmlMemDisplay(f)
|
59
|
-
else:
|
60
|
-
c_count = byte_count
|
61
|
-
tree.xmlMemDisplayLast(f, c_count)
|
62
|
-
finally:
|
63
|
-
stdio.fclose(f)
|
64
|
-
|
65
|
-
def show(self, output_file=None, block_count=None):
|
66
|
-
"""show(self, output_file=None, block_count=None)
|
67
|
-
|
68
|
-
Dumps the current memory blocks allocated by libxml2 to a file.
|
69
|
-
The output file format is suitable for line diffing.
|
70
|
-
|
71
|
-
The optional parameter 'output_file' specifies the file path. It defaults
|
72
|
-
to the file ".memorydump" in the current directory.
|
73
|
-
|
74
|
-
The optional parameter 'block_count' limits the number of blocks
|
75
|
-
in the dump.
|
76
|
-
"""
|
77
|
-
if output_file is None:
|
78
|
-
output_file = b'.memorydump'
|
79
|
-
elif isinstance(output_file, unicode):
|
80
|
-
output_file.encode(sys.getfilesystemencoding())
|
81
|
-
|
82
|
-
f = stdio.fopen(output_file, "w")
|
83
|
-
if f is NULL:
|
84
|
-
raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
|
85
|
-
try:
|
86
|
-
tree.xmlMemShow(f, block_count if block_count is not None else tree.xmlMemBlocks())
|
87
|
-
finally:
|
88
|
-
stdio.fclose(f)
|
89
35
|
|
90
36
|
memory_debugger = _MemDebug()
|
lxml/etree.cp313-win32.pyd
CHANGED
Binary file
|