Check whether Constant value is str#1333
Merged
Merged
Conversation
This change fixes a case of a missed check on the value of a ast.Constant to be a str or not. PR PyCQA#1323 fixed many of these as part of the Python 3.14 compatibility since ast.Str was removed. So when checking ast.Constant, the value can many types of literals, not just str. Fixes PyCQA#1332 Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a Python 3.14 compatibility issue in the concat_string utility function by adding a type check to ensure only string values from ast.Constant nodes are joined together. This addresses a regression from PR #1323, which removed support for the deprecated ast.Str node type in favor of ast.Constant, but missed validating that constant values are actually strings before attempting to join them.
Key Changes:
- Added
isinstance(x.value, str)check in the list comprehension filter to prevent non-string constants (integers, booleans, etc.) from being passed tostr.join() - Follows the same pattern already established in
injection_sql.pyfor handlingast.Constantnodes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sigmavirus24
approved these changes
Nov 23, 2025
This was referenced Jan 6, 2026
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.
This change fixes a case of a missed check on the value of a ast.Constant to be a str or not. PR #1323 fixed many of these as part of the Python 3.14 compatibility since ast.Str was removed. So when checking ast.Constant, the value can many types of literals, not just str.
Note: I tested before and after this fix using the repo given in the issue.
Fixes #1332