[Python-Dev] PEP 7 and braces { .... } on if

Benjamin Peterson benjamin at python.org
Thu Jun 1 02:36:26 EDT 2017


Modern GCC can defend against these kinds of problems. If I introduce a
"goto fail" bug somewhere in Python, I get a nice warning:
../Objects/abstract.c: In function ‘PyObject_Type’:
../Objects/abstract.c:35:5: warning: this ‘if’ clause does not guard...
[-Wmisleading-indentation]
     if (o == NULL)
     ^~
../Objects/abstract.c:37:9: note: ...this statement, but the latter is
misleadingly indented as if it is guarded by the ‘if’
         2 + 3;
         ^

This is not to say that simply bracing everything isn't the right way to
go.

On Wed, May 31, 2017, at 15:59, Greg Ewing wrote:
> Seems like a good idea to tighten it up.
> 
> If a style guide is going to say "you can either do X or
> not do X", it might as well not mention X at all. :-)
> 
> -- 
> Greg
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/benjamin%40python.org


More information about the Python-Dev mailing list