[Stackless] Fwd: deepcopying (pickling) channels

lars van Gemerden lars at rational-it.com
Mon Nov 4 11:59:36 CET 2013


Thank you Chris,

My (pickling) tests are working again.

One note: for other using this script: the script must run before other
imports (don't know exactly which, but as early as possible seems like a
good idea; after 'import unittest, pickle, sys' did not work).

Also thanks John for your integration efforts for stackless.

Cheers, Lars


On Sat, Nov 2, 2013 at 1:25 AM, Christian Tismer <tismer at stackless.com>wrote:

> On 01.11.13 23:57, Christian Tismer wrote:
> ...
>
> Ok, this one is probably better.
> It is also independant from the python version.
>
> It will also give you a hint when it becomes obsolete at some later time
> ;-)
>
> #------------------------------------------------------------------
> # universal pickling wrapper for WingIDE
>
> import os
>
> def wing_hack(logger):
>
>     '''
>     when wing has replaced __import__, wrap that with a function
>     that pretends to be the original __import__
>     '''
>     import sys
>     if sys.version_info[0] >= 3:
>         import builtins
>     else:
>         import __builtin__ as builtins
>     imp = builtins.__import__
>     if imp.__name__ != '__import__':
>         logger.info("fixing Wing's import hook")
>
>         def __import__(*args, **kw):
>             return imp(*args, **kw)
>         __import__.__module__ = builtins.__name__
>         builtins.__import__ = __import__
>     else:
>         logger.warn("you can trash the Wing hack")
>
> if 'WINGDB_PYTHON' in os.environ:
>     import logging
>
>     logging.basicConfig(level=logging.INFO)
>     wing_hack(logging.getLogger('WingIDE'))
>
>
> if __name__ == '__main__':
>
>     import unittest
>     import pickle
>     import sys
>
>     @unittest.skipIf('Stackless' not in sys.version, 'Stackless only')
>     class Test(unittest.TestCase):
>
>         def testAPickle(self):
>             def test():
>                 pass
>
>             string = pickle.dumps(test)
>
>     unittest.main()
>
> #------------------------------------------------------------------
>
> --
> 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
====================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20131104/d8fc52e7/attachment.html>


More information about the Stackless mailing list