Documentation
Documentation of multiprocessing.Array describes the optional Attributes value and raw for c_char-Arrays with a short line:
Note that an array of ctypes.c_char has value and raw attributes which allow one to use it to store and retrieve strings.
While it might be obvious to C-developers, there is no note that setting Array.value to a bytes-object containing a nullbyte will skip the rest of the content when retrieving the value-Attribute:
from multiprocessing import Array
from ctypes import c_char
uut = Array(c_char, 50)
uut.value = bytes.fromhex('48656c6c6f 00 576f726c64')
print(uut.value.hex()) # Gives only 48656c6c6f
As c_char is intended for usage of strings, this might not be too large of an issue, but as Array.value accepts and gives bytes-objects, I expected to have no changes.
My suggestion would be to add a sentence to the documentation, I'll provide a small PR shortly to discussion.
Linked PRs
Documentation
Documentation of
multiprocessing.Arraydescribes the optional Attributesvalueandrawforc_char-Arrays with a short line:While it might be obvious to C-developers, there is no note that setting
Array.valueto a bytes-object containing a nullbyte will skip the rest of the content when retrieving thevalue-Attribute:As
c_charis intended for usage of strings, this might not be too large of an issue, but asArray.valueaccepts and gives bytes-objects, I expected to have no changes.My suggestion would be to add a sentence to the documentation, I'll provide a small PR shortly to discussion.
Linked PRs