With statement should allow suppressing exceptions
patiences opened this issue · comments
Patience Shyu commented
class BlockExceptions(object):
def __enter__(self):
pass
def __exit__(self, *args):
return True
with BlockExceptions():
raise ValueError()
The ValueError
should be suppressed according to https://docs.python.org/3/reference/compound_stmts.html#with. Currently the exception is not suppressed, it fails with
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at python.testdaemon.TestDaemon.main(TestDaemon.java:65)
Caused by: ValueError:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.python.types.Type.invoke(Type.java:478)
at python.test.module$import(test.py:10)
at python.test.main(test.py)
... 5 more