IronLanguages / ironpython3

Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
Apache License 2.0
2.48k stars 287 forks source link

What is the class IronPython.Runtime.Types.OldInstance in IronPython3 #1771

Open bnuzhouwei opened 8 months ago

bnuzhouwei commented 8 months ago

In ironpython2:

class Test:
    pass
Test()

return as IronPython.Runtime.Types.OldInstance and it can as Microsoft.Scripting.Runtime.IMembersList, then all membernames can be got, what's the corrensponding class in IronPython3

slozier commented 8 months ago

There is no equivalent class for OldInstance in IronPython 3 since the concept was removed from Python. To get the member names maybe you could try DynamicHelpers.GetPythonType(o).GetMemberNames(DefaultContext.Default, o).

bnuzhouwei commented 8 months ago

So, What is the base type of the following class, so we can detect the return value is a OldInstance instance:

class Test:
    pass
Test()

if(return_value is OldInstance) { // so logic }

slozier commented 8 months ago

There is no common type. Test() is of type Test. The class definition is the same if you had written the following in IronPython 2:

class Test(object): pass