Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81911

Re: PyEval_GetLocals and unreferenced variables

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 <ian.g.kelly@gmail.com>
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; '&gt;&gt;': 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; '&gt;': 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 <ce8dv5Fm877U1@mid.individual.net>
References <mailman.70.1417604405.15533.python-list@python.org> <mailman.16527.1417605559.18130.python-list@python.org> <ce8dv5Fm877U1@mid.individual.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 4 Dec 2014 08:42:09 -0700
Subject Re: PyEval_GetLocals and unreferenced variables
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16561.1417707778.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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
>> 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.

Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: PyEval_GetLocals and unreferenced variables Kasper Peeters <kasper@phi-sci.com> - 2014-12-03 11:18 +0000
  Re: PyEval_GetLocals and unreferenced variables Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-04 01:28 +1300
    Re: PyEval_GetLocals and unreferenced variables Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-04 08:42 -0700

csiph-web