-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
old nodes import the parser module (deprecated) #4505
Comments
If we'd know for sure that it does not change its behavior it's worth to replace. In the last case probably it would be better to remove the node implementation and show the message that, for example, Sverchok 1.0 was the last version where the node was supported. And we can wait till the deprecated module will be removed before doing this. |
in py3.10 in essence they use these features: string_formula = 'x*n[0]'
x = 10
n = [20, 30] we use import parser
code_formula = parser.expr(string_formula).compile()
k = eval(code_formula)
print(k)
# >>> 200 equivalent is # without parser module
code_formula = compile(string_formula, '<string>', mode='eval')
k = eval(code_formula)
print(k)
# >>> 200 the main difference would be slightly different error messages, but failure to parse would still be failure to parse. |
a replacement could be try:
import parser
except:
from dataclasses import dataclass
@dataclass
class Expr(str):
str_formula: str
def compile(self):
# print('use mock')
return compile(self.str_formula, '<string>', mode='eval')
parser = lambda: None
parser.expr = lambda str_formula: Expr(str_formula) |
resolved: #4509 |
what to do.. replace with
ast.parse()
?The text was updated successfully, but these errors were encountered: