Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-26 Thread R. David Murray
On Tue, 26 May 2015 08:20:01 +0200, Victor Stinner wrote: > What is wrong with "except:" in this specific case? Nothing is wrong with it from a technical standpoint. However, if we use 'except BaseException' that makes it clear that someone has thought about it and decided that all exceptions s

Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-26 Thread Yury Selivanov
On 2015-05-26 3:54 AM, Victor Stinner wrote: 2015-05-26 8:44 GMT+02:00 Serhiy Storchaka : No, finally is not correct there. buffer shouldn't be closed if no exception is raised. Yep. The binary file must only be closed in case of error, as written in the commit message. Right. My bad, sor

Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-26 Thread Victor Stinner
2015-05-26 8:44 GMT+02:00 Serhiy Storchaka : > No, finally is not correct there. buffer shouldn't be closed if no exception > is raised. Yep. The binary file must only be closed in case of error, as written in the commit message. > And this is one of the cases in which bare 'except:' is absolutel

Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-25 Thread Serhiy Storchaka
On 26.05.15 08:33, Yury Selivanov wrote: On 2015-05-26 12:26 AM, Terry Reedy wrote: +try: +encoding, lines = detect_encoding(buffer.readline) +buffer.seek(0) +text = TextIOWrapper(buffer, encoding, line_buffering=True) +text.mode = 'r' +return text +

Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-25 Thread Victor Stinner
What is wrong with "except:" in this specific case? Victor Le mardi 26 mai 2015, Yury Selivanov a écrit : > > > On 2015-05-26 12:26 AM, Terry Reedy wrote: > >> +try: >>> +encoding, lines = detect_encoding(buffer.readline) >>> +buffer.seek(0) >>> +text = TextIOWrapper

Re: [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to

2015-05-25 Thread Yury Selivanov
On 2015-05-26 12:26 AM, Terry Reedy wrote: +try: +encoding, lines = detect_encoding(buffer.readline) +buffer.seek(0) +text = TextIOWrapper(buffer, encoding, line_buffering=True) +text.mode = 'r' +return text +except: +buffer.close() +