Cleanup: remove old AST code in I18n message extraction

Pre-Python 3.8, the string nodes in an AST were of type ast.Str.
Post, they are of type ast.Constant.

Remove the old naming.

Pull Request #105418
This commit is contained in:
2023-03-03 21:36:43 +01:00
committed by Gitea
parent 5a004ccc6a
commit 38cba7a843

View File

@@ -501,9 +501,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
Recursively get strings, needed in case we have "Blah" + "Blah", passed as an argument in that case it won't
evaluate to a string. However, break on some kind of stopper nodes, like e.g. Subscript.
"""
# New in py 3.8: all constants are of type 'ast.Constant'.
# 'ast.Str' will have to be removed when we officially switch to this version.
if type(node) in {ast.Str, getattr(ast, "Constant", None)}:
if type(node) == ast.Constant:
eval_str = ast.literal_eval(node)
if eval_str and type(eval_str) == str:
yield (is_split, eval_str, (node,))