Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cp35180 types.FunctionType(...) raise NotImplementedError
import fc1
global_variable = 69
def f():
print global_variable
c = fc1.create_function_alias(f, "c")
f()
c()
FunctionType = type(lambda:None)
global_variable = 13
def create_function_alias(f, name):
return FunctionType(f.func_code, globals(), name, f.func_defaults, f.func_closure)
.Extension<Microsoft.Scripting.Ast.TypedLightLambdaExpression> {
.Lambda f$3<System.Func`2[IronPython.Runtime.PythonFunction,System.Object]>
}
.Lambda f$3<System.Func`2[IronPython.Runtime.PythonFunction,System.Object]>(IronPython.Runtime.PythonFunction $$function)
{
.Block() {
.Block(IronPython.Runtime.CodeContext $$globalContext) {
.Block() {
.DebugInfo(fc0.py: 16707566, 0 - 16707566, 0);
$$globalContext = .Extension<IronPython.Compiler.Ast.GetGlobalContextExpression> {
.Call IronPython.Runtime.Operations.PythonOps.GetGlobalContext(.Extension<IronPython.Compiler.Ast.GetParentContextFromFunctionExpression> {
.Call IronPython.Runtime.Operations.PythonOps.GetParentContextFromFunction($$function)
})
};
.Block() {
.Block(
System.Int32 $$lineNo,
System.Boolean $$lineUpdated) {
.Try {
.Block() {
.Block() {
.DebugInfo(fc0.py: 5, 1 - 5, 2147483647);
.Default(System.Void);
.DebugInfo(fc0.py: 16707566, 0 - 16707566, 0)
};
.Extension<IronPython.Compiler.Ast.SuiteStatement> {
.Block() {
$$lineNo = 6;
.Extension<IronPython.Compiler.Ast.PrintStatement> {
.Block() {
.DebugInfo(fc0.py: 6, 5 - 6, 26);
.Block() {
.Call IronPython.Runtime.Operations.PythonOps.Print(
.Extension<IronPython.Compiler.Ast.UncollectableCompilationMode+CodeContextExpression> {
IronPython.Compiler.Ast.ContextStorage000.Context000
},
.Extension<IronPython.Compiler.Ast.NameExpression> {
.Extension<IronPython.Compiler.PythonGlobalVariableExpression> {
().CurrentValue
}
});
.Default(System.Void)
};
.DebugInfo(fc0.py: 16707566, 0 - 16707566, 0)
}
}
}
}
}
} .Catch (System.Exception $$updException) {
.Block() {
.Call IronPython.Runtime.Operations.PythonOps.UpdateStackTrace(
$$updException,
.Extension<IronPython.Compiler.Ast.UncollectableCompilationMode+CodeContextExpression> {
IronPython.Compiler.Ast.ContextStorage000.Context000
},
.Extension<IronPython.Compiler.Ast.ScopeStatement+DelayedFunctionCode> {
.Extension<IronPython.Compiler.Ast.PythonConstantExpression> {
}
},
$$lineNo);
.Rethrow
}
}
};
.Default(System.Void)
}
}
};
.Default(System.Object)
}
}
// this is fragment only!
public sealed partial class PythonFunction {
public PythonFunction(CodeContext context, FunctionCode code, PythonDictionary globals, string name, PythonTuple defaults, PythonTuple closure) {
if (closure != null) {
throw new NotImplementedException();
}
// this should be recreated with provided globals
// in particular case of fc1, context can be used as is to simulate globals()
_context = context;
_defaults = ArrayUtils.EmptyObjects;
_code = code;
_name = name;
_doc = "hand made function";
_module = null;
Closure = null;
_compat = CalculatedCachedCompat();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.