This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients arhadthedev, erlendaasland, gdr@garethrees.org, lemburg, mark.dickinson, rhettinger, vstinner
Date 2021-11-29.14:57:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638197827.87.0.378068796647.issue45476@roundup.psfhosted.org>
In-reply-to
Content
PyBytes_AS_STRING() and PyByteArray_AS_STRING() are used to modify string characters, but not used directly as l-value.

Search in PyPI top 5000 packages:

$ ./search_pypi_top_5000.sh '(PyByteArray|PyBytes)_AS_.*[^!<>=]=[^=]'
pypi-top-5000_2021-08-17/plyvel-1.3.0.tar.gz
pypi-top-5000_2021-08-17/numexpr-2.7.3.tar.gz
pypi-top-5000_2021-08-17/Cython-0.29.24.tar.gz

numexpr-2.7.3, numexpr/numexpr_object.cpp:

PyBytes_AS_STRING(constsig)[i] = 'b';
PyBytes_AS_STRING(constsig)[i] = 'i';
PyBytes_AS_STRING(constsig)[i] = 'l';
PyBytes_AS_STRING(constsig)[i] = 'f';
PyBytes_AS_STRING(constsig)[i] = 'd';
PyBytes_AS_STRING(constsig)[i] = 'c';
PyBytes_AS_STRING(constsig)[i] = 's';

plyvel-1.3.0, plyvel/_plyvel.cpp: 

PyByteArray_AS_STRING(string)[i] = (char) v;
PyByteArray_AS_STRING(string)[i] = (char) v;

Cython-0.29.24:

$ grep -E '(PyByteArray|PyBytes)_AS_.*[^!<>=]=[^=]' -R .
./Cython/Utility/StringTools.c:            PyByteArray_AS_STRING(string)[i] = (char) v;
./Cython/Utility/StringTools.c:        PyByteArray_AS_STRING(string)[i] = (char) v;
./Cython/Utility/StringTools.c:            PyByteArray_AS_STRING(bytearray)[n] = value;
History
Date User Action Args
2021-11-29 14:57:08vstinnersetrecipients: + vstinner, lemburg, rhettinger, mark.dickinson, gdr@garethrees.org, erlendaasland, arhadthedev
2021-11-29 14:57:07vstinnersetmessageid: <1638197827.87.0.378068796647.issue45476@roundup.psfhosted.org>
2021-11-29 14:57:07vstinnerlinkissue45476 messages
2021-11-29 14:57:07vstinnercreate