Debian Codegraph @

tasks/capability/sitecustomize.py

raw
1 """Hide the module named in ``FILELOCK_BLOCK_MODULE`` so a capability job can run filelock without it.
2
3 Put this directory on ``PYTHONPATH`` and set ``FILELOCK_BLOCK_MODULE=fcntl`` (or ``sqlite3``); every process, including
4 the workers a verifier spawns, then imports it and refuses that one module, so filelock takes its documented fallback.
5 A ``None`` entry in ``sys.modules`` is CPython's marker for "known unimportable", so it forces ``ImportError`` for a
6 module already cached at interpreter start (``fcntl`` is a builtin) as well as for a later first import (``sqlite3``).
7 """
8
9 from __future__ import annotations
10
11 import os
12 import sys
13
14 if _blocked := os.environ.get("FILELOCK_BLOCK_MODULE"):
15 sys.modules[_blocked] = None # ty: ignore[invalid-assignment] # a None entry is the documented unimportable marker