1.1 --- a/templates/ops.c Thu Nov 24 22:43:29 2016 +0100
1.2 +++ b/templates/ops.c Thu Nov 24 23:42:19 2016 +0100
1.3 @@ -82,6 +82,14 @@
1.4
1.5 /* Attribute testing and retrieval operations. */
1.6
1.7 +static __attr __check_and_load_via_object_null(__ref obj, int pos, int code)
1.8 +{
1.9 + if (__HASATTR(obj, pos, code))
1.10 + return __load_via_object(obj, pos);
1.11 + else
1.12 + return __NULL;
1.13 +}
1.14 +
1.15 __attr __check_and_load_via_class(__ref obj, int pos, int code)
1.16 {
1.17 return __check_and_load_via_object(__get_class(obj), pos, code);
1.18 @@ -89,12 +97,16 @@
1.19
1.20 __attr __check_and_load_via_object(__ref obj, int pos, int code)
1.21 {
1.22 - return __HASATTR(obj, pos, code) ? __load_via_object(obj, pos) : __NULL;
1.23 + if (__HASATTR(obj, pos, code))
1.24 + return __load_via_object(obj, pos);
1.25 +
1.26 + __raise_type_error();
1.27 + return __NULL;
1.28 }
1.29
1.30 __attr __check_and_load_via_any(__ref obj, int pos, int code)
1.31 {
1.32 - __attr out = __check_and_load_via_object(obj, pos, code);
1.33 + __attr out = __check_and_load_via_object_null(obj, pos, code);
1.34 if (out.value == 0)
1.35 out = __check_and_load_via_class(obj, pos, code);
1.36 return out;
1.37 @@ -132,8 +144,7 @@
1.38 if (!__is_instance(context) && __test_common_type(context, __TYPEPOS(attr.context), __TYPECODE(attr.context)))
1.39 return __update_context(context, attr);
1.40
1.41 - /* NOTE: An error may be more appropriate. */
1.42 -
1.43 + __raise_type_error();
1.44 return __NULL;
1.45 }
1.46