Skip to content

Commit 2863597

Browse files
committed
convert single function defined via exec() due to Python2/3 differences
1 parent 5e33b75 commit 2863597

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

dill/source.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -506,39 +506,20 @@ def outdent(code, spaces=None, all=True):
506506

507507

508508
#XXX: not sure what the point of _wrap is...
509-
#exec_ = lambda s, *a: eval(compile(s, '<string>', 'exec'), *a)
510509
__globals__ = globals()
511510
__locals__ = locals()
512-
wrap2 = '''
513511
def _wrap(f):
514512
""" encapsulate a function and it's __import__ """
515513
def func(*args, **kwds):
516514
try:
517515
# _ = eval(getsource(f, force=True)) #XXX: safer but less robust
518-
exec getimportable(f, alias='_') in %s, %s
516+
exec(getimportable(f, alias='_'), __globals__, __locals__)
519517
except:
520518
raise ImportError('cannot import name ' + f.__name__)
521519
return _(*args, **kwds)
522520
func.__name__ = f.__name__
523521
func.__doc__ = f.__doc__
524522
return func
525-
''' % ('__globals__', '__locals__')
526-
wrap3 = '''
527-
def _wrap(f):
528-
""" encapsulate a function and it's __import__ """
529-
def func(*args, **kwds):
530-
try:
531-
# _ = eval(getsource(f, force=True)) #XXX: safer but less robust
532-
exec(getimportable(f, alias='_'), %s, %s)
533-
except:
534-
raise ImportError('cannot import name ' + f.__name__)
535-
return _(*args, **kwds)
536-
func.__name__ = f.__name__
537-
func.__doc__ = f.__doc__
538-
return func
539-
''' % ('__globals__', '__locals__')
540-
exec(wrap3)
541-
del wrap2, wrap3
542523

543524

544525
def _enclose(object, alias=''): #FIXME: needs alias to hold returned object

0 commit comments

Comments
 (0)