[Python-Dev] issue5578 - explanation (original) (raw)
Chris Withers chris at simplistix.co.uk
Thu Apr 2 23:21:31 CEST 2009
- Previous message: [Python-Dev] issue5578 - explanation
- Next message: [Python-Dev] issue5578 - explanation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
from functools import partial from new import instancemethod
def meth(name,self,*args): return getattr(self.sock,name)(*args) for m in socketmethods: p = partial(meth,m) p.name = m p.doc = getattr(realsocket,m).doc m = instancemethod(p,None,socketobject) setattr(socketobject,m,m) Have I missed something or is that a suitable replacement that gets rid of the exec nastiness? That code in socket.py is much older that functools... I don't know if the dependency matters, probably not. But anyways this is moot, the bug was only about exec in a class body nested inside a function.
Indeed, I just hate seeing execs and it was an interesting mental exercise to try and get rid of the above one ;-)
Assuming it breaks no tests, would there be objection to me committing the above change to the Python 3 trunk?
Chris
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
- Previous message: [Python-Dev] issue5578 - explanation
- Next message: [Python-Dev] issue5578 - explanation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]