Opened 16 years ago

Closed 13 years ago

Last modified 13 years ago

#7431 closed (fixed)

change import pwd library for import os in createsuperuser

Reported by: Kenneth Belitzky Owned by:
Component: contrib.auth Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

the file createsuperuser.py (rev 7590) is using the pwd method to detect default user. while this is good alternative on Unix based systems, this library (pwd) is not included on the windows version of python.
my suggestion is to change this:

try:
  import pwd
except ImportError:
  default_username = ''
else:
  default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()


with

  default_username = os.path.expanduser("~").replace(' ', '').lower().split(os.sep)[-1]


or something similar, in order to get a windows compartible method too.

Attachments (1)

windows-superuser.diff (1.0 KB ) - added by Eric Holscher 16 years ago.

Download all attachments as: .zip

Change History (5)

by Eric Holscher, 16 years ago

Attachment: windows-superuser.diff added

comment:1 by Eric Holscher, 16 years ago

Component: UncategorizedAuthentication
Has patch: set
milestone: post-1.0
Owner: nobody removed
Triage Stage: UnreviewedAccepted

comment:2 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

(In [14607]) Fixed #7077 and #7431 -- Use getpass.getuser instead of pwd.getpwuid to determine the current system user's username in the createsuperuser management command to enable the feature on Windows. getpass.getuser automatically falls back to the previous method.

comment:4 by Jannis Leidel, 13 years ago

(In [14608]) [1.2.X] Fixed #7077 and #7431 -- Use getpass.getuser instead of pwd.getpwuid to determine the current system user's username in the createsuperuser management command to enable the feature on Windows. getpass.getuser automatically falls back to the previous method.

Backport from trunk (r14607).

Note: See TracTickets for help on using tickets.
Back to Top