[issue9616] copy.deepcopy() copying pointers from a dict/dict/list, should copy values
New submission from Neil Harkins : hi. after using deepcopy() on a nested dict/list structure, i noticed that modifications to the deepcopied structure were affecting the original. this looks to me like a serious bug: >>> import copy >>> foo = { 'a':[1,2,3], 'b':{'c':[4,5]} } >>> bar = copy.deepcopy(foo) >>> id(foo) 4297360512 >>> id(bar) 4297373104 >>> id(foo['a']) 4299410752 >>> id(bar['a']) 4299760200 >>> id(foo['b']) 4297371984 >>> id(bar['b']) 4297373920 >>> id(foo['b']['c']) 4299721040 >>> id(bar['b']['c']) 4299761496 >>> id(foo['b']['c'][0]) 4297074656 >>> id(bar['b']['c'][0]) 4297074656 -- components: Extension Modules messages: 114007 nosy: nharkins priority: normal severity: normal status: open title: copy.deepcopy() copying pointers from a dict/dict/list, should copy values type: behavior versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue9616> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9616] copy.deepcopy() copying pointers from a dict/dict/list, should copy values
Neil Harkins added the comment: thanks for the quick response. that was just my working up a simplified repro, but you are correct: on modification there, it gets a new id() location. totally not what i would've expected (python flags it for copying when it changes, to save space?) however i am still seeing the problem in my code, so i will continue to whittle it down to a simpler repro, and hopefully add it here later today. -- ___ Python tracker <http://bugs.python.org/issue9616> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9616] copy.deepcopy() copying pointers from a dict/dict/list, should copy values
Neil Harkins added the comment: learn something everyday. i have found the bug in my code, deepcopy() is not to blame. thx for your time! -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue9616> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com