pymoab tag_get_default_value returns NULL when tag created via pymoab with default = None

Issue #176 new
Paul Wilson created an issue

When a tag is created via pymoab tag_get_handle() and the default value is set to None (which is the default), then that property of the tag is initialized with NULL on the C++ side.

When the default value is requested via pymoab’s tag_get_default_value() it returns the NULL pointer to the python code via cython.

Should this be interpreted in pymoab such that None can be returned? or should we expect the calling code to catch this somehow? Currently it results in error: ValueError: Cannot create cython.array from NULL pointer and I think this needs to be resolved on the pymoab side.

Comments (4)

  1. Paul Wilson reporter

    Upon further inspection, MOAB’s Core::tag_get_default_value() should return MB_ENTITY_NOT_FOUND when the default value was initialized as NULL, and pymoab is setup to check and handle that, throwing a RuntimeError. It might be that we need to handle this on the calling side, after all.

  2. Vijay M

    I still like the idea of returning None if the underlying default value is a nullptr. MB_ENTITY_NOT_FOUND as a return error code does not make sense to me in this context.

  3. Paul Wilson reporter

    The specific ValueError still makes me suspicious that this is happening before pymoab throws the exception.

  4. Log in to comment