Lxml

Latest version: v5.3.0

Safety actively analyzes 681866 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 26 of 28

1.1

================

Features added
--------------

* Comments and processing instructions return '<!-- comment -->' and
'<?pi-target content?>' for repr()

* Parsers are now the preferred (and default) place where element class lookup
schemes should be registered. Namespace lookup is no longer supported by
default.

* Support for Python 2.5 beta

* Unlock the GIL for deep copying documents and for XPath()

* New ``compact`` keyword argument for parsing read-only documents

* Support for parser options in iterparse()

* The ``namespace`` axis is supported in XPath and returns (prefix, URI)
tuples

* The XPath expression "/" now returns an empty list instead of raising an
exception

* XML-Object API on top of lxml (lxml.objectify)

* Customizable Element class lookup:

* different pre-implemented lookup mechanisms

* support for externally provided lookup functions

* Support for processing instructions (ET-like, not compatible)

* Public C-level API for independent extension modules

* Module level ``iterwalk()`` function as 'iterparse' for trees

* Module level ``iterparse()`` function similar to ElementTree (see
documentation for differences)

* Element.nsmap property returns a mapping of all namespace prefixes known at
the Element to their namespace URI

* Reentrant threading support in RelaxNG, XMLSchema and XSLT

* Threading support in parsers and serializers:

* All in-memory operations (tostring, parse(StringIO), etc.) free the GIL

* File operations (on file names) free the GIL

* Reading from file-like objects frees the GIL and reacquires it for reading

* Serialisation to file-like objects is single-threaded (high lock overhead)

* Element iteration over XPath axes:

* Element.iterdescendants() iterates over the descendants of an element

* Element.iterancestors() iterates over the ancestors of an element (from
parent to parent)

* Element.itersiblings() iterates over either the following or preceding
siblings of an element

* Element.iterchildren() iterates over the children of an element in either
direction

* All iterators support the ``tag`` keyword argument to restrict the
generated elements

* Element.getnext() and Element.getprevious() return the direct siblings of an
element

Bugs fixed
----------

* filenames with local 8-bit encoding were not supported

* 1.1beta did not compile under Python 2.3

* ignore unknown 'pyval' attribute values in objectify

* objectify.ObjectifiedElement.addattr() failed to accept Elements and Lists

* objectify.ObjectPath.setattr() failed to accept Elements and Lists

* XPathSyntaxError now inherits from XPathError

* Threading race conditions in RelaxNG and XMLSchema

* Crash when mixing elements from XSLT results into other trees, concurrent
XSLT is only allowed when the stylesheet was parsed in the main thread

* The EXSLT ``regexp:match`` function now works as defined (except for some
differences in the regular expression syntax)

* Setting element.text to '' returned None on request, not the empty string

* ``iterparse()`` could crash on long XML files

* Creating documents no longer copies the parser for later URL resolving. For
performance reasons, only a reference is kept. Resolver updates on the
parser will now be reflected by documents that were parsed before the
change. Although this should rarely become visible, it is a behavioral
change from 1.0.

1.0.4

==================

Features added
--------------

* List-like ``Element.extend()`` method

Bugs fixed
----------

* Crash in tail handling in ``Element.replace()``

1.0.3

==================

Features added
--------------

* Element.replace(old, new) method to replace a subelement by another one

Bugs fixed
----------

* Crash when mixing elements from XSLT results into other trees

* Copying/deepcopying did not work for ElementTree objects

* Setting an attribute to a non-string value did not raise an exception

* Element.remove() deleted the tail text from the removed Element

1.0.2

==================

Features added
--------------

* Support for setting a custom default Element class as opposed to namespace
specific classes (which still override the default class)

Bugs fixed
----------

* Rare exceptions in Python list functions were not handled

* Parsing accepted unicode strings with XML encoding declaration in certain
cases

* Parsing 8-bit encoded strings from StringIO objects raised an exception

* Module function ``initThread()`` was removed - useless (and never worked)

* XSLT and parser exception messages include the error line number

1.0.1

==================

Features added
--------------

* Repeated calls to Element.attrib now efficiently return the same instance

Bugs fixed
----------

* Document deallocation could crash in certain garbage collection scenarios

* Extension function calls in XSLT variable declarations could break the
stylesheet and crash on repeated calls

* Deep copying Elements could lose namespaces declared in parents

* Deep copying Elements did not copy tail

