Message166144
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. |
|
Date |
User |
Action |
Args |
2012-07-22 15:42:56 | mstefanro | set | recipients:
+ mstefanro, loewis, rhettinger, ncoghlan, alexandre.vassalotti, asvetlov, meador.inge, daniel.urban, sbt, yselivanov |
2012-07-22 15:42:56 | mstefanro | set | messageid: <1342971776.47.0.310431776305.issue15397@psf.upfronthosting.co.za> |
2012-07-22 15:42:55 | mstefanro | link | issue15397 messages |
2012-07-22 15:42:55 | mstefanro | create | |
|