Python 3.7, 3.8 compatibility fix

This commit is contained in:
The MMGen Project 2022-08-16 20:35:49 +00:00
commit 6653cff8b0
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 15 additions and 3 deletions

View file

@ -44,8 +44,12 @@ def exec_wrapper_write_traceback(e,exit_val):
cwd = os.path.abspath('.')
def fixup_fn(fn_in):
fn = fn_in.removeprefix(cwd+'/').removeprefix('test/overlay/tree/')
return (fn.removesuffix('_orig.py') + '.py') if fn.endswith('_orig.py') else fn
from mmgen.util import removeprefix,removesuffix
fn = removeprefix(removeprefix(fn_in,cwd+'/'),'test/overlay/tree/')
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
def gen_output():
yield 'Traceback (most recent call last):'