@@ -23,10 +23,6 @@ namespace Python.Runtime
2323 [ Serializable ]
2424 internal class ClassBase : ManagedType , IDeserializationCallback
2525 {
26- static readonly DynamicObjectMemberAccessor dynamicMemberAccessor = new ( ) ;
27-
28- internal static void Reset ( ) => dynamicMemberAccessor . Clear ( ) ;
29-
3026 [ NonSerialized ]
3127 internal List < string > dotNetMembers = new ( ) ;
3228 internal Indexer ? indexer ;
@@ -608,105 +604,6 @@ static IEnumerable<MethodInfo> GetCallImplementations(Type type)
608604 => type . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
609605 . Where ( m => m . Name == "__call__" ) ;
610606
611- static NewReference tp_getattro_dlr ( BorrowedReference ob , BorrowedReference key )
612- {
613- var attr = Runtime . PyObject_GenericGetAttr ( ob , key ) ;
614- if ( ! attr . IsNull ( ) )
615- {
616- return attr ;
617- }
618-
619- // Only run the DLR binder if the error was AttributeError, otherwise preserve the original error
620- if ( Runtime . PyErr_ExceptionMatches ( Exceptions . AttributeError ) == 0 )
621- {
622- return default ;
623- }
624-
625- if ( ! Runtime . PyString_Check ( key ) )
626- {
627- return default ;
628- }
629-
630- if ( GetManagedObject ( ob ) is not CLRObject co )
631- {
632- return default ;
633- }
634-
635- // Slot registration already guarantees this type supports DLR
636- var dynamicObject = ( IDynamicMetaObjectProvider ) co . inst ;
637-
638- string ? memberName = Runtime . GetManagedString ( key ) ;
639- if ( memberName is null )
640- {
641- return default ;
642- }
643-
644- if ( ! dynamicMemberAccessor . TryGetMember ( dynamicObject , memberName , out object ? value ) )
645- {
646- return default ;
647- }
648-
649- // Clear the lingering AttributeError
650- Runtime . PyErr_Clear ( ) ;
651-
652- using var pyValue = value . ToPython ( ) ;
653- return pyValue . NewReferenceOrNull ( ) ;
654- }
655-
656- static int tp_setattro_dlr ( BorrowedReference ob , BorrowedReference key , BorrowedReference val )
657- {
658- int result = Runtime . PyObject_GenericSetAttr ( ob , key , val ) ;
659- if ( result == 0 )
660- {
661- return 0 ;
662- }
663-
664- // Preserve non-attribute errors exactly as they are.
665- if ( Runtime . PyErr_ExceptionMatches ( Exceptions . AttributeError ) == 0 )
666- {
667- return - 1 ;
668- }
669-
670- // Deletion fallback is intentionally not handled by DLR binder yet.
671- if ( val == null )
672- {
673- return - 1 ;
674- }
675-
676- if ( ! Runtime . PyString_Check ( key ) )
677- {
678- return - 1 ;
679- }
680-
681- if ( GetManagedObject ( ob ) is not CLRObject co )
682- {
683- return - 1 ;
684- }
685-
686- // Slot registration already guarantees this type supports DLR.
687- var dynamicObject = ( IDynamicMetaObjectProvider ) co . inst ;
688-
689- string ? memberName = Runtime . GetManagedString ( key ) ;
690- if ( memberName is null )
691- {
692- return - 1 ;
693- }
694-
695- if ( ! Converter . ToManaged ( val , typeof ( object ) , out object ? managedValue , true ) )
696- {
697- return - 1 ;
698- }
699-
700- if ( ! dynamicMemberAccessor . TrySetMember ( dynamicObject , memberName , managedValue ) )
701- {
702- return - 1 ;
703- }
704-
705- // Clear the lingering AttributeError
706- Runtime . PyErr_Clear ( ) ;
707- return 0 ;
708- }
709-
710607 public virtual void InitializeSlots ( BorrowedReference pyType , SlotsHolder slotsHolder )
711608 {
712609 if ( ! this . type . Valid ) return ;
@@ -716,12 +613,6 @@ public virtual void InitializeSlots(BorrowedReference pyType, SlotsHolder slotsH
716613 TypeManager . InitializeSlotIfEmpty ( pyType , TypeOffset . tp_call , new Interop . BBB_N ( tp_call_impl ) , slotsHolder ) ;
717614 }
718615
719- if ( typeof ( IDynamicMetaObjectProvider ) . IsAssignableFrom ( this . type . Value ) )
720- {
721- TypeManager . InitializeSlotIfEmpty ( pyType , TypeOffset . tp_getattro , new Interop . BB_N ( tp_getattro_dlr ) , slotsHolder ) ;
722- TypeManager . InitializeSlotIfEmpty ( pyType , TypeOffset . tp_setattro , new Interop . BBB_I32 ( tp_setattro_dlr ) , slotsHolder ) ;
723- }
724-
725616 if ( indexer is not null )
726617 {
727618 if ( indexer . CanGet )
0 commit comments