New submission from Stephen Vavasis <[email protected]>:
There seems to be a serious bug in how python 2.7.2 binds variables to values.
In the attached function buildfunclist, you see that there is a variable called
'funclist' that is initialized to [], and then is modified only with 'append'
calls. This means that once append is called 46 times, one expects that
funclist[45] is defined and will not change? And yet funclist[45] changes
several times as more data items are appended. The same bug is present in
3.2.2. My operating system is Windows 7 64-bit on a Lenovo Thinkpad T410. I'm
guessing that there is a problem with python's lazy copying-- it is a bit too
lazy and failing to make copies when lists are changed.
To exhibit this bug, proceed as follows:
import pickle
h = open('combined_oplists_pickle','r')
combined_oplists = pickle.Unpickler(h).load()
import pybugreport
funclist,funcdist = pybugreport.buildfunclist(combined_oplists)
and then you will see funclist[45] printed out on two successive iterations.
It has changed as a result of an append operation, which should not happen.
(It's 6th entry is longer.)
Here is the output:
funclist[45] = [0, 22973, '$FUNC', 'splitBoxInterior', [['InArg', [[['',
'ActiveBoxVectorI', '::', 'iterator', ''], ['thisboxdata_p', '']], [['',
'FaceIndex', ''], ['faceind', '']]]], ['InOutArg', [[['', 'ActiveBoxVectorI',
''], ['interiorOrbitNextLev', '']]]], ['RefGlobal', [[['', 'MIndex', ''],
['guiActiveBoxCount', '']]]], ['Workspace', [[['', 'QMGVector', '<', '',
'BoxCreationData', '', '> ', ''], ['boxCreationVec', '']]]]], [], [[0, 23017],
[0, 23048], [0, 23068], [0, 23069]], [[0, 23001]]]
funclist[45] = [0, 22973, '$FUNC', 'splitBoxInterior', [['InArg', [[['',
'ActiveBoxVectorI', '::', 'iterator', ''], ['thisboxdata_p', '']], [['',
'FaceIndex', ''], ['faceind', '']]]], ['InOutArg', [[['', 'ActiveBoxVectorI',
''], ['interiorOrbitNextLev', '']]]], ['RefGlobal', [[['', 'MIndex', ''],
['guiActiveBoxCount', '']]]], ['Workspace', [[['', 'QMGVector', '<', '',
'BoxCreationData', '', '> ', ''], ['boxCreationVec', '']]]]], [[0, 23115], [0,
23116], [0, 23117], [0, 23118], [0, 23119], [0, 23120], [0, 23121], [0, 23122],
[0, 23123], [0, 23124], [0, 23125], [0, 23126], [0, 23127], [0, 23128], [0,
23129], [0, 23130], [0, 23131], [0, 23132], [0, 23133], [0, 23134], [0, 23135],
[0, 23136], [0, 23139], [0, 23140], [0, 23141], [0, 23142], [0, 23143], [0,
23144], [0, 23145], [0, 23146]], [[0, 23017], [0, 23048], [0, 23068], [0,
23069], [0, 23137], [0, 23138], [0, 23147], [0, 23148], [0, 23149], [0,
23161]], [[0, 23001]]]
----------
components: Interpreter Core
files: pybugreport.zip
messages: 144261
nosy: vavasis
priority: normal
severity: normal
status: open
title: bug in core python variable binding
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file23190/pybugreport.zip
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13006>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com