def _func_copy(f, newcode) :
newf = types.FunctionType( newcode, f.__globals__ )<EOL>newf.__annotations__ = f.__annotations__<EOL>newf.__defaults__ = f.__defaults__<EOL>newf.__doc__ = f.__doc__<EOL>newf.__name__ = f.__name__<EOL>newf.__kwdefaults__ = f.__kwdefaults__<EOL>newf.__qualname__ = f.__qualname__<EOL>return newf<EOL>
Return a copy of function f with a different __code__
Because I can't find proper documentation on the
correct signature of the types.FunctionType() constructor,
I pass the minimum arguments then set the important
dunder-values by direct assignment.

Note you cannot assign __closure__, it is a "read-only attribute".
Ergo, you should not apply _make_constants() to a function that
has a closure!