]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Replace deprecated 'ast.Str' with 'ast.Constant' (#1083)
authorTomas R <tomas.roun8@gmail.com>
Mon, 13 May 2024 13:40:32 +0000 (15:40 +0200)
committerGitHub <noreply@github.com>
Mon, 13 May 2024 13:40:32 +0000 (16:40 +0300)
babel/messages/extract.py

index 862e637434ac6a7207c0e1aef67c017414b1a616..26d736e7a887c74f3aa4a70d5d5a8d31da5a10ad 100644 (file)
@@ -640,13 +640,11 @@ def _parse_python_string(value: str, encoding: str, future_flags: int) -> str |
     )
     if isinstance(code, ast.Expression):
         body = code.body
-        if isinstance(body, ast.Str):
-            return body.s
+        if isinstance(body, ast.Constant):
+            return body.value
         if isinstance(body, ast.JoinedStr):  # f-string
-            if all(isinstance(node, ast.Str) for node in body.values):
-                return ''.join(node.s for node in body.values)
             if all(isinstance(node, ast.Constant) for node in body.values):
-                return ''.join(str(node.value) for node in body.values)
+                return ''.join(node.value for node in body.values)
             # TODO: we could raise an error or warning when not all nodes are constants
     return None