[PATCH 08 of 52 Narval cube] [new style] fix ModuleNotFoundError: No module named 'cStringIO'

Nsukami Patrick ptrck at nskm.xyz
Wed Apr 1 11:34:08 CEST 2020


# HG changeset patch
# User Nsukami Patrick <ptrck at nskm dot xyz>
# Date 1585414699 0
#      Sat Mar 28 16:58:19 2020 +0000
# Node ID c51b1029cd9cabe2c8b41aef5dcc3202ae7e16e7
# Parent  d2064d69a600f58b38a3066716701124dce56611
[new style] fix ModuleNotFoundError: No module named 'cStringIO'

diff --git a/cubicweb_narval/testutils.py b/cubicweb_narval/testutils.py
--- a/cubicweb_narval/testutils.py
+++ b/cubicweb_narval/testutils.py
@@ -20,7 +20,7 @@
 import sys
 import subprocess
 import urllib.error
-from cStringIO import StringIO
+from io import BytesIO
 from json import load
 
 from logilab.common.tasksqueue import LOW
@@ -92,12 +92,12 @@
                     if isinstance(fval[1], unicode):
                         fval = (fval[0], fval[1].encode('utf-8'))
                     if isinstance(fval[1], basestring):
-                        fval = (fval[0], StringIO(fval[1]))
+                        fval = (fval[0], BytesIO(fval[1]))
                     form[fname] = fval
             if '_cw_fields' not in form:
                 form['_cw_fields'] = ','.join([x for x in form.keys() if not x.startswith('__')])
             data, req = self.http_publish(url, form)
-            fp = StringIO(data)
+            fp = BytesIO(data)
             if req.status_out not in (200,303):
                 raise urllib.error.HTTPError(url, req.status_out,
                                         "Failed", req.headers_out, fp)




More information about the cubicweb-devel mailing list