]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-48496: Added example and link to faq for UnboundLocalError in reference (GH-93068)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 22 Dec 2022 23:30:09 +0000 (15:30 -0800)
committerGitHub <noreply@github.com>
Thu, 22 Dec 2022 23:30:09 +0000 (15:30 -0800)
(cherry picked from commit f3db68e6e66ebb36e1b9cb30daba913ecc736169)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Doc/faq/programming.rst
Doc/reference/executionmodel.rst

index f8140481b1204142cb9fc9a64f685ddc21e5b9b8..bd75801cc2427819571f57e00f1539dda14e18cb 100644 (file)
@@ -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?
 --------------------------------------------------------------------
 
index d9183561820b2beedbb200068775e3862bab9f0a..081f71cf2e7d9780aa58da6e8fc453e9bf09dd98 100644 (file)
@@ -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