From 743c06010ec947ca4d1e55157a9a44733f2c3017 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 22 May 2019 21:21:16 +0200 Subject: [PATCH] test: StringIO compatibility with Python 3 With Python 3, StringIO has been moved from the "cStringIO" module to the "io" module. Use a try-catch block to intercept ImportErrors and fall back to the new module to support both Python 2 and Python 3. --- test/zziptests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/zziptests.py b/test/zziptests.py index 49f43f6..e605c6a 100644 --- a/test/zziptests.py +++ b/test/zziptests.py @@ -8,7 +8,11 @@ import shutil import random import re from fnmatch import fnmatchcase as matches -from cStringIO import StringIO + +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO try: from urllib import quote_plus, urlretrieve -- 2.40.0