Author ronaldoussoren
Recipients d9pouces, eric.araujo, jrjsmrtn, markgrandi, ned.deily, python-dev, r.david.murray, ronaldoussoren, serhiy.storchaka
Date 2014-01-15.14:40:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389796836.79.0.0324549758779.issue14455@psf.upfronthosting.co.za>
In-reply-to
Content
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;
}
History
Date User Action Args
2014-01-15 14:40:36ronaldoussorensetrecipients: + ronaldoussoren, ned.deily, eric.araujo, r.david.murray, jrjsmrtn, python-dev, serhiy.storchaka, d9pouces, markgrandi
2014-01-15 14:40:36ronaldoussorensetmessageid: <1389796836.79.0.0324549758779.issue14455@psf.upfronthosting.co.za>
2014-01-15 14:40:36ronaldoussorenlinkissue14455 messages
2014-01-15 14:40:36ronaldoussorencreate