mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #35942 -- Fixed createsuperuser crash on Python 3.13+ when username is unavailable.
Thanks Mariusz Felisiak and Jacob Tyler Walls for reviews.
This commit is contained in:
@@ -115,10 +115,12 @@ def get_system_username():
|
||||
"""
|
||||
try:
|
||||
result = getpass.getuser()
|
||||
except (ImportError, KeyError):
|
||||
# KeyError will be raised by os.getpwuid() (called by getuser())
|
||||
# if there is no corresponding entry in the /etc/passwd file
|
||||
# (a very restricted chroot environment, for example).
|
||||
except (ImportError, KeyError, OSError):
|
||||
# TODO: Drop ImportError and KeyError when dropping support for PY312.
|
||||
# KeyError (Python <3.13) or OSError (Python 3.13+) will be raised by
|
||||
# os.getpwuid() (called by getuser()) if there is no corresponding
|
||||
# entry in the /etc/passwd file (for example, in a very restricted
|
||||
# chroot environment).
|
||||
return ""
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user