I don't know if 'items' is the right attribute to check, or if it would actually be better to change to isinstance(data, dict). What other data structures are mean to be acceptable? What is "something similar" to a dict?

For whoever wants to work on it, regarding
...
I don't know if 'items' is the right attribute to check, or if it would actually be better to change to isinstance(data, dict). What other data structures are mean to be acceptable? What is "something similar" to a dict?

There is some custom "Mapping types" in sage like FreeModuleElement_generic_sparse, which implements items and iteritems but doesn't inherit from dict.