simplegeo/python-oauth2 — pull request #120 by k0s (2012-09-19 16:56:23+00:00)
Title: use the '__iter__' attribute to determine if something is iterable vs a volatile error message

oauth2 uses the error string 'is not iterable' after try to cast to a list:

https://github.com/simplegeo/python-oauth2/blob/master/oauth2/__init__.py#L135

This is a fragile way of determining if something is an iterable or not. Instead, the '__iter__' attribute can be checked for.

As a case in point, for python 2.4 the error message is:

>>> list(12345)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: iteration over non-sequence

See https://bugzilla.mozilla.org/show_bug.cgi?id=789972#c12 which is the motivation for this pull request