[New-bugs-announce] [issue18209] Bytearray type not supported as a mutable object in the fcntl.ioctl function
report at bugs.python.org
Fri Jun 14 10:58:44 CEST 2013
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.
>>> file_handle = open('/dev/my_device')
>>> arg = bytearray()
>>> arg += pack('IL',1,2)
>>> command = 0
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
TypeError: an integer is required
title: Bytearray type not supported as a mutable object in the fcntl.ioctl function
versions: Python 2.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce