summary refs log tree commit diff stats
path: root/tests/qemu-iotests/nbd-fault-injector.py
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2018-10-22 14:53:06 +0100
committerEduardo Habkost <ehabkost@redhat.com>2018-10-30 21:13:54 -0300
commit2d894bee1c907399fbd59163a18e42c41daf4863 (patch)
tree89634e65be7ec206e333d52de4e260e511bef2e8 /tests/qemu-iotests/nbd-fault-injector.py
parentc1a65cba9c1b9a0ad72046dc73ab0e316b9cb7fe (diff)
downloadfocaccia-qemu-2d894bee1c907399fbd59163a18e42c41daf4863.tar.gz
focaccia-qemu-2d894bee1c907399fbd59163a18e42c41daf4863.zip
iotests: Modify imports for Python 3
There are two imports that need to be modified when running the iotests
under Python 3: One is StringIO, which no longer exists; instead, the
StringIO class comes from the io module, so import it from there (and
use the BytesIO class for Python 2).  The other is the ConfigParser,
which has just been renamed to configparser.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20181022135307.14398-9-mreitz@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/nbd-fault-injector.py')
-rwxr-xr-xtests/qemu-iotests/nbd-fault-injector.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
index d45e2e0a6a..6b2d659dee 100755
--- a/tests/qemu-iotests/nbd-fault-injector.py
+++ b/tests/qemu-iotests/nbd-fault-injector.py
@@ -48,7 +48,10 @@ import sys
 import socket
 import struct
 import collections
-import ConfigParser
+if sys.version_info.major >= 3:
+    import configparser
+else:
+    import ConfigParser as configparser
 
 FAKE_DISK_SIZE = 8 * 1024 * 1024 * 1024 # 8 GB
 
@@ -225,7 +228,7 @@ def parse_config(config):
     return rules
 
 def load_rules(filename):
-    config = ConfigParser.RawConfigParser()
+    config = configparser.RawConfigParser()
     with open(filename, 'rt') as f:
         config.readfp(f, filename)
     return parse_config(config)