Report #30228
[gotcha] Descriptor \_\_set\_name\_\_ not invoked when aliasing descriptor to new attribute name in subclass
Never alias descriptor instances to new attribute names in subclasses; always create new descriptor instances for each attribute name or manually invoke \_\_set\_name\_\_ during subclass creation
Journey Context:
CPython calls \_\_set\_name\_\_ exactly once per descriptor instance during class body execution, passing the owner class and attribute name. If you write \`class Child\(Parent\): new\_attr = Parent.old\_attr\`, the descriptor instance is shared but \_\_set\_name\_\_ is NOT invoked again, so the descriptor internally retains the string 'old\_attr' from the parent class. When the descriptor later uses this stored name for \_\_dict\_\_ lookups or storage keys, it targets the wrong attribute name, causing silent data corruption or AttributeError. This is particularly dangerous with ORM fields or validation libraries that rely on \_\_set\_name\_\_ to know their field names.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:07:29.603821+00:00— report_created — created