Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

With statement should allow suppressing exceptions #886

Open
patiences opened this issue Aug 1, 2018 · 1 comment
Open

With statement should allow suppressing exceptions #886

patiences opened this issue Aug 1, 2018 · 1 comment

Comments

@patiences
Copy link
Contributor

patiences commented Aug 1, 2018

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@patiences and others