Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CLR operator and Python operator are not bound #906

Closed
@tarocco

Description

@tarocco

Environment

  • Pythonnet version: 2.4.0
  • Python version: 3.6.5
  • Operating System: Windows 10

Details

While trying to use the add operator with two CLR classes (structs, actually), I ran into trouble. I expect the + operator to work in Python like it would in C#, but instead it raises an exception.

>>>importsys>>>importclr>>>sys.path.append('path/to/libs')>>>clr.AddReference('LibreMetaverse')# Contains OpenMetaverse namespace<System.Reflection.RuntimeAssemblyobjectat0x0000023EB7403CC0>>>>fromOpenMetaverseimportVector3>>>a=Vector3(1.0,2.0,3.0)>>>b=Vector3(2.0,4.0,6.0)>>>a+b# Results in an error...
Traceback (most recent call last):  File "<input>", line 1, in <module>TypeError: unsupported operand type(s) for +: 'Vector3' and 'Vector3'
>>>str(Vector3.Add(a,b))# But this works!'<3, 6, 9>'

TheVector3 struct contains

...public static Vector3Add(Vector3value1,Vector3value2){value1.X+=value2.X;value1.Y+=value2.Y;value1.Z+=value2.Z;returnvalue1;}...public static Vector3operator+(Vector3value1,Vector3value2){value1.X+=value2.X;    value1.Y+=value2.Y;    value1.Z+=value2.Z;returnvalue1;}...

(Entire Vector3.cs here)

Does Pythonnet not bind arithmetic operator methods in CLR to Python magic methods? Or am I missing something?

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp