This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jabowery2
Recipients jabowery2, lys.nikolaou, pablogsal
Date 2021-11-03.20:24:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635971080.35.0.70243315955.issue45705@roundup.psfhosted.org>
In-reply-to
Content
Comment out the |= line and it prints "{'b':2}" as expected.

$ cat t.py
scoped_dict = {'b':2}
def scoped_def():
    print(scoped_dict)
    scoped_dict |= {'a',1}
scoped_def()

$ p t.py 
Traceback (most recent call last):
  File "/home/jabowery/dev/t.py", line 5, in <module>
    scoped_def()
  File "/home/jabowery/dev/t.py", line 3, in scoped_def
    print(scoped_dict)
UnboundLocalError: local variable 'scoped_dict' referenced before assignment

$ python --version
Python 3.10.0
History
Date User Action Args
2021-11-03 20:24:40jabowery2setrecipients: + jabowery2, lys.nikolaou, pablogsal
2021-11-03 20:24:40jabowery2setmessageid: <1635971080.35.0.70243315955.issue45705@roundup.psfhosted.org>
2021-11-03 20:24:40jabowery2linkissue45705 messages
2021-11-03 20:24:40jabowery2create