Skip to content

Conversation

@jayClean
Copy link
Contributor

@jayClean jayClean commented Dec 9, 2025

Fix AttributeError when pin_security=False (#3075)

Starting with werkzeug 3.1.4, initializing DebuggedApplication with
pin_security=False raises an AttributeError because the pin setter
attempts to delete self._pin before it has been initialized.

The issue occurs in __init__ when pin_security=False: it calls
self.pin = None, which triggers the setter that tries to execute
del self._pin. Since _pin hasn't been created yet (it's lazily
initialized by the getter), this raises an AttributeError.

The fix changes the setter to explicitly set _pin = None instead of
deleting it. This prevents the error and ensures that when pin security
is disabled, the pin remains None and doesn't get regenerated by the
lazy getter. The type annotation for _pin is also updated from str
to str | None to reflect that it can be None.

#3075
fixes #3075

  • Added test case test_debugged_application_pin_security_false() that
    verifies DebuggedApplication can be initialized with pin_security=False
    without raising an error. The test would fail before the fix.

  • Updated type annotation for _pin from str to str | None to allow
    None values.

  • Added entry in CHANGES.rst under Version 3.2.0 (Unreleased) section.

  • No documentation changes needed as the behavior is now correct and
    matches the documented API.

@davidism davidism changed the title Fix: initialize _pin in DebuggedApplication.__init__ to avoid Attribu… initialize _pin in debugger Jan 2, 2026
@davidism davidism added this to the 3.1.5 milestone Jan 2, 2026
@davidism davidism changed the base branch from main to stable January 2, 2026 18:43
@davidism davidism force-pushed the fix/3075-init-_pin branch from 44416f7 to fa0f4f2 Compare January 2, 2026 18:49
@davidism davidism merged commit b48878c into pallets:stable Jan 2, 2026
13 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DebugApplication(..., pin_security=False) no longer works

2 participants