Ticket #6682: PYTHONSTARTUP_support_in_shell_management_command.diff

File PYTHONSTARTUP_support_in_shell_management_command.diff, 1.4 KB (added by hekevintran@…, 11 years ago)
  • django/core/management/commands/shell.py

    diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
    index f883fb9..7be3897 100644
    a b class Command(NoArgsCommand):  
    8383
    8484            # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
    8585            # conventions and get $PYTHONSTARTUP first then .pythonrc.py.
    86             if not use_plain:
    87                 for pythonrc in (os.environ.get("PYTHONSTARTUP"),
    88                                  os.path.expanduser('~/.pythonrc.py')):
    89                     if pythonrc and os.path.isfile(pythonrc):
    90                         try:
    91                             with open(pythonrc) as handle:
    92                                 exec(compile(handle.read(), pythonrc, 'exec'))
    93                         except NameError:
    94                             pass
     86            for pythonrc in (os.environ.get("PYTHONSTARTUP"),
     87                             os.path.expanduser('~/.pythonrc.py')):
     88                if pythonrc and os.path.isfile(pythonrc):
     89                    try:
     90                        with open(pythonrc) as handle:
     91                            exec(compile(handle.read(), pythonrc, 'exec'), imported_objects)
     92                    except NameError:
     93                        pass
    9594            code.interact(local=imported_objects)
Back to Top