Message284313
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()
<class '__main__.A'>
>>> a.fn()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
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). |
|
Date |
User |
Action |
Args |
2016-12-30 05:53:38 | lanfon72 | set | recipients:
+ lanfon72 |
2016-12-30 05:53:38 | lanfon72 | set | messageid: <1483077218.4.0.672977492114.issue29114@psf.upfronthosting.co.za> |
2016-12-30 05:53:38 | lanfon72 | link | issue29114 messages |
2016-12-30 05:53:37 | lanfon72 | create | |
|