From 1727452c78c2c8ff2c9c7342a238d4e671d2de52 Mon Sep 17 00:00:00 2001 From: SpencerPark Date: Wed, 1 May 2019 17:29:50 -0400 Subject: [PATCH 1/2] Print all values passed to console.log and fix js object str representation on py3. --- js2py/base.py | 4 ++-- js2py/host/console.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js2py/base.py b/js2py/base.py index cf1eca08..ce9fda66 100644 --- a/js2py/base.py +++ b/js2py/base.py @@ -250,7 +250,7 @@ def is_generic_descriptor(desc): ############################################################################## - +@six.python_2_unicode_compatible class PyJs(object): PRIMITIVES = frozenset( ['String', 'Number', 'Boolean', 'Undefined', 'Null']) @@ -952,7 +952,7 @@ def create(self, *args): '''Generally not a constructor, raise an error''' raise MakeError('TypeError', '%s is not a constructor' % self.Class) - def __unicode__(self): + def __str__(self): return self.to_string().value def __repr__(self): diff --git a/js2py/host/console.py b/js2py/host/console.py index 50a08632..7e1104a5 100644 --- a/js2py/host/console.py +++ b/js2py/host/console.py @@ -6,7 +6,8 @@ def console(): @Js def log(): - print(arguments[0]) + args = arguments + print(*(args[i] for i in args)) console.put('log', log) console.put('debug', log) From aebbabe842a9c8437bfad1bf022a546e6919f4d3 Mon Sep 17 00:00:00 2001 From: SpencerPark Date: Thu, 2 May 2019 11:31:21 -0400 Subject: [PATCH 2/2] Make sure to use the print function on python 2 for calling with varargs. --- js2py/host/console.py | 1 + 1 file changed, 1 insertion(+) diff --git a/js2py/host/console.py b/js2py/host/console.py index 7e1104a5..3d099630 100644 --- a/js2py/host/console.py +++ b/js2py/host/console.py @@ -1,3 +1,4 @@ +from __future__ import print_function from ..base import * @Js