From 6a5162606f8c6e68539792b240cce085c4816636 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 9 Jan 2022 12:02:08 -0600 Subject: [PATCH] Drop vestigial compat.str_type Signed-off-by: Rob Browning Tested-by: Rob Browning --- 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 507a21e..33e8c1d 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 84fbce6..a5a04e9 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 0856699..2ac3075 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 a16fb50..e68b60c 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 d9aeaae..e2b5284 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.39.2