[Stackless] Fwd: deepcopying (pickling) channels
lars van Gemerden
lars at rational-it.com
Fri Nov 1 12:28:09 CET 2013
I tested wing_hack() a little bit:
It does not work with my pickling in unit tests:
#------------------------------------------------------------------
import unittest
import pickle
#other imports ...
from toolshed.hacks import wing_hack
class Test(unittest.TestCase):
def testAPickle(self):
string = pickle.dumps(WorldModel(config = config.flow_test_config))
if __name__ == "__main__":
wing_hack()
unittest.main(verbosity = 2)
#---------------------------------------------------------
WorldModel is far too complex to post, but somewhere i assign a method like
self.func = self.func2 in the test case.
I hope it's something simple but i don't know enough about the import
mechanism to spot it.
Cheers, Lars
PS: declickification
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__
On Fri, Nov 1, 2013 at 11:36 AM, lars van Gemerden <lars at rational-it.com>wrote:
> Thank you Chris,
>
> I am doing something else now but will be testing/using this asap (a lot
> on my plate).
>
> 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.
>
> Cheers, Lars
>
>
> On Wed, Oct 30, 2013 at 12:42 AM, Christian Tismer <tismer at stackless.com>wrote:
>
>> 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:tismer at stackless.com>
>> 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/
>>
>>
>> _______________________________________________
>> Stackless mailing list
>> Stackless at stackless.com
>> http://www.stackless.com/mailman/listinfo/stackless
>>
>
>
>
> --
> ====================================
> Lars van Gemerden
> lars at rational-it.com
> +31 6 26 88 55 39
> ====================================
>
--
====================================
Lars van Gemerden
lars at rational-it.com
+31 6 26 88 55 39
====================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20131101/2cc126f6/attachment.html>
More information about the Stackless
mailing list