Skip to content

Commit

Permalink
Compatibility with python 2.7 versions before 2.7.9
Browse files Browse the repository at this point in the history
This is a workaround for https://bugs.python.org/issue21591 which
affect Python 2 versions before 2.7.9. This includes Python 2.7.5
which is the Python 2 version on RHEL/CentOS 7.
  • Loading branch information
ellert authored and etejedor committed Jul 2, 2020
1 parent c8bae42 commit 02921ab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bindings/pyroot/pythonizations/python/ROOT/_numbadeclare.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _NumbaDeclareDecorator(input_types, return_type, name=None):
import cffi
except:
raise Exception('Failed to import cffi')
import re
import re, sys

# Normalize input types by stripping ROOT and VecOps namespaces from input types
def normalize_typename(t):
Expand Down Expand Up @@ -195,7 +195,11 @@ def pywrapper({SIGNATURE}):
if 'RVec' in return_type:
glob['dtype_r'] = get_numba_type(get_inner_type(return_type))

exec(pywrappercode, glob, locals())
if sys.version_info[0] >= 3:
exec(pywrappercode, glob, locals()) in {}
else:
exec(pywrappercode) in glob, locals()

if not 'pywrapper' in locals():
raise Exception('Failed to create Python wrapper function:\n{}'.format(pywrappercode))

Expand Down

0 comments on commit 02921ab

Please sign in to comment.