The docs for PyRun_String say that both globals and locals should be 
dictionaries [1].

However, digging into the source [2] shows me that locals doesn’t need to be a 
dictionary;
it just needs to implement the mapping protocol.  Is it a bad idea to rely on 
this fact?

(Context: I’m plugging a custom object into locals that uses __getitem__ to 
track lookups.)

Thanks,
Matt

[1] https://docs.python.org/3.4/c-api/veryhigh.html#c.PyRun_StringFlags
[2] 
https://github.com/python/cpython/blob/master/Objects/frameobject.c#L628-L629
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to