On 29.10.13 16:54, John Ehresman wrote:
On 10/27/13 6:18 PM, Christian Tismer wrote:
So my guess of the solution is this:
Let wingdb_import_hook report "__builtin__" as its module and
'__import__' as
its name, and you are fine.
You're right. The problem with simply using a name other than
__builtin__.__import__ is that it may not be there when a pickle is
loaded because the debugger may not be running. This is illustrated
by the attached failimp.py file. Try running:
failimp.py debug dump
failimp.py load
This simulates creating a pickle when the debugger is running and then
trying to load it when the debugger is not running. The workaround is
to set __module__ to '__builtin__' and __name__ to '__import__' on the
import_hook function.
Here is a simple work-around that people might want to use until either
Wing or Stackless are changed a bit.
It crashes in the Wing IDE, unless you specify 'fix' on the command line.
cheers - chris
--
Christian Tismer :^) <mailto:[email protected]>
Software Consulting : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* http://starship.python.net/
14482 Potsdam : PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776 fax +49 (30) 700143-0023
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
# pickle wing test
import sys
import stackless # make sure we are using stackless
def wing_hack():
'''
when wing has replaced __import__, wrap that with a function
that pretends to be the original __import__
'''
import __builtin__
imp = __builtin__.__import__
if imp.__name__ != '__import__':
print("fixing Wing's import hook")
def __import__(*args, **kw):
return imp(*args, **kw)
__import__.__module__ = '__builtin__'
__builtin__.__import__ = __import__
if 'fix' in sys.argv:
wing_hack()
import pickle, pickletools
class Test1(object):
def __init__(self):
self.func = lambda s: 0
if __name__ == '__main__':
print(__import__, __import__.__name__, __import__.__module__)
s = pickle.dumps(Test1()) #ERROR
pickletools.dis(s)
t = pickle.loads(s)
print 'done'
#-------------------------------------------------------------
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless