[PATCH 7/9] Drop vestigial compat.str_type

0 views
Skip to first unread message

Rob Browning

unread,
Jan 16, 2022, 3:51:30 PM1/16/22
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/compat.py | 1 -
lib/bup/drecurse.py | 3 +--
lib/bup/helpers.py | 6 +++---
lib/bup/vfs.py | 4 ++--
test/lib/buptest/__init__.py | 4 ++--
5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/lib/bup/compat.py b/lib/bup/compat.py
index 507a21e5..33e8c1da 100644
--- a/lib/bup/compat.py
+++ b/lib/bup/compat.py
@@ -10,7 +10,6 @@ from os import environb as environ
from os import fsdecode, fsencode
from shlex import quote

-str_type = str
int_types = (int,)

def hexstr(b):
diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py
index 84fbce60..a5a04e9a 100644
--- a/lib/bup/drecurse.py
+++ b/lib/bup/drecurse.py
@@ -2,7 +2,6 @@
from __future__ import absolute_import
import stat, os

-from bup.compat import str_type
from bup.helpers \
import (add_error,
debug1,
@@ -89,7 +88,7 @@ def recursive_dirlist(paths, xdev, bup_dir=None,
xdev_exceptions=frozenset()):
with finalized_fd(b'.') as startdir:
try:
- assert not isinstance(paths, str_type)
+ assert not isinstance(paths, str)
for path in paths:
try:
pst = xstat.lstat(path)
diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index 0856699d..2ac3075b 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -286,7 +286,7 @@ def squote(x):
def quote(x):
if isinstance(x, bytes):
return bquote(x)
- if isinstance(x, compat.str_type):
+ if isinstance(x, str):
return squote(x)
assert False
# some versions of pylint get confused
@@ -301,11 +301,11 @@ def shstr(cmd):
call() and friends. e.g. log(shstr(cmd)); call(cmd)

"""
- if isinstance(cmd, (bytes, compat.str_type)):
+ if isinstance(cmd, (bytes, str)):
return cmd
elif all(isinstance(x, bytes) for x in cmd):
return b' '.join(map(bquote, cmd))
- elif all(isinstance(x, compat.str_type) for x in cmd):
+ elif all(isinstance(x, str) for x in cmd):
return ' '.join(map(squote, cmd))
raise TypeError('unsupported shstr argument: ' + repr(cmd))

diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index a16fb50a..e68b60cc 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -57,7 +57,7 @@ from time import localtime, strftime
import re, sys

from bup import git, vint
-from bup.compat import hexstr, pending_raise, str_type
+from bup.compat import hexstr, pending_raise
from bup.git import BUP_CHUNKED, parse_commit, tree_decode
from bup.helpers import debug2, last, nullcontext_if_not
from bup.io import path_msg
@@ -951,7 +951,7 @@ def _resolve_path(repo, path, parent=None, want_meta=True, follow=True):
if parent:
for x in parent:
assert len(x) == 2
- assert isinstance(x[0], (bytes, str_type))
+ assert isinstance(x[0], (bytes, str))
assert isinstance(x[1], item_types)
assert parent[0][1] == _root
if not S_ISDIR(item_mode(parent[-1][1])):
diff --git a/test/lib/buptest/__init__.py b/test/lib/buptest/__init__.py
index d9aeaaed..e2b5284d 100644
--- a/test/lib/buptest/__init__.py
+++ b/test/lib/buptest/__init__.py
@@ -9,7 +9,7 @@ from traceback import extract_stack
import errno, os, subprocess, sys, tempfile

from bup import helpers
-from bup.compat import fsencode, str_type
+from bup.compat import fsencode
from bup.io import byte_stream


@@ -35,7 +35,7 @@ def run(cmd, check=True, input=None, **kwargs):

def logcmd(cmd):
s = helpers.shstr(cmd)
- if isinstance(cmd, str_type):
+ if isinstance(cmd, str):
print(s, file=sys.stderr)
else:
# bytes - for now just escape it
--
2.30.2

Reply all
Reply to author
Forward
0 new messages