[Python-checkins] gh-48496: Added example and link to faq for UnboundLocalError in reference (GH-93068)
miss-islington
webhook-mailer at python.org
Thu Dec 22 18:30:18 EST 2022
https://github.com/python/cpython/commit/1fa4c6bd1f895df1ca6205a8bd3f60fdd287405c
commit: 1fa4c6bd1f895df1ca6205a8bd3f60fdd287405c
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-12-22T15:30:12-08:00
summary:
gh-48496: Added example and link to faq for UnboundLocalError in reference (GH-93068)
(cherry picked from commit f3db68e6e66ebb36e1b9cb30daba913ecc736169)
Co-authored-by: Stanley <46876382+slateny at users.noreply.github.com>
files:
M Doc/faq/programming.rst
M Doc/reference/executionmodel.rst
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 584d33e9622e..c396e2b081fc 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -113,6 +113,8 @@ Yes. The coding style required for standard library modules is documented as
Core Language
=============
+.. _faq-unboundlocalerror:
+
Why am I getting an UnboundLocalError when the variable has a value?
--------------------------------------------------------------------
diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst
index 3f01180e13f7..a264015cbf40 100644
--- a/Doc/reference/executionmodel.rst
+++ b/Doc/reference/executionmodel.rst
@@ -128,6 +128,8 @@ lead to errors when a name is used within a block before it is bound. This rule
is subtle. Python lacks declarations and allows name binding operations to
occur anywhere within a code block. The local variables of a code block can be
determined by scanning the entire text of the block for name binding operations.
+See :ref:`the FAQ entry on UnboundLocalError <faq-unboundlocalerror>`
+for examples.
If the :keyword:`global` statement occurs within a block, all uses of the names
specified in the statement refer to the bindings of those names in the top-level
More information about the Python-checkins
mailing list