Skip to content

Commit

Permalink
Make macro context NS readonly
Browse files Browse the repository at this point in the history
Macros really should not be writing information to their expansion ns that might be used at run time, since run time might not be in the same Python session as compile time.
  • Loading branch information
gilch committed Jul 23, 2024
1 parent 4472c31 commit 9bad2f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hissp/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from itertools import chain, starmap, takewhile
from pprint import pformat
from traceback import format_exc
from types import ModuleType
from types import MappingProxyType, ModuleType
from typing import Any, Dict, Iterable, List, NewType, Tuple, TypeVar, Union
from warnings import warn

Expand All @@ -42,7 +42,7 @@
@contextmanager
def macro_context(ns):
"""Sets `NS` during macroexpansions."""
token = NS.set(ns)
token = NS.set(MappingProxyType(ns))
try:
yield
finally:
Expand Down

0 comments on commit 9bad2f1

Please sign in to comment.