anatoly techtonik added the comment:
Attached localtest2.py where an empty locals() call changes behavior.
--- localtest.pyWed Mar 27 19:48:06 2013
+++ localtest2.py Wed Mar 27 19:45:19 2013
@@ -3,6 +3,7 @@
def X():
l = locals()
i = foo
+locals()
print(Is 'i'
Terry J. Reedy added the comment:
Calling locals() updates the dict, just as documented.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7083
___
Changes by Eric Snow ericsnowcurren...@gmail.com:
--
superseder: - Document the circumstances where the locals() dict gets updated
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7083
___
anatoly techtonik added the comment:
Any progress on that? After a month I am inclined that this behavior should be
fixed, not only documented. The correct documentation is:
NOTE: The variable returned by locals() is sporadically updated by core
interpreter.
--
versions: +Python 3.2,
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
versions: -Python 2.4, Python 2.5, Python 2.6, Python 3.1, Python 3.2, Python
3.5
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7083
___
Terry J. Reedy added the comment:
Anatoly, please stop playing with the headers. It is meaningless and
irritating, especially when you set them wrong. The 3.5 choice is for issues
that will *not* apply before then. An example is actually making a change
warned about in a deprecation warning.
anatoly techtonik added the comment:
After a day of meditation I've come to the following definition for locals():
locals() return a dictionary that serves as a cache for current local symbol
table. This cache is updated every time locals() is called or when a trace
function is active.
Terry J. Reedy added the comment:
I agree now that the doc should be clearer (and this issue reopened). For one
thing, the exact CPython behavior is an implementation issue rather than a
language requirement. Which is to say, its behavior is allowed but not
required. I believe an
anatoly techtonik added the comment:
I'm 3rd to vote for reopening this issue to clarify documentation or to fix
(read below).
== Why it is important to fix
1. First personal user story. Until I saw the localstest.py I couldn't figure
out what all locals() definitions are talking about.
Ned Batchelder added the comment:
I wrote about this here:
http://nedbatchelder.com/blog/201211/tricky_locals.html A reader suggested
this addition to the docs, which I like:
Multiple invocations within the scope update and return the same dictionary
instance. When a trace function is in
Ned Batchelder added the comment:
ITSM this could use more clarification. It is subtle and baffling. I'm
struggling to come up with sentences to make it clearer, though.
--
nosy: +nedbat
___
Python tracker rep...@bugs.python.org
New submission from André Bjärby andre.bja...@gmail.com:
Running the attached script shows that locals() behaves differently
depending on whether sys.settrace() is active.
This does not occur when calling locals() in the global scope, only when
used inside functions.
--
components:
Antoine Pitrou pit...@free.fr added the comment:
The same is thing is true of the frame's f_locals attribute. This
attribute is a copy of the local variables in the frame, because the
internal storage of these variables is a raw C array for faster access.
This copy is only synchronized back when
Guido van Rossum gu...@python.org added the comment:
So there's no bug here right? It's even documented.
--
nosy: +gvanrossum
resolution: - rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7083
André Bjärby andre.bja...@gmail.com added the comment:
It's documented that The contents of this dictionary should not be
modified; changes may not affect the values of local variables used by
the interpreter.
The script does the opposite. Perhaps an addition to the documentation?
The contents
Changes by Antoine Pitrou pit...@free.fr:
--
assignee: - georg.brandl
components: +Documentation -Extension Modules, Interpreter Core
nosy: +georg.brandl
versions: +Python 2.7, Python 3.2 -Python 2.4, Python 2.5
___
Python tracker
Terry J. Reedy tjre...@udel.edu added the comment:
I think the doc is clear enough if one reads and believes it. The main
doc is Update and return a dictionary representing the current local
symbol table. That pretty clearly says that subsequent changes to the
local symbol table may make the
Changes by André Bjärby andre.bja...@gmail.com:
--
components: +Extension Modules, Interpreter Core -Documentation
nosy: -andbj
versions: +Python 2.4, Python 2.5 -Python 2.7, Python 3.2
___
Python tracker rep...@bugs.python.org
18 matches
Mail list logo