Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'python': 0.11; 'changes': 0.15; '>>': 0.16; 'cached': 0.16; 'dict': 0.16; 'kasper': 0.16; 'modified.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'seems': 0.21; 'visible': 0.24; '>': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'kept': 0.65; 'detail.': 0.68; 'stated': 0.69; 'around,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=UVslWKwQJ10tDIa7+8wlAjK0ei+9D8WiN31vpYphKsU=; b=Esm6WEtIj+nPQq2CraHCEI0UgJoSQp/BYpAm9Qhl5B3Pq7ptSP0k4RRVMDIpTv3oSl +ZKr9WRJf69GXUBzKAVsRAeHnxCMkmzEqfhzWM9VG4CtQGy6aC3YNE5/BZc0chdbUajm kSN4J7q1SqjX+R4pAIif2awNX9VB3HbIXnCQ3Czi7+fpurKQDCHgusTNe0DvBeuZ4AwJ NHon5rqFJ0Vka/mIEoTFlRjVEpDYj2PyTPUo7y7O31ikRZi3iPJDaM1Gh6BjRXeex/dn woaOfVMgZIbDbxKt+E26w3TAnPuT8GCZ5NnycSAgayCV4I0q/ampSDv0SoqzsncxlJsl n/DQ== X-Received: by 10.66.227.41 with SMTP id rx9mr15783197pac.153.1417707770127; Thu, 04 Dec 2014 07:42:50 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Thu, 4 Dec 2014 08:42:09 -0700 Subject: Re: PyEval_GetLocals and unreferenced variables To: Python Content-Type: multipart/alternative; boundary=047d7b111f8708ac9c050965d0f7 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417707778 news.xs4all.nl 2859 [2001:888:2000:d::a6]:58627 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81911 --047d7b111f8708ac9c050965d0f7 Content-Type: text/plain; charset=UTF-8 On Wed, Dec 3, 2014 at 5:28 AM, Gregory Ewing wrote: > > Kasper Peeters wrote: >> >> That may have been the design plan, but in Python 2.7.6, I definitely >> am able to inject locals via PyEval_GetLocals() and have them be visible >> both from the C and Python side; > > What seems to be happening is that the dict created by > PyEval_GetLocals() is kept around, so you can change it > and have the changes be visible through locals() in > Python. That the dict is cached is an implementation detail. It's not advisable to rely upon this, and as stated in the Python docs, the locals dict should not be modified. --047d7b111f8708ac9c050965d0f7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Wed, Dec 3, 2014 at 5:28 AM, Gregory Ewing <greg.ewing@canterbury.ac.nz>= wrote:
>
> Kasper Peeters wrote:
>>
>> That = may have been the design plan, but in Python 2.7.6, I definitely
>>= ; am able to inject locals via PyEval_GetLocals() and have them be visible<= br>>> both from the C and Python side;
>
> What seems to = be happening is that the dict created by
> PyEval_GetLocals() is kept= around, so you can change it
> and have the changes be visible throu= gh locals() in
> Python.

That the dict is cached is an im= plementation detail. It's not advisable to rely upon this, and as state= d in the Python docs, the locals dict should not be modified.
--047d7b111f8708ac9c050965d0f7--