Open GoogleCodeExporter opened 8 years ago
seems the problem is somewhere esle, not in your code:
meta.py:
--------------------------------------------------------------------------
import __builtin__, imp, sys, tokenize, StringIO, tempfile
def replace_meta( fp ):
output = [ ]
for tkn in tokenize.generate_tokens( fp.readline ):
output.append( tkn )
print tkn
modded_code = tokenize.untokenize( output )
tfile = open( 'aaa.py', 'w' )
tfile.write( modded_code )
return tfile
return StringIO.StringIO( modded_code )
def __import__(name, globals=None, locals=None, fromlist=None):
# Fast path: see if the module has already been imported.
print 'importing module:', name
try:
return sys.modules[name]
except KeyError:
pass
# If any of the following calls raises an exception,
# there's a problem we can't handle -- let the caller handle it.
fp, pathname, description = imp.find_module(name)
fp = replace_meta( fp )
try:
return imp.load_module(name, fp, pathname, description)
finally:
# Since we may exit via an exception, close fp explicitly.
if fp:
fp.close()
__builtin__.__import__ = __import__
import metapython_test
metapython_test
--------------------------------------------------------------------------
metapython_test.py:
--------------------------------------------------------------------------
def aaa():
print 123
--------------------------------------------------------------------------
gives the same error
Matus
Original comment by mat...@gmail.com
on 30 Jul 2009 at 2:05
This is the bug:
http://bugs.python.org/issue9974?@ok_message=msg%20119084%20created%3Cbr%3Eissue
%209974%20message_count,%20messages%20edited%20ok&@template=item
Doesn't happen in 2.5 (for me, anyway).
Original comment by ngv...@gmail.com
on 18 Oct 2010 at 9:34
Original issue reported on code.google.com by
rick446...@gmail.com
on 30 Jul 2009 at 1:24