Example #1
0
def test_free_non_gc_object():
    class TestClass(object):
        _alloc_flavor_ = ""

        def __init__(self, a):
            self.a = a

        def method1(self):
            return self.a

        def method2(self):
            return 42

    class TestClass2(object):
        pass

    t = TestClass(1)
    assert t.method1() == 1
    assert t.method2() == 42
    free_non_gc_object(t)
    py.test.raises(RuntimeError, "t.method1()")
    py.test.raises(RuntimeError, "t.method2()")
    py.test.raises(RuntimeError, "t.a")
    py.test.raises(RuntimeError, "t.a = 1")
    py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
Example #2
0
 def delete(self):
     cur = self.oldest_chunk
     while cur:
         next = cur.next
         unused_chunks.put(cur)
         cur = next
     free_non_gc_object(self)
Example #3
0
 def delete(self):
     cur = self.oldest_chunk
     while cur:
         next = cur.next
         unused_chunks.put(cur)
         cur = next
     free_non_gc_object(self)
Example #4
0
 def f():
     from rpython.rlib.objectmodel import free_non_gc_object
     state.freed_counter = 0
     x = g()
     assert state.freed_counter == 0
     x.y = None
     assert state.freed_counter == 1
     free_non_gc_object(x)
Example #5
0
 def f():
     from rpython.rlib.objectmodel import free_non_gc_object
     state.freed_counter = 0
     x = g()
     assert state.freed_counter == 0
     x.y = None
     assert state.freed_counter == 1
     free_non_gc_object(x)
Example #6
0
 def f(i):
     a = A()
     b = B()
     c = C()
     d = None
     e = None
     if i == 0:
         d = a
     elif i == 1:
         d = b
     elif i == 2:
         e = c
     res = (0x0001 * (a is b) | 0x0002 * (a is c) | 0x0004 * (a is d)
            | 0x0008 * (a is e) | 0x0010 * (b is c) | 0x0020 * (b is d)
            | 0x0040 * (b is e) | 0x0080 * (c is d) | 0x0100 * (c is e)
            | 0x0200 * (d is e))
     free_non_gc_object(a)
     free_non_gc_object(b)
     return res
Example #7
0
 def f(i):
     a = A()
     b = B()
     c = C()
     d = None
     e = None
     if i == 0:
         d = a
     elif i == 1:
         d = b
     elif i == 2:
         e = c
     res =  (0x0001*(a is b) | 0x0002*(a is c) | 0x0004*(a is d) |
             0x0008*(a is e) | 0x0010*(b is c) | 0x0020*(b is d) |
             0x0040*(b is e) | 0x0080*(c is d) | 0x0100*(c is e) |
             0x0200*(d is e))
     free_non_gc_object(a)
     free_non_gc_object(b)
     return res
Example #8
0
def test_free_non_gc_object():
    class TestClass(object):
        _alloc_flavor_ = ""
        def __init__(self, a):
            self.a = a
        def method1(self):
            return self.a
        def method2(self):
            return 42
    class TestClass2(object):
        pass
    t = TestClass(1)
    assert t.method1() == 1
    assert t.method2() == 42
    free_non_gc_object(t)
    py.test.raises(RuntimeError, "t.method1()")
    py.test.raises(RuntimeError, "t.method2()") 
    py.test.raises(RuntimeError, "t.a")
    py.test.raises(RuntimeError, "t.a = 1")
    py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
Example #9
0
 def f(i):
     if i == 0:
         o = None
     elif i == 1:
         o = A()
     elif i == 2:
         o = B()
     else:
         o = C()
     res = 100*isinstance(o, A) + 10*isinstance(o, B) + 1*isinstance(o, C)
     if i == 0:
         pass
     elif i == 1:
         assert isinstance(o, A)
         free_non_gc_object(o)
     elif i == 2:
         assert isinstance(o, B)
         free_non_gc_object(o)
     else:
         assert isinstance(o, C)
         free_non_gc_object(o)
     return res
Example #10
0
 def f(i):
     if i == 0:
         o = None
     elif i == 1:
         o = A()
     elif i == 2:
         o = B()
     else:
         o = C()
     res = 100 * isinstance(o, A) + 10 * isinstance(o, B) + 1 * isinstance(
         o, C)
     if i == 0:
         pass
     elif i == 1:
         assert isinstance(o, A)
         free_non_gc_object(o)
     elif i == 2:
         assert isinstance(o, B)
         free_non_gc_object(o)
     else:
         assert isinstance(o, C)
         free_non_gc_object(o)
     return res
Example #11
0
 def f(x):
     a = A(x + 1)
     result = a.val
     free_non_gc_object(a)
     return result
Example #12
0
 def delete(self):
     if self.gcflag == 0:
         self.seen.delete()
     self.pending.delete()
     lltype.free(self.writebuffer, flavor='raw')
     free_non_gc_object(self)
Example #13
0
 def malloc_and_free(a):
     ci = TestClass(a)
     b = ci.method1()
     free_non_gc_object(ci)
     return b
Example #14
0
 def malloc_and_free(a):
     ci = TestClass(a)
     b = ci.method1()
     free_non_gc_object(ci)
     return b
Example #15
0
 def f(x):
     a = A(x + 1)
     result = a.val
     free_non_gc_object(a)
     return result
Example #16
0
 def delete(self):
     if self.gcflag == 0:
         self.seen.delete()
     self.pending.delete()
     free_non_gc_object(self)
Example #17
0
 def delete(self):
     if self.gcflag == 0:
         self.seen.delete()
     self.pending.delete()
     lltype.free(self.writebuffer, flavor='raw')
     free_non_gc_object(self)