[Python-Dev] python 3.0, tp_compare not used for == test?

Mark Dickinson dickinsm at gmail.com
Mon Feb 2 12:15:19 CET 2009


On Mon, Feb 2, 2009 at 10:36 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> I'm wondering if Mark should add the exception he recently removed back
> in as a Deprecation Warning when tp_compare is defined, but
> tp_richcompare is not.

This sounds reasonable to me.  A third-party module that implements
tp_compare but not tp_richcompare is almost certainly not going to be
giving the behaviour that its author intended, after 3.0.1.

Currently, the only warning that such an author gets is a possible
compiler warning about incompatible pointer types (type of
tp_compare versus type of tp_reserved), should he/she
happen to recompile and be watching the compiler output closely.

> Such a warning should also be present when
> running with -3 in 2.7 (assuming it isn't already there).

I'm not sure how/whether that would work, given that there are
probably still plenty of 2.7 modules in the distribution that
(quite legitimately) define tp_compare but not tp_richcompare.

Mark


More information about the Python-Dev mailing list