Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21439 closed Bug (fixed)

UnboundLocalError in auth backends' get_user

Reported by: Matt Robenolt Owned by: nobody
Component: contrib.auth Version: master
Severity: Normal Keywords: auth, bug, user
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If get_user_model were to raise an exception, it ends up masking that exception and in turn raising UnboundLocalError: local variable 'UserModel' referenced before assignment.

Change History (6)

comment:1 Changed 3 years ago by Matt Robenolt

Version: 1.61.5

Seems to have been introduced with the first implementation of the new user backends.

https://github.com/django/django/commit/70a0de37d132e5f1514fb939875f69649f103124

Last edited 3 years ago by Matt Robenolt (previous) (diff)

comment:2 Changed 3 years ago by Simon Charette

Triage Stage: UnreviewedAccepted
Version: 1.5master

comment:3 Changed 3 years ago by Matt Robenolt

comment:4 Changed 3 years ago by Matt Robenolt <matt@…>

Resolution: fixed
Status: newclosed

In 3560ef043e5c70de30ca7d5d7d6d09c150eb6eb4:

Propagate get_user_model exception from get_user

Fixes #21439

comment:5 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

In 3e845b79ce9f74c0942e2c41259d33bd835f2941:

Merge pull request #1920 from mattrobenolt/unboundlocalerror

Fixed #21439 -- Propagated get_user_model exception from get_user

comment:6 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

In 0aa06bd3782d1bf6961ba846ec79aded82daa5c2:

[1.6.x] Propagate get_user_model exception from get_user

Fixes #21439

Backport of 3560ef04 from master.

Conflicts:

django/contrib/auth/tests/test_auth_backends.py

Note: See TracTickets for help on using tickets.
Back to Top