New syntax error?

118 views
Skip to first unread message

Dave S

unread,
Oct 23, 2017, 6:38:27 PM10/23/17
to web2py-users
In  my 2.15.x testing, I've been concentrating on the https interface, but I now tried to do a -M -S that would queue up a Scheduler task.  And I ran into an unexpected problem with syntax errors on print statements.

   if when:
     
print "ri_s: when " + when

Even when I shorten the line to remove the concatenation, I get a syntax error:

Traceback (most recent call last):
 
File "web2py.py", line 33, in <module>
    gluon
.widget.start(cron=True)
 
File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/widget.py", line 1152, in start
    cronjob
=options.cronjob)
 
File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/shell.py", line 258, in run
    execfile
(pyfile, _env)
 
File "applications/updater/controllers/default.py", line 140
   
print "ri_s: when "
                     
^
SyntaxError: invalid syntax

I tried changing the variable name to "pwhen" in case this was an if-statement/keyword issue, but still "invalid syntax".

As you might guess, default.py loads fine for https requests, and this code loads fine with -S under 2.14.6, so I'm not sure what's going on here.

/dps


Dave S

unread,
Oct 25, 2017, 3:02:12 AM10/25/17
to web2py-users
Changing the print statements to logger calls allows the  -S load to complete, but I don't think anything went to web2py.log from these calls (logging calls used when handling http(s) requests seem to be working normally).

Plus, when you're running from the command line (as is often the case for -S), it's irritating to have to go to the log for what is ordinarily stdout material.

/dps

Anthony

unread,
Oct 25, 2017, 9:03:10 AM10/25/17
to web2py-users
I cannot reproduce, and I can't think of anything web2py would be doing that would be relevant, as this is a standard Python exception. I was thinking maybe you switched to Python 3, but in that case, I would expect a more specific error message indicating the parentheses are missing (unless you're using an older version of Python 3 and the message is different in that version).

Anthony

Dave S

unread,
Oct 25, 2017, 2:58:16 PM10/25/17
to web2py-users


On Wednesday, October 25, 2017 at 6:03:10 AM UTC-7, Anthony wrote:
I cannot reproduce, and I can't think of anything web2py would be doing that would be relevant, as this is a standard Python exception. I was thinking maybe you switched to Python 3, but in that case, I would expect a more specific error message indicating the parentheses are missing (unless you're using an older version of Python 3 and the message is different in that version).

Anthony

Python 2.7.12 on AWS linux.

I have both flavors of web2py (that is, good ol' 2.14.6 and the up-and-coming 2.15.4) on the same machine (VM/cloud instance), using different ports.  The application code was copied via tar from 2.14.6 to 2.15.4.

The web2py signon (version info) doesn't show the python version, but "python" defaults to 2.7.12.

BTW, I see the logger statement are coming out on the console, rather than going to the log file, but that was because I needed to fix the permissions on the log file.

/dps

Dave S

unread,
Dec 22, 2017, 8:46:17 PM12/22/17
to web2py-users


I think I've found the cause:  in 2.15.4, gluon/shell.py  has the line

from __future__ import print_function

I have an "add_user.py" script picked up some time ago from the group, which I was running with -S, and the print statements were getting syntax errors.  Changing

print "..."

to

print ("...")

fixed things.  I haven't gone to my other system to see if that would fix the module from the original post.

/dps

Reply all
Reply to author
Forward
0 new messages