diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-11-15 13:53:57 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2017-11-15 14:03:37 -0700 |
commit | 0a1069ae98f49ba7fa87a37fc62f0db904265c2c (patch) | |
tree | e3b03fb8184cbd95dc8cba5bb808ce932215b945 /numpy/f2py | |
parent | abbf4155a0b068520138245b67c34a034a52c42a (diff) | |
download | numpy-0a1069ae98f49ba7fa87a37fc62f0db904265c2c.tar.gz |
BUG: Fix f2py string variables in callbacks.
When NPY_CHAR was deprecated and replaced by NPY_STRING in f2py, calls
to PyArray_New that previously relied on the type to get the itemsize
needed the size explicitly specified, but that modification was missed
in some of the code. Because the strings that replacee the 'c' type are
always 'S1', we use an itemsize of 1 for the string types and pass it
explicitly.
Closes #10027.
Diffstat (limited to 'numpy/f2py')
-rw-r--r-- | numpy/f2py/cb_rules.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/f2py/cb_rules.py b/numpy/f2py/cb_rules.py index 2f68c4d50..e68fdc17d 100644 --- a/numpy/f2py/cb_rules.py +++ b/numpy/f2py/cb_rules.py @@ -367,11 +367,15 @@ cb_arg_rules = [ 'pyobjfrom': [{debugcapi: '\tfprintf(stderr,"debug-capi:cb:#varname#\\n");'}, {isintent_c: """\ \tif (#name#_nofargs>capi_i) { -\t\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,0,NPY_ARRAY_CARRAY,NULL); /*XXX: Hmm, what will destroy this array??? */ +\t\tint itemsize_ = #atype# == NPY_STRING ? 1 : 0; +\t\t/*XXX: Hmm, what will destroy this array??? */ +\t\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,itemsize_,NPY_ARRAY_CARRAY,NULL); """, l_not(isintent_c): """\ \tif (#name#_nofargs>capi_i) { -\t\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,0,NPY_ARRAY_FARRAY,NULL); /*XXX: Hmm, what will destroy this array??? */ +\t\tint itemsize_ = #atype# == NPY_STRING ? 1 : 0; +\t\t/*XXX: Hmm, what will destroy this array??? */ +\t\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname_i#_Dims,#atype#,NULL,(char*)#varname_i#,itemsize_,NPY_ARRAY_FARRAY,NULL); """, }, """ |