Skip to content

Commit 522573e

Browse files
committed
Recover behaviour for derived types
1 parent 6fa03af commit 522573e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/runtime/TypeManager.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ public static int tp_setattro_dlr_proxy(BorrowedReference ob, BorrowedReference
172172
&& memberName is not null
173173
&& !HasClrMember(instance, memberName);
174174

175+
// For Python-derived types (IPythonDerivedType), the Python descriptor protocol
176+
// (e.g. @property setters) takes priority over DLR member storage. Try
177+
// PyObject_GenericSetAttr first; only fall back to DLR on AttributeError.
178+
if (canUseDynamic && instance is IPythonDerivedType)
179+
{
180+
int pyResult = Runtime.PyObject_GenericSetAttr(ob, key, val);
181+
if (pyResult == 0) return 0;
182+
if (Runtime.PyErr_ExceptionMatches(Exceptions.AttributeError) == 0) return pyResult;
183+
Runtime.PyErr_Clear();
184+
// fall through to DLR path below
185+
}
186+
175187
if (canUseDynamic)
176188
{
177189
if (val == null)

0 commit comments

Comments
 (0)