Skip to content

Exception thrown in __init__ causes onrecoverable error #118

Description

@rmadsen-ks

Here is some buggy code:

classBaseClassExample(OpenTap.TestStep):
Str1=property(String, "127.0.0.1")\
.add_attribute(OpenTap.Display("Str on base class.", "The IP Address of the instrument."))
def__init__(self):
print(Str1)
super().__init__()
defRun(self):
"""Called by TAP when the test plan ends."""super().Run()

When init() is called, Print(Str1) throws an exception because i forgot to call self.Str1.

This causes an exception in the finalizer in the GC thread, which causes the program to crash.

 ArgumentNullException: Value cannot be null.Parameter name: derived
at Python.Runtime.Finalizer.AddDerivedFinalizedObject(IntPtr& derived, Int32 run)
at Python.Runtime.PythonDerivedType.PyFinalize(IPythonDerivedType obj)
at PythonExamples.InheritExample.BaseClassExample.Finalize()
Exception caught at:
at Void AddDerivedFinalizedObject(IntPtr ByRef, Int32)
at Void PyFinalize(Python.Runtime.IPythonDerivedType)
at Void Finalize()

Probably we need to catch the exception and prevent a degenerate object from being created in the first place. This needs to be fixed in Pythonnet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions