self.obj.close()
+def wrap(new, old):
+ """Simple substitute for functools.wraps."""
+ for replace in ['__module__', '__name__', '__doc__']:
+ setattr(new, replace, getattr(old, replace))
+ new.__dict__.update(old.__dict__)
+
+
def set___package__(fxn):
"""Set __package__ on the returned module."""
def wrapper(*args, **kwargs):
if not hasattr(module, '__path__'):
module.__package__ = module.__package__.rpartition('.')[0]
return module
+ wrap(wrapper, fxn)
return wrapper
if self._name != name:
raise ImportError("loader cannot handle %s" % name)
return method(self, name, *args, **kwargs)
- inner.__name__ = method.__name__
- inner.__doc__ = method.__doc__
- inner.__dict__.update(method.__dict__)
+ wrap(inner, method)
return inner
elif hasattr(module, attr):
delattr(module, attr)
raise
+ wrap(decorated, fxn)
return decorated