|
From: <bc...@wo...> - 2001-11-18 13:43:18
|
[Chris Monson]
>My program works fine in jython, but I can't use jythonc to create an
>applet.
>
>I narrowed the problem down to this line of python code:
>
> import random
>
>The stack trace given when I try to run the applet is as follows (it's
>longer than that, but I'm trying to keep the message short).
>
> Java Traceback:
>
> at org.python.core.__builtin__.eval(__builtin__.java)
>...
> at random$_PyInner._verify$1(random.java:377)
>
> <snip>
>
>So, it appears that the _verify method in the random module is doing an
>eval!
Indeed. Rather thoughless bit of code there. I suggest you edit your
copy of random.py to have an empty _verify() function:
def _verify(name, expected):
pass
I have posted a patch to CPython and will include a version of random.py
in 2.1b1 that does not use eval().
>That's all well and good, but I don't have org.python.core.parser
>anywhere in my jar file. Oops.
>
>It turns out that adding that file doesn't help. If I use the --all
>flag, I get this:
>Java Traceback:
>
>java.security.AccessControlException: access denied
Using --all with applets is a topic for a different post.
>So, I tried not importing random at all, but rather doing a simple eval:
>
>print eval("1 + 1")
>
>Again, I am required to use --all (which kind of makes sense), and
>again, I get an AccessControlException just like above.
>
>Does this mean that I can't use eval or any module that uses eval in my
>applets?
Correct, you can't use eval() or compile() in a restricted environment
such as applets.
regards,
finn
|