Skip to content

Commit

Permalink
Remove builtins invalid in Python 3 from Python runner (#4375)
Browse files Browse the repository at this point in the history
These few builtins were available in Python 2.7 but not anymore
in Python 3, making the runner fail to start.
  • Loading branch information
NicolasLM authored and arikfr committed Nov 27, 2019
1 parent 5de291a commit f5a4082
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions redash/query_runner/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Python(BaseQueryRunner):
should_annotate_query = False

safe_builtins = (
'sorted', 'reversed', 'map', 'reduce', 'any', 'all',
'sorted', 'reversed', 'map', 'any', 'all',
'slice', 'filter', 'len', 'next', 'enumerate',
'sum', 'abs', 'min', 'max', 'round', 'cmp', 'divmod',
'str', 'unicode', 'int', 'float', 'complex',
'sum', 'abs', 'min', 'max', 'round', 'divmod',
'str', 'int', 'float', 'complex',
'tuple', 'set', 'list', 'dict', 'bool',
)

Expand Down Expand Up @@ -261,7 +261,7 @@ def run_query(self, query, user):
# One option is to use ETA with Celery + timeouts on workers
# And replacement of worker process every X requests handled.

exec((code), restricted_globals, self._script_locals)
exec(code, restricted_globals, self._script_locals)

result = self._script_locals['result']
result['log'] = self._custom_print.lines
Expand Down

0 comments on commit f5a4082

Please sign in to comment.