simplegeo/python-oauth2 — Issue #94: to_unicode_optional_iterator() is broken in python 2.4.3
Author: cdunklau
Created: 2011-10-26 18:24:15+00:00
State: open

This snippet doesn't work right in python 2.4.3 (and likely others before class-based exceptions were introduced). It appears again in get_normalized_parameters().

```python
except TypeError, e:
assert 'is not iterable' in str(e)
```

The problem is that the string describing the TypeError does not contain 'is not iterable' in 2.4.3:

```
Python 2.4.3 (#1, May 5 2011, 16:39:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = list(1)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: iteration over non-sequence

Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16)
[GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = list(1)
Traceback (most recent call last):
File "", line 1, in
TypeError: 'int' object is not iterable
```

The snippet seems like it's pretty fragile... depending on the string contents of a built-in exception seems like a very bad idea, but maybe that's just me.

This bit me pretty hard, since there's no note anywhere (that I could find) that mentioned a minimum python version. I had put my interface code together on python 2.6.4, but needed to implement some OAuth stuff on an appliance... ouch!

Overall I love this project, though. Keep up the good work! I'll post a workaround patch if I come up with a decent solution.