Skip to content

Commit ccaaf4b

Browse files
committed
mitogen: Clarify blacklisted ModuleNotFoundError message
Previous phrasing was misleading - it implied a given module was explicitly on the blacklist, even if it was due to a restrictive whitelist and the blacklist was empty. Arguably the blacklist/whitelist semantics are themselves misleading. A redesign is tempting.
1 parent 073fc48 commit ccaaf4b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ In progress (unreleased)
2525
* :gh:issue:`1385` :mod:`ansible_mitogen`: Remove a use of
2626
``ansible.module_utils.six``
2727
* :gh:issue:`1354` docs: Document Ansible 13 (ansible-core 2.20) support
28+
* :gh:issue:`1354` :mod:`mitogen`: Clarify error message when a module
29+
request would be refused by allow or deny listing
2830

2931

3032
v0.3.35 (2025-12-01)

mitogen/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ def is_blacklisted_import(importer, fullname):
541541
any packages have been whitelisted and `fullname` is not part of one.
542542
543543
NB:
544+
- The default whitelist is `['']` which matches any module name.
544545
- If a package is on both lists, then it is treated as blacklisted.
545546
- If any package is whitelisted, then all non-whitelisted packages are
546547
treated as blacklisted.
@@ -1536,9 +1537,8 @@ def find_spec(self, fullname, path, target=None):
15361537
return importlib.machinery.ModuleSpec(fullname, loader=self)
15371538

15381539
blacklisted_msg = (
1539-
'%r is present in the Mitogen importer blacklist, therefore this '
1540-
'context will not attempt to request it from the master, as the '
1541-
'request will always be refused.'
1540+
'A %r request would be refused by the Mitogen master. The module is '
1541+
'on the deny list (blacklist) or not on the allow list (whitelist).'
15421542
)
15431543
pkg_resources_msg = (
15441544
'pkg_resources is prohibited from importing __main__, as it causes '

0 commit comments

Comments
 (0)