From 60c167f53244a53c30f4327f94a34bb498afc4dd Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 19 Aug 2020 03:19:25 -0700 Subject: [PATCH] Begin fixing functional tests for deform 2.0-branch - Fix my_safe_repr to actually support both Python 2 and 3 - Pin selenium to >=3 --- deformdemo/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/deformdemo/__init__.py b/deformdemo/__init__.py index 76eda75d..fbe9c153 100644 --- a/deformdemo/__init__.py +++ b/deformdemo/__init__.py @@ -40,6 +40,7 @@ PY3 = sys.version_info[0] == 3 +PY38MIN = sys.version_info[0] == 3 and sys.version_info[1] >= 8 if PY3: @@ -69,16 +70,12 @@ def __call__(self, method): # eliminate u'' def my_safe_repr(obj, context, maxlevels, level, sort_dicts=True): - from inspect import signature - if type(obj) == unicode: obj = obj.encode("utf-8") # Python 3.8 changed the call signature of pprint._safe_repr. - # In order to support both Python 3.8 and earlier versions - # we have to check its signature before calling - sig = signature(pprint._safe_repr) - if len(sig.parameters) == 5: + # by adding sort_dicts. + if PY38MIN: return pprint._safe_repr(obj, context, maxlevels, level, sort_dicts) else: return pprint._safe_repr(obj, context, maxlevels, level)