[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Python bots in Galcon (or your game!) safe_eval

Phil Hassey wrote:

I spent some time today working on building a safe_eval function that would make it "safe" to run user submitted bots in games

Does it need any particular version of Python? When I run it using the following (in 2.3 or 2.4):

import safe
safe.safe_eval('print "Hello world!"')

I get

Traceback (most recent call last):
  File "bug.py", line 2, in ?
    safe.safe_eval('print "Hello world!"')
  File "/Users/greg/Safe/safe.py", line 160, in safe_eval
  File "/Users/greg/Safe/safe.py", line 146, in safe_run
    b = _builtins_destroy()
  File "/Users/greg/Safe/safe.py", line 128, in _builtins_destroy
    for k in __builtins__.__dict__.keys():
AttributeError: 'dict' object has no attribute '__dict__'

It seems like it's expecting __builtins__ to be something
other than a normal dict here.