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
The "except" statement is used to catch exceptions, and it expects to receive an exception class or tuple of exception classes from catching. In the code "except 1:", the number "1" is not an exception class, and it does not represent an exception. Therefore, it may be better to raise a TypeError instead of an assertion failure.
test.py
try:
raise Exception()
except 1:
pass
The output on Codon v0.16.0
Assert failed: 1 is not a class [test.py:14:1]
Expression: t && t->getClass()
Source: /github/workspace/codon/parser/visitors/translate/translate.cpp:544
Aborted (core dumped)
The output on CPython 3.10.8(As expected):
Traceback (most recent call last):
File "/home/xxm/Desktop/Codon/test.py", line 15, in <module>
raise Exception()
Exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/Codon/test.py", line 16, in <module>
except 1:
TypeError: catching classes that do not inherit from BaseException is not allowed
The output on RustPython 0.2.0 (As expected):
Traceback (most recent call last):
File "/home/xxm/Desktop/Codon/test.py", line 15, in <module>
raise Exception()
Exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/Codon/test.py", line 16, in <module>
except 1:
TypeError: isinstance() arg 2 must be a type or tuple of types, not int
Reproduce step:
download the Pre-built binaries for Linux
Type " codon run --release test.py" in the console.
Environment:
Ubuntu 18.04
Codon v0.16.0
The text was updated successfully, but these errors were encountered:
The "except" statement is used to catch exceptions, and it expects to receive an exception class or tuple of exception classes from catching. In the code "except 1:", the number "1" is not an exception class, and it does not represent an exception. Therefore, it may be better to raise a TypeError instead of an assertion failure.
test.py
The output on Codon v0.16.0
The output on CPython 3.10.8(As expected):
The output on RustPython 0.2.0 (As expected):
Reproduce step:
Environment:
Ubuntu 18.04
Codon v0.16.0
The text was updated successfully, but these errors were encountered: