Problem can be identified with the following:
>>> from pygraph.classes.digraph import digraph
>>> gr = digraph()
>>> gr.add_node(1)
>>> gr.add_node(2)
>>> print gr.node_attributes(1)
[]
>>> print gr.node_attributes(2)
[]
>>> gr.node_attributes(1).append('hi')
>>> print gr.node_attributes(1)
['hi'] # good
>>> print gr.node_attributes(2)
['hi'] # whoops
The python list given as a default argument is mutable and shared among all
instances.
Not sure if this was meant to be done on purpose or not. For someone who wants
this behavior, they should probably pass in their own list and modify it
externally.
Attached is a proposed patch.
Original issue reported on code.google.com by jonathan...@gmail.com on 10 Apr 2011 at 4:03
Original issue reported on code.google.com by
jonathan...@gmail.com
on 10 Apr 2011 at 4:03Attachments: