From 51bbebd178387033440eb24119c5e644d3cd36f6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 22 May 2019 21:22:01 +0200 Subject: [PATCH] test: basestring compatibility with Python 3 In Python 2, strings were represented by the class basestring, which has been removed in Python 3 in favor of the str class. To keep compatibility with both versions of Python, let's alias basestring to str if basestring is not available. --- docs/zzipdoc/match.py | 5 +++++ test/zziptests.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docs/zzipdoc/match.py b/docs/zzipdoc/match.py index a089ec3..47582a1 100644 --- a/docs/zzipdoc/match.py +++ b/docs/zzipdoc/match.py @@ -5,6 +5,11 @@ import re +try: + basestring +except NameError: + basestring = str + # ---------------------------------------------------------- Regex Match() # beware, stupid python interprets backslashes in replace-parts only partially! class MatchReplace: diff --git a/test/zziptests.py b/test/zziptests.py index fe16601..9e814bf 100644 --- a/test/zziptests.py +++ b/test/zziptests.py @@ -20,6 +20,11 @@ except ImportError: from urllib.parse import quote_plus from urllib.request import urlretrieve +try: + basestring +except NameError: + basestring = str + logg = logging.getLogger("test") topsrcdir = "../.." -- 2.40.0