[Python-Dev] python 3.0, tp_compare not used for == test? (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Feb 2 12:38:19 CET 2009


Mark Dickinson wrote:

On Mon, Feb 2, 2009 at 10:36 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

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 tpcompare but not tprichcompare.

That's what the -3 command line switch is for - it sets a boolean flag that C code can check to see if it should emit warnings for things that are going to break in Python 3.x. There's already at least one example of its use in typeobject.c (relating to inheritance of the tp_hash slot). There are a few other examples about the place (e.g. I believe that when -3 is defined the return value of dict.keys and friends is changed to a list subclass that warns on certain operations that have different semantics in 3.x).

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list