pull/1013/merge
Alex Willmer 2 months ago committed by GitHub
commit 90df70dda5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -533,6 +533,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.
@ -1528,9 +1529,9 @@ 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.'
"%r is blacklisted (on the Mitogen importer blacklist (%r) or not "
"on the whitelist (%r)). This context won't try to request it from "
"the master, it would be refused."
)
pkg_resources_msg = (
'pkg_resources is prohibited from importing __main__, as it causes '
@ -1545,7 +1546,10 @@ class Importer(object):
def _refuse_imports(self, fullname):
if is_blacklisted_import(self, fullname):
raise ModuleNotFoundError(self.blacklisted_msg % (fullname,))
raise ModuleNotFoundError(
self.blacklisted_msg
% (fullname, self.blacklist, self.whitelist),
)
f = sys._getframe(2)
requestee = f.f_globals['__name__']

@ -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

Loading…
Cancel
Save