summaryrefslogtreecommitdiffstats
path: root/Lib/ihooks.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-03-14 23:05:54 (GMT)
committerGuido van Rossum <guido@python.org>2002-03-14 23:05:54 (GMT)
commit8c8425531638fcab2093639d29c413cdb3bea787 (patch)
tree2506d03952de8ec487ffd333d4d3f80cc119d177 /Lib/ihooks.py
parent0628dcfe1faac4926505f8c4cb1905d7700d1bf1 (diff)
downloadcpython-8c8425531638fcab2093639d29c413cdb3bea787.zip
cpython-8c8425531638fcab2093639d29c413cdb3bea787.tar.gz
cpython-8c8425531638fcab2093639d29c413cdb3bea787.tar.bz2
"Fix" for SF bug #520644: __slots__ are not pickled.
As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Bugfix candidate (also the checkin to typeobject.c, of course).
Diffstat (limited to 'Lib/ihooks.py')
0 files changed, 0 insertions, 0 deletions
pan> True # Must have some module named ``_thread`` that implements its API # in order to initially import ``threading``. sys_modules['_thread'] = sys_modules['_dummy_thread'] if 'threading' in sys_modules: # If ``threading`` is already imported, might as well prevent # trying to import it more than needed by saving it if it is # already imported before deleting it. held_threading = sys_modules['threading'] holding_threading = True del sys_modules['threading'] if '_threading_local' in sys_modules: # If ``_threading_local`` is already imported, might as well prevent # trying to import it more than needed by saving it if it is # already imported before deleting it. held__threading_local = sys_modules['_threading_local'] holding__threading_local = True del sys_modules['_threading_local'] import threading # Need a copy of the code kept somewhere... sys_modules['_dummy_threading'] = sys_modules['threading'] del sys_modules['threading'] sys_modules['_dummy__threading_local'] = sys_modules['_threading_local'] del sys_modules['_threading_local'] from _dummy_threading import * from _dummy_threading import __all__ finally: # Put back ``threading`` if we overwrote earlier if holding_threading: sys_modules['threading'] = held_threading del held_threading del holding_threading # Put back ``_threading_local`` if we overwrote earlier if holding__threading_local: sys_modules['_threading_local'] = held__threading_local del held__threading_local del holding__threading_local # Put back ``thread`` if we overwrote, else del the entry we made if holding_thread: sys_modules['_thread'] = held_thread del held_thread else: del sys_modules['_thread'] del holding_thread del _dummy_thread del sys_modules