From: Patrick Steinhardt Date: Wed, 22 May 2019 19:21:16 +0000 (+0200) Subject: test: StringIO compatibility with Python 3 X-Git-Tag: v0.13.72~57^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=743c06010ec947ca4d1e55157a9a44733f2c3017;p=zziplib 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. --- 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