From 9a47f06a59cbeef6cf2729abe99282dbcc6eaf75 Mon Sep 17 00:00:00 2001 From: hpk Date: Wed, 18 Mar 2009 00:34:59 +0100 Subject: [PATCH] [svn r63016] * fix setattr on apimodules * higher timeout --HG-- branch : trunk --- py/execnet/testing/test_gwmanage.py | 4 ++-- py/initpkg.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/py/execnet/testing/test_gwmanage.py b/py/execnet/testing/test_gwmanage.py index 044949b35..29485f1e4 100644 --- a/py/execnet/testing/test_gwmanage.py +++ b/py/execnet/testing/test_gwmanage.py @@ -215,8 +215,8 @@ class TestMultiChannel: channel.send(os.getpid()) """) queue = mc.make_receive_queue() - ch, item = queue.get(timeout=0.5) - ch2, item2 = queue.get(timeout=0.5) + ch, item = queue.get(timeout=10) + ch2, item2 = queue.get(timeout=10) assert ch != ch2 assert ch.gateway != ch2.gateway assert item != item2 diff --git a/py/initpkg.py b/py/initpkg.py index 1bf620230..126bbc0de 100644 --- a/py/initpkg.py +++ b/py/initpkg.py @@ -165,9 +165,9 @@ def setmodule(modpath, module): class ApiModule(ModuleType): def __init__(self, pkg, name): + self.__map__ = {} self.__pkg__ = pkg self.__name__ = name - self.__map__ = {} def __repr__(self): return '' % (self.__name__,) @@ -178,17 +178,24 @@ class ApiModule(ModuleType): result = self.__pkg__._resolve(extpy) else: try: - extpy = self.__map__[name] + extpy = self.__map__.pop(name) except KeyError: __tracebackhide__ = True raise AttributeError(name) else: result = self.__pkg__._resolve(extpy) - del self.__map__[name] + setattr(self, name, result) #self._fixinspection(result, name) return result + def __setattr__(self, name, value): + super(ApiModule, self).__setattr__(name, value) + try: + del self.__map__[name] + except KeyError: + pass + def _deprecated_fixinspection(self, result, name): # modify some attrs to make a class appear at export level if hasattr(result, '__module__'):