<div dir="ltr">I tested wing_hack() a little bit:<div><br></div><div>It does not work with my pickling in unit tests:</div><div><br></div><div>#------------------------------------------------------------------</div><div><div>
import unittest<br></div><div>import pickle</div><div><br></div><div>#other imports ...</div><div><br></div><div>from toolshed.hacks import wing_hack<br></div><div><br></div><div>class Test(unittest.TestCase):</div><div>        </div>
<div>    def testAPickle(self):<br></div><div>         string = pickle.dumps(WorldModel(config = config.flow_test_config))</div><div><br></div><div><br></div><div>if __name__ == "__main__":</div><div><br></div><div>
    wing_hack()</div><div>    unittest.main(verbosity = 2)  </div><div><br></div><div>#---------------------------------------------------------</div><div>WorldModel is far too complex to post, but somewhere i assign a method like self.func = self.func2 in the test case.</div>
<div><br></div><div>I hope it's something simple but i don't know enough about the import mechanism to spot it.</div><div><br></div><div>Cheers, Lars</div><div><br></div><div>PS: declickification</div><div><br></div>
<div>def wing_hack():<br></div><div>    '''</div><div>    when wing has replaced __import__, wrap that with a function</div><div>    that pretends to be the original __import__</div><div>    '''</div>
<div>    import __builtin__</div><div>    imp = __builtin__.__import__</div><div>    if imp.__name__ != '__import__':</div><div>        print("fixing Wing's import hook")</div><div>        def __import__(*args, **kw):</div>
<div>            return imp(*args, **kw)</div><div>        __import__.__module__ = '__builtin__'</div><div>        __builtin__.__import__ = __import__</div><div><br></div><div> </div><div>    </div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Nov 1, 2013 at 11:36 AM, lars van Gemerden <span dir="ltr"><<a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Thank you Chris,<div><br></div><div>I am doing something else now but will be testing/using this asap (a lot on my plate).<br><div><br></div><div>Has anyone checked what the behavior of non-stackless python is (with and/or without Wing debugger). I think that if possible that should be the situation to mimic and should give an indication who is best positioned (Wing and/or Stackless) to do the final fix.</div>

</div><div><br></div><div>Cheers, Lars</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Wed, Oct 30, 2013 at 12:42 AM, Christian Tismer <span dir="ltr"><<a href="mailto:tismer@stackless.com" target="_blank">tismer@stackless.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div><div>On 29.10.13 16:54, John Ehresman wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/27/13 6:18 PM, Christian Tismer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So my guess of the solution is this:<br>
<br>
Let wingdb_import_hook report "__builtin__" as its module and<br>
'__import__' as<br>
its name, and you are fine.<br>
</blockquote>
<br>
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:<br>


    failimp.py debug dump<br>
    failimp.py load<br>
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.<br>


</blockquote>
<br></div></div>
Here is a simple work-around that people might want to use until either<br>
Wing or Stackless are changed a bit.<br>
It crashes in the Wing IDE, unless you specify 'fix' on the command line.<br>
<br>
cheers - chris<div><div><br>
<br>
-- <br>
Christian Tismer             :^)   <mailto:<a href="mailto:tismer@stackless.com" target="_blank">tismer@stackless.com</a>><br>
Software Consulting          :     Have a break! Take a ride on Python's<br>
Karl-Liebknecht-Str. 121     :    *Starship* <a href="http://starship.python.net/" target="_blank">http://starship.python.net/</a><br>
14482 Potsdam                :     PGP key -> <a href="http://pgp.uni-mainz.de" target="_blank">http://pgp.uni-mainz.de</a><br>
phone <a href="tel:%2B49%20173%2024%2018%20776" value="+491732418776" target="_blank">+49 173 24 18 776</a>  fax <a href="tel:%2B49%20%2830%29%20700143-0023" value="+49307001430023" target="_blank">+49 (30) 700143-0023</a><br>


PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04<br>
      whom do you want to sponsor today?   <a href="http://www.stackless.com/" target="_blank">http://www.stackless.com/</a><br>
<br>
</div></div><br></div></div><div class="im">_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com" target="_blank">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><br></div></blockquote></div><br><br clear="all"><div class="im"><div><br></div>-- <br>
====================================<br>
Lars van Gemerden<br><a href="mailto:lars@rational-it.com" target="_blank">lars@rational-it.com</a><br><a href="tel:%2B31%206%2026%2088%2055%2039" value="+31626885539" target="_blank">+31 6 26 88 55 39</a><br>====================================
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>====================================<br>Lars van Gemerden<br><a href="mailto:lars@rational-it.com">lars@rational-it.com</a><br>+31 6 26 88 55 39<br>====================================
</div>