summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-31 20:26:44 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-31 20:40:31 +0300
commitb509f73982309e713513830f1c17efef7d912592 (patch)
tree38e04f7bd82775b60fb02b939b7a71ba83d09af2 /py
parenta8dda295c4452dab4c36ad873a4a1a992498399c (diff)
objtype: Wrap .__name__ handling in MICROPY_CPYTHON_COMPAT.
Because it's runtime reflection feature, not required for many apps. Rant time: Python could really use better str() vs repr() distinction, for example, repr(type) could be "<class 'foo'>" (as it is now), and str(type) just "foo". But alas, getting straight name requires adhoc attribute.
Diffstat (limited to 'py')
-rw-r--r--py/objtype.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/objtype.c b/py/objtype.c
index ee3ce12ab..06bc803eb 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -297,10 +297,12 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj
STATIC void type_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_type));
mp_obj_type_t *self = self_in;
+#if MICROPY_CPYTHON_COMPAT
if (attr == MP_QSTR___name__) {
dest[0] = MP_OBJ_NEW_QSTR(self->name);
return;
}
+#endif
mp_obj_t member = mp_obj_class_lookup(self, attr);
if (member != MP_OBJ_NULL) {
// check if the methods are functions, static or class methods