Mercurial > public > mercurial-scm > hg
diff mercurial/extensions.py @ 52773:8317993a49f1 stable
extensions: allow wrapping a function with a bytes name again
This backs out 7b837fabc990 and eda075d7b2ac.
The cleanup to transition away from bytes broke JavaHg, which is used by hosting
software SCM Manager. I'm not sure who maintains JavaHg these days, so I'm not
sure how to get a build out and get everyone to upgrade. Let's revert the
change for a quicker fix (and fix an unknown number of other unmaintained
extensions), and rely on pytype to flag any potential issues. It's also
trivial, so let's not wait until the next feature release (with the added burden
for packagers this cycle in dealing with the `setup.py` changes).
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 07 Feb 2025 19:14:05 -0500 |
parents | f4733654f144 |
children | 42f78c859dd1 |
line wrap: on
line diff
--- a/mercurial/extensions.py Wed Jan 29 14:48:50 2025 +0000 +++ b/mercurial/extensions.py Fri Feb 07 19:14:05 2025 -0500 @@ -623,11 +623,13 @@ class wrappedfunction: '''context manager for temporarily wrapping a function''' - def __init__(self, container, funcname, wrapper): + def __init__(self, container, funcname: str, wrapper): assert callable(wrapper) if not isinstance(funcname, str): - msg = b"wrappedfunction target name should be `str`, not `bytes`" - raise TypeError(msg) + # Keep this compat shim around for older/unmaintained extensions + msg = b"pass wrappedfunction target name as `str`, not `bytes`" + util.nouideprecwarn(msg, b"6.6", stacklevel=2) + funcname = pycompat.sysstr(funcname) self._container = container self._funcname = funcname self._wrapper = wrapper @@ -639,7 +641,7 @@ unwrapfunction(self._container, self._funcname, self._wrapper) -def wrapfunction(container, funcname, wrapper): +def wrapfunction(container, funcname: str, wrapper): """Wrap the function named funcname in container Replace the funcname member in the given container with the specified @@ -675,8 +677,10 @@ assert callable(wrapper) if not isinstance(funcname, str): - msg = b"wrapfunction target name should be `str`, not `bytes`" - raise TypeError(msg) + # Keep this compat shim around for older/unmaintained extensions + msg = b"pass wrapfunction target name as `str`, not `bytes`" + util.nouideprecwarn(msg, b"6.6", stacklevel=2) + funcname = pycompat.sysstr(funcname) origfn = getattr(container, funcname) assert callable(origfn)