> > > If you want to run untrusted Python code and prevent malice (or stupidity) > from harming you, you need OS-level protection. > > Agreed. Just for fun here's a simple example of what could be an honest mistake that consumes all physical memory and swap. A well behaved kernel will kill the process eventually when it can no longer allocate memory, but not before bringing the machine to its knees:
class Foo(object): def __init__(self): self.x = 1 def __iter__(self): return self def next(self): self.x += 1 # Oops. In a well behaved iterator this should eventually # raise 'StopIteration'. I knew I forgot something. a = Foo() b = list(a) -Modulok-
-- https://mail.python.org/mailman/listinfo/python-list