On Apr 12, 5:51 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > I can reproduce > > tburg...@-dev:~/Applications/web2py$ python web2py.py -S pms -M > web2py Enterprise Web Framework > Created by Massimo Di Pierro, Copyright 2007-2010 > Version 1.76.5 (2010-03-20 12:12:17) > Database drivers available: SQLite3 > Traceback (most recent call last): > File "/home/tburgess/Applications/web2py/gluon/restricted.py", line > 171, in restricted > ccode = compile(code.replace('\r\n', '\n'), layer, 'exec') > File "applications/pms/models/db.py", line 656 > # > ^ > SyntaxError: invalid syntax > > I just appended this to the end of my db.py file. > > for i in range(5): > print i > #
Ok - not sure why I was not able to reproduce before: I put a breakpoint on line 179 of restricted, and sure enough code, when it had no ending newline, would cause an error. This seems like it is a bug with the builtin, compile() ... For now, this should be harmless, and ensure this doesn't happen: in gluon/restricted.py, change line 179 as follows: < before: ccode = compile(code.replace('\r\n', '\n'), layer, 'exec') > after: ccode = compile(code.replace('\r\n', '\n')+'\n', layer, 'exec') - Yarko > > After testing, it seems to do it if any statement that requires an > indentation before the hash sign. So if statements, while statements, > try/except, and on and on. > > -- > Thadeus > > On Mon, Apr 12, 2010 at 5:34 PM, Yarko Tymciurak > > <resultsinsoftw...@gmail.com> wrote: > > On Apr 12, 5:09 pm, Yarko Tymciurak <resultsinsoftw...@gmail.com> > > wrote: > >> On Apr 12, 3:59 pm, DenesL <denes1...@yahoo.ca> wrote: > > >> > Very simple, in db.py: > > >> > db=SQLDB(...) > >> > db.define_table('person', > >> > Field('name') > >> > ) > > >> > s=[] > >> > for f in db.person.fields: > >> > s.append(db.person[f].type) > >> > # > > >> > will fail. > >> > It is a stupid loop, but it illustrates the problem. > > >> Thanks Denes - this is specific; I cannot reproduce the problem with > >> this (that is, it runs fine on Ubuntu / Python 2.6.4 / web2py 1.76.5 > > >> I'll try it later tonight in a windows VM (I just checked - don't have > >> a recent web2py, other things to do). > > >> If someone else can reproduce this on Windows, trace it down to where > >> it's happening, that would be great. > > >> - Yarko > > >> > If you comment out the for then it is ok. > >> > If you add an empty line or remove the comment it is ok. > > >> > On Apr 12, 4:10 pm, Yarko Tymciurak <resultsinsoftw...@gmail.com> > >> > wrote: > > >> > > On Apr 12, 3:00 pm, DenesL <denes1...@yahoo.ca> wrote: > > >> > > > Running on Windows here. > > >> > > > @Yarko, yes, there seems to be an additional ingredient to this. > >> > > > A prerequisite seems to be the existence of a for statement > >> > > > somewhere. > >> > > > (!?!?). > > >> > > Denes - I'm assuming you've found a bug (perhaps a subtle one); Let's > >> > > see if get to some minimal situation where this occurs so others can > >> > > reproduce... > > >> > > I am perfectly willing to run this on Windows-7 in a virtual > >> > > machine... > > > Just tested w/ Win-7, web2py 1.76.5, and python 2.6.4 (with source > > distribution); this also works for me. > > > I think we still need to identify the specific context that makes this > > fail. > > > Can you download web2py 1.76.5 source, and see if you can still see > > the problem on your system with that? > > > - Yarko > > >> > > - Yarko > > > -- > > To unsubscribe, reply using "remove me" as the subject.