[PATCH 2 of 3] py3: avoid use of basestring

Pulkit Goyal 7895pulkit at gmail.com
Sun Dec 4 09:00:51 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1480530071 -19800
#      Wed Nov 30 23:51:11 2016 +0530
# Node ID 3743d04e0403e49cd5a9c00d753262162712eeab
# Parent  d8439c1b853de322d88b60ee14ab29b065ae6b5b
py3: avoid use of basestring

"In this case, result is a source variable of a list to be returned, it
shouldn't be unicode. Hence we can use bytes instead of basestring here." -Yuya

diff -r d8439c1b853d -r 3743d04e0403 mercurial/ui.py
--- a/mercurial/ui.py	Wed Nov 30 23:38:50 2016 +0530
+++ b/mercurial/ui.py	Wed Nov 30 23:51:11 2016 +0530
@@ -535,7 +535,7 @@
         result = self.config(section, name, untrusted=untrusted)
         if result is None:
             result = default or []
-        if isinstance(result, basestring):
+        if isinstance(result, bytes):
             result = _configlist(result.lstrip(' ,\n'))
             if result is None:
                 result = default or []
diff -r d8439c1b853d -r 3743d04e0403 tests/test-check-py3-commands.t
--- a/tests/test-check-py3-commands.t	Wed Nov 30 23:38:50 2016 +0530
+++ b/tests/test-check-py3-commands.t	Wed Nov 30 23:51:11 2016 +0530
@@ -9,6 +9,6 @@
   >   $PYTHON3 `which hg` $cmd 2>&1 2>&1 | tail -1
   > done
   version
-  NameError: name 'basestring' is not defined
+  TypeError: Can't convert 'bytes' object to str implicitly
   debuginstall
-  NameError: name 'basestring' is not defined
+  TypeError: Can't convert 'bytes' object to str implicitly


More information about the Mercurial-devel mailing list