#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)
by , 16 years ago
Attachment: | windows-superuser.diff added |
---|
comment:1 by , 16 years ago
Component: | Uncategorized → Authentication |
---|---|
Has patch: | set |
milestone: | → post-1.0 |
Owner: | removed |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
milestone: | post-1.0 |
---|
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 14 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).
Milestone post-1.0 deleted