#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)
Change History (5)
Changed 15 years ago by
Attachment: | windows-superuser.diff added |
---|
comment:1 Changed 15 years ago by
Component: | Uncategorized → Authentication |
---|---|
Has patch: | set |
milestone: | → post-1.0 |
Owner: | nobody deleted |
Triage Stage: | Unreviewed → Accepted |
comment:2 Changed 15 years ago by
milestone: | post-1.0 |
---|
comment:3 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 Changed 13 years ago by
(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).
Milestone post-1.0 deleted