Commit 5596655d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

avoid exec statements; they cause problems with Python 3

parent dd87b630
Pipeline #14884 passed with stage
in 6 minutes and 20 seconds
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
from __future__ import division from __future__ import division
import ast
import itertools import itertools
import numpy as np import numpy as np
...@@ -1519,7 +1520,8 @@ class Field(Loggable, Versionable, object): ...@@ -1519,7 +1520,8 @@ class Field(Loggable, Versionable, object):
temp_domain.append(repository.get('s_' + str(i), hdf5_group)) temp_domain.append(repository.get('s_' + str(i), hdf5_group))
new_field.domain = tuple(temp_domain) new_field.domain = tuple(temp_domain)
exec('new_field.domain_axes = ' + hdf5_group.attrs['domain_axes']) new_field.domain_axes = ast.literal_eval(
hdf5_group.attrs['domain_axes'])
try: try:
new_field._val = repository.get('val', hdf5_group) new_field._val = repository.get('val', hdf5_group)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes. # and financially supported by the Studienstiftung des deutschen Volkes.
import ast
import numpy as np import numpy as np
from d2o import distributed_data_object from d2o import distributed_data_object
...@@ -311,6 +312,6 @@ class PowerSpace(Space): ...@@ -311,6 +312,6 @@ class PowerSpace(Space):
@classmethod @classmethod
def _from_hdf5(cls, hdf5_group, repository): def _from_hdf5(cls, hdf5_group, repository):
hp = repository.get('harmonic_partner', hdf5_group) hp = repository.get('harmonic_partner', hdf5_group)
exec("bb = " + hdf5_group.attrs['binbounds']) bb = ast.literal_eval(hdf5_group.attrs['binbounds'])
ds = hdf5_group.attrs['distribution_strategy'] ds = hdf5_group.attrs['distribution_strategy']
return PowerSpace(hp, ds, binbounds=bb) return PowerSpace(hp, ds, binbounds=bb)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment