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 pablogsal
Recipients Mark.Shannon, oleksandr.suvorov, pablogsal
Date 2020-05-22.11:19:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590146391.91.0.455497428218.issue40728@roundup.psfhosted.org>
In-reply-to
Content
> as it's either the
variable should exist and have a value or it should be unknown and result
in NameError at this point.

One thing is the symbol and another thing is its value. The function is always aware of the existence of the symbol. For instance:

def f(x):
   del x
   print(x)

>>> print(f.__code__.co_varnames)
('x',)

But when the function tries to use it, it has no value associated to it because del x removed it, so it emits an UnboundLocalError because there is no value.

raceback (most recent call last):
  File "lel.py", line 7, in <module>
    f(3)
  File "lel.py", line 3, in f
    print(x)
UnboundLocalError: local variable 'x' referenced before assignment

A NameError will occur if the symbol is unknown to the function.
History
Date User Action Args
2020-05-22 11:19:51pablogsalsetrecipients: + pablogsal, Mark.Shannon, oleksandr.suvorov
2020-05-22 11:19:51pablogsalsetmessageid: <1590146391.91.0.455497428218.issue40728@roundup.psfhosted.org>
2020-05-22 11:19:51pablogsallinkissue40728 messages
2020-05-22 11:19:51pablogsalcreate