# HG changeset patch # User Paul Boddie # Date 1480074395 -3600 # Node ID 9d5c5b5edf03f46d052334e2a70fe483fc8b269a # Parent 2ddfe1bdf7b742b909c4d31733fb50c351a13100 Change __test_context to only raise a TypeError for instance contexts, preserving retrieved attributes otherwise. diff -r 2ddfe1bdf7b7 -r 9d5c5b5edf03 templates/ops.c --- a/templates/ops.c Fri Nov 25 00:53:22 2016 +0100 +++ b/templates/ops.c Fri Nov 25 12:46:35 2016 +0100 @@ -139,13 +139,19 @@ if (__is_instance(attr.context)) return attr; - if (__is_instance(context) && __test_common_instance(context, __TYPEPOS(attr.context), __TYPECODE(attr.context))) - return __replace_context(context, attr); - if (!__is_instance(context) && __test_common_type(context, __TYPEPOS(attr.context), __TYPECODE(attr.context))) - return __update_context(context, attr); + + /* Test any instance context against the context employed by the + attribute. */ - __raise_type_error(); - return __NULL; + if (__is_instance(context)) + if (__test_common_instance(context, __TYPEPOS(attr.context), __TYPECODE(attr.context))) + return __replace_context(context, attr); + else + __raise_type_error(); + + /* Otherwise, preserve the attribute as retrieved. */ + + return attr; } __attr __replace_context(__ref context, __attr attr)