[Twisted-Python] Apply Deprecation
Moshe Zadka
m at moshez.org
Sun May 4 04:33:02 MDT 2003
On 4 May 2003, Moshe Zadka <m at moshez.org> wrote:
> I've run a quick grep over the unittest log, and saw that an overwhelming
> majority of the errors come from relatively few places, namely:
>
> 104 twisted/test/test_internet.py:502
> 38 twisted/python/failure.py:230
> 31 twisted/enterprise/xmlreflector.py:94
> 24 twisted/spread/util.py:80
> 24 twisted/spread/util.py:76
>
> These are five lines which, if properly fixed, would make the tests
> more readable.
>
> I realize there are good reasons for *not* stomping over the tree, randomly
> changing stuff, and I'm not suggesting it. I'm suggesting changing five
> lines.
Following up on myself, here is a patch:
Index: twisted/test/test_internet.py
===================================================================
RCS file: /cvs/Twisted/twisted/test/test_internet.py,v
retrieving revision 1.25
diff -u -r1.25 test_internet.py
--- twisted/test/test_internet.py 12 Apr 2003 20:16:35 -0000 1.25
+++ twisted/test/test_internet.py 4 May 2003 10:29:45 -0000
@@ -499,7 +499,7 @@
def schedule(self, *args, **kwargs):
"""Override in subclasses."""
- apply(reactor.callFromThread, args, kwargs)
+ reactor.callFromThread(*args, **kwargs)
def testScheduling(self):
c = Counter()
Index: twisted/python/failure.py
===================================================================
RCS file: /cvs/Twisted/twisted/python/failure.py,v
retrieving revision 1.31
diff -u -r1.31 failure.py
--- twisted/python/failure.py 3 May 2003 04:23:15 -0000 1.31
+++ twisted/python/failure.py 4 May 2003 10:29:45 -0000
@@ -227,7 +227,7 @@
@type errorTypes: L{Exception}
"""
- error = apply(self.check, errorTypes)
+ error = self.check(*errorTypes)
if not error:
raise self
return error
Index: twisted/enterprise/xmlreflector.py
===================================================================
RCS file: /cvs/Twisted/twisted/enterprise/xmlreflector.py,v
retrieving revision 1.12
diff -u -r1.12 xmlreflector.py
--- twisted/enterprise/xmlreflector.py 12 Jan 2003 06:26:48 -0000 1.12
+++ twisted/enterprise/xmlreflector.py 4 May 2003 10:29:45 -0000
@@ -91,7 +91,8 @@
# find the row in the cache or add it
resultObject = self.findInCache(tableInfo.rowClass, proxy.kw)
if not resultObject:
- resultObject = apply(tableInfo.rowFactoryMethod[0], (tableInfo.rowClass, data, proxy.kw) )
+ resultObject = tableInfo.rowFactoryMethod[0](
+ tableInfo.rowClass, data, proxy.kw)
self.addToCache(resultObject)
newRows.append(resultObject)
results.append(resultObject)
Index: twisted/spread/util.py
===================================================================
RCS file: /cvs/Twisted/twisted/spread/util.py,v
retrieving revision 1.8
diff -u -r1.8 util.py
--- twisted/spread/util.py 27 Aug 2002 19:57:57 -0000 1.8
+++ twisted/spread/util.py 4 May 2003 10:29:45 -0000
@@ -73,11 +73,11 @@
self.failWhenNotImplemented = failWhenNotImplemented
def _callMethod(self, method, *args, **kw):
- return apply(getattr(self.forwarded, method), args, kw)
+ return getattr(self.forwarded, method)(*args, **kw)
def callRemote(self, method, *args, **kw):
if hasattr(self.interfaceClass, method):
- result = apply(defer.execute, (self._callMethod,method)+args, kw)
+ result = defer.execute(self._callMethod, method, *args, **kw)
return result
elif self.failWhenNotImplemented:
return defer.fail(
Please look through it to see if there are any glaring mistake.
Naturally, I *have* run the unit tests.
Thanks,
Moshe
--
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/
More information about the Twisted-Python
mailing list