[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-23 Thread knzsys
knzsys added the comment: Ah OKAY! That's the key which makes all clear to me! I didn't thought at that! Thanks a lot Serhiy Storchaka for your help! -- ___ Python tracker ___

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Because the size of '2s2s29H' is 62 bytes. If the following C float needs to be aligned on 4 bytes boundary, it should start at offset 64, after 2 padding bytes. -- ___ Python tracker

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-21 Thread knzsys
knzsys added the comment: many many thanks for your help! and fast responses :-) this explain my oberservations why only the first 2 bytes are padded? 0xAABBCCDD (4 bytes = real32) to 0xAABBCCDD (6 bytes) and not to 0xAABBCCDD (8 bytes) it has something to do with the behavior of th

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment """ Notes: 1. Padding is only automatically added between successive structure members. No padding is added at the beginning or the end of the encoded struct. """ -- ___

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
knzsys added the comment: just an example, how the pack function behaves with the same format string: before: 13830108be00cafe3e05ecbc513800043c9be14125359541bf3380447452e041. after: 13830108be00cafe3e05ecbc513800043c9be14125359541bf3380447452e041

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
knzsys added the comment: Thanks a lot. changing format string from '2s2s29H26f3L4s' to '=2s2s29H26f3L4s' worked for me. But I still do not understand, why it's working if I splitt format string in 2 parts + use the (un)pack command 2 times ('2s2s29H' + '26f3L4s' are working separately, but '=

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Don't forget about an alignment. If the first character is not one of '@', '=', '<', '>' or '!', '@' is assumed, which means native byte order, type sizes and alignments. If the 'f' format character require 4-byte alignment, 2 padding bytes are inserted befo

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread SylvainDe
SylvainDe added the comment: Could it be caused by alignment ? Also, it could be interesting to explain a bit more what you expect and what you actually get. -- ___ Python tracker

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- Removed message: http://bugs.python.org/msg296425 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
knzsys added the comment: the pack function has the same error: it adds additional 2 bytes -- ___ Python tracker ___ ___ Python-bugs-l

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread SylvainDe
Changes by SylvainDe : -- nosy: +SylvainDe ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
knzsys added the comment: #Working code: from struct import * rawdata = 'A'*196 laserdata = list(unpack('2s2s29H',rawdata[14:76])) laserdata += list(unpack('26f3L4s',rawdata[76:196])) #This code generates error: from struct import * rawdata = 'A'*196 laserdat

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
Changes by knzsys : -- type: crash -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue30712] struct.unpack generates wrong error in certain conditions

2017-06-20 Thread knzsys
New submission from knzsys: #Working code: from struct import * rawdata = 'A'*196 laserdata = list(unpack('2s2s29H',rawdata[14:76])) laserdata += list(unpack('26f3L4s',rawdata[76:196])) #This code generates error: from struct import * rawdata = 'A'*196 laserd