[Python-Dev] Update PEP 7 to require curly braces in C (original) (raw)
Andrew Barnert abarnert at yahoo.com
Mon Jan 18 03:39:42 EST 2016
- Previous message (by thread): [Python-Dev] Update PEP 7 to require curly braces in C
- Next message (by thread): [Python-Dev] Update PEP 7 to require curly braces in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Jan 17, 2016, at 11:10, Brett Cannon <brett at python.org> wrote:
While doing a review of 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?
There are two ways you could do that.
The first is to just change "braces may be omitted where C permits, but when present, they should be formatted as follows" to something like "braces must not be omitted, and should be formatted as follows", changing one-liner tests into this:
if (!obj) {
return -1;
}
Alternatively, it could say something like "braces must not be omitted; when other C styles would use a braceless one-liner, a one-liner with braces should be used instead; otherwise, they should be formatted as follows", changing the same tests into:
if (!obj) { return -1; }
The first one is obviously a much bigger change in the formatting of actual code, even if it's a simpler change to the PEP. Is that what was intended? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160118/bff98213/attachment-0001.html>
- Previous message (by thread): [Python-Dev] Update PEP 7 to require curly braces in C
- Next message (by thread): [Python-Dev] Update PEP 7 to require curly braces in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]