1313from mathics .core .parser .convert import convert
1414from mathics .core .parser .feed import MathicsSingleLineFeeder
1515from mathics .core .parser .parser import Parser
16- from mathics .core .symbols import Symbol , ensure_context
16+ from mathics .core .symbols import Symbol , SymbolTrue , ensure_context
17+ from mathics .core .systemsymbols import SymbolFailed
1718
1819parser = Parser ()
1920
2021
21- def dump_exprs_to_pcl_file (exprs , pickle_file : str ) -> Optional [ str ] :
22+ def dump_exprs_to_pcl_file (exprs , pickle_file : str ) -> Symbol :
2223 """
2324 Parse input from `feeder` and pickle serialize the parsed M-expression Python written
2425 to pickle_file.
2526 Serializes a Mathics3 AST Node to a file `pickle_file` using Python pickle.
27+
28+ Return SymbolTrue if things went okay.
2629 """
2730 # Open the file in binary write mode
2831 with open (pickle_file , "wb" ) as f :
2932 # Protocol -1 uses the highest available binary protocol for efficiency
3033 pickle .dump (exprs , f , protocol = pickle .HIGHEST_PROTOCOL )
34+ return SymbolTrue
3135
3236
3337def parse (definitions , feeder : LineFeeder ) -> Optional [BaseElement ]:
@@ -99,7 +103,7 @@ def parse_returning_code(
99103 return converted , source_text
100104
101105
102- def parse_dump_to_pcl_file (feeder : LineFeeder , pickle_file : str ) -> Optional [ str ] :
106+ def parse_dump_to_pcl_file (feeder : LineFeeder , pickle_file : str ) -> Symbol :
103107 """
104108 Parse input from `feeder` and pickle serialize the parsed M-expression Python written
105109 to pickle_file.
@@ -108,7 +112,7 @@ def parse_dump_to_pcl_file(feeder: LineFeeder, pickle_file: str) -> Optional[str
108112 ast = parser .parse (feeder )
109113
110114 if ast is None :
111- return None
115+ return SymbolFailed
112116 # Ensure the input is actually a Node (optional safety check)
113117 if not isinstance (ast , ASTNode ):
114118 raise TypeError (f"Expected mathics.core.parser.ast.Node, got { type (ast )} " )
@@ -117,6 +121,7 @@ def parse_dump_to_pcl_file(feeder: LineFeeder, pickle_file: str) -> Optional[str
117121 with open (pickle_file , "wb" ) as f :
118122 # Protocol -1 uses the highest available binary protocol for efficiency
119123 pickle .dump (ast , f , protocol = pickle .HIGHEST_PROTOCOL )
124+ return SymbolTrue
120125
121126
122127def parse_from_pcl_file (definitions , pickle_file : str ):
0 commit comments