[Zodb-checkins] CVS: Zope3/lib/python/ZODB - ConflictResolution.py:1.7.30.4

Jeremy Hylton jeremy@zope.com
Wed, 20 Mar 2002 00:55:19 -0500


Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv6730

Modified Files:
      Tag: Zope-3x-branch
	ConflictResolution.py 
Log Message:
Possible fix for __new__() bugs seen in nightly test run.

I never saw the errors in my local checkout, so I'm not certain that
this change fixes the problem.  The tests run successfully on my
machine before and after.  OTOH, I think this is the pattern used
everywhere else in ZODB to re-create an instance without call
__init__().



=== Zope3/lib/python/ZODB/ConflictResolution.py 1.7.30.3 => 1.7.30.4 ===
 from ZODB.POSException import ConflictError
 
-__new__=object.__new__
-
 bad_classes={}
 def bad_class(class_tuple):
     if bad_classes.has_key(class_tuple) or class_tuple[0][0] == '*':
@@ -77,7 +75,6 @@
 
 def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
                          committedData=''):
-    #class_tuple, old, committed, newstate = ('',''), 0, 0, 0
     try:
         file=StringIO(newpickle)
         unpickler=Unpickler(file)
@@ -85,23 +82,16 @@
         unpickler.persistent_load=prfactory
         class_tuple=unpickler.load()[0]
         if bad_class(class_tuple):
-            #sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
             return 0
 
-        newstate=unpickler.load()
-        klass=_classFactory(class_tuple[0], class_tuple[1])
-        
-        #??? inst=klass.__basicnew__()
-        # CXX This isn't quite right, but I'm not sure what is.
-        # The contacts are a bit unclear.
-        inst=__new__(klass)
+        newstate = unpickler.load()
+        klass = _classFactory(class_tuple[0], class_tuple[1])
+        inst = klass.__new__(klass)
 
         try:
-            resolve=inst._p_resolveConflict
+            resolve = inst._p_resolveConflict
         except AttributeError:
             bad_classes[class_tuple]=1
-            #traceback.print_exc()
-            #sys.stderr.write(' b%s ' % class_tuple[1]); sys.stderr.flush()
             return 0
 
         old=state(self, oid, oldSerial, prfactory)
@@ -114,7 +104,6 @@
         pickler.persistent_id=persistent_id
         pickler.dump(class_tuple)
         pickler.dump(resolved)
-        #sys.stderr.write(' r%s ' % class_tuple[1]); sys.stderr.flush()
         return file.getvalue(1)
     except ConflictError:
         return 0