MCPcopy Create free account
hub / github.com/pybind/pybind11 / _proxy_dereference

Function _proxy_dereference

tests/test_class_sh_property.py:127–135  ·  view source on GitHub ↗
(proxy, xxxattr, *args, **kwargs)

Source from the content-addressed store, hash-verified

125
126
127def _proxy_dereference(proxy, xxxattr, *args, **kwargs):
128 obj = object.__getattribute__(proxy, "__obj")
129 field_name = object.__getattribute__(proxy, "__field_name")
130 field = getattr(obj, field_name) # Disowns the C++ unique_ptr member.
131 assert field is not None
132 try:
133 return xxxattr(field, *args, **kwargs)
134 finally:
135 setattr(obj, field_name, field) # Disowns the temporary Python object (field).
136
137
138@pytest.mark.parametrize("m_attr", ["m_uqmp", "m_uqcp"])

Callers 3

__getattr__Method · 0.85
__setattr__Method · 0.85
__delattr__Method · 0.85

Calls 2

getattrFunction · 0.85
setattrFunction · 0.85

Tested by

no test coverage detected