Skip to content

Debugger fails to start under Python 3.13 when user has no name #2957

@Derkades

Description

@Derkades

python/cpython#29739

getpass.getuser() now raises OSError if the current user does not have a username:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/getpass.py", line 173, in getuser
    return pwd.getpwuid(os.getuid())[0]
           ~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'getpwuid(): uid not found: 1000'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  [ own code removed ]
  File "/mp/raphson_mp/__main__.py", line 31, in handle_start
    app.run(host=args.host, port=args.port, debug=True)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/flask/app.py", line 625, in run
    run_simple(t.cast(str, host), port, self, **options)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/werkzeug/serving.py", line 1081, in run_simple
    application = DebuggedApplication(application, evalex=use_evalex)
  File "/usr/local/lib/python3.13/site-packages/werkzeug/debug/__init__.py", line 297, in __init__
    if self.pin is None:
       ^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/werkzeug/debug/__init__.py", line 315, in pin
    pin_cookie = get_pin_and_cookie_name(self.app)
  File "/usr/local/lib/python3.13/site-packages/werkzeug/debug/__init__.py", line 175, in get_pin_and_cookie_name
    username = getpass.getuser()
  File "/usr/local/lib/python3.13/getpass.py", line 175, in getuser
    raise OSError('No username set in the environment') from e
OSError: No username set in the environment

Under Python 3.12, the exact same code runs without an error and is able to start the development environment.

Environment:

  • Python version: 3.13
  • Werkzeug version: 3.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions