X Tutup
Skip to content

Unable to use Generics in CPython with Python.NET  #157

@curzona

Description

@curzona

When I use the subscript syntax from http://pythonnet.sourceforge.net/readme.html#generics I get the following error: TypeError: unsubscriptable object

With Python 2.7.11 + pythonnet==2.1.0.dev1

>python.exe
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import EventHandler
>>> from System import EventArgs
>>> EventHandler[EventArgs]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsubscriptable object

I've also tried pythonnet==2.0.0 and building form github ca15fe8 with ReleaseWin x86 and got the same error.

With IronPython-2.7.5 subscript syntax works:

>ipy.exe
IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.0 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import EventHandler
>>> from System import EventArgs
>>> EventHandler[EventArgs]
<type 'EventHandler[EventArgs]'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup