pypy/interpreter/test/test_typedef.py::TestTypeDef::()::test_subclass_cache
self = <pypy.interpreter.test.test_typedef.TestTypeDef instance at 0xf3cccecc>
def test_subclass_cache(self):
# check that we don't create more than 6 subclasses of a
# given W_XxxObject (instead of the 16 that follow from
# all combinations)
space = self.space
sources = []
for hasdict in [False, True]:
for wants_slots in [False, True]:
for needsdel in [False, True]:
for weakrefable in [False, True]:
print 'Testing case', hasdict, wants_slots,
print needsdel, weakrefable
slots = []
checks = []
if hasdict:
slots.append('__dict__')
checks.append('x.foo=5; x.__dict__')
else:
checks.append('raises(AttributeError, "x.foo=5");'
'raises(AttributeError, "x.__dict__")')
if wants_slots:
slots.append('a')
checks.append('x.a=5; assert X.a.__get__(x)==5')
else:
checks.append('')
if weakrefable:
slots.append('__weakref__')
checks.append('import _weakref;_weakref.ref(x)')
else:
checks.append('')
if needsdel:
methodname = '__del__'
checks.append('X();X();X();'
'import gc;gc.collect();'
'assert seen')
else:
methodname = 'spam'
checks.append('assert "Del" not in irepr')
assert len(checks) == 4
space.appexec([], """():
seen = []
class X(list):
__slots__ = %r
def %s(self):
seen.append(1)
x = X()
import __pypy__
irepr = __pypy__.internal_repr(x)
print irepr
%s
%s
%s
%s
""" % (slots, methodname, checks[0], checks[1],
> checks[2], checks[3]))
interpreter/test/test_typedef.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
interpreter/baseobjspace.py:1479: in appexec
return self.call_args(w_func, args)
objspace/descroperation.py:186: in call_args
return w_obj.call_args(args)
interpreter/function.py:68: in call_args
w_res = self.getcode().funcrun(self, args)
interpreter/pycode.py:223: in funcrun
return frame.run()
interpreter/pyframe.py:253: in run
return self.execute_frame()
interpreter/pyframe.py:290: in execute_frame
raise self._convert_unexpected_exception(e)
interpreter/pyframe.py:943: in _convert_unexpected_exception
operr = error.get_converted_unexpected_exception(self.space, e)
interpreter/pyframe.py:286: in execute_frame
executioncontext)
interpreter/pyopcode.py:63: in dispatch
next_instr = self.handle_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:70: in handle_bytecode
next_instr = self.dispatch_bytecode(co_code, next_instr, ec)
interpreter/pyopcode.py:356: in dispatch_bytecode
self.LOOKUP_METHOD(oparg, next_instr)
objspace/std/callmethod.py:63: in LOOKUP_METHOD
w_value = w_obj.getdictvalue(space, name)
interpreter/mixedmodule.py:93: in getdictvalue
return self._load_lazily(space, name)
interpreter/mixedmodule.py:103: in _load_lazily
w_value = loader(space)
interpreter/mixedmodule.py:182: in ifileloader
d[name] = __import__(pkgroot+'.'+name, None, None, [name])
module/gc/interp_gc.py:4: in <module>
from pypy.module.gc.hook import W_GcCollectStepStats
module/gc/hook.py:2: in <module>
from rpython.memory.gc import incminimark
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
"""
# XXX Should find a way to bound the major collection threshold by the
# XXX total addressable size. Maybe by keeping some minimarkpage arenas
# XXX pre-reserved, enough for a few nursery collections? What about
# XXX raw-malloced memory?
# XXX try merging old_objects_pointing_to_pinned into
# XXX old_objects_pointing_to_young (IRC 2014-10-22, fijal and gregor_w)
import sys
import os
import time
from rpython.rtyper.lltypesystem import lltype, llmemory, llarena, llgroup
from rpython.rtyper.lltypesystem.lloperation import llop
from rpython.rtyper.lltypesystem.llmemory import raw_malloc_usage
from rpython.memory.gc.base import GCBase, MovingGCBase
> from rpython.memory.gc import env
E File "/build_dir/own-linux-x86-32/build/rpython/memory/gc/env.py", line 423
E SyntaxError: Non-ASCII character '\xe2' in file /build_dir/own-linux-x86-32/build/rpython/memory/gc/env.py on line 423, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
../rpython/memory/gc/incminimark.py:70: SyntaxError
---------- Captured stdout call ----------
Testing case False False False False
Testing case False False False True
Testing case False False True False
builder: own-linux-x86-32 build #9360
test: pypy/interpreter/test/test_typedef/py/TestTypeDef/()/test_subclass_cache