PEP 667 -- Consistent views of namespaces

Pytest has some non-critical (and kinda terrifying) testing code like this (paraphrasing):

backlocals = sys._getframe(1).f_locals
eval(..., backlocals, ...)

which started failing in Python 3.13 beta with “TypeError: globals must be a real dict; try eval(expr, {}, mapping)”.

I am changing this to backlocals = dict(sys._getframe(1).f_locals), just wanted to leave a note in case this was somehow not intended.

4 Likes