Re: [Python-Dev] Python3 "complexity"

2014-01-08 Thread Chris Angelico
On Thu, Jan 9, 2014 at 11:21 AM, MRAB wrote: > On the other hand: > > "I need a new battery." > > "What kind of battery?" > > "I don't care!" Or, bringing it back to Python: How do you write a set out to a file? foo = {1, 2, 4, 8, 16, 32} open("foo.txt","w").write(foo) # Uh... nope!

Re: [Python-Dev] Python3 "complexity"

2014-01-09 Thread Chris Angelico
On Thu, Jan 9, 2014 at 5:50 PM, Lennart Regebro wrote: > To be honest, you can define text as "A stream of bytes that are split > up in lines separated by a linefeed", and do some basic text > processing like that. Just very *basic*, but still. Replacing > characters. Extracting certain lines etc.

Re: [Python-Dev] Python3 "complexity"

2014-01-09 Thread Chris Angelico
On Fri, Jan 10, 2014 at 11:53 AM, anatoly techtonik wrote: > 2. introduce autodetect mode to open functions > 1. read and transform on the fly, maintaining a buffer that > stores original bytes > and their mapping to letters. The mapping is updated as bytes > frequency >

Re: [Python-Dev] Python3 "complexity"

2014-01-09 Thread Chris Angelico
On Fri, Jan 10, 2014 at 1:39 PM, Steven D'Aprano wrote: > On Fri, Jan 10, 2014 at 12:22:02PM +1100, Chris Angelico wrote: >> On Fri, Jan 10, 2014 at 11:53 AM, anatoly techtonik >> wrote: >> > 2. introduce autodetect mode to open functions >> >

Re: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

2014-01-12 Thread Chris Angelico
On Mon, Jan 13, 2014 at 4:57 AM, Juraj Sukop wrote: > On Sun, Jan 12, 2014 at 6:22 PM, Steven D'Aprano > wrote: >> First, "utf16_string" confuses me. What is it? If it is a Unicode >> string, i.e.: > > It is a Unicode string which happens to contain code points outside U+00FF > (as with the TTF e

Re: [Python-Dev] Automatic encoding detection [was: Re: Python3 "complexity" - 2 use cases]

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 10:48 AM, Jim J. Jewett wrote: >> The barrier for entry to the standard library is higher than mere >> usefulness. > > Agreed. But "most programs will need it, and people will either > include (the same) 3rd-party library themselves, or write their > own workaround, or hav

[Python-Dev] Test failures when running as root

2014-01-13 Thread Chris Angelico
And now for something completely different. My root buildbot is finally now able to telnet out and get "Connection refused" errors. (For the curious, the VirtualBox "NAT" mode doesn't work properly, but the new "NAT Network" mode does. Why? I have no idea. But if anyone else is having the same pro

Re: [Python-Dev] Test failures when running as root

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 2:14 PM, Zachary Ware wrote: > On Mon, Jan 13, 2014 at 6:48 PM, Chris Angelico wrote: >> And secondly, how can I run the tests manually? I can't find a binary >> inside the buildarea tree. Does it get deleted afterward? > > Yes, that's t

Re: [Python-Dev] Test failures when running as root

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 2:03 PM, Terry Reedy wrote: > On 1/13/2014 7:48 PM, Chris Angelico wrote: >> >> ValueError: max() arg is an empty sequence > > > try: > > g = max(self.saved_groups) + 1 > except ValueError: > g = 1 > > > Unless someone

Re: [Python-Dev] Test failures when running as root

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 2:16 PM, MRAB wrote: > Alternatively: > > g = max(self.saved_groups, [1]) > > or even: > > g = max(self.saved_groups or [1]) Patch created and tracker issue opened. I've used something similar to MRAB's idea as it looks compact. Thanks all! http://bugs.python.org/issue202

Re: [Python-Dev] Common subset of python 2 and python 3

2014-01-15 Thread Chris Angelico
On Wed, Jan 15, 2014 at 11:22 PM, "Martin v. Löwis" wrote: > I don't think that it is possible to write an interpreter that is fully > compatible for all it accepts. Would you think that the program > > print(repr(2**80).endswith("L")) > > is in the subset that should be supported by both Python 2

Re: [Python-Dev] Common subset of python 2 and python 3

2014-01-15 Thread Chris Angelico
On Thu, Jan 16, 2014 at 1:25 AM, Eric V. Smith wrote: >> Easiest fix for that would be to have long.__repr__ omit the L tag. >> Then it'll do the same as it would in Py3. > > I think Martin's point is not this specific thing, but that such a > subset would be useless. Would you drop dict.items() b

Re: [Python-Dev] PEP 461 Final?

2014-01-17 Thread Chris Angelico
On Sat, Jan 18, 2014 at 12:51 PM, Ethan Furman wrote: > It seems there are two possibilities with %a: > > 1) have it be ascii(repr(obj)) Wouldn't that be redundant? ascii() is already repr()-like. ChrisA ___ Python-Dev mailing list Python-Dev@python.

