From 073fc48afc0cc344026959aa84172a05e8ff29d8 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sun, 30 Jul 2023 11:24:12 +0100 Subject: [PATCH 1/2] tests: Remove BlacklistTest stubs (covered by ImporterBlacklistTest) --- tests/responder_test.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/responder_test.py b/tests/responder_test.py index d1e65816..1e376078 100644 --- a/tests/responder_test.py +++ b/tests/responder_test.py @@ -198,21 +198,3 @@ class ForwardTest(testlib.RouterMixin, testlib.TestCase): self.assertEqual(2+os_fork, self.router.responder.good_load_module_count) self.assertLess(10000, self.router.responder.good_load_module_size) self.assertGreater(40000, self.router.responder.good_load_module_size) - - -class BlacklistTest(testlib.TestCase): - @unittest.skip('implement me') - def test_whitelist_no_blacklist(self): - assert 0 - - @unittest.skip('implement me') - def test_whitelist_has_blacklist(self): - assert 0 - - @unittest.skip('implement me') - def test_blacklist_no_whitelist(self): - assert 0 - - @unittest.skip('implement me') - def test_blacklist_has_whitelist(self): - assert 0 From ccaaf4b7fe2d59dc86a35cc5b5fe8d9d0b6a271f Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sun, 30 Jul 2023 11:32:59 +0100 Subject: [PATCH 2/2] 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. --- docs/changelog.rst | 2 ++ mitogen/core.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 7b02c56e..af756f37 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,8 @@ In progress (unreleased) * :gh:issue:`1385` :mod:`ansible_mitogen`: Remove a use of ``ansible.module_utils.six`` * :gh:issue:`1354` docs: Document Ansible 13 (ansible-core 2.20) support +* :gh:issue:`1354` :mod:`mitogen`: Clarify error message when a module + request would be refused by allow or deny listing v0.3.35 (2025-12-01) diff --git a/mitogen/core.py b/mitogen/core.py index 441743d4..90499fac 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -541,6 +541,7 @@ def is_blacklisted_import(importer, fullname): any packages have been whitelisted and `fullname` is not part of one. NB: + - The default whitelist is `['']` which matches any module name. - If a package is on both lists, then it is treated as blacklisted. - If any package is whitelisted, then all non-whitelisted packages are treated as blacklisted. @@ -1536,9 +1537,8 @@ class Importer(object): return importlib.machinery.ModuleSpec(fullname, loader=self) blacklisted_msg = ( - '%r is present in the Mitogen importer blacklist, therefore this ' - 'context will not attempt to request it from the master, as the ' - 'request will always be refused.' + 'A %r request would be refused by the Mitogen master. The module is ' + 'on the deny list (blacklist) or not on the allow list (whitelist).' ) pkg_resources_msg = ( 'pkg_resources is prohibited from importing __main__, as it causes '