##// END OF EJS Templates
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
- Fixes for doctest support. Need more testing, esp. to be sure they don't introduce any side-effects, since I'm messing with the FakeModule object which Pickle and others depend on. - Small fixes in object inspection. - Restored a number of magics that should NOT have been moved out to ipy_legacy.

File last commit:

r834:a1312bc6
r834:a1312bc6
Show More
FakeModule.py
52 lines | 1.7 KiB | text/x-python | PythonLexer
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # -*- coding: utf-8 -*-
"""
Class which mimics a module.
Needed to allow pickle to correctly resolve namespaces during IPython
sessions.
fperez
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
r834 $Id: FakeModule.py 2723 2007-09-07 07:44:16Z fperez $"""
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
#*****************************************************************************
# 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.
#*****************************************************************************
fperez
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
r834 import types
class FakeModule(types.ModuleType):
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """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):
vivainio
revert fakemodule and oinspect mods, they broke unittest. monkeypatch is back
r363
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # 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__
fperez
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
r834 self._dict_ = adict
vivainio
revert fakemodule and oinspect mods, they broke unittest. monkeypatch is back
r363
fperez
- add support for PyCrust-style _getAttributeNames magic method. Closes #50....
r292 # modules should have a __file__ attribute
fperez
Small fix to respect the __file__ attribute when using %run
r566 adict.setdefault('__file__',__file__)
fperez
- add support for PyCrust-style _getAttributeNames magic method. Closes #50....
r292
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def __getattr__(self,key):
vivainio
revert fakemodule and oinspect mods, they broke unittest. monkeypatch is back
r363 try:
fperez
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
r834 return self._dict_[key]
vivainio
revert fakemodule and oinspect mods, they broke unittest. monkeypatch is back
r363 except KeyError, e:
raise AttributeError("FakeModule object has no attribute %s" % e)
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 def __str__(self):
return "<IPython.FakeModule instance>"
def __repr__(self):
return str(self)