improve compatibility with SWIG, patch by James Knight!