Author: Maciej Fijalkowski <fij...@gmail.com> Branch: kill-someobject Changeset: r57843:d37368dbd72a Date: 2012-10-07 19:49 +0200 http://bitbucket.org/pypy/pypy/changeset/d37368dbd72a/
Log: in-progress diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py --- a/pypy/translator/c/genc.py +++ b/pypy/translator/c/genc.py @@ -276,44 +276,6 @@ extrafiles.append(fn) return extrafiles -class ModuleWithCleanup(object): - def __init__(self, mod): - self.__dict__['mod'] = mod - - def __getattr__(self, name): - mod = self.__dict__['mod'] - obj = getattr(mod, name) - parentself = self - if callable(obj) and getattr(obj, '__module__', None) == mod.__name__: - # The module must be kept alive with the function. - # This wrapper avoids creating a cycle. - class Wrapper: - def __init__(self, obj): - self.myself = parentself - self.func = obj - def __call__(self, *args, **kwargs): - return self.func(*args, **kwargs) - obj = Wrapper(obj) - return obj - - def __setattr__(self, name, val): - mod = self.__dict__['mod'] - setattr(mod, name, val) - - def __del__(self): - import sys - if sys.platform == "win32": - from _ctypes import FreeLibrary as dlclose - else: - from _ctypes import dlclose - # XXX fish fish fish - mod = self.__dict__['mod'] - dlclose(mod._lib._handle) - try: - del sys.modules[mod.__name__] - except KeyError: - pass - class CStandaloneBuilder(CBuilder): standalone = True diff --git a/pypy/translator/c/test/test_genc.py b/pypy/translator/c/test/test_genc.py --- a/pypy/translator/c/test/test_genc.py +++ b/pypy/translator/c/test/test_genc.py @@ -44,19 +44,11 @@ def test_simple(): def f(x): return x*2 - t = TranslationContext() - t.buildannotator().build_types(f, [int]) - t.buildrtyper().specialize() - t.config.translation.countmallocs = True - builder = genc.CExtModuleBuilder(t, f, config=t.config) - builder.generate_source() - builder.compile() - f1 = builder.get_entry_point() + f1 = compile(f, [int]) assert f1(5) == 10 assert f1(-123) == -246 - assert builder.get_malloc_counters()() == (0, 0) py.test.raises(Exception, f1, "world") # check that it's really typed _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit