[issue38934] Dictionaries of dictionaries behave incorrectly when created from dict.fromkeys()

sourya varenya report at bugs.python.org
Wed Nov 27 22:55:29 EST 2019


New submission from sourya varenya <souryavarenya at gmail.com>:

Here's a sample run for reproducibility:
---
Python 3.6.9(Ubuntu 18.04) & 3.7.4(Windows)
---
                                                                                     >>> a = {1:{5:8},2:{5:8}}         
                                                                                     >>> b = dict.fromkeys([1,2],{5:8})   
                                                                                  >>> a                                                                                                                  {1: {5: 8}, 2: {5: 8}}          
                                                                                       >>> b                                                                                                                  {1: {5: 8}, 2: {5: 8}}   
                                                                                              >>> a[1].update({6:9})       
                                                                                          >>> b[1].update({6:9})  
                                                                                               >>> a                                                                                                                  {1: {5: 8, 6: 9}, 2: {5: 8}}     
                                                                                      >>> b                                                                                                                  {1: {5: 8, 6: 9}, 2: {5: 8, 6: 9}}

----------
components: Interpreter Core
messages: 357589
nosy: sourya varenya
priority: normal
severity: normal
status: open
title: Dictionaries of dictionaries behave incorrectly when created from dict.fromkeys()
type: behavior
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38934>
_______________________________________


More information about the Python-bugs-list mailing list