Message191110
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 |
|
Date |
User |
Action |
Args |
2013-06-14 08:58:44 | vxgmichel | set | recipients:
+ vxgmichel |
2013-06-14 08:58:44 | vxgmichel | set | messageid: <1371200324.57.0.0793560197908.issue18209@psf.upfronthosting.co.za> |
2013-06-14 08:58:44 | vxgmichel | link | issue18209 messages |
2013-06-14 08:58:44 | vxgmichel | create | |
|