Commits

Lucian Brănescu-Mihăilă committed 166e96c

Minor fixes and cleanups. Int tests still fail.

Comments (0)

Files changed (2)

objects/src/int.winxed

 namespace Python {
 
 function int(type, object) {
-    var f = type.__new__;
-    var i = f(type, 'int', [object]);
+    var i = type.__new__(type, 'int', [object]);
 
     i.__new__ = function(cls, int value[optional]) {
         var n = new Python.instance;
 
     i.__add__ = function(obj, other) {
         var result = obj.__value__ + other.__value__;
-        var f = obj.__new__;
-        return f(obj.__class__, result);
+        return obj.__new__(obj.__class__, result);
     };
 
     return i;

objects/src/type.winxed

     t.__str__ = t.__repr__;
 
     t.__getattribute__ = function(obj, key) {
+        cry('key: ' + key);
+
         var cls = obj.__dict__['__class__'];
         var chain = get_mro(cls);
         
 
         // then attr on actual obj
         if(id(cls) != id(t)) { // if obj is a class
-            for(var i in chain) {
+            cry('obj is class');
+            for(var i in get_mro(obj)) {
                 if(exists i.__dict__[key]) {
                     cry('getting from obj or parents');
                     var attr = i.__dict__[key];
                 }
             }
         } else {
+            cry('obj is not class');
             if(exists obj.__dict__[key]) {
                 return obj.__dict__[key];
             }
                 cry('getting from class');
             
                 // only for python objects
-                if(typeof(attr) == 'Python;instance') {
-                    // if data-descriptor
-                    if(exists attr.__dict__['__get__'] && exists attr.__dict__['__set__'])
+                if(typeof(attr) == 'Python;instance')
+                    if(exists attr.__dict__['__get__']) // if non-data descriptor
                         return attr.__dict__['__get__'](attr, obj);
-                    // if non-data descriptor
-                    if(exists attr.__dict__['__get__'])
-                        return attr.__dict__['__get__'](attr, obj);
-                }
 
                 return attr;
             }