Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def patchable_builtin(klass):
name = klass.__name__
target = klass.__dict__
proxy_dict = SlotsProxy.from_address(id(target))
namespace = {}
# This code casts `proxy_dict.dict` into a python object and
# `from_address()` returns `py_object`
ctypes.pythonapi.PyDict_SetItem(
ctypes.py_object(namespace),
ctypes.py_object(name),
proxy_dict.dict,
)
return namespace[name]