Skip to content

Commit 8fd24ea

Browse files
committed
fix: nested exec call
1 parent f493bbd commit 8fd24ea

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

nipype/utils/tests/test_functions.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ def test_func_to_str_err():
2121
bad_src = "obbledygobbledygook"
2222
with pytest.raises(RuntimeError): create_function_from_source(bad_src)
2323

24+
def _print_statement():
25+
try:
26+
exec('print ""')
27+
return True
28+
except SyntaxError:
29+
return False
30+
2431
@pytest.mark.skipif(sys.version_info[0] > 2, reason="breaks python 3")
2532
def test_func_py2():
2633
def is_string():
2734
return isinstance('string', str)
2835

29-
def print_statement():
30-
# test python 2 compatibility
31-
try:
32-
exec('print ""')
33-
return True
34-
except SyntaxError:
35-
return False
36-
3736
wrapped_func = create_function_from_source(getsource(is_string))
3837
assert is_string() == wrapped_func()
3938

40-
wrapped_func2 = create_function_from_source(getsource(print_statement))
39+
wrapped_func2 = create_function_from_source(getsource(_print_statement))
4140
assert wrapped_func2()

0 commit comments

Comments
 (0)