[Python-Dev] doc for new restricted execution design for Python

Neal Norwitz nnorwitz at gmail.com
Wed Jun 28 05:44:23 CEST 2006


On 6/27/06, Brett Cannon <brett at python.org> wrote:
>
> > (5)  I think file creation/writing should be capped rather than
> > binary; it is reasonable to say "You can create a single temp file up
> > to 4K" or "You can create files, but not more than 20Meg total".
>
> That has been suggested before.  Anyone else like this idea?

What would this code do:

    MAX = 4
    for i in xrange(10):
      fp = open(str(i), 'w+')
      fp.write(' ' * (MAX // 4))
      fp.close()
      if i % 2:
          os.unlink(str(i))

How many times should this execute, 4 or 8?  What about if there is no
if i % 2 and the file is unlinked at the end of each loop?  Should
that loop 10 times without error?  What would happen if we used the
same file name?  What would happen if we did something like:

    fp = open(str(i), 'w+')
    MAX = 4
    for i in xrange(10000):
      fp.seek(0)
      fp.write(' ' * (MAX // 4))

Should this succeed?

n


More information about the Python-Dev mailing list