This avoids making calls into Python's C API from our methods. The problem with that is that in SWIG "thread" mode, we are not holding the Python interpreter lock, and some Python functions (including allocation functions) expect to be single-threaded. While in the area, prefer generic SWIG macros to Python-specific ones and avoid int returns that are used purely for error checking. closes #374