Skip to content

Commit

Permalink
Merge pull request Pyomo#3231 from jsiirola/ipopt_v2-disable-universa…
Browse files Browse the repository at this point in the history
…l-newlines

Disable the use of universal newlines in the ipopt_v2 NL file
  • Loading branch information
jsiirola authored Apr 11, 2024
2 parents 3e14f80 + d19c8c9 commit fa5d0b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyomo/contrib/solver/ipopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ def solve(self, model, **kwds):
raise RuntimeError(
f"NL file with the same name {basename + '.nl'} already exists!"
)
with open(basename + '.nl', 'w') as nl_file, open(
# Note: the ASL has an issue where string constants written
# to the NL file (e.g. arguments in external functions) MUST
# be terminated with '\n' regardless of platform. We will
# disable universal newlines in the NL file to prevent
# Python from mapping those '\n' to '\r\n' on Windows.
with open(basename + '.nl', 'w', newline='\n') as nl_file, open(
basename + '.row', 'w'
) as row_file, open(basename + '.col', 'w') as col_file:
timer.start('write_nl_file')
Expand Down

0 comments on commit fa5d0b6

Please sign in to comment.