You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've defined a custom Exception that takes more than one argument to __init__:
class InvalidUnitError(UnitConversionError):
"""
Exception raised when a unit is not in the Unit conversion database
"""
def __init__(self, unit, type = ""):
self.unit = unit
self.type = type
as you can see, it takes two arguments -- Gython chokes on this:
File "/Users/chris.barker/Temp/Py2JS_test/Gython/pythonjs/python_to_pythonjs.py", line 1404, in visit_Raise
raise SyntaxError( self.format_error('raise Error(x) can only have a single argument') )
SyntaxError: line 129
FromUnit = self.Synonyms[FromUnit]
except KeyError:
raise InvalidUnitError(FromUnit, self.Name)
raise Error(x) can only have a single argument
One can certainly argue that changing the API to an Exception is bad form that pythonjs doesn't support, but I thought I'd log this.
The text was updated successfully, but these errors were encountered:
Actuallly -- looking more, it turns out that Exceptions are designed to take an arbitraty number of arguments, which by default get stored in the "args" attribute:
In [10]: e = Exception("this", "is", "more", "than", "one", "argument")
In [11]: e.args
Out[11]: ('this', 'is', 'more', 'than', 'one', 'argument')
In [12]: print e
('this', 'is', 'more', 'than', 'one', 'argument')
I've defined a custom Exception that takes more than one argument to
__init__
:as you can see, it takes two arguments -- Gython chokes on this:
One can certainly argue that changing the API to an Exception is bad form that pythonjs doesn't support, but I thought I'd log this.
The text was updated successfully, but these errors were encountered: