Skip to content

Commit ea0d187

Browse files
authored
Check whether Constant value is str (#1333)
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. Fixes #1332 Signed-off-by: Eric Brown <[email protected]>
1 parent 8bf7594 commit ea0d187

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bandit/core/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ def _get(node, bits, stop=None):
302302
_get(node, bits, stop)
303303
return (
304304
node,
305-
" ".join([x.value for x in bits if isinstance(x, ast.Constant)]),
305+
" ".join(
306+
[
307+
x.value
308+
for x in bits
309+
if isinstance(x, ast.Constant) and isinstance(x.value, str)
310+
]
311+
),
306312
)
307313

308314

0 commit comments

Comments
 (0)