diff --git a/mmgen/cfg.py b/mmgen/cfg.py index d9b2813e..dc5487dd 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -75,10 +75,7 @@ class GlobalConstants(Lockable): # Resource Access without the performance overhead of that package. # https://importlib-resources.readthedocs.io/en/latest/migration.html # https://setuptools.readthedocs.io/en/latest/pkg_resources.html - try: - from importlib.resources import files # Python 3.9 - except ImportError: - from importlib_resources import files + from importlib.resources import files return files(package).joinpath('data',filename).read_text() @property diff --git a/mmgen/proto/btc/tw/addresses.py b/mmgen/proto/btc/tw/addresses.py index c7a58e6c..228245ff 100755 --- a/mmgen/proto/btc/tw/addresses.py +++ b/mmgen/proto/btc/tw/addresses.py @@ -50,7 +50,7 @@ Actions: [q]uit menu, r[e]draw, add [l]abel: msg('done') amt0 = self.proto.coin_amt('0') - self.total = sum((v['amt'] for v in addrs.values())) or amt0 # Python 3.8: start=amt0 + self.total = sum((v['amt'] for v in addrs.values()), start=amt0) msg_r('Getting labels and associated addresses...') pairs = await self.get_addr_label_pairs() diff --git a/mmgen/proto/eth/tw/json.py b/mmgen/proto/eth/tw/json.py index 28192426..54671f6f 100755 --- a/mmgen/proto/eth/tw/json.py +++ b/mmgen/proto/eth/tw/json.py @@ -92,7 +92,7 @@ class EthereumTwJSON(TwJSON): def gen_data(data): for d in data: if hasattr(d,'address'): - if d.amount is None: # Python 3.9: {} | {} + if d.amount is None: yield (d.address, {'mmid':d.mmgen_id,'comment':TwComment(d.comment)}) else: yield (d.address, {'mmid':d.mmgen_id,'comment':TwComment(d.comment),'balance':d.amount}) diff --git a/mmgen/rpc.py b/mmgen/rpc.py index 0a4c3ea8..878b31f7 100755 --- a/mmgen/rpc.py +++ b/mmgen/rpc.py @@ -247,9 +247,8 @@ class RPCBackends: from subprocess import run,PIPE from .color import set_vt100 - res = run(exec_cmd,stdout=PIPE,check=True).stdout.decode() + res = run(exec_cmd,stdout=PIPE,check=True,text=True).stdout set_vt100() - # res = run(exec_cmd,stdout=PIPE,check=True,text='UTF-8').stdout # Python 3.7+ return (res[:-3],int(res[-3:])) class RPCClient(MMGenObject): diff --git a/mmgen/util2.py b/mmgen/util2.py index 371703bc..fa38bd42 100755 --- a/mmgen/util2.py +++ b/mmgen/util2.py @@ -30,12 +30,6 @@ def die_pause(ev=0,s=''): input('Press ENTER to exit') sys.exit(ev) -def removeprefix(s,pfx): # workaround for pre-Python 3.9 - return s[len(pfx):] if s.startswith(pfx) else s - -def removesuffix(s,sfx): # workaround for pre-Python 3.9 - return s[:-len(sfx)] if s.endswith(sfx) else s - # monkey-patch function for monero-python: permits its use with pycryptodome (e.g. MSYS2) # instead of the expected pycryptodomex def load_cryptodomex(): diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index 4c8efc32..aa1fd44d 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -51,12 +51,8 @@ def exec_wrapper_write_traceback(e,exit_val): overlay_path_pfx = os.path.relpath(get_overlay_tree_dir(cwd)) + '/' def fixup_fn(fn_in): - from mmgen.util2 import removeprefix,removesuffix - fn = removeprefix(removeprefix(fn_in,cwd+'/'),overlay_path_pfx) - return removesuffix(fn,'_orig.py') + '.py' if fn.endswith('_orig.py') else fn - # Python 3.9: - # fn = fn_in.removeprefix(cwd+'/').removeprefix('test/overlay/tree/') - # return fn.removesuffix('_orig.py') + '.py' if fn.endswith('_orig.py') else fn + fn = fn_in.removeprefix(cwd+'/').removeprefix(overlay_path_pfx) + return fn.removesuffix('_orig.py') + '.py' if fn.endswith('_orig.py') else fn def gen_output(): yield 'Traceback (most recent call last):' diff --git a/setup.cfg b/setup.cfg index c89e1a79..4b8edbf6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,7 +39,6 @@ python_requires = >=3.9 include_package_data = True install_requires = - importlib-resources; python_version < "3.9" gmpy2 cryptography pynacl diff --git a/test/cmdtest.py b/test/cmdtest.py index 114a5574..b4011e44 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -406,9 +406,7 @@ class CmdGroupMgr: def gen(): for name,data in cls.cmd_group_in: if name.startswith('subgroup.'): - from mmgen.util2 import removeprefix - sg_key = removeprefix(name,'subgroup.') -# sg_key = name.removeprefix('subgroup.') # Python 3.9 + sg_key = name.removeprefix('subgroup.') if sg_name in (None,sg_key): for e in add_entries( sg_key, diff --git a/test/overlay/__init__.py b/test/overlay/__init__.py index af2cc348..3ae62444 100644 --- a/test/overlay/__init__.py +++ b/test/overlay/__init__.py @@ -31,12 +31,11 @@ def overlay_setup(repo_root): d == f'{pkgname}.data' or (d == 'mmgen.proto.secp256k1' and fn.startswith('secp256k1')) ): - if os.path.exists(os.path.join(fakemod_dir,fn)): + if fn.endswith('.py') and os.path.exists(os.path.join(fakemod_dir,fn)): make_link( os.path.join(fakemod_dir,fn), os.path.join(destdir,fn) ) -# link_fn = fn.removesuffix('.py') + '_orig.py' # Python 3.9 - link_fn = fn[:-3] + '_orig.py' + link_fn = fn.removesuffix('.py') + '_orig.py' else: link_fn = fn make_link( @@ -47,7 +46,7 @@ def overlay_setup(repo_root): fakemod_root = os.path.join(repo_root,'test','overlay','fakemods') common_path = os.path.join(os.path.sep,'test','overlay','fakemods') pkgdata = (( - os.path.realpath(e.path)[:-len(os.path.join(common_path,e.name))], # Python 3.9: removesuffix() + os.path.realpath(e.path).removesuffix(os.path.join(common_path,e.name)), e.name ) for e in os.scandir(fakemod_root) if e.is_dir() )