diff options
author | Marien Zwart <marienz@gentoo.org> | 2006-09-20 21:46:00 +0000 |
---|---|---|
committer | Marien Zwart <marienz@gentoo.org> | 2006-09-20 21:46:00 +0000 |
commit | 40894830bb6d50764ceae9d087817f77c6949e95 (patch) | |
tree | d8f96df5b733c6a4871e65b77a2c680e069b0d49 /dev-python/twisted | |
parent | Disabled tests wrt bug #147897 (diff) | |
download | historical-40894830bb6d50764ceae9d087817f77c6949e95.tar.gz historical-40894830bb6d50764ceae9d087817f77c6949e95.tar.bz2 historical-40894830bb6d50764ceae9d087817f77c6949e95.zip |
Add a couple of patches from upstream to work with python 2.5. Does not quite pass its tests, that needs a fix in zopeinterface.
Package-Manager: portage-2.1.2_pre1
Diffstat (limited to 'dev-python/twisted')
-rw-r--r-- | dev-python/twisted/ChangeLog | 13 | ||||
-rw-r--r-- | dev-python/twisted/Manifest | 45 | ||||
-rw-r--r-- | dev-python/twisted/files/digest-twisted-2.4.0-r1 | 3 | ||||
-rw-r--r-- | dev-python/twisted/files/twisted-2.4.0-python-2.5-compat.patch | 463 | ||||
-rw-r--r-- | dev-python/twisted/files/twisted-2.4.0-remove-newjelly.patch | 329 | ||||
-rw-r--r-- | dev-python/twisted/files/twisted-2.4.0-trial-attempted-fix.patch | 22 | ||||
-rw-r--r-- | dev-python/twisted/files/twisted-2.4.0-trial-python-2.5-compat.patch | 49 | ||||
-rw-r--r-- | dev-python/twisted/files/twisted-2.4.0-unjellyable.patch | 110 | ||||
-rw-r--r-- | dev-python/twisted/twisted-2.4.0-r1.ebuild | 123 |
9 files changed, 1152 insertions, 5 deletions
diff --git a/dev-python/twisted/ChangeLog b/dev-python/twisted/ChangeLog index 2a6bb3bb4654..f984b9267f80 100644 --- a/dev-python/twisted/ChangeLog +++ b/dev-python/twisted/ChangeLog @@ -1,6 +1,17 @@ # ChangeLog for dev-python/twisted # Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/twisted/ChangeLog,v 1.80 2006/07/16 10:34:49 dertobi123 Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/twisted/ChangeLog,v 1.81 2006/09/20 21:46:00 marienz Exp $ + +*twisted-2.4.0-r1 (20 Sep 2006) + + 20 Sep 2006; Marien Zwart <marienz@gentoo.org> + +files/twisted-2.4.0-python-2.5-compat.patch, + +files/twisted-2.4.0-remove-newjelly.patch, + +files/twisted-2.4.0-trial-attempted-fix.patch, + +files/twisted-2.4.0-trial-python-2.5-compat.patch, + +files/twisted-2.4.0-unjellyable.patch, +twisted-2.4.0-r1.ebuild: + Add a couple of patches from upstream to work with python 2.5. Does not + quite pass its tests, that needs a fix in zopeinterface. 16 Jul 2006; Tobias Scherbaum <dertobi123@gentoo.org> twisted-2.4.0.ebuild: diff --git a/dev-python/twisted/Manifest b/dev-python/twisted/Manifest index 8d40d44f6d21..478b57c3ac3e 100644 --- a/dev-python/twisted/Manifest +++ b/dev-python/twisted/Manifest @@ -1,3 +1,6 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + AUX twistd.conf 277 RMD160 c959b879d6f7358b647c71c3b514a4a6c8a49eef SHA1 661269a3ce6ed02f03d4fce07757e77420fd44c4 SHA256 aa2ffa5b128973bc0c58a1251b8bbb56f6f890728bc902805ea2db7606416119 MD5 7ec438488427334851e2eb977e4d8073 files/twistd.conf 277 RMD160 c959b879d6f7358b647c71c3b514a4a6c8a49eef files/twistd.conf 277 @@ -26,6 +29,26 @@ AUX twisted-2.1.0-zsh-head.patch 592 RMD160 1fc8e7f8de64055e3801b442b4f666aef567 MD5 1dea79601dae42090b4d8f34ecfc62a7 files/twisted-2.1.0-zsh-head.patch 592 RMD160 1fc8e7f8de64055e3801b442b4f666aef567ac71 files/twisted-2.1.0-zsh-head.patch 592 SHA256 c9b8a994685159f21a3b0512eed1144876453db09f8d6843529dc0ef8d886029 files/twisted-2.1.0-zsh-head.patch 592 +AUX twisted-2.4.0-python-2.5-compat.patch 16764 RMD160 1422984dd5f1503b27780c34620313b5690585b6 SHA1 9b3c244a6581245b80295be8e55950c249b2d5e2 SHA256 3c771296865c4f68d91a28074706e75a56dcf64f675aefda691652a457474c8f +MD5 170dd5da0c675366b359ebcfda3d1ec4 files/twisted-2.4.0-python-2.5-compat.patch 16764 +RMD160 1422984dd5f1503b27780c34620313b5690585b6 files/twisted-2.4.0-python-2.5-compat.patch 16764 +SHA256 3c771296865c4f68d91a28074706e75a56dcf64f675aefda691652a457474c8f files/twisted-2.4.0-python-2.5-compat.patch 16764 +AUX twisted-2.4.0-remove-newjelly.patch 9386 RMD160 805130cd16f66a2991f413e5523723068c8a9f22 SHA1 6d7b225a15ee57da80c3655a951382932659301f SHA256 3b3220af4a6d5199d320a5772338bec0e6fd81d49597eba08ec407b77bba0687 +MD5 3e43b069cd3106382dbe0765a9aeb768 files/twisted-2.4.0-remove-newjelly.patch 9386 +RMD160 805130cd16f66a2991f413e5523723068c8a9f22 files/twisted-2.4.0-remove-newjelly.patch 9386 +SHA256 3b3220af4a6d5199d320a5772338bec0e6fd81d49597eba08ec407b77bba0687 files/twisted-2.4.0-remove-newjelly.patch 9386 +AUX twisted-2.4.0-trial-attempted-fix.patch 821 RMD160 8ad6d48f2911292f58f1e75c1cbe14a45a60a70c SHA1 37740479f797dc51441896daa0e1c0271d6cc4a1 SHA256 5243eb50d3a8edd4be02ce8688da55a048ceeba96549ae34e3948ed74f908d39 +MD5 843ae7acb941b6699b0a3be386b6f157 files/twisted-2.4.0-trial-attempted-fix.patch 821 +RMD160 8ad6d48f2911292f58f1e75c1cbe14a45a60a70c files/twisted-2.4.0-trial-attempted-fix.patch 821 +SHA256 5243eb50d3a8edd4be02ce8688da55a048ceeba96549ae34e3948ed74f908d39 files/twisted-2.4.0-trial-attempted-fix.patch 821 +AUX twisted-2.4.0-trial-python-2.5-compat.patch 1664 RMD160 e21834d9c39a8fed3f28e49674bcc985e79871e2 SHA1 4b1c0b76cd1a6cab214b437a8c42b40ced1af74f SHA256 d5e02028d7a4d2888ea5f95e754c8cd08ecc41eaaeb35e73a8885c41af5ee8d5 +MD5 da67af00880597aa23e899620f72b5a4 files/twisted-2.4.0-trial-python-2.5-compat.patch 1664 +RMD160 e21834d9c39a8fed3f28e49674bcc985e79871e2 files/twisted-2.4.0-trial-python-2.5-compat.patch 1664 +SHA256 d5e02028d7a4d2888ea5f95e754c8cd08ecc41eaaeb35e73a8885c41af5ee8d5 files/twisted-2.4.0-trial-python-2.5-compat.patch 1664 +AUX twisted-2.4.0-unjellyable.patch 3404 RMD160 31ac45ff0e7ef4687c236439d7d617b42d71f0d9 SHA1 9653d6762e61bbf4dd52772f7a1d4222766e80ed SHA256 bfeb1dc3ab4a4b4ce46c134099c60a2be85b47f48095ec20853a0ed70bb2a04b +MD5 e4b9f71282b5de7423e0059dd5d0e626 files/twisted-2.4.0-unjellyable.patch 3404 +RMD160 31ac45ff0e7ef4687c236439d7d617b42d71f0d9 files/twisted-2.4.0-unjellyable.patch 3404 +SHA256 bfeb1dc3ab4a4b4ce46c134099c60a2be85b47f48095ec20853a0ed70bb2a04b files/twisted-2.4.0-unjellyable.patch 3404 DIST Twisted-2.0.1.tar.bz2 1061899 RMD160 e67033a2a936d2252c7e039bfc41d4f74012a6ef SHA256 78d0908db2933de8f78db564ec5f035c0a171e19d8f6a375d4164f8422c29c09 DIST Twisted-2.1.0.tar.bz2 1078044 RMD160 d4048661396c25392b048ed2b74200757b1e63c0 SHA256 a34e6fb06797c3de1e2c4037b373e633e7265e336b84a61d4f7ea8a7f0f07579 DIST Twisted-2.2.0.tar.bz2 1285316 RMD160 c11353da93878721c8549a0594363b9d8ee38e12 SHA1 fcce114624dfde91bc1c2358f905d3170e72ad6a SHA256 537ec738c23ced2ec4a9b7f7124c2cd9bded1308331442ced0f3de7cd7562387 @@ -52,14 +75,18 @@ EBUILD twisted-2.2.0.ebuild 3190 RMD160 3769541ef6c2e45e4a408c9fd0737606ccb1dd27 MD5 892475710d346ea0897f4341d4f96b94 twisted-2.2.0.ebuild 3190 RMD160 3769541ef6c2e45e4a408c9fd0737606ccb1dd27 twisted-2.2.0.ebuild 3190 SHA256 8e3bf6445430a6b046350ef379971f69d7c6b0ad554fb645c6695e57a4d65bf3 twisted-2.2.0.ebuild 3190 +EBUILD twisted-2.4.0-r1.ebuild 3734 RMD160 bd3a5fc2e05fe65df23a923071889e85154b7a74 SHA1 1a00b5f5d2a8e492febc7539f437ec303527fdea SHA256 f5b5758fdd20923f1e2867e1c69dcea697d9062e3da486d8dcd415bc573ba053 +MD5 62a33533c4877af90d31bcdf7906685b twisted-2.4.0-r1.ebuild 3734 +RMD160 bd3a5fc2e05fe65df23a923071889e85154b7a74 twisted-2.4.0-r1.ebuild 3734 +SHA256 f5b5758fdd20923f1e2867e1c69dcea697d9062e3da486d8dcd415bc573ba053 twisted-2.4.0-r1.ebuild 3734 EBUILD twisted-2.4.0.ebuild 3312 RMD160 23201e6f846496a58662df99e0a06cea37e11a0d SHA1 4f7144f3571cb20a0e4e525e51506183ce15c2a8 SHA256 6c931c7bbb036d8b5cd35c3941d0b401aa1dc41b2217c83b408d52f99482bafb MD5 63daf6ed532eebe0a7a4966cf280af2c twisted-2.4.0.ebuild 3312 RMD160 23201e6f846496a58662df99e0a06cea37e11a0d twisted-2.4.0.ebuild 3312 SHA256 6c931c7bbb036d8b5cd35c3941d0b401aa1dc41b2217c83b408d52f99482bafb twisted-2.4.0.ebuild 3312 -MISC ChangeLog 13930 RMD160 fd8d4517de536555df2809418dd3627e50172978 SHA1 5bcd2adaa17981da59c44a2702de2a01eeb5b570 SHA256 388aad594004c900a85f3506e2508305111ab6f3068f8d06642c707526e98417 -MD5 9c3f28a71fbe2fc5dbd7aad3c3fc3b8e ChangeLog 13930 -RMD160 fd8d4517de536555df2809418dd3627e50172978 ChangeLog 13930 -SHA256 388aad594004c900a85f3506e2508305111ab6f3068f8d06642c707526e98417 ChangeLog 13930 +MISC ChangeLog 14409 RMD160 17cb1f39c75d75b9dfdf85807c795169f5f5b449 SHA1 955973bbbb255c99263fd8bab8b317322c34d503 SHA256 fe011bee641f7268d1a6b4276049898c7621f13711263b3a312818aa27ecdb6f +MD5 b8e562ad50d3640bb30ab4cd4909d459 ChangeLog 14409 +RMD160 17cb1f39c75d75b9dfdf85807c795169f5f5b449 ChangeLog 14409 +SHA256 fe011bee641f7268d1a6b4276049898c7621f13711263b3a312818aa27ecdb6f ChangeLog 14409 MISC metadata.xml 492 RMD160 3e1f73c8b2f6645c1fb4d5b67c9c2491c9e73e2c SHA1 02360c6042bbdb343476a8332b7920ce6e6fda35 SHA256 cf5b2de8fe20a286ef9eeb5d4069eb462b240af70fdb869f26ba4b275552f01f MD5 f21532a778f6bd2aa2879327084e8aa5 metadata.xml 492 RMD160 3e1f73c8b2f6645c1fb4d5b67c9c2491c9e73e2c metadata.xml 492 @@ -82,3 +109,13 @@ SHA256 96a113abfd84248e540db84f191f4cb900770f3d53c9d01a725f82b85d83a401 files/di MD5 644568c96d8f56d8e3fb6b24be628214 files/digest-twisted-2.4.0 259 RMD160 9fa12863b5188c5f7bca79fe65af5ecc2a36eca7 files/digest-twisted-2.4.0 259 SHA256 0c8c3cb6af6123bb8bd8e83c6696eb5998a8b1742e33bbab28aa051110a72123 files/digest-twisted-2.4.0 259 +MD5 644568c96d8f56d8e3fb6b24be628214 files/digest-twisted-2.4.0-r1 259 +RMD160 9fa12863b5188c5f7bca79fe65af5ecc2a36eca7 files/digest-twisted-2.4.0-r1 259 +SHA256 0c8c3cb6af6123bb8bd8e83c6696eb5998a8b1742e33bbab28aa051110a72123 files/digest-twisted-2.4.0-r1 259 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.5 (GNU/Linux) + +iD8DBQFFEbaeUElL7eJpfEQRAkjjAJ42GxnQ1Uwmi7uVdnmA52X2EJuNAwCgjaHJ +ZD0rzLiawDAetisdLDE1k4E= +=PMVt +-----END PGP SIGNATURE----- diff --git a/dev-python/twisted/files/digest-twisted-2.4.0-r1 b/dev-python/twisted/files/digest-twisted-2.4.0-r1 new file mode 100644 index 000000000000..8ffcaca36b46 --- /dev/null +++ b/dev-python/twisted/files/digest-twisted-2.4.0-r1 @@ -0,0 +1,3 @@ +MD5 042a57f65fe919a9234047d7ce8c43f1 TwistedCore-2.4.0.tar.bz2 1213389 +RMD160 2ee341412675d2ef4582ae595adf49ce254eb88b TwistedCore-2.4.0.tar.bz2 1213389 +SHA256 114f8ecf2625916f6cd65099d4321243f2b56704dddb0c96b30f6b991db484d2 TwistedCore-2.4.0.tar.bz2 1213389 diff --git a/dev-python/twisted/files/twisted-2.4.0-python-2.5-compat.patch b/dev-python/twisted/files/twisted-2.4.0-python-2.5-compat.patch new file mode 100644 index 000000000000..2721a7de3356 --- /dev/null +++ b/dev-python/twisted/files/twisted-2.4.0-python-2.5-compat.patch @@ -0,0 +1,463 @@ +Index: twisted/python/usage.py +=================================================================== +--- twisted/python/usage.py (revision 17447) ++++ twisted/python/usage.py (revision 17448) +@@ -129,9 +129,12 @@ + self.__dispatch.update(dispatch) + + def __hash__(self): +- # This is required because dicts aren't hashable by default +- # (They define __cmp__ but no __hash__) +- return id(self) ++ """ ++ Define a custom hash function so that Options instances can be used ++ as dictionary keys. This is an internal feature used to implement ++ the parser. Do not rely on it in application code. ++ """ ++ return int(id(self) % sys.maxint) + + def opt_help(self): + """Display this help and exit.""" +Index: twisted/python/failure.py +=================================================================== +--- twisted/python/failure.py (revision 17447) ++++ twisted/python/failure.py (revision 17448) +@@ -14,6 +14,7 @@ + import sys + import linecache + import string ++import inspect + from cStringIO import StringIO + import types + +@@ -201,7 +202,7 @@ + globalz.items(), + ]) + tb = tb.tb_next +- if isinstance(self.type, types.ClassType): ++ if inspect.isclass(self.type) and issubclass(self.type, Exception): + parentCs = reflect.allYourBase(self.type) + self.parents = map(reflect.qual, parentCs) + self.parents.append(reflect.qual(self.type)) +@@ -244,7 +245,7 @@ + """ + for error in errorTypes: + err = error +- if isinstance(error, types.ClassType) and issubclass(error, Exception): ++ if inspect.isclass(error) and issubclass(error, Exception): + err = reflect.qual(error) + if err in self.parents: + return error +@@ -349,7 +350,7 @@ + + # postamble, if any + if not detail == 'brief': +- w("%s: %s\n" % (reflect.safe_str(self.type), ++ w("%s: %s\n" % (reflect.qual(self.type), + reflect.safe_str(self.value))) + # chaining + if isinstance(self.value, Failure): +Index: twisted/python/zipstream.py +=================================================================== +--- twisted/python/zipstream.py (revision 17447) ++++ twisted/python/zipstream.py (revision 17448) +@@ -10,6 +10,7 @@ + import os.path + import binascii + import zlib ++import struct + + class ChunkingZipFile(zipfile.ZipFile): + """A ZipFile object which, with readfile(), also gives you access +@@ -23,7 +24,24 @@ + raise RuntimeError, \ + "Attempt to read ZIP archive that was already closed" + zinfo = self.getinfo(name) +- self.fp.seek(zinfo.file_offset, 0) ++ ++ self.fp.seek(zinfo.header_offset, 0) ++ ++ # Skip the file header: ++ fheader = self.fp.read(30) ++ if fheader[0:4] != zipfile.stringFileHeader: ++ raise zipfile.BadZipfile, "Bad magic number for file header" ++ ++ fheader = struct.unpack(zipfile.structFileHeader, fheader) ++ fname = self.fp.read(fheader[zipfile._FH_FILENAME_LENGTH]) ++ if fheader[zipfile._FH_EXTRA_FIELD_LENGTH]: ++ self.fp.read(fheader[zipfile._FH_EXTRA_FIELD_LENGTH]) ++ ++ if fname != zinfo.orig_filename: ++ raise zipfile.BadZipfile, \ ++ 'File name in directory "%s" and header "%s" differ.' % ( ++ zinfo.orig_filename, fname) ++ + if zinfo.compress_type == zipfile.ZIP_STORED: + return ZipFileEntry(self.fp, zinfo.compress_size) + elif zinfo.compress_type == zipfile.ZIP_DEFLATED: +Index: twisted/python/log.py +=================================================================== +--- twisted/python/log.py (revision 17447) ++++ twisted/python/log.py (revision 17448) +@@ -74,7 +74,7 @@ + + def showwarning(message, category, filename, lineno, file=None): + if file is None: +- msg(warning=message, category=category, filename=filename, lineno=lineno, ++ msg(warning=message, category=reflect.qual(category), filename=filename, lineno=lineno, + format="%(filename)s:%(lineno)s: %(category)s: %(warning)s") + else: + _oldshowwarning(message, category, filename, lineno, file) +Index: twisted/test/test_failure.py +=================================================================== +--- twisted/test/test_failure.py (revision 17447) ++++ twisted/test/test_failure.py (revision 17448) +@@ -12,7 +12,7 @@ + import StringIO + import traceback + +-from twisted.trial import unittest ++from twisted.trial import unittest, util + + + from twisted.python import failure +@@ -105,6 +105,8 @@ + self.assertEquals(sys.exc_info()[0], "bugger off") + else: + raise AssertionError("Should have raised") ++ testStringExceptions.suppress = [ ++ util.suppress(message='raising a string exception is deprecated')] + + def testBrokenStr(self): + x = BrokenStr() +Index: twisted/test/test_pbfailure.py +=================================================================== +--- twisted/test/test_pbfailure.py (revision 17447) ++++ twisted/test/test_pbfailure.py (revision 17448) +@@ -4,23 +4,37 @@ + + from twisted.trial import unittest + +-from twisted.spread import pb, flavors, jelly ++from twisted.spread import pb, flavors + from twisted.internet import reactor, defer + from twisted.python import log, failure + + ## + # test exceptions + ## +-class PoopError(Exception): pass +-class FailError(Exception): pass +-class DieError(Exception): pass +-class TimeoutError(Exception): pass ++class PoopError(Exception): ++ pass + + ++class FailError(Exception): ++ pass ++ ++ ++class DieError(Exception): ++ pass ++ ++ ++class TimeoutError(Exception): ++ pass ++ ++ + #class JellyError(flavors.Jellyable, pb.Error): pass +-class JellyError(flavors.Jellyable, pb.Error, pb.RemoteCopy): pass +-class SecurityError(pb.Error, pb.RemoteCopy): pass ++class JellyError(flavors.Jellyable, pb.Error, pb.RemoteCopy): ++ pass + ++ ++class SecurityError(pb.Error, pb.RemoteCopy): ++ pass ++ + pb.setUnjellyableForClass(JellyError, JellyError) + pb.setUnjellyableForClass(SecurityError, SecurityError) + pb.globalSecurity.allowInstancesOf(SecurityError) +@@ -98,13 +112,94 @@ + class PBFailureTest(PBConnTestCase): + compare = unittest.TestCase.assertEquals + +- def testPBFailures(self): +- d = self.clientFactory.getRootObject() +- d.addCallback(self.connected) +- d.addCallback(self.cleanupLoggedErrors) +- return d + ++ def _addFailingCallbacks(self, remoteCall, expectedResult, eb): ++ remoteCall.addCallbacks(self.success, eb, ++ callbackArgs=(expectedResult,)) ++ return remoteCall + ++ ++ def _testImpl(self, method, expected, eb, exc=None): ++ rootDeferred = self.clientFactory.getRootObject() ++ def gotRootObj(obj): ++ failureDeferred = self._addFailingCallbacks(obj.callRemote(method), expected, eb) ++ if exc is not None: ++ def gotFailure(err): ++ self.assertEquals(len(log.flushErrors(exc)), 1) ++ return err ++ failureDeferred.addBoth(gotFailure) ++ return failureDeferred ++ rootDeferred.addCallback(gotRootObj) ++ return rootDeferred ++ ++ ++ def testPoopError(self): ++ """ ++ Test that a Deferred returned by a remote method which already has a ++ Failure correctly has that error passed back to the calling side. ++ """ ++ return self._testImpl('poop', 42, self.failurePoop, PoopError) ++ ++ ++ def testFailureFailure(self): ++ """ ++ Test that a remote method which synchronously raises an exception ++ has that exception passed back to the calling side. ++ """ ++ return self._testImpl('fail', 420, self.failureFail, FailError) ++ ++ ++ def testDieFailure(self): ++ """ ++ The same as testFailureFailure (it is not clear to me why this ++ exists, but I am not deleting it as part of this refactoring. ++ -exarkun). ++ """ ++ return self._testImpl('die', 4200, self.failureDie, DieError) ++ ++ ++ def testNoSuchFailure(self): ++ """ ++ Test that attempting to call a method which is not defined correctly ++ results in an AttributeError on the calling side. ++ """ ++ return self._testImpl('nosuch', 42000, self.failureNoSuch, AttributeError) ++ ++ ++ def testJellyFailure(self): ++ """ ++ Test that an exception which is a subclass of L{pb.Error} has more ++ information passed across the network to the calling side. ++ """ ++ return self._testImpl('jelly', 43, self.failureJelly) ++ ++ ++ def testSecurityFailure(self): ++ """ ++ Test that even if an exception is not explicitly jellyable (by being ++ a L{pb.Jellyable} subclass), as long as it is an L{pb.Error} ++ subclass it receives the same special treatment. ++ """ ++ return self._testImpl('security', 430, self.failureSecurity) ++ ++ ++ def testDeferredJellyFailure(self): ++ """ ++ Test that a Deferred which fails with a L{pb.Error} is treated in ++ the same way as a synchronously raised L{pb.Error}. ++ """ ++ return self._testImpl('deferredJelly', 4300, self.failureDeferredJelly, JellyError) ++ ++ ++ def testDeferredSecurity(self): ++ """ ++ Test that a Deferred which fails with a L{pb.Error} which is not ++ also a L{pb.Jellyable} is treated in the same way as a synchronously ++ raised exception of the same type. ++ """ ++ return self._testImpl('deferredSecurity', 43000, self.failureDeferredSecurity, SecurityError) ++ ++ + def testCopiedFailureLogging(self): + d = self.clientFactory.getRootObject() + +@@ -120,12 +215,6 @@ + + return d + +- +- def addFailingCallbacks(self, remoteCall, expectedResult, eb): +- remoteCall.addCallbacks(self.success, eb, +- callbackArgs=(expectedResult,)) +- return remoteCall +- + ## + # callbacks + ## +@@ -136,19 +225,6 @@ + self.assertEquals(len(errors), 6) + return ignored + +- def connected(self, persp): +- methods = (('poop', 42, self.failurePoop), +- ('fail', 420, self.failureFail), +- ('die', 4200, self.failureDie), +- ('nosuch', 42000, self.failureNoSuch), +- ('jelly', 43, self.failureJelly), +- ('security', 430, self.failureSecurity), +- ('deferredJelly', 4300, self.failureDeferredJelly), +- ('deferredSecurity', 43000, self.failureDeferredSecurity)) +- return defer.gatherResults([ +- self.addFailingCallbacks(persp.callRemote(meth), result, eb) +- for (meth, result, eb) in methods]) +- + def success(self, result, expectedResult): + self.assertEquals(result, expectedResult) + return result +Index: twisted/test/test_stdio.py +=================================================================== +--- twisted/test/test_stdio.py (revision 17447) ++++ twisted/test/test_stdio.py (revision 17448) +@@ -42,7 +42,7 @@ + return reactor.spawnProcess( + proto, + sys.executable, +- ["python", filepath.FilePath(__file__).sibling(sibling).path, reactor.__class__.__module__] + list(args), ++ [sys.executable, filepath.FilePath(__file__).sibling(sibling).path, reactor.__class__.__module__] + list(args), + env=subenv, + ) + +Index: twisted/test/test_jelly.py +=================================================================== +--- twisted/test/test_jelly.py (revision 17447) ++++ twisted/test/test_jelly.py (revision 17448) +@@ -62,7 +62,7 @@ + def __init__(self, x, y): + self.x = x + self.y = y +- ++ + def isTheSameAs(self, other): + return self.__dict__ == other.__dict__ + +@@ -95,7 +95,6 @@ + m = jelly.unjelly(c) + self.failUnless(isinstance(m, NewStyle)) + self.assertIdentical(m.n2, m.n3) +- testNewStyle.todo = "jelly does not support new-style classes yet" + + + def testDateTime(self): +Index: twisted/spread/flavors.py +=================================================================== +--- twisted/spread/flavors.py (revision 17447) ++++ twisted/spread/flavors.py (revision 17448) +@@ -27,7 +27,7 @@ + # mechanisms (like XMLRPC) + + # system imports +-import types ++import sys + from zope.interface import implements + + # twisted imports +@@ -480,7 +480,7 @@ + def __hash__(self): + """Hash me. + """ +- return id(self.__dict__) ++ return int(id(self.__dict__) % sys.maxint) + + broker = None + luid = None +Index: twisted/spread/jelly.py +=================================================================== +--- twisted/spread/jelly.py (revision 17447) ++++ twisted/spread/jelly.py (revision 17448) +@@ -58,7 +58,6 @@ + # System Imports + import string + import pickle +-import sys + import types + from types import StringType + try: +@@ -68,7 +67,6 @@ + from types import IntType + from types import TupleType + from types import ListType +-from types import DictType + from types import LongType + from types import FloatType + from types import FunctionType +@@ -88,9 +86,9 @@ + from zope.interface import implements + + # Twisted Imports +-from twisted.python.reflect import namedObject, namedModule, qual ++from twisted.python.reflect import namedObject, qual + from twisted.persisted.crefutil import NotKnown, _Tuple, _InstanceMethod, _DictKeyAndValue, _Dereference +-from twisted.python import runtime, components ++from twisted.python import runtime + + from twisted.spread.interfaces import IJellyable, IUnjellyable + +@@ -416,8 +414,7 @@ + return preRef + return obj.jellyFor(self) + objType = type(obj) +- if self.taster.isTypeAllowed( +- string.replace(objType.__name__, ' ', '_')): ++ if self.taster.isTypeAllowed(qual(objType)): + # "Immutable" Types + if ((objType is StringType) or + (objType is IntType) or +@@ -455,7 +452,7 @@ + return ['date', '%s %s %s' % (obj.year, obj.month, obj.day)] + elif objType is datetime.timedelta: + return ['timedelta', '%s %s %s' % (obj.days, obj.seconds, obj.microseconds)] +- elif objType is ClassType or issubclass(type, objType): ++ elif objType is ClassType or issubclass(objType, type): + return ['class', qual(obj)] + else: + preRef = self._checkMutable(obj) +@@ -475,7 +472,7 @@ + sxp.append(dictionary_atom) + for key, val in obj.items(): + sxp.append([self.jelly(key), self.jelly(val)]) +- elif objType is InstanceType: ++ else: + className = qual(obj.__class__) + persistent = None + if self.persistentStore: +@@ -494,11 +491,9 @@ + self.unpersistable( + "instance of class %s deemed insecure" % + qual(obj.__class__), sxp) +- else: +- raise NotImplementedError("Don't know the type: %s" % objType) + return self.preserve(obj, sxp) + else: +- if objType is types.InstanceType: ++ if objType is InstanceType: + raise InsecureJelly("Class not allowed for instance: %s %s" % + (obj.__class__, obj)) + raise InsecureJelly("Type not allowed for object: %s %s" % +@@ -682,7 +677,7 @@ + raise InsecureJelly("module %s not allowed" % modName) + klaus = namedObject(rest[0]) + if type(klaus) is not types.ClassType: +- raise InsecureJelly("class %s unjellied to something that isn't a class: %s" % (repr(name), repr(klaus))) ++ raise InsecureJelly("class %s unjellied to something that isn't a class: %s" % (repr(rest[0]), repr(klaus))) + if not self.taster.isClassAllowed(klaus): + raise InsecureJelly("class not allowed: %s" % qual(klaus)) + return klaus +@@ -833,7 +828,9 @@ + """SecurityOptions.allowTypes(typeString): Allow a particular type, by its name. + """ + for typ in types: +- self.allowedTypes[string.replace(typ, ' ', '_')]=1 ++ if not isinstance(typ, str): ++ typ = qual(typ) ++ self.allowedTypes[typ] = 1 + + def allowInstancesOf(self, *classes): + """SecurityOptions.allowInstances(klass, klass, ...): allow instances diff --git a/dev-python/twisted/files/twisted-2.4.0-remove-newjelly.patch b/dev-python/twisted/files/twisted-2.4.0-remove-newjelly.patch new file mode 100644 index 000000000000..3490006f17cb --- /dev/null +++ b/dev-python/twisted/files/twisted-2.4.0-remove-newjelly.patch @@ -0,0 +1,329 @@ +Index: twisted/test/test_jelly.py +=================================================================== +--- twisted/test/test_jelly.py (revision 17351) ++++ twisted/test/test_jelly.py (revision 17352) +@@ -6,10 +6,12 @@ + """Test cases for 'jelly' object serialization. + """ + +-from twisted.spread import jelly ++import datetime, types + +-from twisted.test import test_newjelly ++from twisted.spread import jelly, pb + ++from twisted.trial import unittest ++ + class TestNode(object, jelly.Jellyable): + """An object to test jellyfying of new style class isntances. + """ +@@ -24,12 +26,224 @@ + self.children = [] + + +-class JellyTestCase(test_newjelly.JellyTestCase): +- jc = jelly +- if test_newjelly.haveDatetime: +- def testDateTime(self): +- test_newjelly.JellyTestCase.testDateTime(self) ++class A: ++ """ ++ dummy class ++ """ ++ def amethod(self): ++ pass + ++def afunc(self): ++ pass ++ ++class B: ++ """ ++ dummy class ++ """ ++ def bmethod(self): ++ pass ++ ++ ++class C: ++ """ ++ dummy class ++ """ ++ def cmethod(self): ++ pass ++ ++ ++class D(object): ++ """ ++ newstyle class ++ """ ++ ++ ++class SimpleJellyTest: ++ def __init__(self, x, y): ++ self.x = x ++ self.y = y ++ ++ def isTheSameAs(self, other): ++ return self.__dict__ == other.__dict__ ++ ++ ++class NewStyle(object): ++ pass ++ ++ ++class JellyTestCase(unittest.TestCase): ++ """ ++ testcases for `jelly' module serialization. ++ """ ++ ++ def testMethodSelfIdentity(self): ++ a = A() ++ b = B() ++ a.bmethod = b.bmethod ++ b.a = a ++ im_ = jelly.unjelly(jelly.jelly(b)).a.bmethod ++ self.assertEquals(im_.im_class, im_.im_self.__class__) ++ ++ ++ def testNewStyle(self): ++ n = NewStyle() ++ n.x = 1 ++ n2 = NewStyle() ++ n.n2 = n2 ++ n.n3 = n2 ++ c = jelly.jelly(n) ++ m = jelly.unjelly(c) ++ self.failUnless(isinstance(m, NewStyle)) ++ self.assertIdentical(m.n2, m.n3) ++ testNewStyle.todo = "jelly does not support new-style classes yet" ++ ++ ++ def testDateTime(self): ++ dtn = datetime.datetime.now() ++ dtd = datetime.datetime.now() - dtn ++ input = [dtn, dtd] ++ c = jelly.jelly(input) ++ output = jelly.unjelly(c) ++ self.assertEquals(input, output) ++ self.assertNotIdentical(input, output) ++ ++ ++ def testSimple(self): ++ """ ++ simplest test case ++ """ ++ self.failUnless(SimpleJellyTest('a', 'b').isTheSameAs(SimpleJellyTest('a', 'b'))) ++ a = SimpleJellyTest(1, 2) ++ cereal = jelly.jelly(a) ++ b = jelly.unjelly(cereal) ++ self.failUnless(a.isTheSameAs(b)) ++ ++ ++ def testIdentity(self): ++ """ ++ test to make sure that objects retain identity properly ++ """ ++ x = [] ++ y = (x) ++ x.append(y) ++ x.append(y) ++ self.assertIdentical(x[0], x[1]) ++ self.assertIdentical(x[0][0], x) ++ s = jelly.jelly(x) ++ z = jelly.unjelly(s) ++ self.assertIdentical(z[0], z[1]) ++ self.assertIdentical(z[0][0], z) ++ ++ ++ def testUnicode(self): ++ if hasattr(types, 'UnicodeType'): ++ x = unicode('blah') ++ y = jelly.unjelly(jelly.jelly(x)) ++ self.assertEquals(x, y) ++ self.assertEquals(type(x), type(y)) ++ ++ ++ def testStressReferences(self): ++ reref = [] ++ toplevelTuple = ({'list': reref}, reref) ++ reref.append(toplevelTuple) ++ s = jelly.jelly(toplevelTuple) ++ z = jelly.unjelly(s) ++ self.assertIdentical(z[0]['list'], z[1]) ++ self.assertIdentical(z[0]['list'][0], z) ++ ++ ++ def testMoreReferences(self): ++ a = [] ++ t = (a,) ++ a.append((t,)) ++ s = jelly.jelly(t) ++ z = jelly.unjelly(s) ++ self.assertIdentical(z[0][0][0], z) ++ ++ ++ def testTypeSecurity(self): ++ """ ++ test for type-level security of serialization ++ """ ++ taster = jelly.SecurityOptions() ++ dct = jelly.jelly({}) ++ self.assertRaises(jelly.InsecureJelly, jelly.unjelly, dct, taster) ++ ++ ++ def testNewStyleClasses(self): ++ j = jelly.jelly(D) ++ uj = jelly.unjelly(D) ++ self.assertIdentical(D, uj) ++ ++ ++ def testLotsaTypes(self): ++ """ ++ test for all types currently supported in jelly ++ """ ++ a = A() ++ jelly.unjelly(jelly.jelly(a)) ++ jelly.unjelly(jelly.jelly(a.amethod)) ++ items = [afunc, [1, 2, 3], not bool(1), bool(1), 'test', 20.3, (1,2,3), None, A, unittest, {'a':1}, A.amethod] ++ for i in items: ++ self.assertEquals(i, jelly.unjelly(jelly.jelly(i))) ++ ++ ++ def testSetState(self): ++ global TupleState ++ class TupleState: ++ def __init__(self, other): ++ self.other = other ++ def __getstate__(self): ++ return (self.other,) ++ def __setstate__(self, state): ++ self.other = state[0] ++ def __hash__(self): ++ return hash(self.other) ++ a = A() ++ t1 = TupleState(a) ++ t2 = TupleState(a) ++ t3 = TupleState((t1, t2)) ++ d = {t1: t1, t2: t2, t3: t3, "t3": t3} ++ t3prime = jelly.unjelly(jelly.jelly(d))["t3"] ++ self.assertIdentical(t3prime.other[0].other, t3prime.other[1].other) ++ ++ ++ def testClassSecurity(self): ++ """ ++ test for class-level security of serialization ++ """ ++ taster = jelly.SecurityOptions() ++ taster.allowInstancesOf(A, B) ++ a = A() ++ b = B() ++ c = C() ++ # add a little complexity to the data ++ a.b = b ++ a.c = c ++ # and a backreference ++ a.x = b ++ b.c = c ++ # first, a friendly insecure serialization ++ friendly = jelly.jelly(a, taster) ++ x = jelly.unjelly(friendly, taster) ++ self.failUnless(isinstance(x.c, jelly.Unpersistable), ++ "C came back: %s" % x.c.__class__) ++ # now, a malicious one ++ mean = jelly.jelly(a) ++ try: ++ x = jelly.unjelly(mean, taster) ++ self.fail("x came back: %s" % x) ++ except jelly.InsecureJelly: ++ # OK ++ pass ++ self.assertIdentical(x.x, x.b, "Identity mismatch") ++ #test class serialization ++ friendly = jelly.jelly(A, taster) ++ x = jelly.unjelly(friendly, taster) ++ self.assertIdentical(x, A, "A came back: %s" % x) ++ ++ + def testUnjellyable(self): + """ + Test that if Unjellyable is used to deserialize a jellied object, +@@ -58,7 +272,6 @@ + pid = int(pidstr) + return perst[0][pid] + +- SimpleJellyTest = test_newjelly.SimpleJellyTest + a = SimpleJellyTest(1, 2) + b = SimpleJellyTest(3, 4) + c = SimpleJellyTest(5, 6) +@@ -67,26 +280,28 @@ + a.c = c + c.b = b + +- jel = self.jc.jelly(a, persistentStore = persistentStore) +- x = self.jc.unjelly(jel, persistentLoad = persistentLoad) ++ jel = jelly.jelly(a, persistentStore = persistentStore) ++ x = jelly.unjelly(jel, persistentLoad = persistentLoad) + + self.assertIdentical(x.b, x.c.b) + # assert len(perst) == 3, "persistentStore should only be called 3 times." + self.failUnless(perst[0], "persistentStore was not called.") + self.assertIdentical(x.b, a.b, "Persistent storage identity failure.") + ++ + def testNewStyleClasses(self): + n = TestNode() + n1 = TestNode(n) + n11 = TestNode(n1) + n2 = TestNode(n) + # Jelly it +- jel = self.jc.jelly(n) +- m = self.jc.unjelly(jel) ++ jel = jelly.jelly(n) ++ m = jelly.unjelly(jel) + # Check that it has been restored ok + TestNode.classAttr == 5 # Shouldn't override jellied values + self._check_newstyle(n,m) + ++ + def _check_newstyle(self, a, b): + self.assertEqual(a.id, b.id) + self.assertEqual(a.classAttr, 4) +@@ -95,5 +310,36 @@ + for x,y in zip(a.children, b.children): + self._check_newstyle(x,y) + +-class CircularReferenceTestCase(test_newjelly.CircularReferenceTestCase): +- jc = jelly ++ ++ ++class ClassA(pb.Copyable, pb.RemoteCopy): ++ def __init__(self): ++ self.ref = ClassB(self) ++ ++ ++ ++class ClassB(pb.Copyable, pb.RemoteCopy): ++ def __init__(self, ref): ++ self.ref = ref ++ ++ ++ ++class CircularReferenceTestCase(unittest.TestCase): ++ def testSimpleCircle(self): ++ jelly.setUnjellyableForClass(ClassA, ClassA) ++ jelly.setUnjellyableForClass(ClassB, ClassB) ++ a = jelly.unjelly(jelly.jelly(ClassA())) ++ self.failUnless(a.ref.ref is a, "Identity not preserved in circular reference") ++ ++ ++ def testCircleWithInvoker(self): ++ class dummyInvokerClass: pass ++ dummyInvoker = dummyInvokerClass() ++ dummyInvoker.serializingPerspective = None ++ a0 = ClassA() ++ jelly.setUnjellyableForClass(ClassA, ClassA) ++ jelly.setUnjellyableForClass(ClassB, ClassB) ++ j = jelly.jelly(a0, invoker=dummyInvoker) ++ a1 = jelly.unjelly(j) ++ self.failUnlessIdentical(a1.ref.ref, a1, ++ "Identity not preserved in circular reference") diff --git a/dev-python/twisted/files/twisted-2.4.0-trial-attempted-fix.patch b/dev-python/twisted/files/twisted-2.4.0-trial-attempted-fix.patch new file mode 100644 index 000000000000..ae0ea71566a6 --- /dev/null +++ b/dev-python/twisted/files/twisted-2.4.0-trial-attempted-fix.patch @@ -0,0 +1,22 @@ +Index: twisted/trial/reporter.py +=================================================================== +--- twisted/trial/reporter.py (revision 17375) ++++ twisted/trial/reporter.py (revision 17376) +@@ -71,7 +71,7 @@ + @type fail: L{failure.Failure} or L{tuple} + """ + if isinstance(fail, tuple): +- fail = failure.Failure(*fail) ++ fail = failure.Failure(fail[1], fail[0], fail[2]) + self.failures.append((test, fail)) + + def addError(self, test, error): +@@ -81,7 +81,7 @@ + @type fail: L{failure.Failure} or L{tuple} + """ + if isinstance(error, tuple): +- error = failure.Failure(*error) ++ error = failure.Failure(error[1], error[0], error[2]) + self.errors.append((test, error)) + + def addSkip(self, test, reason): diff --git a/dev-python/twisted/files/twisted-2.4.0-trial-python-2.5-compat.patch b/dev-python/twisted/files/twisted-2.4.0-trial-python-2.5-compat.patch new file mode 100644 index 000000000000..e31f3e9bb5d6 --- /dev/null +++ b/dev-python/twisted/files/twisted-2.4.0-trial-python-2.5-compat.patch @@ -0,0 +1,49 @@ +Index: twisted/trial/test/test_output.py +=================================================================== +--- twisted/trial/test/test_output.py (revision 17477) ++++ twisted/trial/test/test_output.py (revision 17478) +@@ -101,7 +101,7 @@ + self.failUnlessIn(d, '[ERROR]') + self.failUnlessIn(d, 'package.test_bad_module') + self.failIfIn(d, 'IOError') +- self.failIfIn(d, '<module') ++ self.failIfIn(d, '<module ') + return d + + def test_badimport(self): +@@ -109,7 +109,7 @@ + self.failUnlessIn(d, '[ERROR]') + self.failUnlessIn(d, 'package.test_import_module') + self.failIfIn(d, 'IOError') +- self.failIfIn(d, '<module') ++ self.failIfIn(d, '<module ') + return d + + def test_recurseImport(self): +@@ -117,7 +117,7 @@ + self.failUnlessIn(d, '[ERROR]') + self.failUnlessIn(d, 'test_bad_module') + self.failUnlessIn(d, 'test_import_module') +- self.failIfIn(d, '<module') ++ self.failIfIn(d, '<module ') + self.failIfIn(d, 'IOError') + return d + +@@ -127,7 +127,7 @@ + self.failUnlessIn(d, 'package2') + self.failUnlessIn(d, 'test_module') + self.failUnlessIn(d, "No module named frotz") +- self.failIfIn(d, '<module') ++ self.failIfIn(d, '<module ') + self.failIfIn(d, 'IOError') + return d + +@@ -135,7 +135,7 @@ + d = self.runTrial('-N', 'package2') + self.failUnlessIn(d, '[ERROR]') + self.failUnlessIn(d, "No module named frotz") +- self.failIfIn(d, '<module') ++ self.failIfIn(d, '<module ') + return d + + def test_regularRun(self): diff --git a/dev-python/twisted/files/twisted-2.4.0-unjellyable.patch b/dev-python/twisted/files/twisted-2.4.0-unjellyable.patch new file mode 100644 index 000000000000..e63ee95b53de --- /dev/null +++ b/dev-python/twisted/files/twisted-2.4.0-unjellyable.patch @@ -0,0 +1,110 @@ +Index: twisted/test/test_jelly.py +=================================================================== +--- twisted/test/test_jelly.py (revision 17255) ++++ twisted/test/test_jelly.py (revision 17256) +@@ -30,6 +30,23 @@ + def testDateTime(self): + test_newjelly.JellyTestCase.testDateTime(self) + ++ def testUnjellyable(self): ++ """ ++ Test that if Unjellyable is used to deserialize a jellied object, ++ state comes out right. ++ """ ++ class JellyableTestClass(jelly.Jellyable): ++ pass ++ jelly.setUnjellyableForClass(JellyableTestClass, jelly.Unjellyable) ++ input = JellyableTestClass() ++ input.attribute = 'value' ++ output = jelly.unjelly(jelly.jelly(input)) ++ self.assertEquals(output.attribute, 'value') ++ self.failUnless( ++ isinstance(output, jelly.Unjellyable), ++ "Got instance of %r, not Unjellyable" % (output.__class__,)) ++ ++ + def testPersistentStorage(self): + perst = [{}, 1] + def persistentStore(obj, jel, perst = perst): +@@ -80,6 +97,3 @@ + + class CircularReferenceTestCase(test_newjelly.CircularReferenceTestCase): + jc = jelly +- +- +-testCases = [JellyTestCase, CircularReferenceTestCase] +Index: twisted/spread/jelly.py +=================================================================== +--- twisted/spread/jelly.py (revision 17255) ++++ twisted/spread/jelly.py (revision 17256) +@@ -273,13 +273,15 @@ + Inherit from me to Jelly yourself directly with the `getStateFor' + convenience method. + """ ++ implements(IJellyable) + +- implements(IJellyable) +- + def getStateFor(self, jellier): + return self.__dict__ + + def jellyFor(self, jellier): ++ """ ++ @see L{twisted.spread.interfaces.IJellyable.jellyFor} ++ """ + sxp = jellier.prepare(self) + sxp.extend([ + qual(self.__class__), +@@ -287,22 +289,29 @@ + return jellier.preserve(self, sxp) + + ++ + class Unjellyable: + """ + Inherit from me to Unjelly yourself directly with the + `setStateFor' convenience method. + """ ++ implements(IUnjellyable) + +- implements(IUnjellyable) +- + def setStateFor(self, unjellier, state): + self.__dict__ = state + + def unjellyFor(self, unjellier, jellyList): ++ """ ++ Perform the inverse operation of L{Jellyable.jellyFor}. ++ ++ @see L{twisted.spread.interfaces.IUnjellyable.unjellyFor} ++ """ + state = unjellier.unjelly(jellyList[1]) + self.setStateFor(unjellier, state) ++ return self + + ++ + class _Jellier: + """(Internal) This class manages state for a call to jelly() + """ +Index: twisted/spread/interfaces.py +=================================================================== +--- twisted/spread/interfaces.py (revision 17255) ++++ twisted/spread/interfaces.py (revision 17256) +@@ -14,7 +14,15 @@ + """ + + class IUnjellyable(Interface): +- def unjellyFor(self, jellier): ++ def unjellyFor(self, jellier, jellyList): + """ + Unjelly myself for the jellier. ++ ++ @param jellier: A stateful object which exists for the lifetime of a ++ single call to L{unjelly}. ++ ++ @param jellyList: The C{list} which represents the jellied state of the ++ object to be unjellied. ++ ++ @return: The object which results from unjellying. + """ diff --git a/dev-python/twisted/twisted-2.4.0-r1.ebuild b/dev-python/twisted/twisted-2.4.0-r1.ebuild new file mode 100644 index 000000000000..0e312b4ee553 --- /dev/null +++ b/dev-python/twisted/twisted-2.4.0-r1.ebuild @@ -0,0 +1,123 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/twisted/twisted-2.4.0-r1.ebuild,v 1.1 2006/09/20 21:46:00 marienz Exp $ + +inherit eutils distutils versionator + +MY_P=TwistedCore-${PV} + +DESCRIPTION="An asynchronous networking framework written in Python" +HOMEPAGE="http://www.twistedmatrix.com/" +SRC_URI="http://tmrc.mit.edu/mirror/twisted/Twisted/$(get_version_component_range 1-2)/${MY_P}.tar.bz2" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +IUSE="gtk serial crypt" + +DEPEND=">=dev-lang/python-2.3 + >=net-zope/zopeinterface-3.0.1 + serial? ( dev-python/pyserial ) + crypt? ( >=dev-python/pyopenssl-0.5.1 ) + gtk? ( >=dev-python/pygtk-1.99 ) + !dev-python/twisted-docs" + +S="${WORKDIR}/${MY_P}" + +DOCS="CREDITS INSTALL NEWS README" + +src_unpack() { + unpack ${A} + cd "${S}" + + # Give a load-sensitive test a better chance of succeeding. + epatch "${FILESDIR}/${PN}-2.1.0-echo-less.patch" + + # Pass valid arguments to "head" in the zsh completion function. + epatch "${FILESDIR}/${PN}-2.1.0-zsh-head.patch" + + # Remove a mostly-empty file with a syntax error ("???" placeholder) + rm twisted/test/stdio_test_halfclose.py + + # We need this to make remove-newjelly apply + epatch "${FILESDIR}/${P}-unjellyable.patch" + + # We need this to make python-2.5-compat apply + epatch "${FILESDIR}/${P}-remove-newjelly.patch" + rm twisted/spread/newjelly.py twisted/test/test_newjelly.py + + epatch "${FILESDIR}/${P}-python-2.5-compat.patch" + + epatch "${FILESDIR}/${P}-trial-attempted-fix.patch" + epatch "${FILESDIR}/${P}-trial-python-2.5-compat.patch" +} + +src_install() { + distutils_src_install + + # get rid of this to prevent collision-protect from killing us. it + # is regenerated in pkg_postinst. + rm "${D}/usr/$(get_libdir)"/python*/site-packages/twisted/plugins/dropin.cache + + # weird pattern to avoid installing the index.xhtml page + doman doc/man/*.? + insinto /usr/share/doc/${PF} + doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man) + + # workaround for a possible portage bug + mkdir -p "${D}/etc/conf.d/" + newconfd "${FILESDIR}/twistd.conf" twistd + newinitd "${FILESDIR}/twistd.init" twistd + + # zsh completion + insinto /usr/share/zsh/site-functions/ + doins twisted/python/_twisted_zsh_stub +} + +update_plugin_cache() { + python_version + local tpath="${ROOT}usr/$(get_libdir)/python${PYVER}/site-packages/twisted" + # we have to remove the cache or removed plugins won't be removed + # from the cache (http://twistedmatrix.com/bugs/issue926) + [[ -e "${tpath}/plugins/dropin.cache" ]] && rm -f "${tpath}/plugins/dropin.cache" + if [[ -e "${tpath}/plugin.py" ]]; then + # twisted is still installed, update. + # we have to use getPlugIns here for <=twisted-2.0.1 compatibility + einfo "Regenerating plugin cache" + python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))" + fi +} + +pkg_postinst() { + distutils_pkg_postinst + update_plugin_cache +} + +pkg_postrm() { + distutils_pkg_postrm + update_plugin_cache +} + +src_test() { + python_version + + if has_version ">=dev-lang/python-2.3"; then + "${python}" setup.py install --root="${T}/tests" --no-compile || die + else + "${python}" setup.py install --root="${T}/tests" || die + fi + + cd "${T}/tests/usr/$(get_libdir)/python${PYVER}/site-packages/" || die + + # prevent it from pulling in plugins from already installed + # twisted packages + rm twisted/plugins/__init__.py || die + + # an empty file doesn't work because the tests check for + # docstrings in all packages + echo "'''plugins stub'''" > twisted/plugins/__init__.py || die + + PYTHONPATH=. "${T}"/tests/usr/bin/trial twisted || die "trial failed" + cd "${S}" + rm -rf "${T}/tests" +} |