[Python-checkins] r60399 - in python/trunk: Include/setobject.h Objects/setobject.c

raymond.hettinger python-checkins at python.org
Mon Jan 28 22:47:42 CET 2008


Author: raymond.hettinger
Date: Mon Jan 28 22:47:42 2008
New Revision: 60399

Modified:
   python/trunk/Include/setobject.h
   python/trunk/Objects/setobject.c
Log:
Factor-out common code with a new macro

Modified: python/trunk/Include/setobject.h
==============================================================================
--- python/trunk/Include/setobject.h	(original)
+++ python/trunk/Include/setobject.h	Mon Jan 28 22:47:42 2008
@@ -73,6 +73,8 @@
 	(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \
 	  PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
 	  PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
+#define PySet_Check(ob) \
+	(Py_TYPE(ob) == &PySet_Type || PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
 
 PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);

Modified: python/trunk/Objects/setobject.c
==============================================================================
--- python/trunk/Objects/setobject.c	(original)
+++ python/trunk/Objects/setobject.c	Mon Jan 28 22:47:42 2008
@@ -2158,7 +2158,7 @@
 int
 PySet_Clear(PyObject *set)
 {
-	if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+	if (!PySet_Check(set)) {
 		PyErr_BadInternalCall();
 		return -1;
 	}
@@ -2178,7 +2178,7 @@
 int
 PySet_Discard(PyObject *set, PyObject *key)
 {
-	if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+	if (!PySet_Check(set)) {
 		PyErr_BadInternalCall();
 		return -1;
 	}
@@ -2229,7 +2229,7 @@
 PyObject *
 PySet_Pop(PyObject *set)
 {
-	if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+	if (!PySet_Check(set)) {
 		PyErr_BadInternalCall();
 		return NULL;
 	}
@@ -2239,7 +2239,7 @@
 int
 _PySet_Update(PyObject *set, PyObject *iterable)
 {
-	if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+	if (!PySet_Check(set)) {
 		PyErr_BadInternalCall();
 		return -1;
 	}


More information about the Python-checkins mailing list