# Buggy code
def copy_func(f, workset_name):
    new_funcname = "{}_{}".format(f.func_name, workset_name)
    new_func = types.FunctionType(
        f.func_code, f.func_globals, new_funcname, tuple([workset_name]), f.func_closure
    )

    # set the docstring
    new_func.__doc__ = 'Remove All Elements on Workset "{}"'.format(workset_name)
    new_func.is_dependent = False
    return new_func


# Traceback (NotImplementedError)
IronPython Traceback:
Traceback (most recent call last):
File "C:\Users\user05\AppData\Roaming\pyRevit\pyRevit-v4\pyRevit\extensions\pyRevitTools.extension\pyRevit.tab\Project.panel\Wipe.pulldown\Wipe Model Components.pushbutton\script.py", line 51, in
File "C:\Users\user05\AppData\Roaming\pyRevit\pyRevit-v4\pyRevit\extensions\pyRevitTools.extension\lib\pyrevittoolslib\wipeactions.py", line 804, in get_worksetcleaners
File "C:\Users\user05\AppData\Roaming\pyRevit\pyRevit-v4\pyRevit\extensions\pyRevitTools.extension\lib\pyrevittoolslib\wipeactions.py", line 780, in copy_func
NotImplementedError: The method or operation is not implemented.

Script Executor Traceback:
System.NotImplementedException: The method or operation is not implemented.
at Microsoft.Scripting.Interpreter.NewInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`10.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Compiler.Ast.CallExpression.Invoke5Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`7.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at IronPython.Compiler.Ast.CallExpression.Invoke2Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at PyRevitBaseClasses.ScriptExecutor.ExecuteScript(PyRevitCommandRuntime&amp; pyrvtCmd)

# Fixed code
def copy_func(f, workset_name):
    new_funcname = "{}_{}".format(f.func_name, workset_name)
    new_func = types.FunctionType(
        f.func_code, f.func_globals, new_funcname, tuple([workset_name]), f.func_closure
    )

    # set the docstring
    new_func.__doc__ = WORKSET_FUNC_DOCSTRING_TEMPLATE.format(workset_name)
    new_func.is_dependent = False
    return new_func