
On 17.01.16 21:10, Brett Cannon wrote:
While doing a review of http://bugs.python.org/review/26129/ <http://bugs.python..org/review/26129/> I asked to have curly braces put around all `if` statement bodies. Serhiy pointed out that PEP 7 says curly braces are optional: https://www.python.org/dev/peps/pep-0007/#id5. I would like to change that.
My argument is to require them to prevent bugs like the one Apple made with OpenSSL about two years ago: https://www.imperialviolet.org/2014/02/22/applebug.html. Skipping the curly braces is purely an aesthetic thing while leaving them out can lead to actual bugs.
Anyone object if I update PEP 7 to remove the optionality of curly braces in PEP 7?
I'm -0. The code without braces looks more clear. Especially if the body is one-line return, break, continue or goto statement. Sometimes it is appropriate to add an empty line after it for even larger clearness. On the other hand, there is no a precedence of bugs like the one Apple made in CPython sources. Mandatory braces *may be* will prevent hypothetical bug, but for sure make a lot of correct code harder to read.