]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119180: Fix annotationlib.ForwardRef.evaluate with no globals (#124326)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Mon, 23 Sep 2024 19:06:19 +0000 (12:06 -0700)
committerGitHub <noreply@github.com>
Mon, 23 Sep 2024 19:06:19 +0000 (19:06 +0000)
commit2e0d445364f6d9832e81263c1c68440654924fc4
tree3e2d591603fe99380cb94f3aba9fa9aa75c08330
parente7d465a607b77a552d1e07f3fafa81ef5fc799d2
gh-119180: Fix annotationlib.ForwardRef.evaluate with no globals (#124326)

We were sometimes passing None as the globals argument to eval(), which makes it
inherit the globals from the calling scope. Instead, ensure that globals is always
non-None. The test was passing accidentally because I passed "annotationlib" as a
module object; fix that. Also document the parameters to ForwardRef() and remove
two unused private ones.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Lib/annotationlib.py
Lib/test/test_annotationlib.py