Skip to content

Commit

Permalink
[py3] Ported the 'shell' management command.
Browse files Browse the repository at this point in the history
The user module and the execfile function were removed in Python 3.

Thanks Linovia for the report.
  • Loading branch information
aaugustin committed Aug 29, 2012
1 parent adbdb18 commit 723c9a8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions django/core/management/commands/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def handle_noargs(self, **options):
readline.parse_and_bind("tab:complete")

# 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:
pythonrc = os.environ.get("PYTHONSTARTUP")
if pythonrc and os.path.isfile(pythonrc):
try:
execfile(pythonrc)
except NameError:
pass
# This will import .pythonrc.py as a side-effect
import user
for pythonrc in (os.environ.get("PYTHONSTARTUP"),
os.path.expanduser('~/.pythonrc.py')):
if pythonrc and os.path.isfile(pythonrc):
try:
with open(pythonrc) as handle:
exec(compile(handle.read(), pythonrc, 'exec'))
except NameError:
pass
code.interact(local=imported_objects)

0 comments on commit 723c9a8

Please sign in to comment.