Brett Cannon added the comment:

If you read the docs for sys._getframe() 
(http://docs.python.org/3/library/sys.html#sys._getframe) we explicitly state 
that the function should be considered an implementation detail for CPython. 
While Nick doesn't want to argue from the VM angle, I will.

I would prefer to not rely on this hack in the stdlib to not put the other VMs 
at a disadvantage. Nick also has a good point that it is at best a heuristic as 
you can fool it into using the wrong result.

At minimum I think the keyword argument for the module being used should be 
provided and documented that if it isn't provided then pickling is wishy-washy 
based on how you call the function and that it is not cross-VM compatible. But 
knowing that users won't clearly read the docs if it just happens to work in 
the interpreter and that is partial luck because of the possible indirection 
issue Nick pointed out, I think it would be better to not rely upon 
sys._getframe() and just ask people to explicitly specify the module if they 
happen to care about pickling *and* are using the functional API for enums.

----------
nosy: +brett.cannon

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17963>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to