From bf057941fe4bf9957b1f64dcebeff8a0930e9e9c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 19 Oct 2012 00:50:21 -0400 Subject: [PATCH] Use Cython's libc.errno for EEXIST. Signed-off-by: W. Trevor King --- kmod/_libkmod_h.pxd | 4 ---- kmod/module.pyx | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kmod/_libkmod_h.pxd b/kmod/_libkmod_h.pxd index ef948dd..0153ac0 100644 --- a/kmod/_libkmod_h.pxd +++ b/kmod/_libkmod_h.pxd @@ -18,10 +18,6 @@ cdef extern from *: ctypedef void* const_void_ptr 'const void *' -cdef extern from 'errno.h': - enum: EEXIST - - cdef extern from 'stdbool.h': ctypedef struct bool: pass diff --git a/kmod/module.pyx b/kmod/module.pyx index 379a75d..7c84eb8 100644 --- a/kmod/module.pyx +++ b/kmod/module.pyx @@ -9,6 +9,8 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +cimport libc.errno as _errno + cimport _libkmod_h from error import KmodError as _KmodError cimport list as _list @@ -103,7 +105,7 @@ cdef class Module (object): # TODO: convert callbacks and data from Python object to C types err = _libkmod_h.kmod_module_probe_insert_module( self.module, flags, opt, install, d, print_action) - if err == -_libkmod_h.EEXIST: + if err == -_errno.EEXIST: raise _KmodError('Module already loaded') elif err < 0: raise _KmodError('Could not load module') -- 2.26.2