Commit fd809b39 authored by Fred Drake's avatar Fred Drake

Replace apply(f,args,kw) with f(*args,**kw) to avoid deprecation warnings

from Python 2.3.
These warnings are displayed when running the unit tests.
This patch fixes the occurrances that are triggered by the unit tests;
there are probably others.
parent 04edd680
......@@ -206,8 +206,8 @@ def secureModule(mname, *imp):
return
del _moduleSecurity[mname]
if len(imp):
apply(__import__, (mname,) + tuple(imp))
if imp:
__import__(mname, *imp)
module = sys.modules[mname]
modsec.apply(module.__dict__)
_appliedModuleSecurity[mname] = modsec
......
......@@ -16,7 +16,7 @@
This product provides support for external methods, which allow
domain-specific customization of web environments.
"""
__version__='$Revision: 1.51 $'[11:-2]
__version__='$Revision: 1.52 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition
import AccessControl.Role, sys, os, stat, traceback
......@@ -221,14 +221,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
__traceback_info__=args, kw, self._v_func_defaults
try: return apply(f,args,kw)
try: return f(*args, **kw)
except TypeError, v:
tb=sys.exc_info()[2]
try:
if ((self._v_func_code.co_argcount-
len(self._v_func_defaults or ()) - 1 == len(args))
and self._v_func_code.co_varnames[0]=='self'):
return apply(f,(self.aq_parent.this(),)+args,kw)
return f(self.aq_parent.this(), *args, **kw)
raise TypeError, v, tb
finally: tb=None
......
......@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__='$Revision: 1.47 $'[11:-2]
__version__='$Revision: 1.48 $'[11:-2]
import sys, os, traceback, re, marshal, new
from Globals import DTMLFile, MessageDialog, package_home
......@@ -317,7 +317,7 @@ class PythonScript(Script, Historical, Cacheable):
security=getSecurityManager()
security.addContext(self)
try:
result = apply(f, args, kw)
result = f(*args, **kw)
if keyset is not None:
# Store the result in the cache.
self.ZCacheable_set(result, keywords=keyset)
......
......@@ -18,7 +18,7 @@ Scripts. It can be accessed from Python with the statement
"import Products.PythonScripts.standard"
"""
__version__='$Revision: 1.13 $'[11:-2]
__version__='$Revision: 1.14 $'[11:-2]
from AccessControl import ModuleSecurityInfo, getSecurityManager
security = ModuleSecurityInfo()
......@@ -50,7 +50,7 @@ class DTML(RestrictedDTML, HTML):
security=getSecurityManager()
security.addContext(self)
try:
return apply(HTML.__call__, (self, client, REQUEST), kw)
return HTML.__call__(self, client, REQUEST, **kw)
finally: security.removeContext(self)
......
......@@ -81,9 +81,9 @@ class TestPythonScriptNoAq(unittest.TestCase):
def testParam26(self):
import string
params = string.letters[:26]
sparams = string.join(params, ',')
tup = apply(self._newPS('##parameters=%s\nreturn %s'
% (sparams,sparams)), params)
sparams = ','.join(params)
ps = self._newPS('##parameters=%s\nreturn %s' % (sparams, sparams))
tup = ps(*params)
assert tup == tuple(params), (tup, params)
def testArithmetic(self):
......
......@@ -11,7 +11,7 @@
#
############################################################################
__version__='$Revision: 1.17 $'[11:-2]
__version__='$Revision: 1.18 $'[11:-2]
import Globals
from Persistence import Persistent
from ZODB import TimeStamp
......@@ -507,7 +507,7 @@ def getB64TStamp(
TimeStamp=TimeStamp.TimeStamp, translate=string.translate
):
t=time()
ts=split(b2a(`apply(TimeStamp,(gmtime(t)[:5]+(t%60,)))`)[:-1],'=')[0]
ts=split(b2a(`TimeStamp(*gmtime(t)[:5]+(t%60,))`)[:-1],'=')[0]
return translate(ts, b64_trans)
def getB64TStampToInt(
......
......@@ -14,7 +14,7 @@
"""
def default_call_object(object, args, context):
result=apply(object,args) # Type s<cr> to step into published object.
result=object(*args) # Type s<cr> to step into published object.
return result
def default_missing_name(name, context):
......@@ -86,4 +86,4 @@ def mapply(object, positional=(), keyword={},
args=tuple(args)
if debug is not None: return debug(object,args,context)
else: return apply(object,args)
else: return object(*args)
......@@ -98,7 +98,7 @@ class zope_ftp_channel(ftp_channel):
self.cookies={}
def _join_paths(self,*args):
path=apply(os.path.join,args)
path=os.path.join(*args)
path=os.path.normpath(path)
if os.sep != '/':
path=path.replace(os.sep,'/')
......@@ -543,7 +543,7 @@ class ContentReceiver:
c=self.callback
self.callback=None
self.args=None
apply(c,args)
c(*args)
class FTPLimiter:
......@@ -599,7 +599,7 @@ class FTPServer(ftp_server):
def __init__(self,module,*args,**kw):
self.shutup=1
apply(ftp_server.__init__, (self, None) + args, kw)
ftp_server.__init__(self, None, *args, **kw)
self.shutup=0
self.module=module
self.log_info('FTP server started at %s\n'
......
......@@ -4,7 +4,7 @@
# Author: Sam Rushing <rushing@nightmare.com>
#
RCS_ID = '$Id: resolver.py,v 1.12 2003/03/18 21:15:17 fdrake Exp $'
RCS_ID = '$Id: resolver.py,v 1.13 2003/07/09 16:25:29 fdrake Exp $'
# Fast, low-overhead asynchronous name resolver. uses 'pre-cooked'
......@@ -303,15 +303,14 @@ class hooked_callback:
self.hook, self.callback = hook, callback
def __call__ (self, *args):
apply (self.hook, args)
apply (self.callback, args)
self.hook(*args)
self.callback(*args)
class caching_resolver (resolver):
"Cache DNS queries. Will need to honor the TTL value in the replies"
def __init__ (*args):
apply (resolver.__init__, args)
self = args[0]
def __init__(self, *args):
resolver.__init__(self, *args)
self.cache = {}
self.forward_requests = counter()
self.reverse_requests = counter()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment