Edgewall Software

Ticket #227 (reopened defect)

Opened 5 months ago

Last modified 4 months ago

syntax error on os.walk

Reported by: mats_a@… Owned by: cmlenz
Priority: major Milestone:
Component: Template processing Version: devel
Keywords: Cc:

Description

<?python

import os

for root,dirs,files in os.walk():

print root

?>


This should work fine, but it throws a template syntax error

...[snip]...

File "build/bdist.linux-i686/egg/genshi/template/loader.py", line 259, in _instantiate

allow_exec=self.allow_exec)

File "build/bdist.linux-i686/egg/genshi/template/base.py", line 373, in init

self.stream = list(self._prepare(self._parse(source, encoding)))

File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 206, in _parse

pos[2] + (err.offset or 0))

TemplateSyntaxError?: invalid syntax (/home/mats/documents/....../myfile.html, line 54)

Attachments

Change History

Changed 4 months ago by cmlenz

  • status changed from new to closed
  • resolution set to worksforme
  • component changed from General to Template processing
  • milestone 0.5 deleted

An XML document needs a root element. If you just have that PI in a template, that's not well-formed XML.

After adding a root element, this works fine for me, so I'm closing this as worksforme. Please reopen if you actually had a root element, and it didn't work.

Changed 4 months ago by mats_a@…

  • status changed from closed to reopened
  • resolution worksforme deleted

Reopening. I actually had a root element (otherwise wouldn't Genshi fail to work at all?).

It just seems that a syntax error is being thrown for no reason. It works perfectly fine in a python interpreter.

This <?python ... ?> block was inside of a <head py:match="head"></head> tag using the normal Genshi example.

Further testing:

* No syntax error results if it is NOT put in the <head> tag, but rather as a child of <html>. This seems to be a workaround for those who are interested.

* file is not defined inside a Genshi template (another bug?)

* You might need to do os.walk(somepath) (that is however not the issue)

Add/Change #227 (syntax error on os.walk)

Author



Change Properties
<Author field>
Action
as reopened
as The resolution will be set. Next status will be 'closed'
to The owner will change from cmlenz. Next status will be 'new'
 
Note: See TracTickets for help on using tickets.