[Python-checkins] r69431 - python/branches/py3k/Objects/typeobject.c
mark.dickinson
python-checkins at python.org
Sun Feb 8 12:02:10 CET 2009
Author: mark.dickinson
Date: Sun Feb 8 12:02:10 2009
New Revision: 69431
Log:
Issue #1717: add a DeprecationWarning in 3.x on type initialization
for types that implement tp_reserved (formerly tp_compare) but
not tp_richcompare.
Modified:
python/branches/py3k/Objects/typeobject.c
Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c (original)
+++ python/branches/py3k/Objects/typeobject.c Sun Feb 8 12:02:10 2009
@@ -3886,6 +3886,21 @@
goto error;
}
+ /* Warn for a type that implements tp_compare (now known as
+ tp_reserved) but not tp_richcompare. */
+ if (type->tp_reserved && !type->tp_richcompare) {
+ int error;
+ char msg[240];
+ PyOS_snprintf(msg, sizeof(msg),
+ "Type %.100s defines tp_reserved (formerly "
+ "tp_compare) but not tp_richcompare. "
+ "Comparisons may not behave as intended.",
+ type->tp_name);
+ error = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1);
+ if (error == -1)
+ goto error;
+ }
+
/* All done -- set the ready flag */
assert(type->tp_dict != NULL);
type->tp_flags =
More information about the Python-checkins
mailing list