[Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Brett Cannon
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?
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Ethan Furman

On 01/17/2016 11:10 AM, Brett Cannon wrote:


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.


Not sure what that sentence actually says, but +1 on making them mandatory.

--
~Ethan~
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Brett Cannon
On Sun, 17 Jan 2016, 13:59 Ethan Furman  wrote:

> On 01/17/2016 11:10 AM, Brett Cannon wrote:
>
> > 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.
>
> Not sure what that sentence actually says, but +1 on making them mandatory.
>


Yeah, bad phrasing on my part. What I meant to say is leaving them off is
an aesthetic thing while requiring them is a bug prevention thing. When it
comes to writing C code I always vote for practicality over aesthetics.


> --
> ~Ethan~
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Robert Collins
+1 from me on requiring them.

On 18 January 2016 at 11:19, Brett Cannon  wrote:
>
>
> On Sun, 17 Jan 2016, 13:59 Ethan Furman  wrote:
>>
>> On 01/17/2016 11:10 AM, Brett Cannon wrote:
>>
>> > 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.
>>
>> Not sure what that sentence actually says, but +1 on making them
>> mandatory.
>
>
>
> Yeah, bad phrasing on my part. What I meant to say is leaving them off is an
> aesthetic thing while requiring them is a bug prevention thing. When it
> comes to writing C code I always vote for practicality over aesthetics.
>
>>
>> --
>> ~Ethan~
>> ___
>> Python-Dev mailing list
>> [email protected]
>> https://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe:
>> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>
>
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/robertc%40robertcollins.net
>



-- 
Robert Collins 
Distinguished Technologist
HP Converged Cloud
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Guido van Rossum
I'm +0. The editor I use is too smart to let me make this mistake, but I
don't object to recommending it. As usual, though, let's not start mindless
reformatting of existing code.

-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Victor Stinner
I like if without braces when the body is only one line, especially when
there is no else block.

Victor


Le dimanche 17 janvier 2016, Brett Cannon  a écrit :

> 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?
>
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Update PEP 7 to require curly braces in C

2016-01-17 Thread Georg Brandl
On 01/17/2016 11:19 PM, Brett Cannon wrote:
> 
> 
> On Sun, 17 Jan 2016, 13:59 Ethan Furman  > wrote:
> 
> On 01/17/2016 11:10 AM, Brett Cannon wrote:
> 
> > 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.
> 
> Not sure what that sentence actually says, but +1 on making them 
> mandatory.
> 
> 
> 
> Yeah, bad phrasing on my part. What I meant to say is leaving them off is an
> aesthetic thing while requiring them is a bug prevention thing. When it comes 
> to
> writing C code I always vote for practicality over aesthetics.

+1.

Out of curiosity, I made a quick script to see if we had any candidates for
bugs related to this. I didn't expect any bugs to be found, since with the
amount of static checkers that have been run they should have been found.
The only problem I found was in the S390 port of libffi (#ifdef-conditional
code which wouldn't even compile).

I also found (in ast.c) two instances of semantically correct code with the
wrong indent level which I fixed (see rev 1ececa34b748).

cheers,
Georg

___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com