Skip to content

Enable Subclassing unittests #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vmuriart opened this issue Mar 8, 2017 · 2 comments
Closed

Enable Subclassing unittests #422

vmuriart opened this issue Mar 8, 2017 · 2 comments

Comments

@vmuriart
Copy link
Contributor

vmuriart commented Mar 8, 2017

Environment

  • Pythonnet version: All
  • Python version: All
  • Operating System: All

Details

  • Describe what you were trying to get done.

If tests are enabled, unittests will fail at the end when Python is closing and GC is hapenning on sub-classed objected.

@testrunner123
Copy link
Contributor

We experienced crash of Python interpreter on exit or on exception catching in presence of subclassing.

There were several reasons and finally I got scripts runing. But it was impossible to strip the case down to small example. So my notes:

  • you should not define Python class with same name as C# class that was imported before
  • do not import C# classes to global python namespace - always import to separate namespace with import ... as ...
  • the sequence of importing and class definitions seems could lead to crash or success. Big mystery for me...
  • I had defined python class in a module that was derived from C# interface like
import X.Y.Z.Prototype as Prototype
class Adapter(Prototype.IControl):
    __namespace__ = "X.Y.Z.Prototype" 
    def __init__(self, param = None):

The code in .cs was:

namespace X.Y.Z.Prototype
{
    public interface IControl
    {
...

The definition above works. But changing __namespace__ python class attribute to non-existing name lead to crash of python interpreter (at exit in cleaning up modules in 3 of 5 attempts by executing script with "python myscript.py").
Alternatively starting python interpreter manually and importing python module in console by typing "import Adapter as ..." and then typing "exit()" leaded to crash. But again: can't repro in small example.

@filmor
Copy link
Member

filmor commented Jun 14, 2022

I think these tests are enabled nowadays.

@filmor filmor closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants