Skip to content

MontePy cannot handle "read file" with only comments #854

@tjlaboss

Description

@tjlaboss

Bug Description

MontePy cannot process a read file=... target with only comments.

To Reproduce

montepy.read_input("problem.i")

Error Message

Details
Traceback (most recent call last):
  File "./load_problem.py", line 2, in <module>
    montepy.read_input("problem.i")
  File "./montepy/input_parser/input_reader.py", line 45, in read_input
    problem.parse_input(replace=replace)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "./montepy/mcnp_problem.py", line 434, in parse_input
    raise e
  File "./montepy/mcnp_problem.py", line 413, in parse_input
    obj = obj_parser(input)
  File "./montepy/mcnp_object.py", line 49, in wrapped
    add_line_number_to_exception(e, self)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "./montepy/exceptions.py", line 235, in add_line_number_to_exception
    raise error
  File "./montepy/mcnp_object.py", line 41, in wrapped
    return func(*args, **kwargs)
  File "./montepy/cell.py", line 144, in __init__
    super().__init__(input, self._parser, number)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./montepy/mcnp_object.py", line 49, in wrapped
    add_line_number_to_exception(e, self)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "./montepy/exceptions.py", line 235, in add_line_number_to_exception
    raise error
  File "./montepy/mcnp_object.py", line 41, in wrapped
    return func(*args, **kwargs)
  File "./montepy/numbered_mcnp_object.py", line 60, in __init__
    super().__init__(input, parser)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "./montepy/mcnp_object.py", line 49, in wrapped
    add_line_number_to_exception(e, self)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "./montepy/exceptions.py", line 259, in add_line_number_to_exception
    raise error.with_traceback(trace)
  File "./montepy/mcnp_object.py", line 41, in wrapped
    return func(*args, **kwargs)
  File "./montepy/mcnp_object.py", line 137, in __init__
    raise ParsingError(
    ...<3 lines>...
    )
montepy.exceptions.ParsingError:     dummy.i, line 0

         1| c A 'read file' target containing just a comment
    dummy.i, line 0

         1| c A 'read file' target containing just a comment
The input ended prematurely.
sly: Parse error in input. EOF

MCNP input file snippet

problem.i:

Examle Problem
c Cells
1  0  -1  imp:n=1
read file=dummy.i
9  0  +1  imp:n=2

c Surfaces
1 so 1.0 

c Data
nps 1

dummy.i:

c A 'read file' target containing just a comment

Version

  • Version 1.1.3

Additional context

Not a typical usage scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsA deviation from expected behavior that does not reach the level of being reportable as an "Error".low priorityparsers are hardExamples of where MCNP syntax is complicated and should be simplified.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions