Skip to content

Commit

Permalink
use a own namespace for exec command
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Riolo committed Apr 20, 2015
1 parent 6c53d2e commit e41ac76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/martian/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ def __init__(self, *args, **kw):
def check_factory_signature(self, *arguments, **kw):
args, varargs, varkw, defaults = inspect.getargspec(self.factory)
argspec = inspect.formatargspec(args[1:], varargs, varkw, defaults)
exec("def signature_checker" + argspec + ": pass")
ns = dict()
exec("def signature_checker" + argspec + ": pass", dict(), ns)
try:
locals()['signature_checker'](*arguments, **kw)
ns['signature_checker'](*arguments, **kw)
except TypeError as e:
message = e.args[0]
message = message.replace("signature_checker()", self.name)
Expand Down
2 changes: 1 addition & 1 deletion src/martian/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def not_unicode_or_ascii(value):

# python3 compatibility
if sys.version_info < (3,) and isinstance(value, unicode):
if sys.version_info < (3,) and isinstance(value, unicode):
return False
if not isinstance(value, str):
return True
Expand Down

0 comments on commit e41ac76

Please sign in to comment.