mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #918] TypeError in oauth2 #550
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#550
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 @shibli-mueed on GitHub (Dec 10, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/918
In file spotipy/oauth2.py in Class
SpotifyAuthBasemethod__del__. Both arguments were of different types.Before the code was:
After fixing:
Environment:
@dieser-niko commented on GitHub (Jan 3, 2023):
I'm not quite sure how you got this error, but the code seems to work without
type().Also I'm not sure if you know how
isinstanceortypeeven work. Look at this example:As you can see, it returns class
typewhich doesn't directly relate to our session we want to check.This would also further break the code:
So just to make sure that you understand the purpose of the
__del__function, here a small explanation:If the class gets destroyed (for example by stopping the python script), it will call this function so it can properly disconnect itself from the server. But before closing the connection, the function has to check if
self._sessionis actually a session. If so, then it can close the connection. But if theself._sessionvalue got changed to an unfamiliar object, then there's a chance that theself._sessiondoesn't have aclose()function as an attribute. And without that check it would throw an AttributeError.I hope you understand that this is not a bug, but an intended feature.
(Python 3.10.5)
@buanzo commented on GitHub (Apr 14, 2023):
Just to add that I am getting the same error in oauth2.py:156, but also in client.py line 214.
@dieser-niko commented on GitHub (Apr 15, 2023):
Can you give me a code snippet that would trigger the error?
@buanzo commented on GitHub (Apr 15, 2023):
There is nothing strange in the code, but I can tell you it only happens when using flask, and the script is reloaded because of a change:
I used the app for a solid one minute (it has 3 flask routes only, heh, I just started it yesterday). Then had the euroka moment of forcing a reload. And immediatelly, the error appeared.
Hope this helps a bit. I can email you the full script if you want, but I assure you, it's a skeleton app written off gpt.
@buanzo commented on GitHub (Apr 15, 2023):
At the time of the reload, type(request.Session) is NoneType in /home/buanzo/.local/lib/python3.10/site-packages/spotipy/oauth2.py:156
@dieser-niko commented on GitHub (Apr 15, 2023):
That would be great, because I just created my own little flask app with spotipy and it works as expected.
It would be nice if you could send it here, I don't really like having my email address out in the open.
@buanzo commented on GitHub (Apr 15, 2023):
Mine is known. @.***
you mail me, and i will not disclose it.
cheers
On Sat, Apr 15, 2023, 10:31 Niko @.***> wrote:
@dieser-niko commented on GitHub (Apr 15, 2023):
It got censored. Try to add the address to your github profile and set it to public
@buanzo commented on GitHub (Apr 15, 2023):
Google my alias, buanzo. find me anywhere. cheers.
On Sat, Apr 15, 2023, 11:01 Niko @.***> wrote:
@stephanebruckert commented on GitHub (Apr 16, 2023):
@buanzo why not paste a Minimal reproducible example here? It allows anyone with time to easily try it.
@timhagel commented on GitHub (Jul 19, 2023):
On my Flask app I was starting the program with
python (file)instead offlask runand it would give me this error@dieser-niko commented on GitHub (Jul 20, 2023):
Can you provide an example code so that I can reproduce the issue
@timhagel commented on GitHub (Jul 20, 2023):
@dieser-niko Yeah here's a really basic Flask and Spotipy app
app.py
If you run this with
python app.pyAnd if you run with
flask runit should start without the errorHope this helps
@dieser-niko commented on GitHub (Jul 21, 2023):
Finally an example. Also I can't believe I'm saying this, but it works on my machine..
My guess is that it might be because of anaconda. Can you try running it in native python instead?
Also about that
python app.py, you need to putapp.run()at the end of the script to make it actually run.@buanzo commented on GitHub (Jul 21, 2023):
Sorry Niko, I totally changed my code in the meantime and the problem went
away, hence my lack of example -offering.
On Fri, Jul 21, 2023, 06:10 Niko @.***> wrote:
@dieser-niko commented on GitHub (Mar 3, 2025):
Closing in favour of #621 as it seems to be related (garbage collection)