Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These are the patches from dials/cbflib#19.
Problem: All
char *
fields,input[1] and output are mapped tostr
. This works on Python 2, but on Python 3 causes problems that your binary data is now encoded in a string and needs to be converted viaencode('utf-8', errors='surrogateescape')
(see SWIG docs). This can be worked around by settingSWIG_PYTHON_STRICT_BYTE_CHAR
in the build - but now allchar *
fields are bytes, meaning that you need to encode any strings that you are passing into pycbf (see e.g. cctbx/dxtbx@44b6d72).This commit fixes this. When using Python 3, functions that return data will return it as a python
bytes
object, and those that accept data will accept a pythonbytes
object. Everything else will acceptstr
.[1] Input field mapping is mostly solved by 647ffcb, which means that anything that accepts an explicitly string argument will accept both string and bytes. However, we don't want data fields to accept strings - so input handling is still important.