[pypy-dev] [pypy-svn] r29534 - pypy/dist/pypy/rpython/ootypesystem/test

Antonio Cuni anto.cuni at gmail.com
Fri Jun 30 20:28:22 CEST 2006


Samuele Pedroni wrote:

> Records are really like lltypesystem Structs, although because some of 
> their code was copied from Instance, they may give the impression
> that you can add fields after the fact, but that should not be done,
> it breaks the fact that they are supposed to compare by structure.
> 
> If you are needing that you need some other approach or introduce
> some kind of forward definition.
> 
> _add_fields should really disappear from Record.

ok, so it's my fault, but it don't solve my original problem.

The problem is that TestCliTuple.test_inst_tuple_add_getitem in 
test_rpython.py used to fail because the IL code contained two copies of 
the same Record. After a bit of investigation I discovered that the 
reason was because I got two Records that compare equal but have 
different hashes; again, the problem was that the __cached_hash was 
different from the real one.

Then I tried to reproduce the bug, and so I wrote the failing test, 
thinking that using _add_fields was fine. But after your comment I've 
understood that this is not the point, because Record._add_fields is 
called only in its __init__.

For now the problem is worked-around in database.py (the lines marked 
with "XXX: temporary hack"), but the bug is still here: any idea of why 
I get two equal Records with different hashes?

ciao Anto



More information about the Pypy-dev mailing list