Commit ab05dfa5 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

Revert "*: keep using func_code and not yet __code__ with scripts"

This reverts commit eaae74a0.

On Zope4 branch we are ready to use __code__
parent 6f417453
...@@ -164,7 +164,7 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -164,7 +164,7 @@ class Alarm(XMLObject, PeriodicityMixin):
activate_kw['tag'] = '%s_%x' % (self.getRelativeUrl(), getrandbits(32)) activate_kw['tag'] = '%s_%x' % (self.getRelativeUrl(), getrandbits(32))
tag = activate_kw['tag'] tag = activate_kw['tag']
method = getattr(self, method_id) method = getattr(self, method_id)
func_code = method.func_code func_code = method.__code__
try: try:
has_kw = func_code.co_flags & CO_VARKEYWORDS has_kw = func_code.co_flags & CO_VARKEYWORDS
except AttributeError: except AttributeError:
......
...@@ -41,7 +41,7 @@ class Accessor(Method): ...@@ -41,7 +41,7 @@ class Accessor(Method):
def __getinitargs__(self): def __getinitargs__(self):
init = getattr(self, '__init__', None) init = getattr(self, '__init__', None)
if init is not None: if init is not None:
varnames = init.func_code.co_varnames varnames = init.__code__.co_varnames
args = [] args = []
for name in varnames: for name in varnames:
if name == 'self': if name == 'self':
......
...@@ -181,7 +181,7 @@ class Predicate(XMLObject): ...@@ -181,7 +181,7 @@ class Predicate(XMLObject):
try: try:
result = method(self) result = method(self)
except TypeError: except TypeError:
if method.func_code.co_argcount != isinstance(method, MethodType): if method.__code__.co_argcount != isinstance(method, MethodType):
raise raise
# backward compatibilty with script that takes no argument # backward compatibilty with script that takes no argument
warn('Predicate %s uses an old-style method (%s) that does not' warn('Predicate %s uses an old-style method (%s) that does not'
......
...@@ -71,8 +71,8 @@ class InteractorMethod(Method): ...@@ -71,8 +71,8 @@ class InteractorMethod(Method):
self.after_action_list = [] self.after_action_list = []
self.before_action_list = [] self.before_action_list = []
self.method = method self.method = method
self.__code__ = self.func_code = method.func_code self.__code__ = self.func_code = method.__code__
self.__defaults__ = self.func_defaults = method.func_defaults self.__defaults__ = self.func_defaults = method.__defaults__
self.__name__ = method.__name__ self.__name__ = method.__name__
def registerBeforeAction(self, action, args, kw): def registerBeforeAction(self, action, args, kw):
......
...@@ -234,7 +234,7 @@ def deprecated(message=''): ...@@ -234,7 +234,7 @@ def deprecated(message=''):
@simple_decorator @simple_decorator
def _deprecated(wrapped): def _deprecated(wrapped):
m = message or "Use of '%s' function (%s, line %s) is deprecated." % ( m = message or "Use of '%s' function (%s, line %s) is deprecated." % (
wrapped.__name__, wrapped.__module__, wrapped.func_code.co_firstlineno) wrapped.__name__, wrapped.__module__, wrapped.__code__.co_firstlineno)
def deprecated(*args, **kw): def deprecated(*args, **kw):
warnings.warn(m, DeprecationWarning, 2) warnings.warn(m, DeprecationWarning, 2)
return wrapped(*args, **kw) return wrapped(*args, **kw)
......
...@@ -44,7 +44,7 @@ def volatileCached(self, func): ...@@ -44,7 +44,7 @@ def volatileCached(self, func):
self._v_SimpleItem_Item_vCache = cache_dict = {} self._v_SimpleItem_Item_vCache = cache_dict = {}
# Use whole func_code as a key, as it is the only reliable way to identify a # Use whole func_code as a key, as it is the only reliable way to identify a
# function. # function.
key = func.func_code key = func.__code__
try: try:
return cache_dict[key] return cache_dict[key]
except KeyError: except KeyError:
......
...@@ -1451,7 +1451,7 @@ class Catalog(Folder, ...@@ -1451,7 +1451,7 @@ class Catalog(Folder,
if meta_type in self.HAS_ARGUMENT_SRC_METATYPE_SET: if meta_type in self.HAS_ARGUMENT_SRC_METATYPE_SET:
return method.arguments_src.split() return method.arguments_src.split()
elif meta_type in self.HAS_FUNC_CODE_METATYPE_SET: elif meta_type in self.HAS_FUNC_CODE_METATYPE_SET:
return method.func_code.co_varnames[:method.func_code.co_argcount] return method.__code__.co_varnames[:method.__code__.co_argcount]
# Note: Raising here would completely prevent indexation from working. # Note: Raising here would completely prevent indexation from working.
# Instead, let the method actually fail when called, so _catalogObjectList # Instead, let the method actually fail when called, so _catalogObjectList
# can log the error and carry on. # can log the error and carry on.
...@@ -1837,7 +1837,7 @@ class Catalog(Folder, ...@@ -1837,7 +1837,7 @@ class Catalog(Folder,
else: else:
search_key = self.getSearchKey(key, 'RelatedKey') search_key = self.getSearchKey(key, 'RelatedKey')
else: else:
func_code = script.func_code func_code = script.__code__
search_key = ( search_key = (
AdvancedSearchKeyWrapperForScriptableKey if ( AdvancedSearchKeyWrapperForScriptableKey if (
# 5: search_value (under any name), "search_key", "group", # 5: search_value (under any name), "search_key", "group",
......
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