mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #571] UnboundLocalError: local variable 'response' referenced before assignment #342
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @peterbe on GitHub (Sep 5, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/571
Describe the bug
If something goes wrong in
self._session.request()the variableresponsewill never be set. Leading to aUnboundLocalError: local variable 'response' referenced before assignmentYour code

Sorry.
Error from my Rollbar:
Expected behavior
Requests fail and that's fine. Judging from skimming the code, it's trying to package a message to go with raising a
SpotifyExceptionbut it's failing to do so.Output
Paste and format errors (with complete stacktrace) or logs. Make sure to remove sensitive information.
Environment:
spotipy==2.13.0Additional context
Relying on
UnboundLocalErrorfrom a caller isn't nice. If it wasSpotifyExceptionI could do something like this:@stephanebruckert commented on GitHub (Oct 2, 2020):
Should be fixed by https://github.com/plamere/spotipy/pull/580