translator/c/test/test_boehm.py::TestUsingBoehm::()::test_hash_preservation
self = <rpython.translator.c.test.test_boehm.TestUsingBoehm object at 0x000001d7c9b03018>
def test_hash_preservation(self):
class C:
pass
class D(C):
pass
c = C()
d = D()
compute_hash(d) # force to be cached on 'd', but not on 'c'
#
def fn():
d2 = D()
return str((compute_hash(d2),
current_object_addr_as_int(d2),
compute_hash(c),
compute_hash(d),
compute_hash(("Hi", None, (7.5, 2)))))
f = self.getcompiled(fn)
> res = f()
translator\c\test\test_boehm.py:387:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator\c\test\test_genc.py:198: in __call__
return f(*args, **kwds)
translator\c\test\test_genc.py:145: in f
err=return_stderr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.translator.c.genc.CStandaloneBuilder object at 0x000001d7cc3cfa60>
args = '', env = None, err = False, expect_crash = False
exe = local('d:\\systemtemp\\pytest\\usession-pytest3.10-496\\testing_17\\testing_17.exe')
def cmdexec(self, args='', env=None, err=False, expect_crash=False, exe=None):
assert self._compiled
if sys.platform == 'win32':
#Prevent opening a dialog box
import ctypes
winapi = ctypes.windll.kernel32
SetErrorMode = winapi.SetErrorMode
SetErrorMode.argtypes=[ctypes.c_int]
SEM_FAILCRITICALERRORS = 1
SEM_NOGPFAULTERRORBOX = 2
SEM_NOOPENFILEERRORBOX = 0x8000
flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX \
| SEM_NOOPENFILEERRORBOX
#Since there is no GetErrorMode, do a double Set
old_mode = SetErrorMode(flags)
SetErrorMode(old_mode | flags)
if env is None:
envrepr = ''
else:
envrepr = ' [env=%r]' % (env,)
env.update(os.environ)
if exe is None:
exe = self.executable_name
log.cmdexec('%s %s%s' % (exe, args, envrepr))
res = self.translator.platform.execute(exe, args, env=env)
if sys.platform == 'win32':
SetErrorMode(old_mode)
if res.returncode != 0:
if expect_crash:
if type(expect_crash) is int and expect_crash != res.returncode:
raise Exception("Returned %d, but expected %d" % (
res.returncode, expect_crash))
return res.out, res.err
print(res.err, file=sys.stderr)
> raise Exception("Returned %d" % (res.returncode,))
E Exception: Returned 3221225477
translator\c\genc.py:318: Exception
builder: rpython-win-x86-64 build #404
test: translator/c/test/test_boehm/py/TestUsingBoehm/()/test_hash_preservation