diff --git a/js2py/base.py b/js2py/base.py index 5b46e307..2484340f 100644 --- a/js2py/base.py +++ b/js2py/base.py @@ -24,9 +24,9 @@ def str_repr(s): if six.PY2: - return repr(s.encode('utf-8')) + return s.encode('utf-8') else: - return repr(s) + return s def MakeError(name, message): """Returns PyJsException with PyJsError inside""" @@ -907,12 +907,7 @@ def __unicode__(self): return self.to_string().value def __repr__(self): - if self.Class=='Object': - res = [] - for e in self: - res.append(str_repr(e.value)+': '+str_repr(self.get(e))) - return '{%s}'%', '.join(res) - elif self.Class=='String': + if self.Class=='String': return str_repr(self.value) elif self.Class in ['Array','Int8Array','Uint8Array','Uint8ClampedArray','Int16Array','Uint16Array','Int32Array','Uint32Array','Float32Array','Float64Array']: res = [] @@ -2386,6 +2381,9 @@ def __init__(self, args, callee): def to_list(self): return [self.get(str(e)) for e in xrange(self.get('length').to_uint32())] + def to_dict(self): + return dict([(str(e), self.get(str(e))) for e in xrange(self.get('length').to_uint32())]) + #We can define function proto after number proto because func uses number in its init FunctionPrototype = PyJsFunction(Empty, ObjectPrototype) diff --git a/js2py/host/console.py b/js2py/host/console.py index 822219ea..5a5f4154 100644 --- a/js2py/host/console.py +++ b/js2py/host/console.py @@ -6,6 +6,6 @@ def console(): @Js def log(): - print(arguments[0]) + print(' '.join(map(str, arguments.to_list()))) console.put('log', log) \ No newline at end of file