import sys

# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3


if PY3:
    string_types = (str,)
else:  # pragma: no cover
    string_types = (basestring,)  # noqa

@@ -1,146 +1,108 @@
-import sys%0A%0A# True if we are running on Python 3.%0APY3 = sys.version_info%5B0%5D == 3%0A%0A%0Aif PY3:%0A    string_types = (str,)%0Aelse:  # pragma: no cover
+%22%22%22Compatibility support for Python 2 and 3.%22%22%22%0A%0Atry:%0A    string_types = (basestring,)%0Aexcept NameError:
 %0A   
@@ -122,25 +122,10 @@
  = (
-basestring,)  # noqa
+str,)
 %0A

Use feature detection instead of version detection for Python 2/3 compatibility.