D
Devan L
Is there any safe way to create an instance of an untrusted class
without consulting the class in any way? With old-style classes, I can
recreate an instance from another one without worrying about malicious
code (ignoring, for now, malicious code involving attribute access) as
shown below.
.... def __init__(self, who, knows, what, args):
.... self.mystery_args = (who, knows, what, args)
.... print "Your code didn't expect the Spanish inquisition!"
....
I'm not sure how to do the same for new-style classes, if it's at all
possible to do from within Python. Is there any way to accomplish this,
or is there no practical way to do so?
Thanks,
- Devan
without consulting the class in any way? With old-style classes, I can
recreate an instance from another one without worrying about malicious
code (ignoring, for now, malicious code involving attribute access) as
shown below.
.... def __init__(self, who, knows, what, args):
.... self.mystery_args = (who, knows, what, args)
.... print "Your code didn't expect the Spanish inquisition!"
....
I'm not sure how to do the same for new-style classes, if it's at all
possible to do from within Python. Is there any way to accomplish this,
or is there no practical way to do so?
Thanks,
- Devan