[util] add "defaultdict" filters-environment

allows accessing undefined values without raising an exception,
but preserves other errors like TypeError, AttributeError, etc
This commit is contained in:
Mike Fährmann
2024-11-12 21:21:58 +01:00
parent cfe24a9e31
commit 0b99d9e6b9
4 changed files with 118 additions and 62 deletions

View File

@@ -6855,13 +6855,22 @@ Description
filters-environment
-------------------
Type
``bool``
* ``bool``
* ``string``
Default
``true``
Description
Evaluate filter expressions raising an exception as ``false``
instead of aborting the current extractor run
by wrapping them in a `try`/`except` block.
Evaluate filter expressions in a special environment
preventing them from raising fatal exceptions.
``true`` or ``"tryexcept"``:
Wrap expressions in a `try`/`except` block;
Evaluate expressions raising an exception as ``false``
``false`` or ``"raw"``:
Do not wrap expressions in a special environment
``"defaultdict"``:
Prevent exceptions when accessing undefined variables
by using a `defaultdict <https://docs.python.org/3/library/collections.html#collections.defaultdict>`__
format-separator