Re: [Python-Dev] .clinic.c vs .c.clinic

2014-01-18 Thread Chris Angelico
On Sat, Jan 18, 2014 at 8:02 PM, Serhiy Storchaka wrote: > 2. I'm not use any IDE, but if you use, it can be important for you. If IDE > shows sources tree, unlikely you want to see generated *.clinic.c files in > them. This will increase the list of sources almost twice. A point for the contrary

Re: [Python-Dev] Enable Hostname and Certificate Chain Validation

2014-01-22 Thread Chris Angelico
On Wed, Jan 22, 2014 at 11:15 PM, Donald Stufft wrote: > Do you really think those people would be making the same complaints > if they could restore the previous behavior with a simple boolean flag > delivered either via environment variable or in their own code? You assume that it's easy to twe

Re: [Python-Dev] Enable Hostname and Certificate Chain Validation

2014-01-22 Thread Chris Angelico
On Thu, Jan 23, 2014 at 1:08 AM, Jesse Noller wrote: >> Now, maybe it wouldn't be a problem if the fix is an environment >> variable, but imagine a thousand-computer deployment and you have to >> tweak the environment on all of them. Feel like doing that just >> because the newest Python needs it?

Re: [Python-Dev] str.rreplace

2014-01-24 Thread Chris Angelico
On Sat, Jan 25, 2014 at 3:38 AM, Antoine Pitrou wrote: > On Fri, 24 Jan 2014 18:32:17 +0200 > Ram Rachum wrote: >> Question: Why is there no str.rreplace in Python? > > What would it do? > (also, I think such questions are better asked on python-ideas) Or python-list. Chances are there's a way t

Re: [Python-Dev] str.rreplace

2014-01-24 Thread Chris Angelico
On Sat, Jan 25, 2014 at 4:19 AM, Ram Rachum wrote: > I now looked at the 17 most recent python-list threads. Out of them: > > - 58% are about third-party packages. > - 17% are off-topic (not even programming related) > - 11% are 2-vs-3 discussions > - 5% are job offers. > - 5% (which is just

Re: [Python-Dev] Quick poll: should help() show bound arguments?

2014-01-25 Thread Chris Angelico
On Sat, Jan 25, 2014 at 3:07 PM, Larry Hastings wrote: > What should it be? > > A) pydoc and help() should not show bound parameters in the signature, like > inspect.signature. > B) pydoc and help() should show bound parameters in the signature, like > inspect.getfullargspec. Vote for A. As far a

Re: [Python-Dev] PyPI offline, status is ok

