Code

Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#7431 closed (fixed)

change import pwd library for import os in createsuperuser

Reported by: httpdss 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 ericholscher 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by ericholscher

comment:1 Changed 6 years ago by ericholscher

  • Component changed from Uncategorized to Authentication
  • Has patch set
  • milestone set to post-1.0
  • Needs documentation unset
  • Needs tests unset
  • Owner nobody deleted
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(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 3 years ago by jezdez

(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).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.