From 9c62ff057c4a1b2470990259cb57b6978fafebd5 Mon Sep 17 00:00:00 2001 From: mike-tasca Date: Wed, 20 Mar 2024 16:55:46 +0100 Subject: [PATCH] FIX: Try was broken --- package-lock.json | 4 ++-- package.json | 2 +- src/reactive_python_engine.py | 9 ++++++++- src/reactive_python_engine.ts | 9 ++++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59d9a9f..282bc07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reactive-jupyter", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "reactive-jupyter", - "version": "0.4.0", + "version": "0.4.1", "license": "MIT", "dependencies": { "@c4312/evt": "^0.1.1", diff --git a/package.json b/package.json index d9d880d..8fd2a2a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "color": "#ffffff", "theme": "light" }, - "version": "0.4.0", + "version": "0.4.1", "engines": { "vscode": "^1.85.0" }, diff --git a/src/reactive_python_engine.py b/src/reactive_python_engine.py index 9eb787a..6a0051e 100644 --- a/src/reactive_python_engine.py +++ b/src/reactive_python_engine.py @@ -281,11 +281,16 @@ def _visit_try(self, node: ast.Try): # ast.TryStar all_vars_handlers = [] for handler in node.handlers: scope = TempScopeVisitor(ExposedVariables(), is_lhs_target=self.is_lhs_target, is_also_input_of_aug_assign=self.is_also_input_of_aug_assign, _class=self._class) - visit_all(scope, handler.type, handler.name) + visit_all(scope, handler.type) vars_stmts_handler = get_vars_for_nodes(scope, *handler.body, _class=self._class) vars_handler = join_body_stmts_into_vars(*vars_stmts_handler, _class=self._class) + # Remove the handler.name from the input variables AND output variables, by hand: + vars_handler.input_variables -= set([handler.name]) + vars_handler.output_variables -= set([handler.name]) + vars_handler.inputs_variables_in_function_in_class -= set([handler.name]) + all_vars_handlers.append(v_merge(scope.variables, vars_handler, _class=self._class)) # TO CHECK: Is this right? self.variables = v_merge(self.variables, v_merge(vars_body, h_merge(*all_vars_handlers, vars_orelse), vars_finalbody, _class=self._class), _class=self._class) @@ -2237,3 +2242,5 @@ def has_path(G, source, target): return DiGraph, topological_sort, has_path reactive_python_dag_builder_utils__ = ReactivePythonDagBuilderUtils__() + + diff --git a/src/reactive_python_engine.ts b/src/reactive_python_engine.ts index c030578..1b735eb 100644 --- a/src/reactive_python_engine.ts +++ b/src/reactive_python_engine.ts @@ -282,11 +282,16 @@ class ReactivePythonDagBuilderUtils__(): all_vars_handlers = [] for handler in node.handlers: scope = TempScopeVisitor(ExposedVariables(), is_lhs_target=self.is_lhs_target, is_also_input_of_aug_assign=self.is_also_input_of_aug_assign, _class=self._class) - visit_all(scope, handler.type, handler.name) + visit_all(scope, handler.type) vars_stmts_handler = get_vars_for_nodes(scope, *handler.body, _class=self._class) vars_handler = join_body_stmts_into_vars(*vars_stmts_handler, _class=self._class) + # Remove the handler.name from the input variables AND output variables, by hand: + vars_handler.input_variables -= set([handler.name]) + vars_handler.output_variables -= set([handler.name]) + vars_handler.inputs_variables_in_function_in_class -= set([handler.name]) + all_vars_handlers.append(v_merge(scope.variables, vars_handler, _class=self._class)) # TO CHECK: Is this right? self.variables = v_merge(self.variables, v_merge(vars_body, h_merge(*all_vars_handlers, vars_orelse), vars_finalbody, _class=self._class), _class=self._class) @@ -2239,4 +2244,6 @@ class ReactivePythonDagBuilderUtils__(): reactive_python_dag_builder_utils__ = ReactivePythonDagBuilderUtils__() + + `; \ No newline at end of file