spotipy: TypeError in oauth2

In file spotipy/oauth2.py in Class SpotifyAuthBase method __del__. Both arguments were of different types.

File "C:\Storage\Python Programs\project_vid_ed\.vEnv\lib\site-packages\spotipy\oauth2.py", line 156, in __del__
TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union

Before the code was:

def __del__(self):
        """Make sure the connection (pool) gets closed"""
        if isinstance(self._session,requests.Session):
            self._session.close()

After fixing:

def __del__(self):
        """Make sure the connection (pool) gets closed"""
        # print(type(self._session))
        if isinstance(type(self._session),type(requests.Session)):
            self._session.close()

Environment:

  • OS: Windows 11
  • Python version: 3.10.4
  • spotipy version: 2.21.0
  • IDE: Visual Studio Code

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

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:

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 put app.run() at the end of the script to make it actually run.

— Reply to this email directly, view it on GitHub https://github.com/spotipy-dev/spotipy/issues/918#issuecomment-1645260860, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHBT6TF573QQBPQTM26NTXRJBPNANCNFSM6AAAAAASZ6Z7GA . You are receiving this because you were mentioned.Message ID: @.***>