Closed asottile closed 8 years ago
Can you elaborate on exception safety? Won't the same errors be raised in both scenarios?
If read()
(for whatever reason) were to throw an exception, you'd leave an open file descriptor (.close()
would not be called). Though this is unlikely, it's best to write the (simpler) code which does this for you. with
statements are a best practice in python when dealing with file objects (or other closables).
You can read more about them at their PEP (introduced in py25, standard in py26): https://www.python.org/dev/peps/pep-0343/
Ah, right. Good catch :+1: I will land this now.
This has been merged/released in 0.14.3
. Thanks for the fix!
No problem :) Thanks for the merge :D
For exception safety