python3 compatibility fix

From [P3 what's new page](http://docs.python.org/3.0/whatsnew/3.0.html)

string.letters and its friends (string.lowercase and string.uppercase) are gone. Use string.ascii_letters etc. instead. (The reason for the removal is that string.letters and friends had locale-specific behavior, which is a bad idea for such attractively-named global “constants”.)
Add better error message for invalid types
Merge.