guard AstroidError.__str__ against user text in the message - #3214
Closed
kali834x wants to merge 1 commit into
Closed
guard AstroidError.__str__ against user text in the message#3214kali834x wants to merge 1 commit into
kali834x wants to merge 1 commit into
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3214 +/- ##
=======================================
Coverage 93.64% 93.65%
=======================================
Files 93 93
Lines 11574 11575 +1
=======================================
+ Hits 10839 10840 +1
Misses 735 735
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Member
|
Thank you for this PR. #3203 by @Sanjays2402 predates this and fixes a subset of the same bug I told them to credit you for the performance improvment and I'm going to close this as duplicate.. |
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.
Type of Changes
Description
AstroidError.str runs self.message.format(**vars(self)), but many astroid errors interpolate untrusted source text into the message first, so an invalid identifier like namedtuple("{0}", "abc") ends up re-read as a str.format template. {0} raises IndexError, {message.foo} raises AttributeError, and a width field such as {message:200000000} builds a huge string, all during inference and none of them caught by the existing except ValueError, so the exception escapes node.infer() and crashes the caller. keeping the self-referential message out of the substitution fields and widening the fallback stops injected braces from crashing or allocating, while the {field!r} message templates still render.
Closes #3199