PEP 709: Remove obsolete incompatibility subsection (#3030)
This commit is contained in:
parent
cf5741c181
commit
98235c7a0b
18
pep-0709.rst
18
pep-0709.rst
|
@ -225,24 +225,6 @@ the library. In such a scenario it would usually be simpler and more reliable
|
|||
to raise the warning closer to the calling code and bypass fewer frames.
|
||||
|
||||
|
||||
UnboundLocalError instead of NameError
|
||||
--------------------------------------
|
||||
|
||||
Although the value of the comprehension iteration variable is saved and
|
||||
restored to provide isolation, it still becomes a local variable of the outer
|
||||
function under this PEP. This implies a small behavior change in a function
|
||||
where the comprehension iteration variable is accessed outside the
|
||||
comprehension without ever being set outside the comprehension::
|
||||
|
||||
def f(lst):
|
||||
items = [x for x in lst]
|
||||
return x
|
||||
|
||||
Under this PEP, calling ``f()`` will raise ``UnboundLocalError``, where
|
||||
currently it raises ``NameError``. ``UnboundLocalError`` is a subclass of
|
||||
``NameError``, so this should not impact code catching ``NameError``.
|
||||
|
||||
|
||||
How to Teach This
|
||||
=================
|
||||
|
||||
|
|
Loading…
Reference in New Issue