Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5753 -- Allow createsuperuser to work in situations where there

might be a valid password database entry for the current user id.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9158 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c58c1f43cf4f35088f815692a5410261e21dfc47 1 parent e2b02ea
Malcolm Tredinnick authored October 06, 2008
8  django/contrib/auth/management/commands/createsuperuser.py
@@ -57,10 +57,12 @@ def handle(self, *args, **options):
57 57
         # Try to determine the current system user's username to use as a default.
58 58
         try:
59 59
             import pwd
60  
-        except ImportError:
61  
-            default_username = ''
62  
-        else:
63 60
             default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()
  61
+        except (ImportError, KeyError):
  62
+            # KeyError will be raised by getpwuid() if there is no
  63
+            # corresponding entry in the /etc/passwd file (a very restricted
  64
+            # chroot environment, for example).
  65
+            default_username = ''
64 66
 
65 67
         # Determine whether the default username is taken, so we don't display
66 68
         # it as an option.

0 notes on commit c58c1f4

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