Commit df64f044 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: Python2-only, check on Python3.

parent 569729fa
...@@ -59,8 +59,6 @@ def encodeKey(key): ...@@ -59,8 +59,6 @@ def encodeKey(key):
""" """
# According to the memcached's protocol.txt, the key cannot contain # According to the memcached's protocol.txt, the key cannot contain
# control characters and white spaces. # control characters and white spaces.
if isinstance(key, str):
key = key.encode()
return encodestring(key, True).replace(b'\n', b'').replace(b'\r', b'') return encodestring(key, True).replace(b'\n', b'').replace(b'\r', b'')
if memcache is not None: if memcache is not None:
......
...@@ -26,7 +26,7 @@ class _(PatchClass(ExternalMethod)): ...@@ -26,7 +26,7 @@ class _(PatchClass(ExternalMethod)):
reloadIfChanged = getFuncDefaults = getFuncCode = filepath = None reloadIfChanged = getFuncDefaults = getFuncCode = filepath = None
@property @property
def func_defaults(self): def __defaults__(self):
"""Return a tuple of default values. """Return a tuple of default values.
The first value is for the "second" parameter (self is ommited) The first value is for the "second" parameter (self is ommited)
...@@ -35,10 +35,12 @@ class _(PatchClass(ExternalMethod)): ...@@ -35,10 +35,12 @@ class _(PatchClass(ExternalMethod)):
will have func_defaults = ('', ) will have func_defaults = ('', )
""" """
return self._getFunction()[1] return self._getFunction()[1]
func_defaults = __defaults__
@property @property
def func_code(self): def __code__(self):
return self._getFunction()[2] return self._getFunction()[2]
func_code = __code__
@property @property
def func_args(self): def func_args(self):
...@@ -80,7 +82,7 @@ class _(PatchClass(ExternalMethod)): ...@@ -80,7 +82,7 @@ class _(PatchClass(ExternalMethod)):
return _f return _f
except AttributeError: except AttributeError:
pass pass
code = f.__code__ code = f.func_code
argument_object = getargs(code) argument_object = getargs(code)
# reconstruct back the original names # reconstruct back the original names
arg_list = argument_object.args[:] arg_list = argument_object.args[:]
...@@ -95,7 +97,7 @@ class _(PatchClass(ExternalMethod)): ...@@ -95,7 +97,7 @@ class _(PatchClass(ExternalMethod)):
i += has_self i += has_self
if i: if i:
code = FuncCode(ff, i) code = FuncCode(ff, i)
self._v_f = _f = (f, f.__defaults__, code, has_self, arg_list) self._v_f = _f = (f, f.func_defaults, code, has_self, arg_list)
return _f return _f
def __call__(self, *args, **kw): def __call__(self, *args, **kw):
......
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