• Barry Warsaw's avatar
    Packer.pack_uhyper(): Fixes needed to properly pack unsigned 64 bit · 1d0fe31d
    Barry Warsaw yazdı
    longs where the top bit is set.  First, change the masks so that they
    are `L' longs, otherwise the sign bits will get propagated to the
    result.  Next, do not coerce to int before sending to pack_uint()
    otherwise Python will generate an OverflowError.  Here is a test
    program that fails without the patch, but now succeeds:
    
    import xdrlib
    
    addr = (132, 151, 1, 71)
    uint = 0L
    for a in addr:
        uint = (uint << 8) | a
    
    ulong64 = uint << 32
    
    p = xdrlib.Packer()
    p.pack_uhyper(ulong64)
    buf = p.get_buffer()
    u = xdrlib.Unpacker(buf)
    ulong64prime = u.unpack_uhyper()
    
    if ulong64 == ulong64prime:
        print 'okay'
    else:
        print 'bogus'
    
    print ulong64, ulong64prime
    1d0fe31d
Adı
Son kayıt (commit)
Son güncelleme
Demo Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
Parser Loading commit data...
Python Loading commit data...
Tools Loading commit data...
.hgtags Loading commit data...
BUGS Loading commit data...
Makefile.in Loading commit data...
README Loading commit data...
acconfig.h Loading commit data...
config.h.in Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
install-sh Loading commit data...