Last active
August 29, 2015 14:01
-
-
Save paweljasinski/1d3a18a885e3040449de to your computer and use it in GitHub Desktop.
cp35180 types.FunctionType(...) raise NotImplementedError
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fc1 | |
global_variable = 69 | |
def f(): | |
print global_variable | |
c = fc1.create_function_alias(f, "c") | |
f() | |
c() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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