Edgewall Software

Opened 8 years ago

Closed 8 years ago

Last modified 4 years ago

#127 closed defect (fixed)

Strip whitespace at the end of <?python ?> blocks

Reported by: Dale Sedivec <dale-keyword-genshi.e8bcba@…> Owned by: cmlenz
Priority: minor Milestone: 0.4.2
Component: Parsing Version: 0.4
Keywords: python processing instruction pi code block space whitespace Cc:


A line containing nothing but whitespace at the end of a <?python> PI raises a syntax error:

>>> from genshi.template import MarkupTemplate
>>> tmpl = MarkupTemplate("<foo><?python print 'hi'\n ?></foo>")
Traceback (most recent call last):
genshi.template.base.TemplateSyntaxError: invalid syntax (None, line 2)

This exception is present in 0.4.1 as well as SVN head. It seems to me that whitespace at the end of a python PI should be permitted, since it seems typical to indent the block. For example:

        bar = 42

I threw an rstrip in the PI parsing code: all tests pass (Python 2.4), as well as my above snippet. Patch against SVN head attached.

Attachments (1)

genshi-python-pi-whitespace.patch (708 bytes) - added by Dale Sedivec <dale-keyword-genshi.e8bcba@…> 8 years ago.
Trivial patch to rstrip source code in a <?python?> code block

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by Dale Sedivec <dale-keyword-genshi.e8bcba@…>

Trivial patch to rstrip source code in a <?python?> code block

comment:1 Changed 8 years ago by cmlenz

  • Milestone changed from 0.5 to 0.4.2
  • Resolution set to fixed
  • Status changed from new to closed

Patch applied in [624], ported to 0.4.x in [625]. Many thanks!

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.