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
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
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
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
+
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
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()
+