* Parsing file(-like) objects failed to load external entities

* Parsing 8-bit strings from file(-like) objects raised an exception

* xsl:include failed when the stylesheet was parsed from a file-like object

* lxml.sax.ElementTreeProducer did not call startDocument() / endDocument()

* MSVC compiler complained about long strings (supports only 2048 bytes)

1.0

================

Features added
--------------

* Element.getiterator() and the findall() methods support finding arbitrary
elements from a namespace (pattern ``{namespace}*``)

* Another speedup in tree iteration code

* General speedup of Python Element object creation and deallocation

* Writing C14N no longer serializes in memory (reduced memory footprint)

* PyErrorLog for error logging through the Python ``logging`` module

* ``Element.getroottree()`` returns an ElementTree for the root node of the
document that contains the element.

* ElementTree.getpath(element) returns a simple, absolute XPath expression to
find the element in the tree structure

* Error logs have a ``last_error`` attribute for convenience

* Comment texts can be changed through the API

* Formatted output via ``pretty_print`` keyword in serialization functions

* XSLT can block access to file system and network via ``XSLTAccessControl``

* ElementTree.write() no longer serializes in memory (reduced memory
footprint)

* Speedup of Element.findall(tag) and Element.getiterator(tag)

* Support for writing the XML representation of Elements and ElementTrees to
Python unicode strings via ``etree.tounicode()``

* Support for writing XSLT results to Python unicode strings via ``unicode()``

* Parsing a unicode string no longer copies the string (reduced memory
footprint)

* Parsing file-like objects reads chunks rather than the whole file (reduced
memory footprint)

* Parsing StringIO objects from the start avoids copying the string (reduced
memory footprint)

* Read-only 'docinfo' attribute in ElementTree class holds DOCTYPE
information, original encoding and XML version as seen by the parser

* etree module can be compiled without libxslt by commenting out the line
``include "xslt.pxi"`` near the end of the etree.pyx source file

* Better error messages in parser exceptions

* Error reporting also works in XSLT

* Support for custom document loaders (URI resolvers) in parsers and XSLT,
resolvers are registered at parser level

* Implementation of exslt:regexp for XSLT based on the Python 're' module,
enabled by default, can be switched off with 'regexp=False' keyword argument

* Support for exslt extensions (libexslt) and libxslt extra functions
(node-set, document, write, output)

* Substantial speedup in XPath.evaluate()

* HTMLParser for parsing (broken) HTML

* XMLDTDID function parses XML into tuple (root node, ID dict) based on xml:id
implementation of libxml2 (as opposed to ET compatible XMLID)

Bugs fixed
----------

* Memory leak in Element.__setitem__

* Memory leak in Element.attrib.items() and Element.attrib.values()

* Memory leak in XPath extension functions

* Memory leak in unicode related setup code

* Element now raises ValueError on empty tag names

* Namespace fixing after moving elements between documents could fail if the
source document was freed too early

* Setting namespace-less tag names on namespaced elements ('{ns}t' -> 't')
didn't reset the namespace

* Unknown constants from newer libxml2 versions could raise exceptions in the
error handlers

* lxml.etree compiles much faster

* On libxml2 <= 2.6.22, parsing strings with encoding declaration could fail
in certain cases

* Document reference in ElementTree objects was not updated when the root
element was moved to a different document

* Running absolute XPath expressions on an Element now evaluates against the
root tree

* Evaluating absolute XPath expressions (``/*``) on an ElementTree could fail

* Crashes when calling XSLT, RelaxNG, etc. with uninitialized ElementTree
objects

* Removed public function ``initThreadLogging()``, replaced by more general
``initThread()`` which fixes a number of setup problems in threads

* Memory leak when using iconv encoders in tostring/write

* Deep copying Elements and ElementTrees maintains the document information

* Serialization functions raise LookupError for unknown encodings

* Memory deallocation crash resulting from deep copying elements

* Some ElementTree methods could crash if the root node was not initialized
(neither file nor element passed to the constructor)

* Element/SubElement failed to set attribute namespaces from passed ``attrib``
dictionary

* ``tostring()`` adds an XML declaration for non-ASCII encodings

* ``tostring()`` failed to serialize encodings that contain 0-bytes

* ElementTree.xpath() and XPathDocumentEvaluator were not using the
ElementTree root node as reference point

* Calling ``document('')`` in XSLT failed to return the stylesheet

Page 26 of 28

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.