cstring io fix for py3
authorKenneth Reitz <me@kennethreitz.com>
Fri, 18 Feb 2011 21:08:26 +0000 (16:08 -0500)
committerKenneth Reitz <me@kennethreitz.com>
Fri, 18 Feb 2011 21:08:26 +0000 (16:08 -0500)
test_requests.py

index 963abbc..a45f5cb 100644 (file)
@@ -1,12 +1,16 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+import sys
 import unittest
 
-try:
-    from cStringIO import StringIO
-except ImportError:
-    from StringIO import StringIO
+if sys.version_info >= (3,0):
+    from io import StringIO
+else:
+    try:
+        from cStringIO import StringIO
+    except ImportError:
+        from StringIO import StringIO
 
 import requests