in build/fbcode_builder/CMake/fb_py_test_main.py [0:0]
def find_module(self, fullname, path=None):
_, _, basename = fullname.rpartition(".")
try:
fd, pypath, (_, _, kind) = imp.find_module(basename, path)
except Exception:
# Finding without hooks using the imp module failed. One reason
# could be that there is a zip file on sys.path. The imp module
# does not support loading from there. Leave finding this module to
# the others finders in sys.meta_path.
return None
if hasattr(fd, "close"):
fd.close()
if kind != imp.PY_SOURCE:
return None
if self.matcher.include(pypath):
return None
"""
This is defined to match CPython's PyVarObject struct
"""
class PyVarObject(ctypes.Structure):
_fields_ = [
("ob_refcnt", ctypes.c_long),
("ob_type", ctypes.c_void_p),
("ob_size", ctypes.c_ulong),
]
class DebugWipeLoader(SourceFileLoader):
"""
PEP302 loader that zeros out debug information before execution
"""
def get_code(self, fullname):
code = super(DebugWipeLoader, self).get_code(fullname)
if code:
# Ideally we'd do
# code.co_lnotab = b''
# But code objects are READONLY. Not to worry though; we'll
# directly modify CPython's object
code_impl = PyVarObject.from_address(id(code.co_lnotab))
code_impl.ob_size = 0
return code
return DebugWipeLoader(fullname, pypath)