Support for scopes being arbitrary objects

Improves list_to_scope() and scope_to_list() to deal with objects, by
calling str()/unicode() on elements in the lists instead of assuming
they are string/unicode objects.