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 vxgmichel
Recipients vxgmichel
Date 2013-06-14.08:58:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371200324.57.0.0793560197908.issue18209@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-06-14 08:58:44vxgmichelsetrecipients: + vxgmichel
2013-06-14 08:58:44vxgmichelsetmessageid: <1371200324.57.0.0793560197908.issue18209@psf.upfronthosting.co.za>
2013-06-14 08:58:44vxgmichellinkissue18209 messages
2013-06-14 08:58:44vxgmichelcreate