MCPcopy Index your code
hub / github.com/RustPython/RustPython / add_foreign_method

Method add_foreign_method

Lib/test/test_code.py:279–284  ·  view source on GitHub ↗
(cls, name, f)

Source from the content-addressed store, hash-verified

277 return c.replace(co_freevars=c.co_freevars + ('__class__',), co_code=bytes([COPY_FREE_VARS, 1])+c.co_code)
278
279 def add_foreign_method(cls, name, f):
280 code = new_code(f.__code__)
281 assert not f.__closure__
282 closure = create_closure(cls)
283 defaults = f.__defaults__
284 setattr(cls, name, FunctionType(code, globals(), name, defaults, closure))
285
286 class List(list):
287 pass

Callers

nothing calls this directly

Calls 3

FunctionTypeFunction · 0.90
setattrFunction · 0.85
globalsFunction · 0.85

Tested by

no test coverage detected