Closed seamusbleu closed 7 years ago
I can't reproduce this issue. Can you provide an exact command line, directory you're executing from, and the Python version that triggers the problem for you.
A crude fix would be to change line 782 to "active_file = source_file" but that introduces some subtle bugs with tracking line numbers in included files. In all my test cases m4 puts out a syncline entry as the first line of the expanded source code so the else condition is never reached before active_file has been set. The regex must be failing for some unexpected reason.
I have added a --verbose command line option to the Github repo head which is at version 1.3.2. If you install that and run with the verbose option on it will print the exact m4 command line to the output. Can you manually run that command, replacing the final "-" with the path to load.psm4, and capture the output to a file. Version 1.3.2 will also terminate with an error message when active_file is None. Please copy the result from that.
You can install direct from the repo using pip without needing git installed: pip install --upgrade https://github.com/kevinpt/opbasm/tarball/master
Tried to use m4 and it bombs on line 792. I first tried a normal .psm file with the --m4 option, failed. Then I tried it on load.psm4 in the .\test\asm directory, failed. Problem(s) are that active_file = None and source_lines = {}.
Traceback (most recent call last): File "C:\Tools\opbasm-1.3\opbasm.py", line 2530, in
main()
File "C:\Tools\opbasm-1.3\opbasm.py", line 2381, in main
for fname in asm.process_includes():
File "C:\Tools\opbasm-1.3\opbasm.py", line 810, in process_includes
pp_source_file = self.preprocess_with_m4(source_file)
File "C:\Tools\opbasm-1.3\opbasm.py", line 687, in preprocess_with_m4
self.index_expanded_line_numbers(m4_result, pp_source_file, source_file)
File "C:\Tools\opbasm-1.3\opbasm.py", line 792, in index_expanded_line_numbers
index.append((cur_line, source_lines[active_file], active_file))
KeyError: None