[Stackless] Fwd: deepcopying (pickling) channels

Christian Tismer tismer at stackless.com
Fri Nov 1 23:57:22 CET 2013


On 01.11.13 12:28, lars van Gemerden wrote:
> 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
>

Ah, no, you should let that hack run unconditionally at import time.
That was a sample script that could be traced in Wing, not a thing to 
use as-is...
Remove the condition and maybe traces.
(I never used Wing's testing, because pytest is still unsupported :-( ).

#------------------------------------------------------------------
# pickle wing fix, to be run unconditionally at start-up time

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__

wing_hack()
#------------------------------------------------------------------

-- 
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/




More information about the Stackless mailing list