Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3381 - manage.py shell now respects PYTHONSTARTUP/.pythonrc.py.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6231 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 27d027782cc1a99ad22105a39d3bab17ef871cf3 1 parent 17cd87a
Jacob Kaplan-Moss authored September 14, 2007

Showing 1 changed file with 13 additions and 0 deletions. Show diff stats Hide diff stats

  1. 13  django/core/management/commands/shell.py
13  django/core/management/commands/shell.py
... ...
@@ -1,3 +1,4 @@
  1
+import os
1 2
 from django.core.management.base import NoArgsCommand
2 3
 from optparse import make_option
3 4
 
@@ -43,4 +44,16 @@ def handle_noargs(self, **options):
43 44
                 import rlcompleter
44 45
                 readline.set_completer(rlcompleter.Completer(imported_objects).complete)
45 46
                 readline.parse_and_bind("tab:complete")
  47
+
  48
+            # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
  49
+            # conventions and get $PYTHONSTARTUP first then import user.
  50
+            if not use_plain: 
  51
+                pythonrc = os.environ.get("PYTHONSTARTUP") 
  52
+                if pythonrc and os.path.isfile(pythonrc): 
  53
+                    try: 
  54
+                        execfile(pythonrc) 
  55
+                    except NameError: 
  56
+                        pass
  57
+                # This will import .pythonrc.py as a side-effect
  58
+                import user
46 59
             code.interact(local=imported_objects)

0 notes on commit 27d0277

Please sign in to comment.
Something went wrong with that request. Please try again.