[issue32615] Inconsistent behavior if globals is a dict subclass

Pablo Galindo Salgado report at bugs.python.org
Mon Dec 30 18:17:06 EST 2019


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

> The doc for exec says globals "must be a dictionary (and not a subclass of dictionary)"

I agree with Terry, the moment you pass a dict subclass to exec you are out of contract. If any, we may need to sanitize the input to exec, although I don't think is worth paying the performance price for that.

> Some smart maintainer closed https://bugs.python.org/issue36220 as a duplicate of this one.

I closed issue36220 as a duplicate. Paul, I don't know if you are being sarcastic here so I will assume that you are not but in case you are, I suggest you stop as this violates our CoC.

> Docs are full of mistakes and outdated information.

They are also full of contracts and as of today, what the docs document is what is considered the public API. 

In any case, my opinion is that LOAD_NAME and LOAD_GLOBAL should not pay the performance price to handle less-specific APIs just to support a very uncommon case (using dict subclasses as globals) that are also out of contract. For STORE_GLOBAL I feel less strongly about that, but I am still -1 on it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32615>
_______________________________________


More information about the Python-bugs-list mailing list