homepage

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 theller
Recipients castironpi, theller
Date 2008年11月27日.19:20:43
SpamBayes Score 6.875582e-08
Marked as misclassified No
Message-id <1227813646.73.0.547516430997.issue4376@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, the _fields_ of ctypes Structures with non-native byte order
can only contain simple types (like int, char, but not pointers), and
arrays of those.
Since this is all Python code (in Lib/ctypes/endian.py) it should be
possible to extend the code to handle other types as well.
If we do this, it must be decided if a Structure (call it 'part' for
this discussion) of some byte order is contained in a _field_ of a
non-native Structure type:
- Should 'part' be inserted as is, leading to a total structure of
fields with mixed byte order?
- Should a new type be created from the 'part' _fields_, with also
non-native byte-order?
Other approaches would be possible as well...
Here is a simple patch that implements the first approach; I have not
tested if it works correctly:
Index: _endian.py
===================================================================
--- _endian.py	(revision 67045)
+++ _endian.py	(working copy)
@@ -17,6 +17,8 @@
 except AttributeError:
 if type(typ) == _array_type:
 return _other_endian(typ._type_) * typ._length_
+ if issubclass(typ, Structure):
+ return typ
 raise TypeError("This type does not support other endian: %s" %
typ)
 
 class _swapped_meta(type(Structure)):
History
Date User Action Args
2008年11月27日 19:20:47thellersetrecipients: + theller, castironpi
2008年11月27日 19:20:46thellersetmessageid: <1227813646.73.0.547516430997.issue4376@psf.upfronthosting.co.za>
2008年11月27日 19:20:45thellerlinkissue4376 messages
2008年11月27日 19:20:43thellercreate

AltStyle によって変換されたページ (->オリジナル) /