Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Mon, Jan 2, 2012 at 4:22 PM, Ron Adam wrote: > The problem is only when an additional statement is added to the last > block, not the preceding ones, as the compiler will complain about > those.  So I don't know how the 4 line example without braces is any > worse than a 2 line if without brace

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 1, 2012, at 8:44 PM, Nick Coghlan wrote: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: > > if (cond) >statement; > else >statement; > > vs. > > if (cond) { >statement; > } else { >statement; > } Really? Do we

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Mon, Jan 2, 2012 at 6:47 PM, Raymond Hettinger wrote: > Really?  Do we need to have a brace war? > People have different preferences. > The standard library includes some of both styles > depending on what the maintainer thought was cleanest to their eyes in a > given context. If the answer i

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Terry Reedy
On 1/2/2012 12:55 AM, Paul McMillan wrote: Terry Reedy said: I understood Alexander Klink and Julian Wälde, hash...@alech.de, as saying that they consider that using a random non-zero start value is sufficient to make the hash non-vulnerable. I've been talking to them. They're happy to look at

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Antoine Pitrou
On Sun, 1 Jan 2012 21:55:52 -0800 Paul McMillan wrote: > > This is similar to the change proposed by Christian Heimes. > > Most importantly, I moved the xor with r[x % len_r] down a line. > Before, it wasn't being applied to the last character. Shouldn't it be r[i % len(r)] instead? (refer to y

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Antoine Pitrou
On Mon, 2 Jan 2012 14:44:49 +1000 Nick Coghlan wrote: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: > > if (cond) > statement; > else > statement; > > vs. > > if (cond) { > statement; > } else { > statement; > } Go

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Petri Lehtinen
Antoine Pitrou wrote: > I don't like having the else on the same line as the closing brace, > and prefer: > >if (cond) { >statement; >} >else { >statement; >} And this is how it's written in PEP-7. It seems to me that PEP-7 doesn't require braces. But it explicitly

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Ned Batchelder
On 1/1/2012 11:44 PM, Nick Coghlan wrote: I've been having an occasional argument with Benjamin regarding braces in 4-line if statements: if (cond) statement; else statement; vs. if (cond) { statement; } else { statement; } He keeps leaving them out, I occas

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Stephen J. Turnbull
Christian Heimes writes: > Am 31.12.2011 13:03, schrieb Stephen J. Turnbull: > > I don't know the implementation issues well enough to claim it is a > > solution, but this hasn't been mentioned before AFAICS: > > > > While the dictionary probe has to start with a hash for backward > > compat

[Python-Dev] Code reviews

2012-01-02 Thread Antoine Pitrou
On Mon, 2 Jan 2012 14:44:49 +1000 Nick Coghlan wrote: > > He keeps leaving them out, I occasionally tell him they should always > be included (most recently this came up when we gave conflicting > advice to a patch contributor). Oh, by the way, this is also why I avoid arguing too much about sty

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Benjamin Peterson
2012/1/1 Nick Coghlan : > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: Python's C code has been dropping braces long before I ever arrived. See this beautiful example in dictobject.c, for example: if (numfree < PyDict_MAXFREELIST && Py_TYPE

Re: [Python-Dev] cpython: fix some possible refleaks from PyUnicode_READY error conditions

2012-01-02 Thread Antoine Pitrou
On Mon, 02 Jan 2012 16:00:50 +0100 benjamin.peterson wrote: > http://hg.python.org/cpython/rev/d5cda62d0f8c > changeset: 74236:d5cda62d0f8c > user:Benjamin Peterson > date:Mon Jan 02 09:00:30 2012 -0600 > summary: > fix some possible refleaks from PyUnicode_READY error conditi

Re: [Python-Dev] cpython: fix some possible refleaks from PyUnicode_READY error conditions

2012-01-02 Thread Benjamin Peterson
2012/1/2 Antoine Pitrou : > On Mon, 02 Jan 2012 16:00:50 +0100 > benjamin.peterson wrote: >> http://hg.python.org/cpython/rev/d5cda62d0f8c >> changeset:   74236:d5cda62d0f8c >> user:        Benjamin Peterson >> date:        Mon Jan 02 09:00:30 2012 -0600 >> summary: >>   fix some possible refleak

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Christian Heimes
Am 02.01.2012 06:55, schrieb Paul McMillan: > I think Ruby uses FNV-1 with a salt, making it less vulnerable to > this. FNV is otherwise similar to our existing hash function. > > For the record, cryptographically strong hash functions are in the > neighborhood of 400% slower than our existing has

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Anders J. Munch
> On 1/1/2012 12:28 PM, Christian Heimes wrote: > I understood Alexander Klink and Julian Wälde, hash...@alech.de, as > saying that they consider that using a random non-zero start value is > sufficient to make the hash non-vulnerable. Sufficient against their current attack. But will it last? F

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Christian Heimes
Am 01.01.2012 19:45, schrieb Terry Reedy: > On 1/1/2012 10:13 AM, Guido van Rossum wrote: >> PS. Is the collision-generator used in the attack code open source? > > As I posted before, Alexander Klink and Julian Wälde gave their project > email as hash...@alech.de. Since they indicated disappoint

Re: [Python-Dev] Code reviews

2012-01-02 Thread Georg Brandl
On 01/02/2012 03:41 PM, Antoine Pitrou wrote: > On Mon, 2 Jan 2012 14:44:49 +1000 > Nick Coghlan wrote: >> >> He keeps leaving them out, I occasionally tell him they should always >> be included (most recently this came up when we gave conflicting >> advice to a patch contributor). > > Oh, by th

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Georg Brandl
On 01/02/2012 04:47 PM, Christian Heimes wrote: > Am 01.01.2012 19:45, schrieb Terry Reedy: >> On 1/1/2012 10:13 AM, Guido van Rossum wrote: >>> PS. Is the collision-generator used in the attack code open source? >> >> As I posted before, Alexander Klink and Julian Wälde gave their project >> ema

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Guido van Rossum
On Mon, Jan 2, 2012 at 7:47 AM, Christian Heimes wrote: > Am 01.01.2012 19:45, schrieb Terry Reedy: > > On 1/1/2012 10:13 AM, Guido van Rossum wrote: > >> PS. Is the collision-generator used in the attack code open source? > > > > As I posted before, Alexander Klink and Julian Wälde gave their pr

Re: [Python-Dev] Code reviews

2012-01-02 Thread francis
On 01/02/2012 06:35 PM, Georg Brandl wrote: On 01/02/2012 03:41 PM, Antoine Pitrou wrote: On Mon, 2 Jan 2012 14:44:49 +1000 Nick Coghlan wrote: He keeps leaving them out, I occasionally tell him they should always be included (most recently this came up when we gave conflicting advice to a pat

Re: [Python-Dev] Code reviews

2012-01-02 Thread Brian Curtin
On Mon, Jan 2, 2012 at 12:26, francis wrote: > On 01/02/2012 06:35 PM, Georg Brandl wrote: >> >> On 01/02/2012 03:41 PM, Antoine Pitrou wrote: >>> >>> On Mon, 2 Jan 2012 14:44:49 +1000 >>> Nick Coghlan  wrote: He keeps leaving them out, I occasionally tell him they should always be

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Alexey Borzenkov
On Mon, Jan 2, 2012 at 7:18 PM, Christian Heimes wrote: > Am 02.01.2012 06:55, schrieb Paul McMillan: >> I think Ruby uses FNV-1 with a salt, making it less vulnerable to >> this. FNV is otherwise similar to our existing hash function. >> >> For the record, cryptographically strong hash functions

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Alexey Borzenkov
On Mon, Jan 2, 2012 at 10:53 PM, Alexey Borzenkov wrote: > On Mon, Jan 2, 2012 at 7:18 PM, Christian Heimes wrote: >> Am 02.01.2012 06:55, schrieb Paul McMillan: >>> I think Ruby uses FNV-1 with a salt, making it less vulnerable to >>> this. FNV is otherwise similar to our existing hash function.

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/02/2012 01:02 AM, Nick Coghlan wrote: > On Mon, Jan 2, 2012 at 3:04 PM, Scott Dial > wrote: >> On 1/1/2012 11:44 PM, Nick Coghlan wrote: >>> I think it's a recipe for future maintenance hassles when someone >>> adds a second statement to one of

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Benjamin Peterson
2012/1/1 Nick Coghlan : > >  if (cond) { >    statement; >  } else { >    statement; >  } I might add that assuming you have braces, PEP 7 would want you to format it as if (cond) { statement; } else { more_stuff; } -- Regards, Benjamin ___ P

Re: [Python-Dev] Code reviews

2012-01-02 Thread julien tayon
@francis Like indent ? http://www.linuxmanpages.com/man1/indent.1.php @brian > I don't think this is a problem to the point that it needs to be fixed > via automation. The code I write is the code I build and test, so I'd > rather not have some script that goes in and modifies it to some > accepte

Re: [Python-Dev] That depends on what the meaning of "is" is (was Re: http://mail.python.org/pipermail/python-dev/2011-December/115172.html)

2012-01-02 Thread Jim Jewett
On Mon, Jan 2, 2012 at 1:16 AM, PJ Eby wrote: > On Sun, Jan 1, 2012 at 10:28 PM, Jim Jewett wrote: >> >> Given the wording requiring a real dictionary, I would have assumed >> that it was OK (if perhaps not sensible) to do pointer arithmetic and >> access the keys/values/hashes directly.  (Though

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Larry Hastings
On 01/02/2012 12:47 AM, Raymond Hettinger wrote: Really? Do we need to have a brace war? People have different preferences. The standard library includes some of both styles depending on what the maintainer thought was cleanest to their eyes in a given context. I'm with Raymond. Code should

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Guido van Rossum
On Mon, Jan 2, 2012 at 1:50 PM, Larry Hastings wrote: > On 01/02/2012 12:47 AM, Raymond Hettinger wrote: > >> Really? Do we need to have a brace war? >> People have different preferences. >> The standard library includes some of both styles >> depending on what the maintainer thought was cleanes

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tim Delaney
On 3 January 2012 08:50, Larry Hastings wrote: > On 01/02/2012 12:47 AM, Raymond Hettinger wrote: > >> Really? Do we need to have a brace war? >> People have different preferences. >> The standard library includes some of both styles >> depending on what the maintainer thought was cleanest to th

Re: [Python-Dev] Code reviews

2012-01-02 Thread Francisco Martin Brugue
On 01/02/2012 10:02 PM, julien tayon wrote: @francis Like indent ? http://www.linuxmanpages.com/man1/indent.1.php Thank you, I wasn't aware of this one ! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-d

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 12:31 PM, Benjamin Peterson wrote: > I might add that assuming you have braces, PEP 7 would want you to format it > as > > if (cond) { >statement; > } > else { >more_stuff; > } > Running ``grep -B1 else Objects/*c`` shows that we've happily lived with a mixture o

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 2:09 PM, Tim Delaney wrote: > I'd also point out that if you're expecting braces, not having them can make > the code less readable. If a programmer's mind explodes when they look at the simple and beautiful examples in K&R's The C Programming Language, then they've got pro

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Ned Batchelder
On 1/2/2012 5:32 PM, Raymond Hettinger wrote: Running ``grep -B1 else Objects/*c`` shows that we've happily lived with a mixture of styles for a very long time. ISTM, our committers have had good instincts about when braces add clarity and when they add clutter. If Nick pushes through an alwa

Re: [Python-Dev] That depends on what the meaning of "is" is (was Re: http://mail.python.org/pipermail/python-dev/2011-December/115172.html)

2012-01-02 Thread PJ Eby
On Mon, Jan 2, 2012 at 4:07 PM, Jim Jewett wrote: > On Mon, Jan 2, 2012 at 1:16 AM, PJ Eby wrote: > > On Sun, Jan 1, 2012 at 10:28 PM, Jim Jewett > wrote: > >> > >> Given the wording requiring a real dictionary, I would have assumed > >> that it was OK (if perhaps not sensible) to do pointer ar

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Tue, Jan 3, 2012 at 12:54 AM, Benjamin Peterson wrote: > I think it's fine Nick raised this. PEP 7 is not very explicit about > braces at all. I actually discovered in this thread that I've been misreading PEP 7 for going on 7 years now - I thought the brace usage example *did* use "} else {"

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Tue, Jan 3, 2012 at 8:32 AM, Raymond Hettinger wrote: > Running  ``grep -B1 else Objects/*c`` shows that we've happily lived with a > mixture of styles for a very long time. > ISTM, our committers have had good instincts about when braces add clarity > and when they add clutter. > If Nick pushe

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 4:27 PM, Nick Coghlan wrote: > With my perception of the status quo corrected, I can stop worrying > about preserving a non-existent consistency. +1 QOTD Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tim Delaney
On 3 January 2012 09:55, Raymond Hettinger wrote: > > On Jan 2, 2012, at 2:09 PM, Tim Delaney wrote: > > I'd also point out that if you're expecting braces, not having them can > make the code less readable. > > > If a programmer's mind explodes when they look at the simple and beautiful > example

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Guido van Rossum
On Mon, Jan 2, 2012 at 4:27 PM, Nick Coghlan wrote: > On Tue, Jan 3, 2012 at 8:32 AM, Raymond Hettinger > wrote: > > Running ``grep -B1 else Objects/*c`` shows that we've happily lived > with a > > mixture of styles for a very long time. > > ISTM, our committers have had good instincts about wh

Re: [Python-Dev] Code reviews

2012-01-02 Thread Barry Warsaw
On Jan 02, 2012, at 06:35 PM, Georg Brandl wrote: >Exactly. Especially for reviews of patches from non-core people, we >should exercise a lot of restraint: as the committers, I think we can be >expected to bite the sour bullet and apply our uniform style (such as >it is). > >It is tiresome, if not

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Barry Warsaw
On Jan 02, 2012, at 02:08 PM, Guido van Rossum wrote: >The irony is that style guides exist to *avoid* debates like this. Yes, the >choices are arbitrary. Yes, tastes differ. Yes, there are exceptions to the >rules. But still, once a style rule has been set, the idea is to stop >debating and just

Re: [Python-Dev] Hash collision security issue (now public)

2012-01-02 Thread Barry Warsaw
On Jan 02, 2012, at 06:38 PM, Georg Brandl wrote: >I wouldn't expect too much -- they seem rather keen on cheap laughs: > >http://twitter.com/#!/bk3n/status/152068096448921600/photo/1/large Heh, so yeah, it won't be me contacting them. -Barry ___ Pytho