Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Nick Coghlan
On 30 August 2017 at 16:40, Nick Coghlan wrote: > Writing an "update_parent_context" decorator is also trivial (and will > work for both sync and async generators): > > def update_parent_context(gf): > @functools.wraps(gf): > def wrapper(*args, **kwds): > gen = gf(*

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Nick Coghlan
On 30 August 2017 at 10:18, Yury Selivanov wrote: > On Tue, Aug 29, 2017 at 7:36 PM, Greg Ewing > wrote: > [..] >>> For (1) we want the context change to be isolated. For (2) you say >>> that the context change should propagate to the caller. >> >> >> No, I'm saying that the context change shou

Re: [Python-Dev] bpo-5001: More-informative multiprocessing error messages (#3079)

2017-08-29 Thread Serhiy Storchaka
30.08.17 01:52, Antoine Pitrou пише: https://github.com/python/cpython/commit/bd73e72b4a9f019be514954b1d40e64dc3a5e81c commit: bd73e72b4a9f019be514954b1d40e64dc3a5e81c branch: master author: Allen W. Smith, Ph.D committer: Antoine Pitrou date: 2017-08-30T00:52:18+02:00 summary: bpo-5001: More-

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 7:36 PM, Greg Ewing wrote: [..] >> For (1) we want the context change to be isolated. For (2) you say >> that the context change should propagate to the caller. > > > No, I'm saying that the context change should *always* > propagate to the caller, unless you do something

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 7:36 PM, Greg Ewing wrote: > Yury Selivanov wrote: >> >> While we want "yield from" to have semantics close to a function call, > > > That's not what I said! I said that "yield from foo()" should > have semantics close to a function call. If you separate the > "yield from"

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Greg Ewing
Yury Selivanov wrote: While we want "yield from" to have semantics close to a function call, That's not what I said! I said that "yield from foo()" should have semantics close to a function call. If you separate the "yield from" from the "foo()", then of course you can get different behaviours.

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 7:06 PM, Stefan Krah wrote: > On Tue, Aug 29, 2017 at 06:01:40PM -0400, Yury Selivanov wrote: >> PEP 550 positions itself as a replacement for TLS, and clearly defines >> its semantics for regular functions in a single thread, regular >> functions in multithreaded code, gen

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Stefan Krah
On Tue, Aug 29, 2017 at 06:01:40PM -0400, Yury Selivanov wrote: > PEP 550 positions itself as a replacement for TLS, and clearly defines > its semantics for regular functions in a single thread, regular > functions in multithreaded code, generators, and asynchronous code > (async/await). Everythin

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 5:45 PM, Greg Ewing wrote: [..] > What you seem to be suggesting is that generators shouldn't > leak context changes even when you *don't* use a with-statement. Yes, generators shouldn't leak context changes regardless of what and how changes the context inside them: va

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Greg Ewing
Yury Selivanov wrote: Consider the following generator: def gen(): with decimal.context(...): yield We don't want gen's context to leak to the outer scope That's understandable, but fixing that problem shouldn't come at the expense of breaking the ability to refacto

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 4:33 PM, Antoine Pitrou wrote: > > Le 29/08/2017 à 22:20, Yury Selivanov a écrit : >> >> 2) >> >>gvar = new_context_var() >>var = new_context_var() >> >>async def bar(): >># EC = [current_thread_LC_copy, Task_foo_LC_copy, Task_wait_for_LC] > > Ah, thanks

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 22:20, Yury Selivanov a écrit : > > 2) > >gvar = new_context_var() >var = new_context_var() > >async def bar(): ># EC = [current_thread_LC_copy, Task_foo_LC_copy, Task_wait_for_LC] Ah, thanks!... That explains things, though I don't expect most users to spo

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 4:10 PM, Antoine Pitrou wrote: [..] >> "await bar()" and "await wait_for(bar())" are actually quite >> different. Let me illustrate with an example: >> >> b1 = bar() >> # bar() is not running yet >> await b1 >> >> b2 = wait_for(bar()) >> # bar() was wra

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nathaniel Smith
On Tue, Aug 29, 2017 at 12:59 PM, Yury Selivanov wrote: > b2 = wait_for(bar()) > # bar() was wrapped into a Task and is being running right now > await b2 Ah not quite. wait_for is itself implemented as a coroutine, so it doesn't spawn off bar() into its own task until you await b

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 21:59, Yury Selivanov a écrit : > > This absolutely needs to be fixed, and the only way (that I know) it > can be fixed is to revert the "every coroutine has its own LC" > statement (going back to the semantics coroutines had in PEP 550 v2 > and v3). I completely agree with this.

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nathaniel Smith
On Tue, Aug 29, 2017 at 12:32 PM, Antoine Pitrou wrote: > > > Le 29/08/2017 à 21:18, Yury Selivanov a écrit : >> On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >>> On Mon, 28 Aug 2017 17:24:29 -0400 >>> Yury Selivanov wrote: Long story short, I think we need to rollback our last dec

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 3:32 PM, Antoine Pitrou wrote: > > > Le 29/08/2017 à 21:18, Yury Selivanov a écrit : >> On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >>> On Mon, 28 Aug 2017 17:24:29 -0400 >>> Yury Selivanov wrote: Long story short, I think we need to rollback our last deci

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 21:18, Yury Selivanov a écrit : > On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >> On Mon, 28 Aug 2017 17:24:29 -0400 >> Yury Selivanov wrote: >>> Long story short, I think we need to rollback our last decision to >>> prohibit context propagation up the call stack in co

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: > On Mon, 28 Aug 2017 17:24:29 -0400 > Yury Selivanov wrote: >> Long story short, I think we need to rollback our last decision to >> prohibit context propagation up the call stack in coroutines. In PEP >> 550 v3 and earlier, the following s

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Mon, Aug 28, 2017 at 7:16 PM, Yury Selivanov wrote: > On Mon, Aug 28, 2017 at 6:56 PM, Greg Ewing > wrote: >> Yury Selivanov wrote: >>> >>> I saying that the following should not work: >>> >>> def nested_gen(): >>> set_some_context() >>> yield >>> >>> def gen(): >>>

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
On Mon, 28 Aug 2017 17:24:29 -0400 Yury Selivanov wrote: > Long story short, I think we need to rollback our last decision to > prohibit context propagation up the call stack in coroutines. In PEP > 550 v3 and earlier, the following snippet would work just fine: > >var = new_context_var() >

