diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2013-09-08 19:47:21 -0700 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2013-09-08 19:47:21 -0700 |
| commit | c9b06111227f7a4ec213571f97e1b8d19b9c23f5 (patch) | |
| tree | c9d84a2a7218d62c48bce9d646d261cf8b3750a5 | |
| parent | 73fbfb2e168e76e8a0550fbaa680f6be10ba9459 (diff) | |
| parent | 8edccea5a3d7248de4074a7b43ad13bd81f7a535 (diff) | |
| download | numpy-c9b06111227f7a4ec213571f97e1b8d19b9c23f5.tar.gz | |
Merge pull request #3701 from cgohlke/patch-2
ENH: add support for Python 3.4 ast.NameConstant
| -rw-r--r-- | numpy/lib/tests/test_utils.py | 4 | ||||
| -rw-r--r-- | numpy/lib/utils.py | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_utils.py b/numpy/lib/tests/test_utils.py index 21415d96b..93c674766 100644 --- a/numpy/lib/tests/test_utils.py +++ b/numpy/lib/tests/test_utils.py @@ -46,5 +46,9 @@ def test_deprecate_fn(): assert_('old_func3' in new_func3.__doc__) assert_('new_func3' in new_func3.__doc__) +def test_safe_eval_nameconstant(): + # Test if safe_eval supports Python 3.4 _ast.NameConstant + utils.safe_eval('None') + if __name__ == "__main__": run_module_suite() diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 1b968f1fc..bd5d04430 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1062,6 +1062,9 @@ class SafeEval(object): else: raise SyntaxError("Unknown name: %s" % node.id) + def visitNameConstant(self, node): + return node.value + def safe_eval(source): """ Protected string evaluation. |
