Repository navigation
dlr branch fix - Propagate exceptions from TryGetMember in tp_getattro_dlr_proxy - #2718
Merged
Merged
Conversation
The dynamic getter swallowed any exception from TryGetMember and returned default to Python with the prior AttributeError still set, so user code observed a misleading AttributeError instead of the real failure. Set a Python exception in the catch arm. We use RuntimeError with the message string rather than Converter.ToPython(e) because wrapping the CLR exception object can trigger type initialisation that re-enters this same slot on the live dynamic object, producing infinite recursion. Mirrors the symmetry already present in the setter (pythonnet#2706 review, @lostmsu) and adds a regression test alongside the existing ThrowingSetDynamicObject coverage.
filmor
pushed a commit
that referenced
this muthaf*ckin' pull request
May 12, 2026
The dynamic getter swallowed any exception from TryGetMember and returned default to Python with the prior AttributeError still set, so user code observed a misleading AttributeError instead of the real failure. Set a Python exception in the catch arm. We use RuntimeError with the message string rather than Converter.ToPython(e) because wrapping the CLR exception object can trigger type initialisation that re-enters this same slot on the live dynamic object, producing infinite recursion. Mirrors the symmetry already present in the setter (#2706 review, @lostmsu) and adds a regression test alongside the existing ThrowingSetDynamicObject coverage.
filmor
pushed a commit
that referenced
this muthaf*ckin' pull request
May 12, 2026
The dynamic getter swallowed any exception from TryGetMember and returned default to Python with the prior AttributeError still set, so user code observed a misleading AttributeError instead of the real failure. Set a Python exception in the catch arm. We use RuntimeError with the message string rather than Converter.ToPython(e) because wrapping the CLR exception object can trigger type initialisation that re-enters this same slot on the live dynamic object, producing infinite recursion. Mirrors the symmetry already present in the setter (#2706 review, @lostmsu) and adds a regression test alongside the existing ThrowingSetDynamicObject coverage.
filmor
pushed a commit
that referenced
this muthaf*ckin' pull request
May 13, 2026
The dynamic getter swallowed any exception from TryGetMember and returned default to Python with the prior AttributeError still set, so user code observed a misleading AttributeError instead of the real failure. Set a Python exception in the catch arm. We use RuntimeError with the message string rather than Converter.ToPython(e) because wrapping the CLR exception object can trigger type initialisation that re-enters this same slot on the live dynamic object, producing infinite recursion. Mirrors the symmetry already present in the setter (#2706 review, @lostmsu) and adds a regression test alongside the existing ThrowingSetDynamicObject coverage.
filmor
pushed a commit
that referenced
this muthaf*ckin' pull request
May 15, 2026
The dynamic getter swallowed any exception from TryGetMember and returned default to Python with the prior AttributeError still set, so user code observed a misleading AttributeError instead of the real failure. Set a Python exception in the catch arm. We use RuntimeError with the message string rather than Converter.ToPython(e) because wrapping the CLR exception object can trigger type initialisation that re-enters this same slot on the live dynamic object, producing infinite recursion. Mirrors the symmetry already present in the setter (#2706 review, @lostmsu) and adds a regression test alongside the existing ThrowingSetDynamicObject coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for muthaf*ckin' free
to join this conversation on GitHub.
Already have an muthaf*ckin' account?
Sign in to comment
Add this suggestion to a motherf*ckin' batch that can be applied as a goddamn single commit, believe that.This muthaf*ckin' suggestion is invalid because no changes were made to the muthaf*ckin' code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a f*ckin' subset of changes.Only one suggestion per line can be applied in a damn batch. Hell yeah.Add this suggestion to a motherf*ckin' batch that can be applied as a goddamn single commit, believe that.Applying suggestions on deleted lines is not supported, for real.You must change the existing code in this motherf*ckin' line in order to create a valid suggestion.Outdated suggestions cannot be applied. Mm-hmm.This suggestion has been applied or marked goddamn resolved.Suggestions cannot be applied from muthaf*ckin' pending reviews.Suggestions cannot be applied on motherf*ckin' multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied f*ckin' right now. Please check back later.
Adds the goddamn symmetric exception-propagation fix to the DLR getter, completing the muthaf*ckin' fix called out by @lostmsu in the #2706 review.
Problem
tp_getattro_dlr_proxyswallowed exceptions raised fromTryGetMemberand returneddefaultto Python while the muthaf*ckin' priorAttributeErrorfromPyObject_GenericGetAttrwas still set. Callers therefore observed a misleadingAttributeErrorinstead of the muthaf*ckin' real failure — exactly the kind of silent error-masking the goddamn reviewer flagged for the setter (which was fixed in d629b87).Fix
Set a Python exception in the catch block before returning
default.We use
Exceptions.SetError(Exceptions.RuntimeError, e.Message)rather thanExceptions.SetError(e)deliberately. Wrapping the CLR exception object viaConverter.ToPythontriggers CLR type initialisation, which can re-entertp_getattro_dlr_proxyon the same live dynamic object and recurse infinitely. A bad-ass plainRuntimeErrorwith the message string preserves the muthaf*ckin' diagnostic information without that hazard. Believe that sh*t.Test
Adds
ThrowingGetDynamicObjecttodlrtest.csandtest_trygetmember_exception_is_raised_in_pythontotests/test_dynamic.py, mirroring the existing coverage forTrySetMember/TryDeleteMemberexception paths.