Skip to content

Commit eee7cca

Browse files
improve undefined is not a function error message (finally)
1 parent 1158449 commit eee7cca

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

js2py/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def get(self, prop): #external use!
319319
#prop = prop.value
320320
if self.Class == 'Undefined' or self.Class == 'Null':
321321
raise MakeError('TypeError',
322-
'Undefined and null dont have properties!')
322+
'Undefined and null dont have properties (tried getting property %s)' % repr(prop))
323323
if not isinstance(prop, basestring):
324324
prop = prop.to_string().value
325325
if not isinstance(prop, basestring): raise RuntimeError('Bug')
@@ -361,7 +361,7 @@ def put(self, prop, val, op=None): #external use!
361361
* / % + - << >> & ^ |'''
362362
if self.Class == 'Undefined' or self.Class == 'Null':
363363
raise MakeError('TypeError',
364-
'Undefined and null dont have properties!')
364+
'Undefined and null don\'t have properties (tried setting property %s)' % repr(prop))
365365
if not isinstance(prop, basestring):
366366
prop = prop.to_string().value
367367
if NUMPY_AVAILABLE and prop.isdigit():
@@ -991,7 +991,8 @@ def callprop(self, prop, *args):
991991
cand = self.get(prop)
992992
if not cand.is_callable():
993993
raise MakeError('TypeError',
994-
'%s is not a function' % cand.typeof())
994+
'%s is not a function (tried calling property %s of %s)' % (
995+
cand.typeof(), repr(prop), repr(self.Class)))
995996
return cand.call(self, args)
996997

997998
def to_python(self):

js2py/node_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _get_and_translate_npm_module(module_name, include_polyfill=False, update=Fa
130130
return py_code
131131

132132

133-
def require(module_name, include_polyfill=False, update=False, context=None):
133+
def require(module_name, include_polyfill=True, update=False, context=None):
134134
"""
135135
Installs the provided npm module, exports a js bundle via browserify, converts to ECMA 5.1 via babel and
136136
finally translates the generated JS bundle to Python via Js2Py.
@@ -139,7 +139,7 @@ def require(module_name, include_polyfill=False, update=False, context=None):
139139
:param module_name: Name of the npm module to require. For example 'esprima'. Supports specific versions via @
140140
specification. Eg: 'crypto-js@3.3'.
141141
:param include_polyfill: Whether the babel-polyfill should be included as part of the translation. May be needed
142-
for some modules that use unsupported features.
142+
for some modules that use unsupported features of JS6 such as Map or typed arrays.
143143
:param update: Whether to force update the translation. Otherwise uses a cached version if exists.
144144
:param context: Optional context in which the translated module should be executed in. If provided, the
145145
header (js2py imports) will be skipped as it is assumed that the context already has all the necessary imports.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# twine upload dist/*
2828
setup(
2929
name='Js2Py',
30-
version='0.68',
30+
version='0.69',
3131

3232
packages=['js2py', 'js2py.utils', 'js2py.prototypes', 'js2py.translators',
3333
'js2py.constructors', 'js2py.host', 'js2py.es6', 'js2py.internals',

0 commit comments

Comments
 (0)