AttributeError: 'module' object has no attribute 'get_suffixes'

514 views
Skip to first unread message

CoderVic

unread,
Jul 22, 2008, 12:52:24 AM7/22/08
to Google App Engine
I am getting this error consistently when I run my module on GAE. The
error is thrown by a core python module (imp). Has GAE disabled
certain functions from the imp module? It's already caused me a lot of
grief. :-(

Has anyone else encountered this error while running pyparsing? Any
workarounds? Is there a list of altered modules published somewhere?


pyparsing.py", line 3284, in getTokensEndLoc
fstack = inspect.stack()
File "/base/python_dist/lib/python2.5/inspect.py", line 884, in
stack
return getouterframes(sys._getframe(1), context)
File "/base/python_dist/lib/python2.5/inspect.py", line 865, in
getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
File "/base/python_dist/lib/python2.5/inspect.py", line 836, in
getframeinfo
filename = getsourcefile(frame) or getfile(frame)
File "/base/python_dist/lib/python2.5/inspect.py", line 386, in
getsourcefile
for suffix, mode, kind in imp.get_suffixes():
AttributeError: 'module' object has no attribute 'get_suffixes'


Appreciate any help.
Vic

Duncan

unread,
Jul 22, 2008, 3:31:33 AM7/22/08
to Google App Engine
On Jul 22, 5:52 am, CoderVic <vax3...@gmail.com> wrote:
> I am getting this error consistently when I run my module on GAE. The
> error is thrown by a core python module (imp). Has GAE disabled
> certain functions from the imp module? It's already caused me a lot of
> grief. :-(
>
> Has anyone else encountered this error while running pyparsing? Any
> workarounds? Is there a list of altered modules published somewhere?
>
The problem is that the inspect module uses a part of the imp module
which has been removed in the GAE. The simplest thing is just to dummy
out imp.get_suffixes:

import imp
def get_suffixes():
return [('.py', 'U', 1)]
imp.get_suffixes = get_suffixes

should work.

Victor

unread,
Jul 22, 2008, 3:50:58 AM7/22/08
to Google App Engine
Thanks! That worked great. However, not its another function
inspect.getmodule that throws an error. Don't know how I can stub out
this one.


pyparsing.py", line 3284, in getTokensEndLoc
fstack = inspect.stack()
File "/base/python_dist/lib/python2.5/inspect.py", line 884, in
stack
return getouterframes(sys._getframe(1), context)
File "/base/python_dist/lib/python2.5/inspect.py", line 865, in
getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
File "/base/python_dist/lib/python2.5/inspect.py", line 840, in
getframeinfo
lines, lnum = findsource(frame)
File "/base/python_dist/lib/python2.5/inspect.py", line 462, in
findsource
module = getmodule(object, file)
File "/base/python_dist/lib/python2.5/inspect.py", line 436, in
getmodule
os.path.realpath(f)] = module.__name__
File "/base/python_dist/lib/python2.5/posixpath.py", line 422, in
realpath
resolved = _resolve_link(component)
File "/base/python_dist/lib/python2.5/posixpath.py", line 445, in
_resolve_link
resolved = os.readlink(path)
AttributeError: 'module' object has no attribute 'readlink'

Victor

unread,
Jul 22, 2008, 4:03:20 AM7/22/08
to Google App Engine
Ok. Found the solution. Added the following code:

import os
def readlink(path):
return path
os.readlink = readlink


Thanks!

Paul McGuire

unread,
Jul 22, 2008, 10:40:31 AM7/22/08
to Google App Engine
On Jul 21, 11:52 pm, CoderVic <vax3...@gmail.com> wrote:
> I am getting this error consistently when I run my module on GAE. The
> error is thrown by a core python module (imp). Has GAE disabled
> certain functions from the imp module? It's already caused me a lot of
> grief. :-(
>
> Has anyone else encountered this error while running pyparsing? Any
> workarounds? Is there a list of altered modules published somewhere?
>

Victor -

There is also a possible workaround so that you don't need to use
getTokensEndLoc. If you can post or e-mail me more details on your
grammar, I can show you the specific workaround method (which also
should work faster than getTokensEndLoc).

-- Paul

Aral

unread,
Aug 3, 2008, 7:29:17 AM8/3/08
to Google App Engine
With the imp and readlink monkeypatches, I'm not getting the attribute
error on the local SDK but I _am_ still getting it on the deployment
environment.

Any ideas as to why?

Thanks,
Aral

On Jul 22, 3:40 pm, Paul McGuire <pt...@austin.rr.com> wrote:
> On Jul 21, 11:52 pm, CoderVic <vax3...@gmail.com> wrote:
>
> > I am getting this error consistently when I run my module on GAE. The
> > error is thrown by a core python module (imp). Has GAE disabled
> > certain functions from the imp module? It's already caused me a lot of
> > grief. :-(
<snip>
Reply all
Reply to author
Forward
0 new messages