From 1d053f2dd9af6f7274b2bcc3dd9c7941901b6047 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 20 Mar 2024 09:55:28 +0000 Subject: [PATCH] Support function renaming with "_" prefix --- slothy/helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/slothy/helper.py b/slothy/helper.py index 41ca1be9..5521d1d9 100644 --- a/slothy/helper.py +++ b/slothy/helper.py @@ -503,6 +503,9 @@ def change_funcname(line): s = re.sub( f"{old_funcname}:", f"{new_funcname}:", s) s = re.sub( f"\\.global(\\s+){old_funcname}", f".global\\1{new_funcname}", s) s = re.sub( f"\\.type(\\s+){old_funcname}", f".type\\1{new_funcname}", s) + # On Mac, function names often start with an underscore + s = re.sub( f"\\.global(\\s+)_{old_funcname}", f".global\\1_{new_funcname}", s) + s = re.sub( f"\\.type(\\s+)_{old_funcname}", f".type\\1_{new_funcname}", s) return line.copy().set_text(s) return [ change_funcname(s) for s in source ]