Closed MicahGale closed 2 weeks ago
Traceback (most recent call last):
File "grab_beginning_comment.py", line 1, in <module>
import montepy
File "montepy/__init__.py", line 10, in <module>
from . import input_parser
File "montepy/input_parser/__init__.py", line 6, in <module>
from . import input_reader
File "montepy/input_parser/input_reader.py", line 2, in <module>
from montepy import mcnp_problem
File "montepy/mcnp_problem.py", line 397
f"{'\n'.join(obj._input.input_lines)}"
^
SyntaxError: f-string expression part cannot include a backslash
What version of python was this on? I didn't get a syntax error in 3.12.
3.9.9
Description
This wraps almost errors from
MCNP_Object
with information of where in a file this error came from. This works by:montepy.errors.add_line_number_to_exception
. This takes an error and aMCNP_Object
instance. If possible it takes the_input
information and appends that information to the error message (see below).metaclass
(_ExceptionContextAdder
) forMCNP_Object
this modifies all attributes. If it's_private
or__dunder__
it does nothing. Otherwise forcallable
andproperty
it gets wrapped using_wrap_attr_call
. This just wraps the function call in atry except
ParsingError
for use here to print the input, see below.Here is an example stack trace.
Some thoughts:
Fixes #579, fixes #362
Checklist