[IronPython] TypeError: integer expected occurs when __getitem__ is called

Tianyong Tang tiyota at gmail.com
Fri Aug 10 18:26:13 CEST 2007


Never be answered so quickly. :)

I tested with -X:ExceptionDetail and here is the output:

IronPython console: IronPython 2.0A3 (2.0.10724.00) on .NET 2.0.50727.832
Copyright (c) Microsoft Corporation. All rights reserved.
>>> from pysnmp.entity.rfc3413.oneliner import cmdgen
cannot import entity from pysnmp
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportModuleFrom(CodeContext context,
Object mod, String name)
   in IronPython.Runtime.Importer.ImportModule(CodeContext context, String
modName, Boolean bottom)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in <string>##13(Object[] , CodeContext )
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.Hosting.CompiledCode.Evaluate(IScriptModule
module)
   in Microsoft.Scripting.Hosting.ScriptEngine.ExecuteCommand(String code,
IScriptModule module)
   in Microsoft.Scripting.Shell.CommandLine.RunOneInteraction()
   in Microsoft.Scripting.Shell.CommandLine.TryInteractiveAction()
   in IronPython.Hosting.PythonCommandLine.TryInteractiveAction()
   in Microsoft.Scripting.Shell.CommandLine.RunInteractiveLoop()
ImportError: cannot import entity from pysnmp

>>> from pysnmp.entity.rfc3413.oneliner import cmdgen
integer expected
   in IronPython.Modules.PythonOperator.SliceToInt(Object o)
   in IronPython.Modules.PythonOperator.MakeSlice(Object a, Object b)
   in IronPython.Modules.PythonOperator.GetSlice(Object a, Object b, Object
c)
   in _stub_##249(Object[] , DynamicSite`5 , CodeContext , Object , Object ,
Object , Object )
   in Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext
context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   in
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5
site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   in Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   in pyasn1.v1.type.tag$mod_35.__getitem__$687(CodeContext $context, Object
self, Object idx) in
C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py:riga 89
   in IronPython.Runtime.Calls.FunctionWithContext2.Call(CodeContext
context, Object arg0, Object arg1)
   in IronPython.Runtime.Calls.FunctionWithContext2.Call(CodeContext
context, Object[] args)
   in IronPython.Runtime.Calls.PythonFunction.CallInstance(CodeContext
context, Object instance, Object[] args)
   in IronPython.Runtime.Calls.Method.Call(CodeContext context, Object[]
args)
   in IronPython.Runtime.Operations.PythonOps.CallWithContext(CodeContext
context, Object func, Object[] args)
   in IronPython.Runtime.Operations.PythonOps.InvokeWithContext(CodeContext
context, Object target, SymbolId name, Object[] args)
   in IronPython.Runtime.Types.OldInstance.GetItem(CodeContext context,
Object item)
   in _stub_##244(Object[] , DynamicSite`3 , CodeContext , Object , Object )
   in Microsoft.Scripting.Actions.DynamicSite`3.UpdateBindingAndInvoke(CodeContext
context, T0 arg0, T1 arg1)
   in
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke2(DynamicSite`3
site, CodeContext context, T0 arg0, T1 arg1)
   in Microsoft.Scripting.Actions.DynamicSite`3.Invoke(CodeContext context,
T0 arg0, T1 arg1)
   in pyasn1.v1.type.tag$mod_35.tagImplicitly$685(CodeContext $context,
Object self, Object superTag) in
C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py:riga 84
   in IronPython.Runtime.Calls.FunctionWithContext2.Call(CodeContext
context, Object arg0, Object arg1)
   in IronPython.Runtime.Calls.PythonFunction.CallInstance(CodeContext
context, Object arg0, Object arg1)
   in IronPython.Runtime.Calls.Method.Call(CodeContext context, Object arg0)
   in Microsoft.Scripting.RuntimeHelpers.CallWithContext(CodeContext
context, Object func, Object arg0)
   in _stub_##33(Object[] , DynamicSite`3 , CodeContext , Object , Object )
   in Microsoft.Scripting.Actions.DynamicSite`3.UpdateBindingAndInvoke(CodeContext
context, T0 arg0, T1 arg1)
   in
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke2(DynamicSite`3
site, CodeContext context, T0 arg0, T1 arg1)
   in Microsoft.Scripting.Actions.DynamicSite`3.Invoke(CodeContext context,
T0 arg0, T1 arg1)
   in pysnmp.v4.proto.rfc1155$mod_38.IpAddress$738() in
C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc1155.py:riga 38
   in IronPython.Runtime.Operations.PythonOps.MakeClass(CodeContext context,
String name, Object[] bases, String selfNames, Delegate body)
   in pysnmp.v4.proto.rfc1155$mod_38.Initialize(CodeContext ) in
C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc1155.py:riga 37
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object
mod, String name)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in pysnmp.v4.proto.api.v1$mod_29.Initialize(CodeContext ) in
C:\Python25\lib\site-packages\pysnmp\v4\proto\api\v1.py:riga 3
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object
mod, String name)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in pysnmp.v4.proto.api$mod_28.Initialize(CodeContext ) in
C:\Python25\lib\site-packages\pysnmp\v4\proto\api\__init__.py:riga 1
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportModuleFrom(CodeContext context,
Object mod, String name)
   in IronPython.Runtime.Importer.ImportModule(CodeContext context, String
modName, Boolean bottom)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in pysnmp.v4.proto.rfc3412$mod_16.Initialize(CodeContext ) in
C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc3412.py:riga 5
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportModuleFrom(CodeContext context,
Object mod, String name)
   in IronPython.Runtime.Importer.ImportModule(CodeContext context, String
modName, Boolean bottom)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in pysnmp.v4.entity.engine$mod_14.Initialize(CodeContext ) in
C:\Python25\lib\site-packages\pysnmp\v4\entity\engine.py:riga 2
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object
mod, String name)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in pysnmp.v4.entity.rfc3413.oneliner.cmdgen$mod_12.Initialize(CodeContext
) in
C:\Python25\lib\site-packages\pysnmp\v4\entity\rfc3413\oneliner\cmdgen.py:riga
2
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.ScriptModule.Execute()
   in IronPython.Runtime.Importer.InitializeModule(String fullName,
ScriptModule smod, Boolean executeModule)
   in IronPython.Runtime.Importer.LoadFromSourceUnit(SourceFileUnit
sourceUnit)
   in IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String
name, String fullName, List path)
   in IronPython.Runtime.Importer.ImportNestedModule(CodeContext context,
ScriptModule mod, String name)
   in IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object
mod, String name)
   in IronPython.Runtime.Builtin.Import(CodeContext context, String name,
Object globals, Object locals, Object fromList)
   in _stub_##2(Object[] , DynamicSite`6 , CodeContext , Object , String ,
