Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#21439 closed Bug (fixed)

UnboundLocalError in auth backends' get_user

Reported by: mattrobenolt 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 19 months ago by mattrobenolt

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.6 to 1.5

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

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

Last edited 19 months ago by mattrobenolt (previous) (diff)

comment:2 Changed 19 months ago by charettes

  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.5 to master

comment:3 Changed 19 months ago by mattrobenolt

comment:4 Changed 19 months ago by Matt Robenolt <matt@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 3560ef043e5c70de30ca7d5d7d6d09c150eb6eb4:

Propagate get_user_model exception from get_user

Fixes #21439

comment:5 Changed 19 months 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 19 months 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