Message 98217 - Python tracker (original) (raw)

I'm new to this thread, so I hope I didn't miss anything that has been said already. I don't fully understand why TypeError cannot be raised in 2.x. The 2.6 documentation for tp_richcompare says:

"If you want to implement a type for which only a limited set of comparisons makes sense (e.g. == and !=, but not < and friends), directly raise TypeError in the rich comparison function."

I just tried that in the 2.7 version of cdecimal, and it works well:

from cdecimal import * Decimal(9) < 2.5 Traceback (most recent call last): File "", line 1, in TypeError: conversion from float to Decimal is not supported