Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions js2py/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion js2py/host/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def console():

@Js
def log():
print(arguments[0])
print(' '.join(map(str, arguments.to_list())))

console.put('log', log)