Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Ivan Pozdeev via Python-Dev
On 05.06.2018 0:54, Ivan Pozdeev wrote: On 04.06.2018 23:52, Ivan Pozdeev wrote: On 04.06.2018 20:11, Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:57 AM, Yury Selivanov wrote: On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: [..

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Ivan Pozdeev via Python-Dev
On 04.06.2018 23:52, Ivan Pozdeev wrote: On 04.06.2018 20:11, Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:57 AM, Yury Selivanov wrote: On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: [..] For me, it's fine to catch any excepti

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Ivan Pozdeev via Python-Dev
On 04.06.2018 20:11, Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:57 AM, Yury Selivanov wrote: On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: [..] For me, it's fine to catch any exception using "except:" if the block contains "

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Yury Selivanov
On Mon, Jun 4, 2018 at 3:38 PM Victor Stinner wrote: > > 2018-06-04 18:45 GMT+02:00 Guido van Rossum : > > It is currently a general convention in asyncio to only catch Exception, not > > BaseException. I consider this a flaw and we should fix it, but it's > > unfortunately not so easy -- the test

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Victor Stinner
2018-06-04 18:45 GMT+02:00 Guido van Rossum : > It is currently a general convention in asyncio to only catch Exception, not > BaseException. I consider this a flaw and we should fix it, but it's > unfortunately not so easy -- the tests will fail if you replace all > occurrences of Exception with B

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Chris Angelico
On Tue, Jun 5, 2018 at 2:57 AM, Yury Selivanov wrote: > On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: >> >> On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: > [..] >> > For me, it's fine to catch any exception using "except:" if the block >> > contains "raise", typical pattern to cl

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Yury Selivanov
On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: > > On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: [..] > > For me, it's fine to catch any exception using "except:" if the block > > contains "raise", typical pattern to cleanup a resource in case of > > error. Otherwise, there is a ri

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Yury Selivanov
> It is currently a general convention in asyncio to only catch Exception, not > BaseException. I consider this a flaw and we should fix it, but it's > unfortunately not so easy -- the tests will fail if you replace all > occurrences of Exception with BaseException, and it is not always clear >

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Chris Angelico
On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: > Hi, > > I just read a recent bugfix in asyncio: > > https://github.com/python/cpython/commit/9602643120a509858d0bee4215d7f150e6125468 > > + try: > + await waiter > + except Exception: > + transport.close() > + raise > > Why only c

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Guido van Rossum
It is currently a general convention in asyncio to only catch Exception, not BaseException. I consider this a flaw and we should fix it, but it's unfortunately not so easy -- the tests will fail if you replace all occurrences of Exception with BaseException, and it is not always clear what's the ri