##// END OF EJS Templates
Minor fixes in genutils, and a BIG fix for threading. I _think_ I got...
Minor fixes in genutils, and a BIG fix for threading. I _think_ I got Ctrl-C to work in the threaded shells, and the solution is in fact absolutely trivial. The new code is _much_ simpler than what we had! This needs testing, because I find it almost hard to believe that we hadn't tried this before. But if it works, great! The only limitation is that in threaded mode, the traceback shows the internal sigint handler frame. Big deal, it's just cosmetic.

File last commit:

r0:6f629fcc
r20:fb5e5b43
Show More
FakeModule.py
48 lines | 1.6 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""
Class which mimics a module.
Needed to allow pickle to correctly resolve namespaces during IPython
sessions.
$Id: FakeModule.py 410 2004-11-04 07:58:17Z fperez $"""
#*****************************************************************************
# Copyright (C) 2002-2004 Fernando Perez. <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
class FakeModule:
"""Simple class with attribute access to fake a module.
This is not meant to replace a module, but to allow inserting a fake
module in sys.modules so that systems which rely on run-time module
importing (like shelve and pickle) work correctly in interactive IPython
sessions.
Do NOT use this code for anything other than this IPython private hack."""
def __init__(self,adict):
# It seems pydoc (and perhaps others) needs any module instance to
# implement a __nonzero__ method, so we add it if missing:
if '__nonzero__' not in adict:
def __nonzero__():
return 1
adict['__nonzero__'] = __nonzero__
self.__dict__ = adict
def __getattr__(self,key):
try:
return self.__dict__[key]
except KeyError, e:
raise AttributeError("FakeModule object has no attribute %s" % e)
def __str__(self):
return "<IPython.FakeModule instance>"
def __repr__(self):
return str(self)