On Apr 12, 2:39 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
> On Apr 12, 2010, at 12:17 PM, Yarko Tymciurak wrote:
>
>
>
> > On Apr 12, 2:15 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
> >> On Apr 12, 2010, at 11:52 AM, DenesL wrote:
>
> >>> In 1.76.3, and probably others, model files can not end with a comment
> >>> line:
>
> >>> Traceback (most recent call last):
> >>>  File "D:\web2py\hg\gluon\restricted.py", line 171, in restricted
> >>>    ccode = compile(code.replace('\r\n', '\n'), layer, 'exec')
> >>>  File "D:/web2py/hg/applications/mssqltest/models/db.py", line 111
> >>>    #
> >>>    ^
> >>> SyntaxError: invalid syntax
>
> >>> Adding an empty line fixes the problem but figuring that out is a
> >>> waste of time.
>
> >> FWIW, compile() requires at least one terminal newline. Perhaps it'd be 
> >> reasonable to append one (along the the \r\n conversion).
>
> > hmmm..... I am not able to reproce this;  I even ensured that the
> > model file I tested with actually had NO newline after the comment:
>
> > $ od -c mymodel.py
> > ...
> > 0001640   t   i   o   n       t   o   o   l   "  \n   #
> > 0001654
>
> > Mine runs fine.
>
> > I wonder if this is a platform, or python version specific thing...
>
> > Can you provide more details?
>
> I ran into it a week or two ago on OS X, Python 2.6.4.
>
> http://docs.python.org/library/functions.html
>
> > Note When compiling a string with multi-line code, line endings must be 
> > represented by a single newline character ('\n'), and the input must be 
> > terminated by at least one newline character. If line endings are 
> > represented by '\r\n', usestr.replace() to change them into '\n'.

I'm not sure how this impacts the issue Denes brought up - something
is different between what Denes is saying, and what I am trying on my
machine:   if compile() is being called from web2py on _my_ model, it
is not triggering this (either because the comment is stripped, or
because web2py is doing something already).

In either case,  Denes's setup is behaving differently than mine....
so still need more info, to try to reproduce, and track down what is
resulting in this behavior...

- Yarko


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to