Skip to content

Commit

Permalink
convert single function defined via exec() due to Python2/3 differences
Browse files Browse the repository at this point in the history
  • Loading branch information
leogama committed Jun 21, 2022
1 parent 5e33b75 commit 2047c7d
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions dill/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<string>', '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):
Expand All @@ -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
Expand Down

0 comments on commit 2047c7d

Please sign in to comment.