diff --git a/OMPython/om_session_omc.py b/OMPython/om_session_omc.py index e1d0e461..de128913 100644 --- a/OMPython/om_session_omc.py +++ b/OMPython/om_session_omc.py @@ -466,7 +466,7 @@ def sendExpression(self, expr: str, parsed: bool = True, raise_on_error: bool = if not self._re_log_raw: self._re_log_raw = re.compile( pattern=r"\s*info = record OpenModelica\.Scripting\.SourceInfo\n" - r"\s*filename = \"(.*?)\",\n" + r"\s*file[nN]ame = \"(.*?)\",\n" # older omc: filename, newer: fileName r"\s*readonly = (.*?),\n" r"\s*lineStart = (\d+),\n" r"\s*columnStart = (\d+),\n" diff --git a/tests/test_OMSessionCmd.py b/tests/test_OMSessionCmd.py index 7dbb9705..dfcb19db 100644 --- a/tests/test_OMSessionCmd.py +++ b/tests/test_OMSessionCmd.py @@ -1,3 +1,5 @@ +import pytest + import OMPython @@ -18,3 +20,10 @@ def test_isPackage2(): # TODO: add more checks ... + + +def test_error_message_file(): + # omc names the file field of a message filename or fileName (OpenModelica issue 17891) + omcs = OMPython.OMCSessionLocal() + with pytest.raises(OMPython.OMSessionException, match=r"\[bad\.mo:"): + omcs.sendExpression('loadString("model M Real x = ; end M;", "bad.mo")')