Ronald Oussoren added the comment:

Reopening because Cocoa behaves differently that I had noticed earlier...

The (Objective-C) code below serialises an NSDictionary with an unsigned long 
of value ULLONG_MAX and then reads it back. I had expected that restored value 
contained a negative number, but it actually reads back the correct value.

I'm going to do some more spelunking to find out what's going on here, and will 
adjust the plistlib code to fully represent all values of unsigned 64-bit 
integers (likely based on your code for supporting 128-bit integers)



Output (on a 64-bit system running OSX 10.9):

$ ./demo 
2014-01-15 15:34:18.196 demo[77580:507] input dictionary: {
    key = 18446744073709551615;
}   value 18446744073709551615
2014-01-15 15:34:18.198 demo[77580:507] as binary plist: <62706c69 73743030 
d1010253 6b657914 00000000 00000000 ffffffff ffffffff 080b0f00 00000000 
00010100 00000000 00000300 00000000 00000000 00000000 000020>
2014-01-15 15:34:18.198 demo[77580:507] Restored as {
    key = 18446744073709551615;
}


Code:

/*
 * To use:
 *  $ cc -o demo demo.c -framework Cocoa
 *  $ ./demo
 */
#import <Cocoa/Cocoa.h>

int main(void)
{
        NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
        NSNumber* value = [NSNumber numberWithUnsignedLongLong:ULLONG_MAX];

        NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:value, 
@"key", nil];
        NSLog(@"input dictionary: %@   value %llu", dict, ULLONG_MAX);

        NSData* serialized = [NSPropertyListSerialization
            dataWithPropertyList:dict
                          format: NSPropertyListBinaryFormat_v1_0
                         options: 0
                           error: nil];
        NSLog(@"as binary plist: %@", serialized);

        NSDictionary* restored = [NSPropertyListSerialization
            propertyListWithData:serialized
                         options:0
                          format:nil
                           error:nil];
        NSLog(@"Restored as %@", restored);
        return 0;
}

----------
status: closed -> open

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14455>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to