[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-11-28 Thread Meador Inge
Meador Inge mead...@gmail.com added the comment: Without seeing a specific example of what you are trying to do, it is hard to tell whether ctypes would be a good fit. I am closing this issue since the original questions have been answered. Please open a new issue if you think ctypes could

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-12 Thread Pavel Boldin
Pavel Boldin boldin.pa...@gmail.com added the comment: We have raw data packages from some tools. These packages contains bitfields, arrays, simple data and so on. We want to parse them into Python objects (structures) for analysis and storage. I tried to use ctypes, but now I wrote myself

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-11 Thread Pavel Boldin
Pavel Boldin boldin.pa...@gmail.com added the comment: OK. So, it seems just like ctypes work, but don't for my needs. Thing that bothers me anyway is the strange code, where size contains either size (when bitsize==0) or bitsize in upper 16 bits and bitoffset in lower 16 bits. --

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-11 Thread Meador Inge
Meador Inge mead...@gmail.com added the comment: Would you mind explaining your use case and why ctypes won't fit it? Maybe there is something that can be fixed. FWIW, I agree that the overloading of 'size' is unnecessary. -- ___ Python tracker

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-10 Thread Meador Inge
Meador Inge mead...@gmail.com added the comment: Pavel, I looked into to this a little more and have some ideas. First off, '_swappedbytes_' is an undocumented implementation detail that is used to implement the LittleEndianStructure and BigEndianStructure types. So using it directly like

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-10 Thread Pavel Boldin
Pavel Boldin boldin.pa...@gmail.com added the comment: Yes. Thanks. But here is another error: import ctypes class X(ctypes.Structure): _pack_ = 1 _fields_ = [ ('a', ctypes.c_ubyte, 4), ('b', ctypes.c_ubyte, 4), ('c', ctypes.c_ushort, 4), ('d',

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-10 Thread Meador Inge
Meador Inge mead...@gmail.com added the comment: Yes I can. This seems strange, but it is correct. The little endian case look like: Little endian --- | unsigned short | unsigned short | --- |

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-09 Thread Pavel Boldin
New submission from Pavel Boldin boldin.pa...@gmail.com: ctypes seems to work incorrectly with _swappedbytes_ specified. I.e. it misses some values from buffer: class X(ctypes.Structure): _swappedbytes_ = 1 _pack_ = 1 _fields_ = [ ('a', ctypes.c_ubyte, 4), ('b',

[issue12945] ctypes works incorrectly with _swappedbytes_ = 1

2011-09-09 Thread Meador Inge
Meador Inge mead...@gmail.com added the comment: I can reproduce this on Fedora 15 with the Python tip revision. I am investigating the behavior now. -- nosy: +meadori stage: - needs patch type: - behavior versions: +Python 3.2, Python 3.3 ___