core: move importer inline data out to class vars.

issue510
David Wilson 6 years ago
parent ffdd6d2881
commit a156d7aab3

@ -918,9 +918,9 @@ class Importer(object):
:param context: Context to communicate via. :param context: Context to communicate via.
""" """
def __init__(self, router, context, core_src, whitelist=(), blacklist=()): # The Mitogen package is handled specially, since the child context must
self._context = context # construct it manually during startup.
self._present = {'mitogen': [ MITOGEN_PKG_CONTENT = [
'compat', 'compat',
'debug', 'debug',
'doas', 'doas',
@ -941,21 +941,28 @@ class Importer(object):
'su', 'su',
'sudo', 'sudo',
'utils', 'utils',
]} ]
self._lock = threading.Lock()
self.whitelist = list(whitelist) or [''] ALWAYS_BLACKLIST = [
self.blacklist = list(blacklist) + [
# 2.x generates needless imports for 'builtins', while 3.x does the # 2.x generates needless imports for 'builtins', while 3.x does the
# same for '__builtin__'. The correct one is built-in, the other # same for '__builtin__'. The correct one is built-in, the other always
# always a negative round-trip. # a negative round-trip.
'builtins', 'builtins',
'__builtin__', '__builtin__',
# org.python.core imported by copy, pickle, xml.sax; breaks Jython, # org.python.core imported by copy, pickle, xml.sax; breaks Jython, but
# but very unlikely to trigger a bug report. # very unlikely to trigger a bug report.
'org', 'org',
] ]
if PY3: if PY3:
self.blacklist += ['cStringIO'] ALWAYS_BLACKLIST += ['cStringIO']
def __init__(self, router, context, core_src, whitelist=(), blacklist=()):
self._context = context
self._present = {'mitogen': self.MITOGEN_PKG_CONTENT}
self._lock = threading.Lock()
self.whitelist = list(whitelist) or ['']
self.blacklist = list(blacklist) + self.ALWAYS_BLACKLIST
# Presence of an entry in this map indicates in-flight GET_MODULE. # Presence of an entry in this map indicates in-flight GET_MODULE.
self._callbacks = {} self._callbacks = {}

Loading…
Cancel
Save