yejunzhou / typhoonae

Automatically exported from code.google.com/p/typhoonae
0 stars 0 forks source link

strange import syntax errors #91

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.not sure. seems inconsistant

What is the expected output? What do you see instead?

errorless code on GAE (local and cloud) produces various erratic syntax errors 
on imports, or fails to recognise imported classes in the logic code such as:

ERROR    2011-11-25 11:52:42,628 fcgiserver.py:265] invalid syntax 
(languages.py, line 10)
Traceback (most recent call last):
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    run_module(handler_path, script)
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    handler_path, cgi_path)
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    module_code = compile(source_file.read(), cgi_path, 'exec')
  File "/home/phil/typhoonae-buildout-0.2.0/parts/HubApplication/languages.py", line 10
     from cache import smartServerCacheManager
                                             ^M^
 SyntaxError: invalid syntax

What version of the product are you using? On what operating system?
I'm using the buildout to build from scratch on ubuntu 10.10 running python 2.7

Please provide any additional information below.

To begin with I found "import google.appengine.ext.webapp" would work, for 
example, but "from google.appengine.ext import webapp" would give a syntax 
error (being fine on GAE). 

Then I found that this exact same line would then fail in a different module in 
the same application. 

There seems to be no reason behind the combinations of what works and what does 
not. Errors even changing between requests in some cases.

e.g.

ERROR    2011-11-25 12:42:59,440 fcgiserver.py:265] invalid syntax 
(statistics.py, line 1)
Traceback (most recent call last):
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    run_module(handler_path, script)
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    handler_path, cgi_path)
  File "/home/phil/typhoonae-buildout-0.2.0/eggs/typhoonae-0.2.0-py2.6.egg/typhoonae/fcgise$
    module_code = compile(source_file.read(), cgi_path, 'exec')
  File "/home/phil/typhoonae-buildout-0.2.0/parts/HubApplication/statistics.py", line 1
     import google.appengine.ext.webapp
                                      ^M^
 SyntaxError: invalid syntax

works fine in cloud and local, even work in TAE in other modules but fails as 
above in some... 

Going a little crazy here. Any help much appreciated. 

Cheers
Phil

Original issue reported on code.google.com by phil.a.t...@gmail.com on 25 Nov 2011 at 1:03

GoogleCodeExporter commented 9 years ago
further... 

While it seems to be newlines that are causing the syntax errors, and I am 
using a mac to write, checking my python on the server it tells me I have 
universal newline support.

Again, any help greatly appreciated. Otherwise I'll have to go over to appscale 
:( Which I'd rather not do due to the processor support restrictions. Sorry if 
this is a dumb one.

cheers
Phil 

Original comment by phil.a.t...@gmail.com on 25 Nov 2011 at 4:33

GoogleCodeExporter commented 9 years ago
I just copied the content of one module that was work into the file of another 
that was not. The reult - the one that I copied from remains working, the one I 
copied from remains failing. with identical code. 

Seriously confused by this.

Original comment by phil.a.t...@gmail.com on 25 Nov 2011 at 4:47

GoogleCodeExporter commented 9 years ago
Thanks for reporting this! Could you please provide a minimal app to reproduce 
this issue.

Original comment by tobias.r...@gmail.com on 25 Nov 2011 at 6:28

GoogleCodeExporter commented 9 years ago
I'll see what I can do... :) 

Original comment by phil.a.t...@gmail.com on 25 Nov 2011 at 11:08

GoogleCodeExporter commented 9 years ago
So very frustrating, but good news :) 

Eventually I found that it was indeed a character encoding issue. Copying my 
failing code to the clipboard, deleting it from my editor, and simply pasting 
it back in fixed the issue.

Wasted 3 days on this, but means there is no serious issue with TAE. However 
its worth remembering that it worked fine in GAE. So something not quite 
perfect.

My best guess is a mix of Mac, Win, and Linux newlines saved as a mac charset 
was acceptable to GAE but not TAE. I didn't confirm, but I suspect forcing 
universal newline support in the open() of the app modules may fix this. (using 
the 'U' parameter)

If I ever get a spare moment I'll look back into it. Thanks for you help.

Original comment by p...@evolu8.com on 27 Nov 2011 at 6:34