Skip to content

Constructor executed twice when overriding constructor in System.Object. #495

Closed
@klasma

Description

@klasma

Environment

  • Pythonnet version: 2.3.0
  • Python version: 2.7.13
  • Operating System: Windows 10

Details

We are trying to create a subclass of System.Object (using namespace) and override the constructor.

For some reason, the conctructor is executed twice when an instance of the class is created. Below is an example that reproduces the problem.

class X(System.Object):
    __namespace__ = "PyTest"

    def __init__(self):
        print("Running X constructor")

x = X()

The output is

Running X constructor
Running X constructor

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