2014-02-10 Thread Chris Angelico
On Mon, Feb 10, 2014 at 5:23 PM, anatoly techtonik wrote: > http://status.python.org/ shows all green > > https://pypi.python.org/pypi/gazest shows > > Error 503 backend read error > > backend read error > > Guru Meditation: > > XID: 2792709923 Working for me. But then, your email only just came

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-14 Thread Chris Angelico
On Fri, Feb 14, 2014 at 7:04 PM, Chris Withers wrote: > > To implement __lt__ in Python 2, I could do: > > def __lt__(self, other): > if not isinstance(other, Range): > return True > return ((self._lower, self._upper, self._bounds) < > (other._lower,

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-14 Thread Chris Angelico
On Fri, Feb 14, 2014 at 9:20 PM, Antoine Pitrou wrote: > Hmm, it seems you're right, but I'm quite sure some DBMSes have a > consistent way of ordering NULLs when using ORDER BY on a nullable > column. Yes, and I believe it's part of the SQL-92 spec. Certainly here's PostgreSQL's take on the matt

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-14 Thread Chris Angelico
On Fri, Feb 14, 2014 at 9:42 PM, Nick Coghlan wrote: > IIRC, MySQL and PostgreSQL sort them in the opposite order from each > other Ouch! You're right: http://dev.mysql.com/doc/refman/5.7/en/working-with-null.html """When doing an ORDER BY, NULL values are presented first if you do ORDER BY ...

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-14 Thread Chris Angelico
On Sat, Feb 15, 2014 at 4:14 AM, Chris Barker wrote: > (though it could get a bit tricky -- what would AlwaysGreater > float('inf") > evaluate to? > It'd be true. AlwaysGreater is greater than infinity. It is greater than float("nan"). It is greater than the entire concept of floating point. It i

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-17 Thread Chris Angelico
On Tue, Feb 18, 2014 at 1:30 AM, M.-A. Lemburg wrote: >> >> Also think of the implications of changing None at this point. It would >> allow us to write programs that work Python >= 3.5 and Python <= 2.7, but >> fail mysteriously in all other versions in between. What a mess that would >> be...

Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014-02-18 Thread Chris Angelico
On Wed, Feb 19, 2014 at 3:10 AM, Mark Lawrence wrote: > Sorry if this has already been suggested, but why not introduce a new > singleton to make the database people happier if not happy? To avoid > confusion call it dbnull? A reasonable compromise or complete cobblers? :) That would be a major

[Python-Dev] PEPs don't redirect on python.org

2014-02-19 Thread Chris Angelico
Apologies if this is misdirected! I notice the switch to the new python.org web site has happened; but now PEPs are simply 404: http://www.python.org/dev/peps/pep-0008/ However, trimming the URL offers a redirect: http://www.python.org/dev/peps/ -> http://legacy.python.org/dev/peps/ from whi

Re: [Python-Dev] PEPs don't redirect on python.org

2014-02-19 Thread Chris Angelico
On Thu, Feb 20, 2014 at 10:25 AM, Chris Angelico wrote: > I notice the switch to the new python.org web site has happened; but > now PEPs are simply 404: > > http://www.python.org/dev/peps/pep-0008/ > > However, trimming the URL offers a redirect: > > http:/

[Python-Dev] PEP 463: Exception-catching expressions

2014-02-20 Thread Chris Angelico
PEP: 463 Title: Exception-catching expressions Version: $Revision$ Last-Modified: $Date$ Author: Chris Angelico Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 15-Feb-2014 Python-Version: 3.5 Post-History: 16-Feb-2014, 21-Feb-2014 Abstract Just as PEP 308

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-20 Thread Chris Angelico
On Fri, Feb 21, 2014 at 3:54 PM, Ethan Furman wrote: > (I'll vote on the syntax when the bikeshedding begins ;). Go get the keys to the time machine! Bikeshedding begins a week ago. ChrisA ___ Python-Dev mailing list Python-Dev@python.org https://mail.

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Fri, Feb 21, 2014 at 10:35 PM, Nick Coghlan wrote: > On 21 February 2014 13:15, Chris Angelico wrote: >> PEP: 463 >> Title: Exception-catching expressions > Great work on this Chris - this is one of the best researched and > justified Python syntax proposals I've

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Fri, Feb 21, 2014 at 11:37 PM, Paul Moore wrote: > On 21 February 2014 11:35, Nick Coghlan wrote: >>> Just as PEP 308 introduced a means of value-based conditions in an >>> expression, this system allows exception-based conditions to be used >>> as part of an expression. >> >> Great work on th

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 12:53 AM, Nick Coghlan wrote: > On 21 February 2014 22:42, Chris Angelico wrote: >> People can already write: >> >> if (x if y else z): >> >> without the parens, and it works. Readability suffers when the same >> keyword is used twic

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:59 AM, Chris Angelico wrote: > I've spent the better part of the last hour debating this in my head. > It's basically a question of simplicity versus future flexibility: > either keep the syntax clean and deny the multiple-except-clause > option,

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:50 AM, Antoine Pitrou wrote: > On Sat, 22 Feb 2014 00:28:01 +1000 > Nick Coghlan wrote: >> >> Neither of these objections addresses the problems with the status quo, >> though: >> >> - the status quo encourages overbroad exception handling (as >> illustrated by examples

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:03 AM, Eli Bendersky wrote: > Chris, while I also commend you for the comprehensive PEP, I'm -1 on the > proposal, for two main reasons: > > 1. Many proposals suggest new syntax to gain some succinctness. Each has to > be judged for its own merits, and in this case IMHO t

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:22 AM, Rob Cliffe wrote: > Small point: in one of your examples you give a plug for the PEP "note the > DRY improvement". > I would suggest that similarly > perhaps in your Lib/tarfile.py:2198 example you point out the increase > in readability due to the 2 lines lini

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:34 AM, Brett Cannon wrote: > While I like the general concept, I agree that it looks too much like a > crunched statement; the use of the colon is a non-starter for me. I'm sure > I'm not the only one whose brain has been trained to view a colon in Python > to mean "state

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 2:19 AM, Brett Cannon wrote: > I understand you are arguing that a try expression will lead to people just > doing `something() except Exception: None` or whatever and that people will > simply get lazy and not think about what they are doing with their > exceptions. Unfort

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 3:46 AM, Eric Snow wrote: > Be sure to capture in the PEP (within reason) a summary of concerns > and rebuttals/acquiescence. Eli's, Brett's, and Antoine's concerns > likely reflect what others are thinking as well. The PEP and its > result will be better for recording su

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 4:32 AM, Antoine Pitrou wrote: >> value = (expr except Exception then default) > > +0.5 > But I'm aware it requires reserving "then" as a keyword, which might > need a prior SyntaxWarning. There are no instances of "then" used as a name in the Python stdlib, I already chec

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
b/tarfile.py:2198: >> try: >> g = grp.getgrnam(tarinfo.gname)[2] >> except KeyError: >> g = tarinfo.gid >> try: >> u = pwd.getpwnam(tarinfo.uname)[2] >> exce

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 9:06 AM, Greg Ewing wrote: > Nick Coghlan wrote: >> >> On 21 February 2014 13:15, Chris Angelico wrote: >> >>> Generator expressions require parentheses, unless they would be >>> strictly redundant. Ambiguities with except expres

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:29 AM, Greg Ewing wrote: > Antoine Pitrou wrote: > >>>lst = [1, 2] >>>value = lst[2] except IndexError: "No value" >> >> >> the gain in concision is counterbalanced by a loss in >> readability, > > > This version might be more readable: > >value = lst[2] exce

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 12:10 PM, Glenn Linderman wrote: > Here's a challenge: There has been a big thread about None versus (SQL) > Null. Show how an except: expression can help the DB API more easily convert > from using None to using a new Null singleton, and you'll have a winner :) Heh! I'm n

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 12:55 PM, Greg Ewing wrote: > Steven D'Aprano wrote: > >> result = computation( >> int(arg) except ValueError: abort("Invalid int") >> ) >> >> Actually, not quite so nice as I first thought, since you're relying on >> the side-effects o

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 1:07 PM, Victor Stinner wrote: > At the first read, I'm unable to understand this long expression. At > the second read, I'm still unable to see which instruction will be > executed first: lvl1[key] or lvl2[key]? > > The advantage of the current syntax is that the control f

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 3:04 PM, Chris Angelico wrote: > On Sat, Feb 22, 2014 at 1:07 PM, Victor Stinner > wrote: >> At the first read, I'm unable to understand this long expression. At >> the second read, I'm still unable to see which instruction will be >> exe

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-21 Thread Chris Angelico
On Sat, Feb 22, 2014 at 4:01 PM, Steven D'Aprano wrote: > (Chris, I think that ought to go in the motivation section of the PEP.) Added to my draft, and here's the peps diff: diff -r c52a2ae3d98e pep-0463.txt --- a/pep-0463.txt Fri Feb 21 23:27:51 2014 -0500 +++ b/pep-0463.txt Sat Feb 22 16:33:3

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 8:20 PM, Antoine Pitrou wrote: > On Sat, 22 Feb 2014 16:12:27 +0900 > "Stephen J. Turnbull" wrote: >> >> Note in support: I originally thought that "get" methods would be more >> efficient, but since Nick pointed out that "haveattr" is implemented >> by catching the except

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:57 AM, Greg Ewing wrote: > Nick Coghlan wrote: >> >> As Chris later noted, you likely *could* still implement expression >> local name binding for an except expression without a full closure, it >> would just be rather difficult. > > > I'm still not convinced it would be

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 8:58 PM, Antoine Pitrou wrote: > On Sat, 22 Feb 2014 20:29:27 +1100 > Chris Angelico wrote: >> >> Which means that, fundamentally, EAFP is the way to do it. So if PEP >> 463 expressions had existed from the beginning, hasattr() probably >&

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 9:17 PM, Antoine Pitrou wrote: > On Sat, 22 Feb 2014 21:09:07 +1100 > Chris Angelico wrote: >> On Sat, Feb 22, 2014 at 8:58 PM, Antoine Pitrou wrote: >> > On Sat, 22 Feb 2014 20:29:27 +1100 >> > Chris Angelico wrote: >> >> >

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:01 PM, Greg Ewing wrote: > Chris Angelico wrote: >> >> On Sat, Feb 22, 2014 at 10:57 AM, Greg Ewing >> wrote: >> >>> I'm still not convinced it would be all *that* difficult. >>> Seems to me it would be semantically

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:27 PM, Antoine Pitrou wrote: > Yeah, none of these examples makes a convincing case that hasattr() is > useless, IMO. I'm not trying to make the case that it's useless. I'm trying to show that, if it didn't exist, all of these would be written some other way, and the ca

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 11:14 PM, Stephen J. Turnbull wrote: > Antoine Pitrou writes: > > On Sat, 22 Feb 2014 22:13:58 +1100 > > Chris Angelico wrote: > > > > hasattr(x,"y") <-> (x.y or True except AttributeError: False) > > > But it

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sun, Feb 23, 2014 at 11:00 AM, Thomas Wouters wrote: > On Sat, Feb 22, 2014 at 2:08 AM, Thomas Wouters wrote: >> >> (FWIW, I have a working patch without tests that allows all of these, I'll >> upload it tonight so people can play with it. Oh, and FWIW, currently I'm +0 >> on the idea, -0 on t

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Chris Angelico
On Sun, Feb 23, 2014 at 12:56 PM, Ethan Furman wrote: > Open Questions > == > > It has been suggested to use ``%b`` for bytes as well as ``%s``. > > - Pro: clearly says 'this is bytes'; should be used for new code. > > - Con: does not exist in Python 2.x, so we would have two ways

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-23 Thread Chris Angelico
On Mon, Feb 24, 2014 at 6:26 AM, Thomas Wouters wrote: >> I see a risk of interfering with in-place assignment operators, e.g. >> >> x /= y except ZeroDivisionError: 1 >> >> might not do what one could expect, because (as I assume) it would behave >> differently from >> >> x = x / y except

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-23 Thread Chris Angelico
On Mon, Feb 24, 2014 at 7:51 AM, Ethan Furman wrote: >> Yes. Augmented assignment is still assignment, so a statement. The only >> way to parse that is as >> >> x /= (y except ZeroDivisionError: 1) > > > Well, that is certainly not what I would have expected. I can see that you'd want to have tha

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-24 Thread Chris Angelico
On Tue, Feb 25, 2014 at 11:27 AM, Jim J. Jewett wrote: > This also makes me wonder whether the cost of a subscope > (for exception capture) could be limited to when an > exception actually occurs, and whether that might lower > the cost enough to make the it a good tradeoff. > > def myfunc1(a,

Re: [Python-Dev] Python Remote Code Execution in socket.recvfrom_into()

2014-02-25 Thread Chris Angelico
On Tue, Feb 25, 2014 at 11:59 PM, Maciej Fijalkowski wrote: >> Last issues: >> - hash DoS > > is this fixed? Yes, hash randomization was added as an option in 2.7.3 or 2.7.4 or thereabouts, and is on by default in 3.3+. You do have to set an environment variable for 2.7 (and I think 2.6 got that

Re: [Python-Dev] Python Remote Code Execution in socket.recvfrom_into()

2014-02-25 Thread Chris Angelico
On Wed, Feb 26, 2014 at 12:07 AM, Maciej Fijalkowski wrote: > No, the hash randomization is broken, it does not provide enough > randomness (without changing the hash function which only happened in > 3.4+) Hmm, I don't remember reading about that - got a link to more info? Or was that report kep

Re: [Python-Dev] Python Remote Code Execution in socket.recvfrom_into()

2014-02-25 Thread Chris Angelico
On Wed, Feb 26, 2014 at 12:21 AM, Donald Stufft wrote: > Instead of pre-generating one set of values that can be be used to DoS things > you have to pre-generate 256 sets of values and try them until you get the > right one. It’s like putting on armor made of paper and saying it’s harder to > stab

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 7:44 PM, Ronald Oussoren wrote: > What about (also mentioned in the PEP)? > > value = (expr except Exception try default) > > This seems to read nicely, although “try” is at a completely different > position than it is in the equivalent try statement. > > I like the gene

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 9:44 PM, Ronald Oussoren wrote: >> expr except Exception try default # "try" indicates the initial expr, >> not the default > > I didn’t parse the expression this way at all, but quite naturally parsed is > as “use expr, and try using default if expr raises Exception” and

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 6:36 AM, Glenn Linderman wrote: > +1 > > f() except ((TypeError, AttributeError): "No value") > > is a nice extension to the idea of > > value = expr except ( > Exception1: default1, > Exception2: default2, > Exception3: default3, >) > >

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
I've added another utility script to my PEP draft repo: https://github.com/Rosuav/ExceptExpr/blob/master/replace_except_expr.py It's built out of some pretty horrendous hacks, it makes some assumptions about code layout (eg spaces for indentation, and a try/except block never has anything else on

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 8:29 AM, Chris Angelico wrote: > @@ -43,6 +43,34 @@ > > * statistics.mean(data) - no way to handle an empty iterator > > +Had this facility existed early in Python's history, there would have been > +no need to create dict.get() and related methods;

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 10:33 AM, Nick Coghlan wrote: > > On 28 Feb 2014 05:56, "Chris Angelico" wrote: >> >> On Fri, Feb 28, 2014 at 6:36 AM, Glenn Linderman >> wrote: >> > +1 >> > >> > f() except ((TypeError, AttributeErr

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 1:12 PM, Glenn Linderman wrote: > Yes. But the point is really the location of the (), sorry if my "nice > extension" comment is throwing you off that track. Ah! I see. We touched on this syntax on -ideas, but at the time, the proposed syntax didn't have parens around th

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Fri, Feb 28, 2014 at 6:38 PM, Glenn Linderman wrote: > Whereas the current PEP syntax has ambiguity regarding how to interpret > a-expr except except-list-b: b-expr except except-list-c: c-expr (does the > 2nd except apply to a-expr or b-expr?), without parentheses, and, as far as > I am concer

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Fri, Feb 28, 2014 at 8:30 PM, Glenn Linderman wrote: > > Are there any other expressions that allow parens around a part of the > > expression, without the stuff inside them becoming a completely > > separate sub-expression? > > > Sure. Function invocation. You can claim (and it is accurate) t

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Fri, Feb 28, 2014 at 11:51 PM, Nick Coghlan wrote: > So I think that on balance, I actually do prefer your current > proposal. That said, I do think this is a variant worth discussing > explicitly in the PEP, if only to remind people that there's > definitely precedent for using a colon to sepa

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Fri, Feb 28, 2014 at 11:51 PM, Nick Coghlan wrote: >>> > Are there any other expressions that allow parens around a part of the >>> > expression, without the stuff inside them becoming a completely >>> > separate sub-expression? > > Also generator expressions and most uses of yield or yield fro

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Sat, Mar 1, 2014 at 12:24 AM, Nick Coghlan wrote: > Yeah, that works. You may also want to add a "common objections" > section to explicitly cover the "but colons introduce suites" > objection. That would provide a space to explicitly list all of the > current "not introducing a suite" use case

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-28 Thread Chris Angelico
On Sat, Mar 1, 2014 at 12:24 PM, Glenn Linderman wrote: > You are overlooking that the keyword except provides exactly the connotation > of lazy evaluation, so if this is your only reason for preferring the lambda > syntax, you just erased it :) Statements are always executed sequentially. That's

[Python-Dev] "Five reviews to get yours reviewed"?

2014-03-01 Thread Chris Angelico
Way back in 2012, Martin Löwis declared a standing offer on this list to get issue patches reviewed: review five issues and he'll review one of yours. [1] Is that offer still around? Have any other devs made any similar offer? I have a couple of patches outstanding, notably issue 20249 [2], which

Re: [Python-Dev] "Five reviews to get yours reviewed"?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 11:11 AM, Chris Angelico wrote: > I have a couple of patches outstanding, notably issue 20249 [2], which > is a small change, has a patch, and has no activity or nosying since > its creation. And Benjamin Peterson has just looked into this one and committed it,

Re: [Python-Dev] "Five reviews to get yours reviewed"?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 11:25 AM, Antoine Pitrou wrote: > On Sun, 2 Mar 2014 11:11:01 +1100 > Chris Angelico wrote: >> More importantly, if there is such an offer, it'd be great to mention >> it somewhere, so people can know what they can do to move an issue >> fo

Re: [Python-Dev] "Five reviews to get yours reviewed"?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:07 PM, Terry Reedy wrote: > On 3/1/2014 7:11 PM, Chris Angelico wrote: >> I have a couple of patches outstanding, notably issue 20249 [2], which >> is a small change, has a patch, and has no activity or nosying since >> its creation. >

Re: [Python-Dev] "Five reviews to get yours reviewed"?

2014-03-02 Thread Chris Angelico
On Sun, Mar 2, 2014 at 7:48 PM, Terry Reedy wrote: > On 3/2/2014 1:51 AM, Chris Angelico wrote: >> >> On Sun, Mar 2, 2014 at 4:07 PM, Terry Reedy wrote: >>> >>> On 3/1/2014 7:11 PM, Chris Angelico wrote: >>>> >>>> I have a couple of patc

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-03-05 Thread Chris Angelico
On Thu, Mar 6, 2014 at 7:57 AM, Thomas Wouters wrote: > On Thu, Feb 27, 2014 at 1:29 PM, Chris Angelico wrote: >> >> +Had this facility existed early in Python's history, there would have >> been >> +no need to create dict.get() and related methods; > >

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-03-05 Thread Chris Angelico
On Thu, Mar 6, 2014 at 7:57 AM, Thomas Wouters wrote: > All in all I believe I will continue to prefer specific methods for specific > use-cases; I'm -0 on the idea of an except-expression, -0 on the syntax with > the mandatory parentheses around the whole thing (and so far -1 on any of > the othe

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-03-05 Thread Chris Angelico
On Thu, Mar 6, 2014 at 12:03 PM, Thomas Wouters wrote: > PEP update pushed (changeset 59653081cdf6.) > Thanks for that! ChrisA ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://m

Re: [Python-Dev] Alternative forms [was: PEP 463: Exception-catching expressions]

2014-03-06 Thread Chris Angelico
On Fri, Mar 7, 2014 at 7:29 AM, Jim J. Jewett wrote: > > The PEP currently says: > >> Alternative Proposals >> = > >> Discussion on python-ideas brought up the following syntax suggestions:: > >>value = expr except default if Exception [as e] > > This one was rejected becau

Re: [Python-Dev] Alternative forms [was: PEP 463: Exception-catching expressions]

2014-03-07 Thread Chris Angelico
On Sat, Mar 8, 2014 at 5:58 AM, Jim J. Jewett wrote: > > (Thu Mar 6 23:26:47 CET 2014) Chris Angelico responded: > >> On Fri, Mar 7, 2014 at 7:29 AM, Jim J. Jewett >> wrote: > >>> [ note that "x if y" already occurs in multiple contexts, and >>

Re: [Python-Dev] What is the precise problem? [was: Reference cycles in Exception.__traceback__]

2014-03-08 Thread Chris Angelico
On Sat, Mar 8, 2014 at 9:06 PM, Victor Stinner wrote: > And MyObject is not destroyed which is an obvious memory leak, beause > there is no more explicit reference to it. And it doesn't seem to be getting put into gc.garbage, either, which is probably worth mentioning. You have __del__ in there,

Re: [Python-Dev] Why not make frames? [was: Alternative forms [was: PEP 463: Exception-catching expressions]]

2014-03-09 Thread Chris Angelico
On Mon, Mar 10, 2014 at 1:16 PM, Jim J. Jewett wrote: > On Fri Mar 7 20:54:31 CET 2014, Chris Angelico wrote: >> I don't see except expressions as fundamentally more associated with >> if/else than with, say, an or chain, which works left to right. > > I do, becau

Re: [Python-Dev] Scope issues [was: Alternative forms [was: PEP 463: Exception-catching expressions]]

2014-03-09 Thread Chris Angelico
On Mon, Mar 10, 2014 at 1:35 PM, Jim J. Jewett wrote: > The PEP should therefore explicitly state that implementation details > may force the deferral to be permanent, and that this is considered an > acceptable trade-off. How about words to this effect? """Should there be, in future, a way to c

Re: [Python-Dev] Python 4: don't remove anything, don't break backward compatibility

2014-03-10 Thread Chris Angelico
On Tue, Mar 11, 2014 at 3:56 AM, Antoine Pitrou wrote: > On Mon, 10 Mar 2014 17:04:08 +0100 > "Stefan Richthofer" wrote: > >> > Guido famously hates two digit minor version numbers. :) >> >> This is no problem either. Simply switch to hexadecimal numbering ;) > > Or wrap around to negative number

Re: [Python-Dev] Python 4: don't remove anything, don't break backward compatibility

2014-03-10 Thread Chris Angelico
On Tue, Mar 11, 2014 at 4:08 AM, R. David Murray wrote: > (That said, I > do see some merit to doing some extra cleaning at the 4.0 > boundary, just for mental convenience.) A transition from 3.9 to 4.0 that removes a whole lot of deprecated aliases and such wouldn't be a bad thing. It's technic

Re: [Python-Dev] Python 4: don't remove anything, don't break backward compatibility

2014-03-10 Thread Chris Angelico
On Tue, Mar 11, 2014 at 5:17 AM, Ryan Gonzalez wrote: > You forgot 3., and 3.$. > They're both earlier than digits. Comma is 2C and dollar is 24, I remember those from the earliest days of playing around in assembly language on an Epson PC-compatible running MS-DOS 5 :) But that's beside the poi

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-03-11 Thread Chris Angelico
On Wed, Mar 12, 2014 at 2:20 PM, Ethan Furman wrote: > I sure hope this is accepted. I could have used it at least a half-dozen > times in the last week -- which is more often than I would have used the > ternary-if! :) Where do we go from here? I've not made any edits for some time - no materi

[Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-11 Thread Chris Angelico
PEP 463, Exception-catching expressions, is stable and I believe ready for pronouncement. Drumroll please... http://www.python.org/dev/peps/pep-0463/ PEP: 463 Title: Exception-catching expressions Version: $Revision$ Last-Modified: $Date$ Author: Chris Angelico Status: Draft Type: Standards

Re: [Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 2:14 AM, Brett Cannon wrote: > While I'm +0 on the idea, I'm -1 on the syntax; I just don't like having a > colon in an expression. Which is why there are alternatives listed, and the best four of them (including the proposed one) ranked. ChrisA __

Re: [Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 2:44 AM, Barry Warsaw wrote: > That being said, the colon really bothers me, despite what is written in > "Common objections". True, colons are used in places other than suite > introduction, but with exception handling, colons *do* introduce a new suite, > so its use here

Re: [Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 4:09 AM, Guido van Rossum wrote: > But the thing I can't get behind are the motivation and rationale. I don't > think that e.g. dict.get() would be unnecessary once we have except > expressions, and I disagree with the position that EAFP is better than LBYL, > or "generally

Re: [Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 7:14 AM, Barry Warsaw wrote: > Interestingly enough, where ternaries are most useful are in the same > situations where I think exception expressions would be most useful, in the > setting of a variable or attribute to one of two different values. In both > branches of the

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 7:26 AM, "Martin v. Löwis" wrote: > I think you (or someone) first needs to find a BDFL delegate. > Traditionally, with syntax changes, there is a good chance that Guido > doesn't want to delegate at all, so ask him whether he wants to delegate > or not. He beat you to it;

<    1   2   3   4   5   6   7   8   9   10   >