MCPcopy Index your code
hub / github.com/python/cpython / load_defs

Function load_defs

Lib/test/test_crossinterp.py:316–345  ·  view source on GitHub ↗

Return a new copy of the test._crossinterp_definitions module. The module's __name__ matches the "module" arg, which is either a str or a module. If the "module" arg is a module then the just-loaded defs are also copied into that module. Note that the new module is not added t

(module=None)

Source from the content-addressed store, hash-verified

314
315
316def load_defs(module=None):
317 """Return a new copy of the test._crossinterp_definitions module.
318
319 The module's __name__ matches the "module" arg, which is either
320 a str or a module.
321
322 If the "module" arg is a module then the just-loaded defs are also
323 copied into that module.
324
325 Note that the new module is not added to sys.modules.
326 """
327 if module is None:
328 modname = DEFS.__name__
329 elif isinstance(module, str):
330 modname = module
331 module = None
332 else:
333 modname = module.__name__
334 # Create the new module and populate it.
335 defs = import_helper.create_module(modname)
336 defs.__file__ = DEFS.__file__
337 exec(DEFS_TEXT, defs.__dict__)
338 # Copy the defs into the module arg, if any.
339 if module is not None:
340 for name, value in defs.__dict__.items():
341 if name.startswith('_'):
342 continue
343 assert not hasattr(module, name), (name, getattr(module, name))
344 setattr(module, name, value)
345 return defs
346
347
348@contextlib.contextmanager

Calls 3

create_moduleMethod · 0.45
itemsMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…