Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning about the global set_element_class_lookup #341

Merged
merged 3 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
autodoc_default_options = {
'ignore-module-all': True,
'private-members': True,
'inherited-members': True,
}

autodoc_member_order = 'groupwise'
Expand Down
13 changes: 13 additions & 0 deletions src/lxml/classlookup.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,19 @@ def set_element_class_lookup(ElementClassLookup lookup = None):
u"""set_element_class_lookup(lookup = None)

Set the global default element class lookup method.
scoder marked this conversation as resolved.
Show resolved Hide resolved

.. warning::

This should only be changed by applications, not by library packages.
In most cases, parser specific lookups should be preferred,
which can be configured via
:meth:`~lxml.etree.XMLParser.set_element_class_lookup`
(and the same for HTML parsers).

Globally replacing the element class lookup by something other than a
:class:`ParserBasedElementClassLookup` will prevent parser specific lookup
schemes from working. Several tools rely on parser specific lookups,
including :mod:`lxml.html` and :mod:`lxml.objectify`.
"""
if lookup is None or lookup._lookup_function is NULL:
_setElementClassLookupFunction(NULL, None)
Expand Down