Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67445
| From | Roy Smith <roy@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: why indentation should be part of the syntax |
| Date | 2014-03-02 09:38 -0500 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <roy-3F8596.09385002032014@news.panix.com> (permalink) |
| References | <mailman.7568.1393756930.18130.python-list@python.org> |
In article <mailman.7568.1393756930.18130.python-list@python.org>,
Stefan Behnel <stefan_ml@behnel.de> wrote:
> Haven't seen any mention of it on this list yet, but since it's such an
> obvious flaw in quite a number of programming languages, here's a good
> article on the recent security bug in iOS, which was due to accidentally
> duplicated code not actually being as indented as it looked:
>
> https://www.imperialviolet.org/2014/02/22/applebug.html
>
> Stefan
Hogwash. What this looks like is two gotos in a row. Anybody who
reviewed this code would have thrown up a red flag when they saw two
gotos in a row. If anything, the "incorrect" indentation makes it even
more obvious. Any static code analyzer would have also caught this as
an unreachable statement.
Paraphrasing this into Python, you get:
def bogus():
if SSLHashSHA1.update(hashCtx, serverRandom) != 0:
raise fail
if SSLHashSHA1.update(hashCtx, signedParams) != 0:
raise fail
raise fail
if SSLHashSHA1.final(hashCtx, hashOut) != 0:
raise fail
which is syntactically valid (at least, I can import it), but clearly
not what the author intended. So how did Python's indentation rules
save us?
On the other hand, the Python code was actually a little annoying to
type in because emacs refused to auto-indent the second raise! So maybe
the real rule is to only write code using emacs :-)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
why indentation should be part of the syntax Stefan Behnel <stefan_ml@behnel.de> - 2014-03-02 11:41 +0100
Re: why indentation should be part of the syntax Bernd Nawothnig <Bernd.Nawothnig@t-online.de> - 2014-03-02 13:07 +0100
Re: why indentation should be part of the syntax Roy Smith <roy@panix.com> - 2014-03-02 09:38 -0500
Re: why indentation should be part of the syntax Nicholas Cole <nicholas.cole@gmail.com> - 2014-03-02 19:08 +0000
Re: why indentation should be part of the syntax "BartC" <bc@freeuk.com> - 2014-03-03 21:43 +0000
csiph-web