Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Hessian Reap/Sow Broken on Python3 Compiled Psi4 #833
Reaping and sowing seem to be broken for Hessians when using Psi4 compiled with Python 3. None of the following errors could be reproduced when using Psi4 compiled with Python 2.
The following input file produces the following error:
The culprit is exactly what the traceback says: fmaster is opened in binary mode and format_options_for_input returns a string. Python 2 would let you write a string to a binary file, but Python 3 expects bytes. I can fix this locally by adding the required .encode('utf-8') calls to that line as well as several lines afterwards, starting around 1370.
If that was all, I would just fix this myself, but sowing is useless without reaping, and the reaping bug is trickier. The displacement files include bytes encoded from UTF-8 and also bytes dumped from pickle (the gradient kwargs). In general, pickle bytes will not be intelligible in any text encoding scheme. Python 2's naive approach to bytes means this is not a problem. When you try to run one of those files with Python 3-compiled Psi4, however...
Python 3 tries to read all the bytes as UTF-8. This fails for the pickled bytes, so Psi4 crashes. Even if you read the file as binary, you would still have to (somehow) instruct Python 3 which parts of the file should be UTF-8 decoded and which parts should be pickle-loaded.
Yes, the key barrier is that sow/reap pickles its major pieces (mol, opts, call) for transport across p4 instances, and the py Molecule class has serious opposition to being pickled (side effect of the nice