The issue is caused by token variable declaration implemented with the walrus (:=) operator as part of the assert statement -- when the statement is elided as Python runs with -O, the subsequent statement(s) (1) accessing token correctly cause raising of UnboundLocalError trying to access token.
The issue is caused by
token
variable declaration implemented with the walrus (:=
) operator as part of theassert
statement -- when the statement is elided as Python runs with-O
, the subsequent statement(s) (1) accessingtoken
correctly cause raising ofUnboundLocalError
trying to accesstoken
.