From e6b4cce97eef17716004625bcf6754fa930f2618 Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 24 Oct 2024 15:44:53 -0700 Subject: [PATCH] catch OSError from getpass.getuser --- CHANGES.rst | 2 ++ src/werkzeug/debug/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 42dae2470..5350589b2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,8 @@ Unreleased - Logging works with client addresses containing an IPv6 scope :issue:`2952` - Ignore invalid authorization parameters. :issue:`2955` - Improve type annotation fore ``SharedDataMiddleware``. :issue:`2958` +- Compatibility with Python 3.13 when generating debugger pin and the current + UID does not have an associated name. :issue:`2957` Version 3.0.4 diff --git a/src/werkzeug/debug/__init__.py b/src/werkzeug/debug/__init__.py index 69ad3f4f4..0c4cabd89 100644 --- a/src/werkzeug/debug/__init__.py +++ b/src/werkzeug/debug/__init__.py @@ -173,7 +173,8 @@ def get_pin_and_cookie_name( # App Engine. It may also raise a KeyError if the UID does not # have a username, such as in Docker. username = getpass.getuser() - except (ImportError, KeyError): + # Python >= 3.13 only raises OSError + except (ImportError, KeyError, OSError): username = None mod = sys.modules.get(modname)