Python2 vs Python3
See original GitHub issueHi @PiotrDabkowski ,
The following works in python2… however we get an error when using python3
File "/usr/local/lib/python3.5/dist-packages/js2py/base.py", line 547, in to_primitive
return self.default_value(hint)
File "/usr/local/lib/python3.5/dist-packages/js2py/base.py", line 455, in default_value
'Cannot convert object to primitive value')
js2py.internals.simplex.JsException: TypeError: Cannot convert object to primitive value
test code is as follows…
import js2py
import base64
def atob(s):
return base64.b64decode('{}'.format(s))
context = js2py.EvalJs({ "atob": atob })
context.eval(
"""
var t = "www3.hd.today";
function italics (str) { return '<i>' + this + '</i>'; };
var document = {
getElementById: function () {
return {'innerHTML': '+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(+[])+(!+[]+true+true))/+((!+[]+true+true+[])+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true)+(!+[]+true+true+true+true)+(+[])+(!+[]+true+true+true+true+true))'};
}
};
var s,t,o,p,b,r,e,a,k,i,n,g,f, zEANQPm={"UjYfQbvVqXn":+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(+[])+(!+[]+true+true))/+((!+[]+true+true+true+true+true+true+[])+(!+[]+true)+(+[])+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true)+(!+[]+true)+(!+[]+true+true)+(!+[]+true+true))}; ;zEANQPm.UjYfQbvVqXn-=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true))/+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true+true));zEANQPm.UjYfQbvVqXn-=+((!+[]+true+true+true+true+true+true+true+true+[])+(!+[]+true+true+true)+(+true)+(+[])+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(+true))/+((!+[]+true+[])+(!+[]+true)+(!+[]+true)+(+[])+(!+[]+true)+(!+[]+true+true+true+true+true+true)+(+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true));zEANQPm.UjYfQbvVqXn*=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(+true))/+((+true+[])+(+true)+(!+[]+true)+(+true)+(!+[]+true+true+true)+(+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true));zEANQPm.UjYfQbvVqXn+=+((!+[]+true+true+true+true+true+true+true+true+[])+(!+[]+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true)+(!+[]+true+true))/+((!+[]+true+true+true+true+true+[])+(!+[]+true)+(!+[]+true+true+true)+(+[])+(!+[]+true+true+true+true+true)+(+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true));zEANQPm.UjYfQbvVqXn*=+((!+[]+true+true+true+true+true+true+true+true+[])+(!+[]+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true)+(!+[]+true+true))/+((!+[]+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true)+(+[])+(+true)+(!+[]+true+true+true+true+true));zEANQPm.UjYfQbvVqXn*=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true))/+((!+[]+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true+true+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true+true));zEANQPm.UjYfQbvVqXn+=+((!+[]+true+true+true+true+true+true+true+[])+(+true)+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(+[])+(!+[]+true+true+true)+(!+[]+true)+(!+[]+true+true+true+true)+(!+[]+true+true))/+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true)+(!+[]+true)+(!+[]+true)+(!+[]+true+true+true+true+true+true+true+true)+(+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true)+(!+[]+true+true+true+true+true));zEANQPm.UjYfQbvVqXn+=+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true)+(+[])+(+[])+(!+[]+true+true)+(!+[]+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true+true+true+true))/+((!+[]+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true)+(!+[]+true)+(+[])+(!+[]+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true));zEANQPm.UjYfQbvVqXn+=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(+[])+(!+[]+true+true))/+((!+[]+true+true+true+true+true+true+true+true+[])+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true)+(+[])+(!+[]+true+true+true+true+true+true+true)+(+true));zEANQPm.UjYfQbvVqXn-=+((!+[]+true+true+true+true+true+true+true+true+[])+(!+[]+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true)+(!+[]+true+true))/+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(+[])+(!+[]+true)+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true)+(!+[]+true)+(!+[]+true+true+true+true));zEANQPm.UjYfQbvVqXn*=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true))/(+(+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true)+(+true)+(!+[]+true+true+true)+(!+[]+true+true)+(+true)+(!+[]+true+true)+(!+[]+true+true+true)+(+true)))+(function(p){return eval("t"+"."+"c"+"h"+"a"+"r"+"C"+"o"+"d"+"e"+"A"+"t"+"("+p+")")}(+((!+[]+true+true+true+[])))));zEANQPm.UjYfQbvVqXn-=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true))/+((!+[]+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true+true+true)+(+true)+(+true)+(+[])+(!+[]+true+true+true));zEANQPm.UjYfQbvVqXn+=function(p){var p = eval(eval(atob("ZG9jdW1l")+"n"+"t"+"."+"g"+"e"+"t"+"Element"+"B"+"y"+"Id("+"k"+")."+atob("aW5uZXJIVE1M"))); return +(p)}();zEANQPm.UjYfQbvVqXn-=+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true)+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true)+(+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true)+(+true))/+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(+[])+(+[])+(!+[]+true+true+true+true+true+true+true)+(+[])+(!+[]+true+true+true+true+true+true)+(!+[]+true+true+true+true+true)+(!+[]+true+true+true+true+true+true));zEANQPm.UjYfQbvVqXn+=+((!+[]+true+true+true+true+true+true+[])+(!+[]+true+true+true+true+true+true+true+true)+(!+[]+true+true+true+true+true+true)+(+[])+(+[])+(!+[]+true+true)+(!+[]+true+true+true)+(!+[]+true+true)+(!+[]+true+true+true+true+true+true))/+((!+[]+true+true+true+true+true+true+true+[])+(!+[]+true+true+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true)+(!+[]+true+true+true+true+true+true+true)+(!+[]+true+true+true+true)+(!+[]+true+true+true+true+true+true)+(+true)+(!+[]+true+true+true+true));(+zEANQPm.UjYfQbvVqXn).toFixed(10)
"""
)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Python 2 Vs. Python 3: Key Difference Between 2.x & 3.x
Python 3 syntax is simpler and easily understandable whereas Python 2 syntax is comparatively difficult to understand. · Python 3 default storing ...
Read more >Important differences between Python 2.x and Python 3.x with ...
This is the most well-known change. In this, the print keyword in Python 2.x is replaced by the print() function in Python 3.x....
Read more >A 2020 Guide to Python 2 vs Python 3 - Career Karma
Python 3 is more in-demand and includes a typing system. Python 2 is outdated and uses an older syntax for the print function....
Read more >Python 2 vs Python 3: The Key Differences - Great Learning
Python 2 was released in the year 2000 whereas Python 3 was released in the year 2008. ... In Python 2, print is...
Read more >Python 2 vs 3: Everything You Need to Know - DataCamp
Some of the major changes in Python 3 include changing the print declaration to a built-in function, improved integer division, and improved Unicode...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, okay
The reason is your
atob
function that returns the bytes instead of string. The bytes are converted to PyJsObjectWrapper which cannot be converted to a primitive value, hence the error 😃I guess it should be converted to native Js type just like string and unicode types, but this is done currently.