ptl compilation problems

Evan Laforge <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
This happens with quixote 2.1 and 2.3, under python 2.3 (but not python 2.4):

% cat t.py
import quixote
quixote.enable_ptl()
import bug

% cat bug.ptl
def g():
  f(lambda: None)[1:]

% python2.3 t.py
Traceback (most recent call last): -------
t.py:3 in ?()
        import bug
/home/elaforge/lib/python/quixote/ptl/ptl_import.py:120 in
cModuleImporter.find_import_module(fullname='bug', subname='bug',
path=None)
        return self.loader.load_module(fullname, stuff)
/home/elaforge/lib/python/quixote/ptl/ptl_import.py:100 in
PTLLoader.load_module(name='bug', stuff=(<open file '/..)
        return _load_ptl(name, filename, file)
/home/elaforge/lib/python/quixote/ptl/ptl_import.py:71 in
_load_ptl(name='bug', filename='/home/elaforg.., file=<open file
'/h..)
        code = compile_template(file, filename, output)
/home/elaforge/lib/python/quixote/ptl/ptl_compile.py:226 in
compile_template(input=<open file '/h.., filename='/home/elaforg..,
output=<closed file '..)
        template.compile()
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/pycodegen.py:112
in Template.compile(display=0)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/pycodegen.py:1149
in ModuleCodeGenerator.__init__(tree=Module(None, S..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:106
in walk(tree=Module(None, S.., visitor=<compiler.pyco..,
walker=<compiler.visi.., verbose=None)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:63
in ASTVisitor.preorder(tree=Module(None, S..,
visitor=<compiler.pyco.., *args=())
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Module(None, S.., *args=())
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/pycodegen.py:342
in ModuleCodeGenerator.visitModule(node=Module(None, S..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/pycodegen.py:255
in ModuleCodeGenerator.parseSymbols(tree=Module(None, S..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:106
in walk(tree=Module(None, S.., visitor=<compiler.symb..,
walker=<compiler.visi.., verbose=None)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:63
in ASTVisitor.preorder(tree=Module(None, S..,
visitor=<compiler.symb.., *args=())
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Module(None, S.., *args=())
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/symbols.py:207
in SymbolVisitor.visitModule(node=Module(None, S..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Stmt([From('__.., *args=(<ModuleScope:..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:40
in ASTVisitor.default(node=Stmt([From('__.., *args=(<ModuleScope:..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Function('g', .., *args=(<ModuleScope:..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/symbols.py:220
in SymbolVisitor.visitFunction(node=Function('g', ..,
parent=<ModuleScope: ..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Stmt([Discard(.., *args=(<FunctionScop..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:40
in ASTVisitor.default(node=Stmt([Discard(.., *args=(<FunctionScop..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Discard(Slice(.., *args=(<FunctionScop..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:40
in ASTVisitor.default(node=Discard(Slice(.., *args=(<FunctionScop..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Slice(CallFunc.., *args=(<FunctionScop..)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/symbols.py:329
in SymbolVisitor.visitSlice(node=Slice(CallFunc(Name('f'), [Lambda((),
(), 0, Name('None'))], None, None), 'OP_APPLY', Const(1), None),
scope=<FunctionScope: g>, assign=0)
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=CallFunc(Name('f'), [Lambda((), (), 0,
Name('None'))], None, None), *args=(<FunctionScope: g>, 0))
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:40
in ASTVisitor.default(node=CallFunc(Name('f'), [Lambda((), (), 0,
Name('None'))], None, None), *args=(<FunctionScope: g>, 0))
/var/tmp/python2.3-2.3.5-root/usr/lib/python2.3/compiler/visitor.py:57
in ASTVisitor.dispatch(node=Lambda((), (), 0, Name('None')),
*args=(<FunctionScope: g>, 0))
TypeError: visitLambda() takes exactly 3 arguments (4 given)


The original code that triggered this error is of course more
complicated, but the above was the simplest example I was able to
reduce it to.  I don't really understand why it winds up in a module
in /var/tmp (not using zip imports or anything) but I think that's
unrelated to the problem.

visitLambda wants (self, node, parent), and it looks like that extra 0
comes from visitSlice.  I don't understand enough about how the
compiler stuff works to know immediately what this means.  Maybe a
slice should not have a lambda as a subnode and that is the problem?

In any case, it's gone in 2.4, so maybe it is a 2.3 bug?
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.