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): ...@@ -206,8 +206,8 @@ def secureModule(mname, *imp):
return return
del _moduleSecurity[mname] del _moduleSecurity[mname]
if len(imp): if imp:
apply(__import__, (mname,) + tuple(imp)) __import__(mname, *imp)
module = sys.modules[mname] module = sys.modules[mname]
modsec.apply(module.__dict__) modsec.apply(module.__dict__)
_appliedModuleSecurity[mname] = modsec _appliedModuleSecurity[mname] = modsec
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
This product provides support for external methods, which allow This product provides support for external methods, which allow
domain-specific customization of web environments. 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 from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition import OFS.SimpleItem, Acquisition
import AccessControl.Role, sys, os, stat, traceback import AccessControl.Role, sys, os, stat, traceback
...@@ -221,14 +221,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -221,14 +221,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
__traceback_info__=args, kw, self._v_func_defaults __traceback_info__=args, kw, self._v_func_defaults
try: return apply(f,args,kw) try: return f(*args, **kw)
except TypeError, v: except TypeError, v:
tb=sys.exc_info()[2] tb=sys.exc_info()[2]
try: try:
if ((self._v_func_code.co_argcount- if ((self._v_func_code.co_argcount-
len(self._v_func_defaults or ()) - 1 == len(args)) len(self._v_func_defaults or ()) - 1 == len(args))
and self._v_func_code.co_varnames[0]=='self'): 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 raise TypeError, v, tb
finally: tb=None finally: tb=None
......
...@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted ...@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted
Python code. Python code.
""" """
__version__='$Revision: 1.47 $'[11:-2] __version__='$Revision: 1.48 $'[11:-2]
import sys, os, traceback, re, marshal, new import sys, os, traceback, re, marshal, new
from Globals import DTMLFile, MessageDialog, package_home from Globals import DTMLFile, MessageDialog, package_home
...@@ -317,7 +317,7 @@ class PythonScript(Script, Historical, Cacheable): ...@@ -317,7 +317,7 @@ class PythonScript(Script, Historical, Cacheable):
security=getSecurityManager() security=getSecurityManager()
security.addContext(self) security.addContext(self)
try: try:
result = apply(f, args, kw) result = f(*args, **kw)
if keyset is not None: if keyset is not None:
# Store the result in the cache. # Store the result in the cache.
self.ZCacheable_set(result, keywords=keyset) self.ZCacheable_set(result, keywords=keyset)
......
...@@ -18,7 +18,7 @@ Scripts. It can be accessed from Python with the statement ...@@ -18,7 +18,7 @@ Scripts. It can be accessed from Python with the statement
"import Products.PythonScripts.standard" "import Products.PythonScripts.standard"
""" """
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
from AccessControl import ModuleSecurityInfo, getSecurityManager from AccessControl import ModuleSecurityInfo, getSecurityManager
security = ModuleSecurityInfo() security = ModuleSecurityInfo()
...@@ -50,7 +50,7 @@ class DTML(RestrictedDTML, HTML): ...@@ -50,7 +50,7 @@ class DTML(RestrictedDTML, HTML):
security=getSecurityManager() security=getSecurityManager()
security.addContext(self) security.addContext(self)
try: try:
return apply(HTML.__call__, (self, client, REQUEST), kw) return HTML.__call__(self, client, REQUEST, **kw)
finally: security.removeContext(self) finally: security.removeContext(self)
......
...@@ -81,9 +81,9 @@ class TestPythonScriptNoAq(unittest.TestCase): ...@@ -81,9 +81,9 @@ class TestPythonScriptNoAq(unittest.TestCase):
def testParam26(self): def testParam26(self):
import string import string
params = string.letters[:26] params = string.letters[:26]
sparams = string.join(params, ',') sparams = ','.join(params)
tup = apply(self._newPS('##parameters=%s\nreturn %s' ps = self._newPS('##parameters=%s\nreturn %s' % (sparams, sparams))
% (sparams,sparams)), params) tup = ps(*params)
assert tup == tuple(params), (tup, params) assert tup == tuple(params), (tup, params)
def testArithmetic(self): def testArithmetic(self):
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################ ############################################################################
__version__='$Revision: 1.17 $'[11:-2] __version__='$Revision: 1.18 $'[11:-2]
import Globals import Globals
from Persistence import Persistent from Persistence import Persistent
from ZODB import TimeStamp from ZODB import TimeStamp
...@@ -507,7 +507,7 @@ def getB64TStamp( ...@@ -507,7 +507,7 @@ def getB64TStamp(
TimeStamp=TimeStamp.TimeStamp, translate=string.translate TimeStamp=TimeStamp.TimeStamp, translate=string.translate
): ):
t=time() 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) return translate(ts, b64_trans)
def getB64TStampToInt( def getB64TStampToInt(
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
""" """
def default_call_object(object, args, context): 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 return result
def default_missing_name(name, context): def default_missing_name(name, context):
...@@ -86,4 +86,4 @@ def mapply(object, positional=(), keyword={}, ...@@ -86,4 +86,4 @@ def mapply(object, positional=(), keyword={},
args=tuple(args) args=tuple(args)
if debug is not None: return debug(object,args,context) 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): ...@@ -98,7 +98,7 @@ class zope_ftp_channel(ftp_channel):
self.cookies={} self.cookies={}
def _join_paths(self,*args): def _join_paths(self,*args):
path=apply(os.path.join,args) path=os.path.join(*args)
path=os.path.normpath(path) path=os.path.normpath(path)
if os.sep != '/': if os.sep != '/':
path=path.replace(os.sep,'/') path=path.replace(os.sep,'/')
...@@ -543,7 +543,7 @@ class ContentReceiver: ...@@ -543,7 +543,7 @@ class ContentReceiver:
c=self.callback c=self.callback
self.callback=None self.callback=None
self.args=None self.args=None
apply(c,args) c(*args)
class FTPLimiter: class FTPLimiter:
...@@ -599,7 +599,7 @@ class FTPServer(ftp_server): ...@@ -599,7 +599,7 @@ class FTPServer(ftp_server):
def __init__(self,module,*args,**kw): def __init__(self,module,*args,**kw):
self.shutup=1 self.shutup=1
apply(ftp_server.__init__, (self, None) + args, kw) ftp_server.__init__(self, None, *args, **kw)
self.shutup=0 self.shutup=0
self.module=module self.module=module
self.log_info('FTP server started at %s\n' self.log_info('FTP server started at %s\n'
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Author: Sam Rushing <rushing@nightmare.com> # 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' # Fast, low-overhead asynchronous name resolver. uses 'pre-cooked'
...@@ -303,15 +303,14 @@ class hooked_callback: ...@@ -303,15 +303,14 @@ class hooked_callback:
self.hook, self.callback = hook, callback self.hook, self.callback = hook, callback
def __call__ (self, *args): def __call__ (self, *args):
apply (self.hook, args) self.hook(*args)
apply (self.callback, args) self.callback(*args)
class caching_resolver (resolver): class caching_resolver (resolver):
"Cache DNS queries. Will need to honor the TTL value in the replies" "Cache DNS queries. Will need to honor the TTL value in the replies"
def __init__ (*args): def __init__(self, *args):
apply (resolver.__init__, args) resolver.__init__(self, *args)
self = args[0]
self.cache = {} self.cache = {}
self.forward_requests = counter() self.forward_requests = counter()
self.reverse_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