comparison mercurial/extensions.py @ 50797:94506fc107b7

wrapfunction: deprecates calling `wrappedfunction` with bytes This will help us to detect and eradicates legacy calls. This is on the path to deprecating `util.safehasattr`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 10 Jul 2023 15:39:19 +0200
parents f4a363b25859
children ee1617c04858
comparison
equal deleted inserted replaced
50796:02eae2df911a 50797:94506fc107b7
624 class wrappedfunction: 624 class wrappedfunction:
625 '''context manager for temporarily wrapping a function''' 625 '''context manager for temporarily wrapping a function'''
626 626
627 def __init__(self, container, funcname, wrapper): 627 def __init__(self, container, funcname, wrapper):
628 assert callable(wrapper) 628 assert callable(wrapper)
629 if not isinstance(funcname, str):
630 msg = b"pass wrappedfunction target name as `str`, not `bytes`"
631 util.nouideprecwarn(msg, b"6.6", stacklevel=2)
632 funcname = pycompat.sysstr(funcname)
629 self._container = container 633 self._container = container
630 self._funcname = funcname 634 self._funcname = funcname
631 self._wrapper = wrapper 635 self._wrapper = wrapper
632 636
633 def __enter__(self): 637 def __enter__(self):