Message166144
| Author |
mstefanro |
| Recipients |
alexandre.vassalotti, asvetlov, daniel.urban, loewis, meador.inge, mstefanro, ncoghlan, rhettinger, sbt, yselivanov |
| Date |
2012年07月22日.15:42:55 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1342971776.47.0.310431776305.issue15397@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Andrew, thanks for creating a separate issue (the refleak was very rare and I thought I'd put it in the same place, but now I realize it was a bad idea).
Richard, actually, the isinstance(self, type) check I mentioned earlier would have to be before the hastattr(f, '__func__') check, because Python classmethods provide a __func__ too:
def unbind(f):
self = getattr(f, '__self__', None)
if self is not None and not isinstance(self, types.ModuleType) \
and not isinstance(self, type):
if hasattr(f, '__func__'):
return f.__func__
return getattr(type(f.__self__), f.__name__)
raise TypeError('not a bound method')
Anyway, I'm not convinced this is worth adding anymore. As Antoine Pitrou suggested on the ml, it would probably be a better idea if I implemented __reduce__ for builtin methods as well as Python methods rather than having a separate opcode for pickling methods. |
|