Apparently, it must execute things at import time.
(this was noted before)

Your comment about "after import unittest, pickle, sys" is misleading.

The crucial thing is to be run ASAP after import time. I.E. independant from

'__name__ == "__main__".'

Please stop mentioning that, unless you analyzed it further.
I won't spend the time on it.

On 04/11/13 11:59, lars van Gemerden wrote:
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 <[email protected] <mailto:[email protected]>> 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 <http://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:[email protected]
    <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 <tel:%2B49%20173%2024%2018%20776>  fax +49
    (30) 700143-0023 <tel:%2B49%20%2830%29%20700143-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
    [email protected] <mailto:[email protected]>
    http://www.stackless.com/mailman/listinfo/stackless




--
====================================
Lars van Gemerden
[email protected] <mailto:[email protected]>
+31 6 26 88 55 39
====================================


_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless


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

_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to