Opened 9 years ago

Closed 6 years ago

Last modified 6 years ago

#7431 closed (fixed)

change import pwd library for import os in createsuperuser

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

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 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Eric Holscher

Attachment: windows-superuser.diff added

comment:1 Changed 8 years ago by Eric Holscher

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

comment:2 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 Changed 6 years ago by Jannis Leidel

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 Changed 6 years ago by Jannis Leidel

(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