Skip to content

Commit

Permalink
exec_ in Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Jun 27, 2016
1 parent 0f49484 commit 9cc000e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions manage/auto_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
from six import exec_
from manage.utils import import_string


Expand All @@ -25,7 +26,7 @@ def import_objects(manage_dict):
else:
auto_import[get_name(_obj, name)] = _obj
for script in auto_scripts:
exec(script, auto_import)
exec_(script, auto_import)
return auto_import


Expand All @@ -39,4 +40,4 @@ def exec_init(manage_dict, context):

def exec_init_script(manage_dict, context):
if 'init_script' in manage_dict['shell']:
exec(manage_dict['shell']['init_script'], context)
exec_(manage_dict['shell']['init_script'], context)
4 changes: 2 additions & 2 deletions manage/commands_collector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import click
import pkgutil

from six import exec_
from inspect import getmembers
from click.core import BaseCommand
from manage.utils import import_string
Expand Down Expand Up @@ -28,7 +28,7 @@ def add_click_commands(module, cli, command_dict, namespaced):

def make_command_from_string(code, cmd_context, options, help_text=None):
def _command(**kwargs):
exec(code, cmd_context, kwargs)
exec_(code, cmd_context, kwargs)

if help_text:
_command.__doc__ = help_text
Expand Down
3 changes: 2 additions & 1 deletion manage/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# coding: utf-8
import sys
import importlib
from six import exec_

PY2 = sys.version_info[0] == 2
WIN = sys.platform.startswith('win')


if PY2:
exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
exec_('def reraise(tp, value, tb=None):\n raise tp, value, tb')
else:
def reraise(tp, value, tb=None):
if value.__traceback__ is not tb:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

requirements = [
'Click>=6.0',
'PyYAML==3.11'
'PyYAML==3.11',
'six'
]

test_requirements = [
Expand Down

0 comments on commit 9cc000e

Please sign in to comment.