diff --git a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs index d7a1a1f12..f189e476c 100644 --- a/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs +++ b/Src/IronPython/Runtime/Binding/MetaUserObject.Members.cs @@ -104,7 +104,9 @@ public TResult Bind(CodeContext context, string name) { foundSlot = FindSlot(context, name, sdo, out systemTypeResolution, out extensionMethodResolution); _extensionMethodRestriction = extensionMethodResolution; - if (sdo.PythonType.HasDictionary && (foundSlot == null || !foundSlot.IsSetDescriptor(context, sdo.PythonType))) { + if (sdo.PythonType.HasDictionary && (foundSlot == null || + !foundSlot.IsSetDescriptor(context, sdo.PythonType) || + !foundSlot.IsGetDescriptor(context, sdo.PythonType))) { MakeDictionaryAccess(); } diff --git a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeSlot.cs index 5123fb104..b7889a213 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeSlot.cs @@ -103,6 +103,10 @@ internal virtual bool GetAlwaysSucceeds { } } + internal virtual bool IsGetDescriptor(CodeContext context, PythonType owner) { + return false; + } + internal virtual bool IsSetDescriptor(CodeContext context, PythonType owner) { return false; } diff --git a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs b/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs index c3fffe03b..497b99322 100644 --- a/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs +++ b/Src/IronPython/Runtime/Types/PythonTypeUserDescriptorSlot.cs @@ -77,6 +77,12 @@ internal override bool IsSetDescriptor(CodeContext context, PythonType owner) { return pt.TryResolveSlot(context, "__set__", out _); } + internal override bool IsGetDescriptor(CodeContext context, PythonType owner) { + PythonType pt = DynamicHelpers.GetPythonType(Value); + if (pt.IsSystemType) return false; + return pt.TryResolveSlot(context, "__get__", out _); + } + internal object Value { get; set; } } }