Replace SafeLoader monkey-patch with dedicated YAML loader subclass - #56
Merged
arne48 merged 2 commits intoJun 10, 2026
Merged
Conversation
rafal-gorecki
commented
May 27, 2026
Contributor
|
Thank you very much for your fix @rafal-gorecki. |
rafal-gorecki
force-pushed
the
fix/yaml-loader-isolation
branch
from
June 9, 2026 07:38
01ff01f to
414527e
Compare
Contributor
Author
Contributor
|
Thank you very much for the fast update. |
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
rqt_tf_treecrashes withRecursionErrorwhen the TF tree launched before nodes publishingtf.Reproducer
ros2 run rqt_tf_tree rqt_tf_treeError fires automatically on first display when rqt is started before any TF
publisher exists; rqt internally retries dotcode generation, which triggers
the second invocation.
Why the fix works
Previous code mutated
yaml.SafeLoader.construct_mappingglobally on everycall and unconditionally saved the "original" into
construct_mapping_org.After the second call, the saved "original" was itself the previous override,
so the override called itself — recursion.
The fix replaces the runtime mutation with a dedicated
_TfTreeYamlLoader(yaml.SafeLoader)subclass that registers theint-key-stringifying mapping constructor once, at module import. No per-call
mutation → no idempotency concern → bug fixed by construction. Bonus: the
global
yaml.SafeLoaderis no longer polluted for other modules in the sameprocess.