[PATCH] inotify extension: make proper use of Python API to get object size

Renato Cunha renatoc at gmail.com
Wed Jun 16 17:55:41 CDT 2010


# HG changeset patch
# User Renato Cunha <renatoc at gmail.com>
# Date 1276728887 10800
# Node ID 4d7562a192b5cb87f0d79954282fef19353bdafa
# Parent  0044193a1c45790bb3ab1ad998799244b70df1a2
inotify extension: make proper use of Python API to get object size.

In older python versions, it was ok to access an object's type by accessing its
ob_type "member". With python 2.6+, the proper way of accessing it is via
Py_TYPE(object). This patch implements the correct call for the inotify
extension. When under python < 2.6, this macro is defined in mercurial's
util.h.

diff --git a/hgext/inotify/linux/_inotify.c b/hgext/inotify/linux/_inotify.c
--- a/hgext/inotify/linux/_inotify.c
+++ b/hgext/inotify/linux/_inotify.c
@@ -327,7 +327,7 @@
 	Py_XDECREF(evt->cookie);
 	Py_XDECREF(evt->name);
 
-	(*evt->ob_type->tp_free)(evt);
+	Py_TYPE(evt)->tp_free(evt);
 }
 
 static PyObject *event_repr(struct event *evt)


More information about the Mercurial-devel mailing list