New submission from Jeroen Demeyer <[email protected]>:
In contextlib, there is code which roughly looks like
def _exit_wrapper(exc_type, exc, tb):
return cm_exit(cm, exc_type, exc, tb)
_exit_wrapper.__self__ = cm
This creates a new function _exit_wrapper from a given function cm_exit by
prepending the __self__ attribute to *args. Now this is exactly what a method
does too.
It would be better to use an actual method for this: it's cleaner, faster and
it doesn't abuse a double-underscore attribute. The latter will actually break
with PEP 575, as __self__ will become a special name instead of an arbitrary
attribute.
----------
components: Library (Lib)
messages: 315212
nosy: jdemeyer
priority: normal
severity: normal
status: open
title: contextlib.ExitStack abuses __self__
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33265>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com