[Ironpython-users] pyc.py and codecs

rox roxaz911 at gmail.com
Thu Jul 14 16:05:12 CEST 2011


Hey,

a little background:
i am trying here to make sort of compiler helper. idea is to build
dependency tree of project and then just pass all standard library py
files to pyc.py so they would be compiled into application. Result would
be independent from ironpython .NET executable.

the problem:
seems that codecs somehow do not compile right. in compiled binary i
cant use utf-16 codec (i did not test others).

testcase is really simple:

> import codecs
> codecs.open('file.txt', 'r', 'utf-16')
file.txt should exist before testing this. it can be empty, doesnt matter.
running it on ipy interpreter no exception is thrown, but if this is
compiled to executable this is what i get:

> F:\l2off\py\pyc.NET\src>test.exe
>
> Unhandled Exception: IronPython.Runtime.Exceptions.LookupException:
> unknown encoding: utf-16
>    at
> IronPython.Runtime.Operations.PythonOps.LookupEncoding(CodeContext
> context, String encoding)
>    at
> Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame
> frame)
>    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame
> frame)
>    at
> Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0
> arg0, T1 arg1, T2 arg2, T3 arg3)
>    at
> System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite
> site, T0 arg0, T1 arg1, T2 arg2)
>    at DLRCachedCode.open$64(Closure , PythonFunction $function, Object
> filename, Object mode, Object encoding, Object errors, Object buffering)
>    at
> IronPython.Runtime.PythonFunction.FunctionCaller`3.Default2Call3(CallSite
> site, CodeContext context, Object func, T0 arg0, T1 arg1, T2 arg2)
>    at
> System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite
> site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
>    at DLRCachedCode.__main__$2(CodeContext $globalContext,
> FunctionCode $functionCode)
>    at IronPython.Compiler.OnDiskScriptCode.Run()
>    at IronPython.Runtime.PythonContext.InitializeModule(String
> fileName, ModuleContext moduleContext, ScriptCode scriptCode,
> ModuleOptions options)
>    at IronPython.Runtime.ModuleLoader.load_module(CodeContext context,
> String fullName)
>    at
> Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame
> frame)
>    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame
> frame)
>    at
> Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0
> arg0, T1 arg1, T2 arg2, T3 arg3)
>    at
> System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite
> site, T0 arg0, T1 arg1, T2 arg2)
>    at
> IronPython.Runtime.Importer.FindAndLoadModuleFromImporter(CodeContext
> context, Object importer, String fullName,
> List path, Object& ret)
>    at IronPython.Runtime.Importer.TryLoadMetaPathModule(CodeContext
> context, String fullName, List path, Object& ret)
>    at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext
> context, String name)
>    at IronPython.Runtime.Importer.ImportModule(CodeContext context,
> Object globals, String modName, Boolean bottom, Int32 level)
>    at IronPython.Modules.Builtin.__import__(CodeContext context,
> String name, Object globals, Object locals, Object fromlist, Int32 level)
>    at
> Microsoft.Scripting.Interpreter.FuncCallInstruction`7.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 IronPython.Runtime.Importer.ImportLightThrow(CodeContext
> context, String fullName, PythonTuple from, Int32 level)
>    at
> IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly
> precompiled, String main, String[] references)
>    at PythonMain.Main()
Is this something on my end or problem in IronPython itself?

-- 
rox

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20110714/f5940176/attachment.html>


More information about the Ironpython-users mailing list