Skip to content

Commit 2164613

Browse files
committed
Consider globals in ref.evaluate() for undefined generic ForwardRefs
1 parent dd86fb4 commit 2164613

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/annotationlib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ def evaluate(
187187
except Exception:
188188
if not is_forwardref_format:
189189
raise
190+
191+
# All variables, in scoping order, should be checked before
192+
# triggering __missing__ to create a _Stringifier.
190193
new_locals = _StringifierDict(
191-
{**builtins.__dict__, **locals},
194+
{**builtins.__dict__, **globals, **locals},
192195
globals=globals,
193196
owner=owner,
194197
is_class=self.__forward_is_class__,

0 commit comments

Comments
 (0)