Skip to content

Commit 7be79d0

Browse files
authored
Merge pull request #1013 from moreati/issue1011-blacklist-msg
mitogen: Clarify blacklisted import error message
2 parents e0de4d3 + ccaaf4b commit 7be79d0

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
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 '

tests/responder_test.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,3 @@ def test_stats(self):
198198
self.assertEqual(2+os_fork, self.router.responder.good_load_module_count)
199199
self.assertLess(10000, self.router.responder.good_load_module_size)
200200
self.assertGreater(40000, self.router.responder.good_load_module_size)
201-
202-
203-
class BlacklistTest(testlib.TestCase):
204-
@unittest.skip('implement me')
205-
def test_whitelist_no_blacklist(self):
206-
assert 0
207-
208-
@unittest.skip('implement me')
209-
def test_whitelist_has_blacklist(self):
210-
assert 0
211-
212-
@unittest.skip('implement me')
213-
def test_blacklist_no_whitelist(self):
214-
assert 0
215-
216-
@unittest.skip('implement me')
217-
def test_blacklist_has_whitelist(self):
218-
assert 0

0 commit comments

Comments
 (0)