Re: [Python-Dev] [Python-checkins] cpython (3.2): adjust braces a bit
What's the logic for adding some braces, but removing others? On 10/19/2011 4:58 PM, benjamin.peterson wrote:
http://hg.python.org/cpython/rev/9c79a25f4a8b changeset: 73010:9c79a25f4a8b branch: 3.2 parent: 72998:99a9f0251924 user: Benjamin Peterson <benjamin@python.org> date: Wed Oct 19 16:57:40 2011 -0400 summary: adjust braces a bit
files: Objects/genobject.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Objects/genobject.c b/Objects/genobject.c --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -232,8 +232,9 @@
/* First, check the traceback argument, replacing None with NULL. */ - if (tb == Py_None) + if (tb == Py_None) { tb = NULL; + } else if (tb != NULL && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "throw() third argument must be a traceback object"); @@ -244,9 +245,8 @@ Py_XINCREF(val); Py_XINCREF(tb);
- if (PyExceptionClass_Check(typ)) { + if (PyExceptionClass_Check(typ)) PyErr_NormalizeException(&typ, &val, &tb); - }
else if (PyExceptionInstance_Check(typ)) { /* Raising an instance. The value should be a dummy. */ @@ -262,10 +262,9 @@ typ = PyExceptionInstance_Class(typ); Py_INCREF(typ);
- if (tb == NULL) { + if (tb == NULL) /* Returns NULL if there's no traceback */ tb = PyException_GetTraceback(val); - } } } else {
_______________________________________________ Python-checkins mailing list Python-checkins@python.org http://mail.python.org/mailman/listinfo/python-checkins
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10/21/2011 12:31 PM, Benjamin Peterson wrote:
2011/10/21 Eric V. Smith <eric@trueblade.com>:
What's the logic for adding some braces, but removing others?
No braces if everything is a one-liner, otherwise braces everywhere.
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere? Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6hoI4ACgkQ+gerLs4ltQ5xlACeLTfh93yW6jxaySzgVwyA9xDS GxMAn1ZmY5KcjZ50m5eYFusc6FMI++NF =mSl4 -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On Oct 21, 2011, at 12:40 PM, Tres Seaver wrote:
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere?
+1 - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJOoaGfAAoJEBJutWOnSwa/ng4P/AkZvFfMIwYnX5F8ctItZhgS nZjCpbuH1dG0JBrYwXq+A0+CPJM2fnS/UItt1Lmu464XAjs53Gyk5sc4OFR4ex07 7gYz65yrs7YLkefxc+06Ate1VvyTCDy7iagGwjELaRM/Pmt47Ei2Rhm5sVgZNbSa XzoEKURw7Uk5Yc/9/rHW5uo2KmRMp91hvU20oXFE9aq/N5bZXhfRrJqol7CURNgf AfGM7PP/Bl4g3prOJFSXdmELzFuppnlqJ77q8UuckI5I4q7n8dBk8WJskWmZFfo1 xZo7S8P+3wt7BKw3yoOxkjzeYN0Hk17ct9aeDfmQXXKNUNRu7lpiqzCi5mcY5EOL E5Nzw1/qmf9dkSBHUTH/zl1VDw5LFPiUdvTXM1mEROuH5MfpbGob1da+YCSG4UWJ 3ekqSDBmfuaPRfMBD1gY/m4olNW/0Bixb0upWCncuWBdng6SB8qeegEEyAPMQkWz llMOaySLxVFG7zNPJQRli4HbARedqpUzk1SzjPJINaAUuwyVx3KbCpsJIDkwNOHl yJ1MoGYRQzlWdR/X2KJahHzYUaRDa+Rg9p9uXmnoDFAmVomh6HDVDbjHfhsxj5Xd H+wP9wI2k0tI2ZMMHgDJO9nSI51ec2WmMtXe+bYG8D/D1HWuYo/D6qhHFKGR3zNm aLH0qwwieUTpa81Qg7D8 =HB4F -----END PGP SIGNATURE-----
Tres Seaver wrote:
On 10/21/2011 12:31 PM, Benjamin Peterson wrote:
2011/10/21 Eric V. Smith :
What's the logic for adding some braces, but removing others?
No braces if everything is a one-liner, otherwise braces everywhere.
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere?
+1 ~Ethan~
2011/10/21 Tres Seaver <tseaver@palladion.com>:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/21/2011 12:31 PM, Benjamin Peterson wrote:
2011/10/21 Eric V. Smith <eric@trueblade.com>:
What's the logic for adding some braces, but removing others?
No braces if everything is a one-liner, otherwise braces everywhere.
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere?
It certainly doesn't explicitly but if (type->tp_dictoffset != 0 && base->tp_dictoffset == 0 && type->tp_dictoffset == b_size && (size_t)t_size == b_size + sizeof(PyObject *)) return 0; /* "Forgive" adding a __dict__ only */ -- Regards, Benjamin
2011/10/21 Tres Seaver <tseaver@palladion.com>:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/21/2011 12:31 PM, Benjamin Peterson wrote:
2011/10/21 Eric V. Smith <eric@trueblade.com>:
What's the logic for adding some braces, but removing others?
No braces if everything is a one-liner, otherwise braces everywhere.
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere?
Because we're not writing Python? -- Regards, Benjamin
On Fri, Oct 21, 2011 at 8:17 PM, Benjamin Peterson <benjamin@python.org> wrote:
2011/10/21 Tres Seaver <tseaver@palladion.com>:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/21/2011 12:31 PM, Benjamin Peterson wrote:
2011/10/21 Eric V. Smith <eric@trueblade.com>:
What's the logic for adding some braces, but removing others?
No braces if everything is a one-liner, otherwise braces everywhere.
Hmm, PEP 7 doesn't show any example of the one-liner exception. Given that it tends to promote errors, particularly among indentation-conditioned Python programmers (adding another statement at the same indentation level), why not just have braces everywhere?
Because we're not writing Python?
Right. Only CPython here. Where can I find The True Python? =) BTW, some of this stuff may find its way into PEP-7 http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Condi... -- anatoly t.
participants (6)
-
anatoly techtonik -
Barry Warsaw -
Benjamin Peterson -
Eric V. Smith -
Ethan Furman -
Tres Seaver