@@ -333,7 +333,22 @@ def SaveSessionData(sessionfile, Infodict):
333333 # Range of fitting parameters
334334 Parms [idparm ][9 ] = np .array (Parms [idparm ][9 ],dtype = "float" ).tolist ()
335335 Parmlist .append (Parms [idparm ])
336- yaml .safe_dump (Parmlist , open (parmsfilename , "wb" ))
336+ try :
337+ # We would like to perform safe_dump, because in the
338+ # Windoes x64 version, some integers are exported
339+ # like this: `!!python/long '105'` using `yaml.dump`.
340+ with open (parmsfilename , "wb" ) as yamlfd :
341+ yaml .safe_dump (Parmlist , yamlfd )
342+ except :# yaml.representer.RepresenterError:
343+ # This error occured once on Mac OS 10.8.5:
344+ # `RepresenterError: cannot represent an object: 0`
345+ # In this case, we choose to use the normal dump
346+ # and pray.
347+ if os .path .exists (parmsfilename ):
348+ os .remove (parmsfilename )
349+ with open (parmsfilename , "wb" ) as yamlfd :
350+ yaml .dump (Parmlist , yamlfd )
351+
337352 Arc .write (parmsfilename )
338353 os .remove (os .path .join (tempdir , parmsfilename ))
339354 # Supplementary data (errors of fit)
0 commit comments