New submission from Vincent Michel: The Bytearray type is a mutable object that support the read-write buffer interface. The fcntl.ioctl() function is supposed to handle mutable object (such as array.array) for the system calls in order to pass object that are more than 1024 bytes long.
The problem is that in Python 2.7, Bytearray type is not supported as a mutable object in the fcntl.ioctl function. In Python 3.2, it works perfectly. In the specific case where a large C structure is needed (more than 1024 bytes), the Bytearray type is extremely useful compare to the array.array type that is adapted for C arrays. Example : >>> file_handle = open('/dev/my_device') >>> arg = bytearray() >>> arg += pack('IL',1,2) >>> command = 0 >>> ioctl(file_handle,command,arg) Traceback (most recent call last): File "<pyshell#22>", line 1, in <module> ioctl(file_handle,command,arg) TypeError: an integer is required ---------- components: IO messages: 191110 nosy: vxgmichel priority: normal severity: normal status: open title: Bytearray type not supported as a mutable object in the fcntl.ioctl function type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18209> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com