"unqualified exec is not allowed" error w/custom tag lib

Philip Semanchuk <[email protected]>
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
Hi all,
First things first: I am really enjoying Spyce; it is making my 
development work a lot easier.

Today I came across a problem that I don't know what to make of, and 
I've narrowed it down to a very specific test case. My file test.spy 
(at the end of this message) makes use of a custom tag library called 
FooTagLibrary.spy. The custom tag lib is ultra-simple:
[[.tagcollection ]]

[[.begin name=DoNothing buffers=False singleton=True]]
[[\
pass
]]
[[.end]]


test.spy includes this tag lib and uses the DoNothing tag. The strange 
part is that if I define a Python function inside test.spy, including 
certain Python code in that function causes the Spyce compilation to 
error out with this message:
   Traceback (most recent call last):
   File "/usr/local/share/spyce-2.0.3/spyce.py", line 554, in __init__
     try: exec self.getCode() in self._codeenv
SyntaxError: unqualified exec is not allowed in function 'spyceProcess' 
it contains a nested function with free variables (<string>, line 39)

The troublesome code can be quite innocuous; a function body as simple 
as "return True" triggers what I'm seeing. The name of the function 
that I define doesn't appear to have any bearing on the problem. If I 
remove the reference to foo:DoNothing from test.spy, the problem goes 
away. I can't even begin to imagine what's happening here. Any 
suggestions would be appreciated.

CHeers
Philip

The contents of test.spy follow --

[[.taglib from=FooTagLibrary.spy as=foo]]
<html>
<head>
         <title>testing</title>
</head>
<body>
[[\
def trouble():
     # These cause the error --
     bool(0)
     #int(0)
     #str(0)
     #float(0)
     #return True
     #True == 1

     # These do not --
     #return 1
     #pass
     #print "boom"
     #1 == 1
     #return 1 == 1
     #return (1 == 1)
]]

<foo:DoNothing />

</body>
</html>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.