Add aliases for StringIO.StringIO
authorNoel Power <noel.power@suse.com>
Tue, 17 Apr 2018 12:52:58 +0000 (13:52 +0100)
committerNoel Power <npower@samba.org>
Mon, 30 Apr 2018 13:43:19 +0000 (15:43 +0200)
cStringIO doesn't handle unicode, StringIO does. With py2/py3
compatable code we can easily find ourselves getting passed
unicode so we don't alias cStringIO

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/compat.py

index d17dc3c2ce97d9eebf7689c79247866197036d34..5662095fed527f9159b625c495c28a2536a7d769 100644 (file)
@@ -30,6 +30,10 @@ if PY3:
     integer_types = int,
     string_types = str
     text_type = str
+
+    # alias
+    import io
+    StringIO = io.StringIO
 else:
     # compat functions
     from urllib import quote as urllib_quote
@@ -39,3 +43,7 @@ else:
     integer_types = (int, long)
     string_types = basestring
     text_type = unicode
+
+    # alias
+    import StringIO
+    StringIO = StringIO.StringIO