Skip to content

Commit 4cc5c6d

Browse files
committed
small
1 parent 5a80daa commit 4cc5c6d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

docs/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
History
22
=======
33

4+
0.0.66 (2024-10-06)
5+
-------------------
6+
* Small configuration simplification;
7+
48
0.0.65 (2024-08-25)
59
-------------------
610
* Implement garbage collection for invalidated AST bookkeeping;

pyccolo/ast_rewriter.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@ def visit(self, node: ast.AST):
106106
),
107107
)
108108
orig_to_copy_mapping = mapper(node)
109-
tracer = self._tracers[-1]
110-
old_bookkeeper = tracer.ast_bookkeeper_by_fname.get(self._path)
109+
last_tracer = self._tracers[-1]
110+
old_bookkeeper = last_tracer.ast_bookkeeper_by_fname.get(self._path)
111111
module_id = id(node) if self._module_id is None else self._module_id
112-
new_bookkeeper = tracer.ast_bookkeeper_by_fname[
112+
new_bookkeeper = last_tracer.ast_bookkeeper_by_fname[
113113
self._path
114114
] = AstBookkeeper.create(self._path, module_id)
115115
if old_bookkeeper is not None:
116-
tracer.remove_bookkeeping(old_bookkeeper, module_id)
116+
last_tracer.remove_bookkeeping(old_bookkeeper, module_id)
117117
BookkeepingVisitor(
118118
new_bookkeeper.ast_node_by_id,
119119
new_bookkeeper.containing_ast_by_id,
120120
new_bookkeeper.containing_stmt_by_id,
121121
new_bookkeeper.parent_stmt_by_id,
122122
new_bookkeeper.stmt_by_lineno,
123123
).visit(orig_to_copy_mapping[id(node)])
124-
tracer.add_bookkeeping(new_bookkeeper, module_id)
124+
last_tracer.add_bookkeeping(new_bookkeeper, module_id)
125125
self.orig_to_copy_mapping = orig_to_copy_mapping
126126
raw_handler_predicates_by_event: DefaultDict[
127127
TraceEvent, List[Predicate]
@@ -202,4 +202,6 @@ def visit(self, node: ast.AST):
202202
handler_guards_by_event,
203203
expr_rewriter,
204204
).visit(node)
205+
if not any(tracer.requires_ast_bookkeeping for tracer in self._tracers):
206+
last_tracer.remove_bookkeeping(new_bookkeeper, module_id)
205207
return node

pyccolo/import_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def get_data(self, path: str) -> bytes:
128128
if len(parts) < 3:
129129
return super().get_data(path)
130130
source_path = pyccolo_source_from_cache(path)
131-
if parts[-3] == self.make_cache_signature(source_path):
131+
if self.make_cache_signature(source_path) in (parts[-3], "pyccolo"):
132132
return super().get_data(path)
133133
path = source_path
134134
path_str = str(path)

0 commit comments

Comments
 (0)