X-Git-Url: https://projects.mako.cc/source/twitter-api-cdsw/blobdiff_plain/b5d973d7a0a14eca21b2981ffacf4fb9ea77ba41..29c8e0142111e03237eb8f92a9470ba90d295e10:/oauthlib/oauth2/rfc6749/utils.py diff --git a/oauthlib/oauth2/rfc6749/utils.py b/oauthlib/oauth2/rfc6749/utils.py index 6a8e24b..870ac32 100644 --- a/oauthlib/oauth2/rfc6749/utils.py +++ b/oauthlib/oauth2/rfc6749/utils.py @@ -24,20 +24,16 @@ def list_to_scope(scope): """Convert a list of scopes to a space separated string.""" if isinstance(scope, unicode_type) or scope is None: return scope - elif isinstance(scope, (tuple, list)): + elif isinstance(scope, (set, tuple, list)): return " ".join([unicode_type(s) for s in scope]) - elif isinstance(scope, set): - return list_to_scope(list(scope)) else: - raise ValueError("Invalid scope, must be string or list.") + raise ValueError("Invalid scope (%s), must be string, tuple, set, or list." % scope) def scope_to_list(scope): """Convert a space separated string to a list of scopes.""" - if isinstance(scope, list): + if isinstance(scope, (tuple, list, set)): return [unicode_type(s) for s in scope] - if isinstance(scope, set): - scope_to_list(list(scope)) elif scope is None: return None else: