From 2047c7db8a77c654f8f050ca4a5e2150e74382d4 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Tue, 21 Jun 2022 11:00:53 -0300 Subject: [PATCH] convert single function defined via exec() due to Python2/3 differences --- dill/source.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/dill/source.py b/dill/source.py index 1d8bba11..f4a14ee0 100644 --- a/dill/source.py +++ b/dill/source.py @@ -506,24 +506,6 @@ def outdent(code, spaces=None, all=True): #XXX: not sure what the point of _wrap is... -#exec_ = lambda s, *a: eval(compile(s, '', 'exec'), *a) -__globals__ = globals() -__locals__ = locals() -wrap2 = ''' -def _wrap(f): - """ encapsulate a function and it's __import__ """ - def func(*args, **kwds): - try: - # _ = eval(getsource(f, force=True)) #XXX: safer but less robust - exec getimportable(f, alias='_') in %s, %s - except: - raise ImportError('cannot import name ' + f.__name__) - return _(*args, **kwds) - func.__name__ = f.__name__ - func.__doc__ = f.__doc__ - return func -''' % ('__globals__', '__locals__') -wrap3 = ''' def _wrap(f): """ encapsulate a function and it's __import__ """ def func(*args, **kwds): @@ -536,9 +518,6 @@ def func(*args, **kwds): func.__name__ = f.__name__ func.__doc__ = f.__doc__ return func -''' % ('__globals__', '__locals__') -exec(wrap3) -del wrap2, wrap3 def _enclose(object, alias=''): #FIXME: needs alias to hold returned object