[Python-Dev] cpython: Use a known unique object for the dummy entry.

Mark Shannon mark at hotpy.org
Sun Aug 18 18:31:24 CEST 2013


On 17/08/13 19:42, Antoine Pitrou wrote:
> On Sat, 17 Aug 2013 11:32:00 +0200 (CEST)
> raymond.hettinger <python-checkins at python.org> wrote:
>
>> http://hg.python.org/cpython/rev/2c9a2b588a89
>> changeset:   85218:2c9a2b588a89
>> user:        Raymond Hettinger <python at rcn.com>
>> date:        Sat Aug 17 02:31:53 2013 -0700
>> summary:
>>    Use a known unique object for the dummy entry.
>>
>> This lets us run PyObject_RichCompareBool() without
>> first needing to check whether the entry is a dummy.
>>
>> files:
>>    Objects/setobject.c |  45 ++++++++++++++------------------
>>    1 files changed, 20 insertions(+), 25 deletions(-)
>
> This broke test_gdb on several machines:
>
> ======================================================================
> FAIL: test_sets (test.test_gdb.PrettyPrintTests)
> Verify the pretty-printing of sets
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>    File "/home/antoine/cpython/default/Lib/test/test_gdb.py", line 319,
> in test_sets self.assertEqual(gdb_repr, "{'b'}")
> AssertionError: "{<object at remote 0x7ffff7eed040>, 'b'}" != "{'b'}"
> - {<object at remote 0x7ffff7eed040>, 'b'}
> + {'b'}
>
>
> Obviously the pretty-printing of sets isn't able to recognize the dummy
> from regular set contents, anymore :-) It should be fixable, but I
> don't know how.

By giving the dummy object a custom type, the dummy object can be
recognised by testing that its type equals PySetDummy_Type (or
whatever it is called)

See dictobject.c for an implementation of a suitable dummy object.

Cheers,
Mark.

>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/mark%40hotpy.org
>



More information about the Python-Dev mailing list