New submission from lanf0n:
test code below:
```python
>>> from types import MethodType
>>> class A:
... def f(self):
... print(__class__)
...
>>> a = A()
>>> a.fn = MethodType(lambda s: print(__class__), a)
>>>
>>> a.f()
>>> a.fn()
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
NameError: name '__class__' is not defined
```
this behavior affect `super()` not work in patched function scope,
of course we can use old super as super(self.__class__, self) to make it work
as expected, but I think it should work as original method if we already
bounded the function to instance(class).
--
components: Library (Lib)
messages: 284313
nosy: lanfon72
priority: normal
severity: normal
status: open
title: __class__ not exists in the method which bounded by types.MethodType.
type: behavior
versions: Python 3.5, Python 3.6
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29114>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com