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

antocuni@codespeak.net 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.

Samuele Pedroni wrote:
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

Ok, I've found the bug, it's entirely a my fault, because in translator/cli/record.py I attach a new attribute _name to the Record, so the hash is no longer valid. Probably it's safer to store the name in some dictionary. ciao Anto

Hi Antonio, On Fri, Jun 30, 2006 at 08:54:18PM +0200, Antonio Cuni wrote:
Probably it's safer to store the name in some dictionary.
It's even required, yes: no mutating of the low-level type objects please :-) The case of Instance is a bit special in this respect. A bientot, Armin

Samuele Pedroni wrote:
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

Ok, I've found the bug, it's entirely a my fault, because in translator/cli/record.py I attach a new attribute _name to the Record, so the hash is no longer valid. Probably it's safer to store the name in some dictionary. ciao Anto

Hi Antonio, On Fri, Jun 30, 2006 at 08:54:18PM +0200, Antonio Cuni wrote:
Probably it's safer to store the name in some dictionary.
It's even required, yes: no mutating of the low-level type objects please :-) The case of Instance is a bit special in this respect. A bientot, Armin
participants (3)
-
Antonio Cuni
-
Armin Rigo
-
Samuele Pedroni