durusmail: quixote-users: Syntax error if .ptl ends with whitespaces
Syntax error if .ptl ends with whitespaces
2004-07-06
2004-07-06
Re: Syntax error if .ptl ends with whitespaces
2004-07-06
Re: R: [Quixote-users] Syntax error if .ptl ends with whitespaces
Syntax error if .ptl ends with whitespaces
Graham Fawcett
2004-07-06
Oleg Broytmann wrote:

>On Tue, Jul 06, 2004 at 12:57:42PM +0200, Daniele Varrazzo wrote:
>
>
>>As i reported some days ago, any ptl file that ends up with any whitespace
>>after the last cr/lf doesn't compile and issue a SyntaxError.
>>
>>

Yes, I can replicate the error. Using quixote 1.0 on python 2.3.3
(win32), the following test program:

    from quixote import enable_ptl
    enable_ptl()

    f = file('foo.ptl', 'w')
    f.write('def hello [html] ():\n    "Hi there."\n    ')
    f.close()
    import foo

raises a SyntaxError: invalid syntax on line 3 of foo.ptl (the empty line).

The following change to ptl_compile may be necessary. It may also be
overkill: I assume that this problem is occuring on win32 only, but
haven't tested elsewhere, and haven't checked for bug reports on the
Python tracker.

--- quixote\ptl_compile.py      Tue Jul 06 09:14:29 2004
+++ ptl_compile.py      Tue Jul 06 09:14:39 2004
@@ -206,5 +206,5 @@


-if sys.hexversion >= 0x20300b1:
+if sys.hexversion >= 0x20300b1 and sys.platform != 'win32':
     def parse(buf, filename=''):
         buf = translate_tokens(buf)


-- Graham


reply