diff --git a/clvm/op_utils.py b/clvm/op_utils.py index bc409a8e..ad3a20a0 100644 --- a/clvm/op_utils.py +++ b/clvm/op_utils.py @@ -1,8 +1,11 @@ import types -from typing import Callable, Dict +from typing import Callable, Dict, Optional -def operators_for_dict(keyword_to_atom: Dict, op_dict: Dict[str, Callable], op_name_lookup: Dict = {}) -> Dict: +def operators_for_dict(keyword_to_atom: Dict, op_dict: Dict[str, Callable], op_name_lookup: Optional[Dict] = None) -> Dict: + if op_name_lookup is None: + op_name_lookup = {} + d = {} for op in keyword_to_atom.keys(): op_name = "op_%s" % op_name_lookup.get(op, op) @@ -12,5 +15,7 @@ def operators_for_dict(keyword_to_atom: Dict, op_dict: Dict[str, Callable], op_n return d -def operators_for_module(keyword_to_atom: Dict, mod: types.ModuleType, op_name_lookup: Dict = {}) -> Dict: +def operators_for_module(keyword_to_atom: Dict, mod: types.ModuleType, op_name_lookup: Optional[Dict] = None) -> Dict: + if op_name_lookup is None: + op_name_lookup = {} return operators_for_dict(keyword_to_atom, mod.__dict__, op_name_lookup) diff --git a/clvm/serialize.py b/clvm/serialize.py index 04fb4a6d..77cb9af9 100644 --- a/clvm/serialize.py +++ b/clvm/serialize.py @@ -43,7 +43,7 @@ def sexp_to_byte_iterator(sexp: SExp) -> typing.Iterator[bytes]: todo_stack = [sexp] while todo_stack: sexp = todo_stack.pop() - pair = sexp.as_pair() + pair = sexp.pair if pair: yield bytes([CONS_BOX_MARKER]) todo_stack.append(pair[1])