<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -41,6 +41,7 @@ def setupPythonObject():
     kOP_LIST=11
     kOP_DICT=12
     kOP_GLOBAL_EXT=13
+    kOP_FLOAT_STR=14
 
     kKIND = NSString.stringWithString_(u&quot;kind&quot;)
     kFUNC = NSString.stringWithString_(u&quot;func&quot;)
@@ -133,8 +134,11 @@ def setupPythonObject():
     encode_dispatch[long] = save_long
 
     def save_float(coder, obj):
-        coder.encodeInt_forKey_(kOP_FLOAT, kKIND)
-        coder.encodeDouble_forKey_(obj, kVALUE)
+        # Encode floats as strings, this seems to be needed to get
+        # 100% reliable round-trips.
+        coder.encodeInt_forKey_(kOP_FLOAT_STR, kKIND)
+        coder.encodeObject_forKey_(unicode(repr(obj)), kVALUE)
+        #coder.encodeDouble_forKey_(obj, kVALUE)
     encode_dispatch[float] = save_float
 
     def save_string(coder, obj):
@@ -155,7 +159,6 @@ def setupPythonObject():
 
     def save_dict(coder, obj):
         coder.encodeInt_forKey_(kOP_DICT, kKIND)
-
         v = NSDictionary.dictionaryWithDictionary_(obj)
         coder.encodeObject_forKey_(v, kVALUE)
     encode_dispatch[dict] = save_dict
@@ -222,6 +225,10 @@ def setupPythonObject():
         return coder.decodeFloatForKey_(kVALUE)
     decode_dispatch[kOP_FLOAT] = load_float
 
+    def load_float_str(coder, setValue):
+        return float(coder.decodeObjectForKey_(kVALUE))
+    decode_dispatch[kOP_FLOAT_STR] = load_float_str
+
     def load_tuple(coder, setValue):
         return tuple(coder.decodeObjectForKey_(kVALUE))
     decode_dispatch[kOP_TUPLE] = load_tuple</diff>
      <filename>pyobjc/pyobjc-core/Lib/objc/_pycoder.py</filename>
    </modified>
    <modified>
      <diff>@@ -129,18 +129,19 @@ class TestNSNumber (TestCase):
         else:
             self.assertEquals(OC_TestNumber.numberAsUnsignedLong_(v), 18446744073709551488)
 
-        # XXX: the next one is actually incorrect (as can be seen by the following C code,
-        # but is what NSNumber returns).
+        # The first entry in the tuple below is incorrect, that happens to be what
+        # is returned by NSNumber on some platforms (in particular, any Python where
+        # the python framework itself is linked against the 10.4 SDK)
         #
         #   double v = -127.6;
         #   unsigned long long lv = v;
         #   printf(&quot;%llu\n&quot;, lv);
+        # 
 
-        if int(os.uname()[2].split('.')[0]) == 8:
-            self.assertEquals(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551489)
+        self.failUnless(
+                OC_TestNumber.numberAsUnsignedLongLong_(v) in 
+                    (18446744073709551489, 18446744073709551488))
 
-        else:
-            self.assertEquals(OC_TestNumber.numberAsUnsignedLongLong_(v), 18446744073709551488)
         self.assertEquals(OC_TestNumber.numberAsDouble_(v), -127.6)
 
         # Overflow</diff>
      <filename>pyobjc/pyobjc-core/Lib/objc/test/test_number_proxy.py</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,14 @@ An overview of the relevant changes in new, and older, releases.
 Version 2.2 (...)
 -----------------
 
+- BUGFIX: Storing pure python objects in a ``NSKeydArchiver`` archive didn't 
+  work 100% reliably for Python floats. I've changed the implementation on 
+  for encoding floats a little and now floats do get rounddtripped properly.
+
+  The side effect of this is that archives written by PyObjC 2.2b2 or later
+  cannot always be read by earlier versions (but PyObjC 2.2b2 can read archives
+  created with earlier versions).
+
 - BUGFIX: Enable building from source with the Python.org binary distribution.
 
 - BUGFIX: Fix crash when using the animotor proxy feature of CoreAnimation. </diff>
      <filename>pyobjc/pyobjc-core/NEWS.txt</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>dfcb624d47bce8b5eae28a82d1ddc0782ba0a51e</id>
    </parent>
  </parents>
  <author>
    <name>ronaldoussoren</name>
    <email>ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25</email>
  </author>
  <url>http://github.com/orestis/pyobjc/commit/3eee2d5f05ed947e843b4d202a509b4bbb355c08</url>
  <id>3eee2d5f05ed947e843b4d202a509b4bbb355c08</id>
  <committed-date>2009-05-20T23:16:51-07:00</committed-date>
  <authored-date>2009-05-20T23:16:51-07:00</authored-date>
  <message>Fix the two remaining test failures in pyobjc-core. One was a genuine bug,
the other was an incorrect workaround for a Cocoa feature.


git-svn-id: http://svn.red-bean.com/pyobjc/trunk@2227 f55f28a5-9edb-0310-a011-a803cfcd5d25</message>
  <tree>525624561ac294a46109a2360b7d9685758895b9</tree>
  <committer>
    <name>ronaldoussoren</name>
    <email>ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25</email>
  </committer>
</commit>