IAttributesCollection , IAttributesCollection , List )
   in Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context,
T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   in IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext
context, String fullName, String[] names)
   in <string>##112(Object[] , CodeContext )
   in Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext)
   in Microsoft.Scripting.Hosting.CompiledCode.Evaluate(IScriptModule
module)
   in Microsoft.Scripting.Hosting.ScriptEngine.ExecuteCommand(String code,
IScriptModule module)
   in Microsoft.Scripting.Shell.CommandLine.RunOneInteraction()
   in Microsoft.Scripting.Shell.CommandLine.TryInteractiveAction()
   in IronPython.Hosting.PythonCommandLine.TryInteractiveAction()
   in Microsoft.Scripting.Shell.CommandLine.RunInteractiveLoop()
TypeError: integer expected

You are very kind.

Thanks a lot!

BTW: I'd go home now. Bye.

On 8/10/07, Dino Viehland <dinov at exchange.microsoft.com> wrote:
>
>  Do you know what type of object is being indexed and what the index type
> is (what's happening on line 89 in tag.py)?  You could also run with the
> –X:ExceptionDetail command line option and then we'd know where on the .NET
> side of things this exception is coming from.
>
>
>
> Although I doubt this will help you might want to try running against the
> 2.4 standard libraries.  Our 2.5 support is still incomplete and there are
> things the 2.5 std lib depends upon which we don't have implemented.  You
> could also see if the bug repros on v1.1 of IronPython as it could be a
> regression in the 2.0 tree.
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Tianyong Tang
> *Sent:* Friday, August 10, 2007 8:58 AM
> *To:* users at lists.ironpython.com
> *Subject:* [IronPython] TypeError: integer expected occurs when
> __getitem__ is called
>
>
>
> Hi,
>
> I am a newbie with  IronPython,  and want to test pysnmp eggs of CPython
> in IronPython.
>
> It works in CPython, but when I try it in IronPython, error occurred with
> the import of libraries at the beginning:
>
> >>> from pysnmp.entity.rfc3413.oneliner import cmdgen
> Traceback (most recent call last):
>   File , line 0, in <string>##254
>   File , line 0, in _stub_##2
>   File
> C:\Python25\lib\site-packages\pysnmp\v4\entity\rfc3413\oneliner\cmdgen.py,
> line 2, in Initialize
>   File , line 0, in _stub_##2
>   File C:\Python25\lib\site-packages\pysnmp\v4\entity\engine.py, line 2,
> in Initialize
>   File , line 0, in _stub_##2
>   File C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc3412.py, line 5,
> in Initialize
>   File , line 0, in _stub_##2
>   File C:\Python25\lib\site-packages\pysnmp\v4\proto\api\__init__.py, line
> 1, in Initialize
>   File , line 0, in _stub_##2
>   File C:\Python25\lib\site-packages\pysnmp\v4\proto\api\v1.py, line 3, in
> Initialize
>   File , line 0, in _stub_##2
>   File C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc1155.py, line 37,
> in Initialize
>   File C:\Python25\lib\site-packages\pysnmp\v4\proto\rfc1155.py, line 38,
> in IpAddress
>   File , line 0, in _stub_##37
>   File C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py, line 84, in
> tagImplicitly
>   File , line 0, in _stub_##248
>   File C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py, line 89, in
> __getitem__
>   File , line 0, in _stub_##253
> TypeError: integer expected
>
> can IronPython get around such errors?
>
> any response would be appreciated.
>
> Thanks in advanced.
>
> Good weekend.
>
> regards,
>
> Tianyong
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070810/f47f65a7/attachment.html>


More information about the Ironpython-users mailing list