BUG: revise string_from_pyobj/try_pyarr_from_string with respect to malloc and copy (the second round) #19251
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.
Improved #18759 that was reverted by #19235 .
Originally, it was assumed that Fortran treats null values in byte-strings similar to C but that turned out to be wrong and caused failures in scipy tests that use f2py wrapped functions with string
intent(inout)
arguments for Fortran fixed-width character string arguments.This PR (in addition to original changes) replaces the trailing nulls in strings with trailing blanks that Fortran treats as "null values" and when Fortran program returns a string with trailing blanks, these will be replaced with trailing nulls because the content of numpy ndarray of strings is interpreted as C strings.
Fixes #18431 (again) and #19201 .
This PR is tested against the current scipy master: all scipy tests pass ok.