[Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to
Serhiy Storchaka
storchaka at gmail.com
Tue May 26 08:44:22 CEST 2015
More information about the Python-Dev mailing list
Tue May 26 08:44:22 CEST 2015
- Previous message (by thread): [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to
- Next message (by thread): [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 >>> + except: >>> + buffer.close() >>> + raise >> >> Please do not add bare 'except:'. If you mean 'except >> BaseException:', say so. > > try..finally would be even better. No, finally is not correct there. buffer shouldn't be closed if no exception is raised. And this is one of the cases in which bare 'except:' is absolutely legal.
- Previous message (by thread): [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to
- Next message (by thread): [Python-Dev] [Python-checkins] cpython (3.4): Issue #23840: tokenize.open() now closes the temporary binary file on error to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list