With Python 3, StringIO has been moved from the "cStringIO" module to
the "io" module. Use a try-catch block to intercept ImportErrors and
fall back to the new module to support both Python 2 and Python 3.
import random
import re
from fnmatch import fnmatchcase as matches
-from cStringIO import StringIO
+
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from io import StringIO
try:
from urllib import quote_plus, urlretrieve