struct.pack bug?

Jonathan Fine jfine at pytex.org
Thu Feb 8 16:58:33 EST 2007


Hello

I find the following inconsistent:
===
 >>> sys.version
'2.4.1a0 (#2, Feb  9 2005, 12:50:04) \n[GCC 3.3.5 (Debian 1:3.3.5-8)]'
 >>> pack('>B', 256)
'\x00'
 >>> pack('<B', 256)
'\x00'
 >>> pack('B', 256)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
struct.error: ubyte format requires 0<=number<=255
 >>>
===

I was hoping that '>B' and '<B' would raise an exception,
ust as 'B' does.


On Oct 27 2006, 11:17 am, Jansson Christer reported a
different anomoly to this newsgroup, using the same
subject.

-- 
Jonathan




More information about the Python-list mailing list