bugfix: bugs in the error handling for pure C API functions for shared dict. thanks Xiaochen Wang for the patch in #365.