[diffoscope] 01/01: WIP fix string checking

Ximin Luo infinity0 at debian.org
Thu Jun 1 19:16:45 CEST 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch WIP/py2-pypy
in repository diffoscope.

commit dc5223ed050809b103cc1bf563a80ebc1f943bc7
Author: Ximin Luo <infinity0 at debian.org>
Date:   Thu Jun 1 19:16:28 2017 +0200

    WIP fix string checking
---
 diffoscope/difference.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 5f2e454..b1fe879 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -30,6 +30,11 @@ from .diff import diff, reverse_unified_diff
 from .config import Config
 from .profiling import profile
 
+try:
+    str_types = (str, unicode)
+except:
+    str_types = str
+
 DIFF_CHUNK = 4096
 
 logger = logging.getLogger(__name__)
@@ -78,9 +83,9 @@ class Difference(object):
             self._source1 = path1
             self._source2 = path2
         # Ensure renderable types
-        if not isinstance(self._source1, (str, unicode)):
+        if not isinstance(self._source1, str_types):
             raise TypeError("path1/source[0] is not a string")
-        if not isinstance(self._source2, (str, unicode)):
+        if not isinstance(self._source2, str_types):
             raise TypeError("path2/source[1] is not a string")
         # Whether the unified_diff already contains line numbers inside itself
         self._has_internal_linenos = has_internal_linenos

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list