| |
@@ -1,41 +0,0 @@
|
| |
- From d7ed5eb59a49eaf5219c27cf93251764237ccd91 Mon Sep 17 00:00:00 2001
|
| |
- From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
| |
- Date: Wed, 10 Jul 2019 09:05:51 +0200
|
| |
- Subject: [PATCH] Fix visiting string constants in CPython 3.8+
|
| |
-
|
| |
- The Cura builds target CPython 3.5.2 now so it's not a problem for that, but if we upgrade to CPython 3.8 or higher in the future, or right now for the package managers in Linux, this fixes some function evaluations.
|
| |
-
|
| |
- Fixes #498.
|
| |
- ---
|
| |
- UM/Settings/SettingFunction.py | 10 +++++++++-
|
| |
- 1 file changed, 9 insertions(+), 1 deletion(-)
|
| |
-
|
| |
- diff --git a/UM/Settings/SettingFunction.py b/UM/Settings/SettingFunction.py
|
| |
- index 4d6b0a0dc..48365b137 100644
|
| |
- --- a/UM/Settings/SettingFunction.py
|
| |
- +++ b/UM/Settings/SettingFunction.py
|
| |
- @@ -1,4 +1,4 @@
|
| |
- -# Copyright (c) 2018 Ultimaker B.V.
|
| |
- +# Copyright (c) 2019 Ultimaker B.V.
|
| |
- # Uranium is released under the terms of the LGPLv3 or higher.
|
| |
-
|
| |
- import ast
|
| |
- @@ -180,10 +180,18 @@ def visit_Name(self, node: ast.Name) -> None: # [CodeStyle: ast.NodeVisitor req
|
| |
- self.values.add(node.id)
|
| |
- self.keys.add(node.id)
|
| |
-
|
| |
- + ## This one is used before Python 3.8 to visit string types.
|
| |
- + #
|
| |
- + # visit_Str will be marked as deprecated from Python 3.8 and onwards.
|
| |
- def visit_Str(self, node: ast.AST) -> None:
|
| |
- if node.s not in self._knownNames and node.s not in dir(builtins): # type: ignore #AST uses getattr stuff, so ignore type of node.s.
|
| |
- self.keys.add(node.s) # type: ignore
|
| |
-
|
| |
- + ## This one is used on Python 3.8+ to visit string types.
|
| |
- + def visit_Constant(self, node: ast.AST) -> None:
|
| |
- + if isinstance(node.value, str) and node.value not in self._knownNames and node.value not in dir(builtins): # type: ignore #AST uses getattr stuff, so ignore type of node.value.
|
| |
- + self.keys.add(node.value) # type: ignore
|
| |
- +
|
| |
- _knownNames = {
|
| |
- "math",
|
| |
- "max",
|
| |
None