[Twisted-Python] t.p.rebuild

Jp Calderone exarkun at meson.dyndns.org
Thu Dec 12 02:57:03 EST 2002

  twisted.python.rebuild.rebuild() currently breaks in some bizarre
circumstances (which I still cannot really say I understand completely),
however, the below fixes it.  

  The drawbacks: greater up-front costs for rebuilding (whereas the old
behavior spread the costs out over time); doesn't work with Python 2.1
(oops); imho is less desirable, for depending on gc.get_referrers().

  Advantages: -12 lines, +1 line; it works; it unifies one old/new style
class conditional.

  I'm not sure what my point is, except, here's the fix.  If it isn't
appropriate for it to go in for another few months (or however long we go
before deciding 2.1 support is no longer important) I probably don't mind,
I'll just use a locally modified version.


RCS file: /cvs/Twisted/twisted/python/rebuild.py,v
retrieving revision 1.14
diff -u -r1.14 rebuild.py
--- rebuild.py  20 Sep 2002 20:29:41 -0000      1.14
+++ rebuild.py  12 Dec 2002 07:36:34 -0000
@@ -193,18 +193,19 @@
     if doLog:
         log.msg('  (cleaning %s): ' % str(module.__name__))
-    for clazz in classes:
-        if getattr(module, clazz.__name__) is clazz:
-            log.msg("WARNING: class %s not replaced by reload!" % reflect.qual(clazz))
-        else:
-            if doLog:
-                log.logfile.write("x")
-                log.logfile.flush()
-            clazz.__bases__ = ()
-            clazz.__dict__.clear()
-            clazz.__getattr__ = __getattr__
-            clazz.__module__ = module.__name__
-    for nclass in newclasses:
+    for nclass in classes + newclasses:
         ga = getattr(module, nclass.__name__)
         if ga is nclass:
             log.msg("WARNING: new-class %s not replaced by reload!" % reflect.qual(nclass))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20021212/e7d972e4/attachment.pgp 

More information about the Twisted-Python mailing list