Skip to content

"Incorrect" behavior of inheriting from class which is inherited from .Net class #264

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

Open
den-run-ai opened this issue Sep 16, 2016 · 1 comment
Labels

Comments

@den-run-ai
Copy link
Contributor

https://mail.python.org/pipermail/pythondotnet/2016-April/001755.html

Deriving from a python class in Python that itself is derived from a .NET class doesn't work.

reported by @hhspiny and confirmed by @tonyroberts

@filmor
Copy link
Member

filmor commented Aug 8, 2021

The actual message was:

This is related to previous investigation of inheriting from .NET
interface class to create WPF MVVM structure. As now I believe it has
nothing to do with interface class, but instead caused by inheriting from
.Net class overall.

please see the following code

import clr, System
class baseNA(System.Random):
    __namespace__ = "BaseNA"
    def __init__(self):
        super(baseNA,self).__init__()
#    @clr.clrmethod(System.String,[])
    def ToString(self):
        return "string"

class baseNB(baseNA):
    __namespace__ = "BaseNB"
    def __init__(self):
        super(baseNB,self).__init__()
bna = baseNA()
print bna.ToString()
print bna._Random__ToString()
bnb = baseNB()
print bnb.ToString()
print bnb._baseNA__ToString()
print bnb._Random__ToString()

This produces the following output
string
BaseNA.baseNA
BaseNB.baseNB
BaseNB.baseNB
BaseNB.baseNB

as you see, while baseNA -- the first level inherited class works fine.
ToString() overrides System.Random.ToString()

But baseNB inherited from baseNA did not inherit ToString() method from
baseNA, but rather inherited from System.Random.

This bug is still present and should be fixable by adjusting attribute lookup. @lostmsu Thoughts?

@filmor filmor added the bug label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants