From 58b2eb5de7d3b6c004174f4de11d48d2a6d84b4f Mon Sep 17 00:00:00 2001 From: Alessandro Molina Date: Mon, 9 Apr 2018 23:44:23 +0200 Subject: [PATCH] Manually decode JS source code --- dukpy/babel.py | 4 ++-- dukpy/coffee.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dukpy/babel.py b/dukpy/babel.py index 03777ef..1d966c3 100644 --- a/dukpy/babel.py +++ b/dukpy/babel.py @@ -9,9 +9,9 @@ def babel_compile(source, **kwargs): presets = kwargs.get('presets') if not presets: kwargs['presets'] = ["es2015"] - with open(BABEL_COMPILER, 'r') as babel_js: + with open(BABEL_COMPILER, 'rb') as babel_js: return evaljs( - (babel_js.read(), + (babel_js.read().decode('utf-8'), 'var bres, res;' 'bres = Babel.transform(dukpy.es6code, dukpy.babel_options);', 'res = {map: bres.map, code: bres.code};'), diff --git a/dukpy/coffee.py b/dukpy/coffee.py index d9b39c6..121133a 100644 --- a/dukpy/coffee.py +++ b/dukpy/coffee.py @@ -6,9 +6,9 @@ COFFEE_COMPILER = os.path.join(os.path.dirname(__file__), 'jsmodules', 'coffeesc def coffee_compile(source): """Compiles the given ``source`` from CoffeeScript to JavaScript""" - with open(COFFEE_COMPILER, 'r') as coffeescript_js: + with open(COFFEE_COMPILER, 'rb') as coffeescript_js: return evaljs( - (coffeescript_js.read(), + (coffeescript_js.read().decode('utf-8'), 'CoffeeScript.compile(dukpy.coffeecode)'), coffeecode=source )