Re: [Python-Dev] Pep 550 module

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 10:47 AM, Guido van Rossum wrote: > On Tue, Aug 29, 2017 at 6:46 AM, Elvis Pranskevichus > wrote: >> >> On Tuesday, August 29, 2017 9:14:53 AM EDT Yury Selivanov wrote: >> > On Tue, Aug 29, 2017 at 6:53 AM, Nick Coghlan >> wrote: >> > > Given the refocusing of the PEP on

Re: [Python-Dev] [Security-sig] PEP 551: Security transparency in the Python runtime

2017-08-29 Thread Wes Turner
On Tuesday, August 29, 2017, Steve Dower wrote: > On 29Aug2017 0801, Steve Dower wrote: > >> On 29Aug2017 0614, Wes Turner wrote: >> >>> Wouldn't it be great to have the resources to source audit all code? >>> (And expect everyone to GPG sign all their commits someday.) >>> >> >> If you care this

Re: [Python-Dev] [Security-sig] PEP 551: Security transparency in the Python runtime

2017-08-29 Thread Steve Dower
On 29Aug2017 0801, Steve Dower wrote: On 29Aug2017 0614, Wes Turner wrote: Wouldn't it be great to have the resources to source audit all code? (And expect everyone to GPG sign all their commits someday.) If you care this much, then you will find the resources to audit all the code manually a

Re: [Python-Dev] [Security-sig] PEP 551: Security transparency in the Python runtime

2017-08-29 Thread Steve Dower
On 29Aug2017 0614, Wes Turner wrote: Wouldn't it be great to have the resources to source audit all code? (And expect everyone to GPG sign all their commits someday.) If you care this much, then you will find the resources to audit all the code manually after you've downloaded it and before yo

Re: [Python-Dev] Pep 550 module

2017-08-29 Thread Guido van Rossum
On Tue, Aug 29, 2017 at 6:46 AM, Elvis Pranskevichus wrote: > On Tuesday, August 29, 2017 9:14:53 AM EDT Yury Selivanov wrote: > > On Tue, Aug 29, 2017 at 6:53 AM, Nick Coghlan > wrote: > > > Given the refocusing of the PEP on the context variable API, with > > > the > > > other aspects introduc

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Nick Coghlan
On 29 August 2017 at 23:18, Yury Selivanov wrote: > On Tue, Aug 29, 2017 at 5:01 AM, Nick Coghlan wrote: > [..] >> P.S. And I say that as a reader who correctly guessed why you had >> changed the method name in the current iteration of the proposal. I'm >> sympathetic to those reasons, but I thin

Re: [Python-Dev] Pep 550 module

2017-08-29 Thread Elvis Pranskevichus
On Tuesday, August 29, 2017 9:14:53 AM EDT Yury Selivanov wrote: > On Tue, Aug 29, 2017 at 6:53 AM, Nick Coghlan wrote: > > On 28 August 2017 at 01:51, Jim J. Jewett wrote: > >> I think there is general consensus that this should go in a module > >> other than sys. (At least a submodule.) > >>

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 5:01 AM, Nick Coghlan wrote: [..] > P.S. And I say that as a reader who correctly guessed why you had > changed the method name in the current iteration of the proposal. I'm > sympathetic to those reasons, but I think sticking with the > conventional API will make this one

Re: [Python-Dev] Pep 550 module

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 6:53 AM, Nick Coghlan wrote: > On 28 August 2017 at 01:51, Jim J. Jewett wrote: >> I think there is general consensus that this should go in a module other >> than sys. (At least a submodule.) >> >> The specific names are still To Be Determined, but I suspect seeing the >>

Re: [Python-Dev] [Security-sig] PEP 551: Security transparency in the Python runtime

2017-08-29 Thread Wes Turner
On Monday, August 28, 2017, Steve Dower wrote: > On 28Aug2017 1834, Gregory P. Smith wrote: > >> My gut feeling says that there are N interpreters available on just >> about every bloated system image out there. Multiple pythons are often >> among them, other we do not control will also continue

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nick Coghlan
On 29 August 2017 at 07:24, Yury Selivanov wrote: > This means that PEP 550 will have a caveat for async code: don't rely > on context propagation up the call stack, unless you are writing > __aenter__ and __aexit__ that are guaranteed to be called without > being wrapped into a Task. I'm not sur

Re: [Python-Dev] Pep 550 module

2017-08-29 Thread Nick Coghlan
On 28 August 2017 at 01:51, Jim J. Jewett wrote: > I think there is general consensus that this should go in a module other > than sys. (At least a submodule.) > > The specific names are still To Be Determined, but I suspect seeing the > functions and objects as part of a named module will affect

Re: [Python-Dev] PEP 550 v4

2017-08-29 Thread Nick Coghlan
On 27 August 2017 at 03:23, Yury Selivanov wrote: > On Sat, Aug 26, 2017 at 1:23 PM, Ethan Furman wrote: >> On 08/26/2017 09:25 AM, Yury Selivanov wrote: >>> ContextVar.lookup() method *traverses the stack* until it finds the LC >>> that has a value. "get()" does not reflect this subtle semantic