virt-manager/75210ed3-replace-StringIO-with-io.patch

140 lines
3.6 KiB
Diff

Subject: Replace StringIO with io.(StringIO or BytesIO)
From: Radostin Stoyanov rstoyanov1@gmail.com Wed Oct 11 12:35:50 2017 +0100
Date: Fri Oct 20 13:18:31 2017 -0400:
Git: 75210ed37c0c5de569de73e04488808a2521a011
StringIO and cStringIO modules no longer exists in Python 3. [1]
Use either io.StringIO [2] for text or io.BytesIO [3] for bytes.
[1] http://docs.python.org/3.0/whatsnew/3.0.html
[2] https://docs.python.org/3/library/io.html#text-i-o
[3] https://docs.python.org/3/library/io.html#binary-i-o
diff --git a/tests/clitest.py b/tests/clitest.py
index bdc1b44..cf140a9 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -16,6 +16,7 @@
# MA 02110-1301 USA.
import atexit
+import io
import logging
import os
import shlex
@@ -23,7 +24,6 @@ import shutil
import sys
import traceback
import unittest
-import StringIO
from virtinst import support
@@ -144,7 +144,7 @@ class Command(object):
oldstdin = sys.stdin
oldargv = sys.argv
try:
- out = StringIO.StringIO()
+ out = io.BytesIO()
sys.stdout = out
sys.stderr = out
sys.argv = self.argv
diff --git a/tests/virtconvtest.py b/tests/virtconvtest.py
index f804883..3afb392 100644
--- a/tests/virtconvtest.py
+++ b/tests/virtconvtest.py
@@ -18,8 +18,8 @@
from __future__ import print_function
import glob
+import io
import os
-import StringIO
import unittest
from virtconv import VirtConverter
@@ -32,7 +32,7 @@ out_dir = base_dir + "libvirt_output"
class TestVirtConv(unittest.TestCase):
def _convert_helper(self, infile, outfile, in_type, disk_format):
- outbuf = StringIO.StringIO()
+ outbuf = io.BytesIO()
def print_cb(msg):
print(msg, file=outbuf)
diff --git a/virtManager/create.py b/virtManager/create.py
index 8b4d75d..5629396 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -18,10 +18,10 @@
# MA 02110-1301 USA.
#
+import io
import logging
import pkgutil
import os
-import cStringIO
import threading
import time
@@ -2633,7 +2633,7 @@ class vmmCreate(vmmGObjectUI):
return True
# Use string buffer to store log messages
- log_stream = cStringIO.StringIO()
+ log_stream = io.StringIO()
# Get virt-bootstrap logger
vbLogger = logging.getLogger('virtBootstrap')
diff --git a/virtManager/snapshots.py b/virtManager/snapshots.py
index eeb1a9f..0d905e3 100644
--- a/virtManager/snapshots.py
+++ b/virtManager/snapshots.py
@@ -20,9 +20,9 @@
import datetime
import glob
+import io
import logging
import os
-import StringIO
from gi.repository import Gdk
from gi.repository import GdkPixbuf
@@ -394,7 +394,7 @@ class vmmSnapshotPage(vmmGObjectUI):
flags = 0
mime = self.vm.get_backend().screenshot(stream, screen, flags)
- ret = StringIO.StringIO()
+ ret = io.StringIO()
def _write_cb(_stream, data, userdata):
ignore = stream
ignore = userdata
diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
index c57c9e1..ebc5c7a 100644
--- a/virtinst/urlfetcher.py
+++ b/virtinst/urlfetcher.py
@@ -21,11 +21,11 @@
import ConfigParser
import ftplib
+import io
import logging
import os
import re
import stat
-import StringIO
import subprocess
import tempfile
import urllib2
@@ -169,7 +169,7 @@ class _URLFetcher(object):
"""
Grab the passed filename from self.location and return it as a string
"""
- fileobj = StringIO.StringIO()
+ fileobj = io.StringIO()
self._grabURL(filename, fileobj)
return fileobj.getvalue()