[py3] Ported the 'shell' management command.

The user module and the execfile function were removed in Python 3.

Thanks Linovia for the report.
This commit is contained in:
Aymeric Augustin 2012-08-29 23:43:10 +02:00
parent adbdb18adc
commit 723c9a8c6d
1 changed files with 9 additions and 9 deletions

View File

@ -80,14 +80,14 @@ class Command(NoArgsCommand):
readline.parse_and_bind("tab:complete") readline.parse_and_bind("tab:complete")
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
# conventions and get $PYTHONSTARTUP first then import user. # conventions and get $PYTHONSTARTUP first then .pythonrc.py.
if not use_plain: if not use_plain:
pythonrc = os.environ.get("PYTHONSTARTUP") for pythonrc in (os.environ.get("PYTHONSTARTUP"),
if pythonrc and os.path.isfile(pythonrc): os.path.expanduser('~/.pythonrc.py')):
try: if pythonrc and os.path.isfile(pythonrc):
execfile(pythonrc) try:
except NameError: with open(pythonrc) as handle:
pass exec(compile(handle.read(), pythonrc, 'exec'))
# This will import .pythonrc.py as a side-effect except NameError:
import user pass
code.interact(local=imported_objects) code.interact(local=imported_objects)