Skip to content

Commit

Permalink
revert iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgen-lentz committed Dec 3, 2024
1 parent d25fd30 commit 5a68136
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions amplpy/iterators.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,8 @@ cdef class EnvIterator(object):
cdef char* value_c
campl.AMPL_EnvironmentVarGetName(it, &name_c)
campl.AMPL_EnvironmentVarGetValue(it, &value_c)

import sys
if sys.platform == "win32":
try:
name = name_c.decode('utf-16', errors='replace')
value = value_c.decode('utf-16', errors='replace')
except UnicodeDecodeError as e:
raise RuntimeError(f"Failed to decode environment variable (Windows): {e}")
else:
try:
name = name_c.decode('utf-8', errors='replace')
value = value_c.decode('utf-8', errors='replace')
except UnicodeDecodeError as e:
raise RuntimeError(f"Failed to decode environment variable (Non-Windows): {e}")
name = name_c.decode('utf-8', errors='replace')
value = value_c.decode('utf-8', errors='replace')

return (name, value)

Expand Down

0 comments on commit 5a68136

Please sign in to comment.