mkb79 / Audible

A(Sync) Interface for internal Audible API written in pure Python.
https://audible.readthedocs.io
GNU Affero General Public License v3.0
317 stars 36 forks source link

RecursionError introduced in 0.9.0 in some cases #235

Closed CuriousEl3phant502 closed 1 year ago

CuriousEl3phant502 commented 1 year ago

Describe the bug When using this library sometimes an error occurs: RecursionError: maximum recursion depth exceeded. This does not happen in 0.8.2 only in 0.9.0 and 0.9.1

Example stack trace:

File "...\Lib\site-packages\audible\auth.py", line 254, in len return len(list(self)) ^^^^^^^^^^ File "...\Lib\site-packages\audible\auth.py", line 254, in len return len(list(self)) ^^^^^^^^^^ File "...\Lib\site-packages\audible\auth.py", line 254, in len return len(list(self)) ^^^^^^^^^^ [Previous line repeated 992 more times] RecursionError: maximum recursion depth exceeded

even when setting: sys.setrecursionlimit(1500) it still encounters the error To Reproduce Steps to reproduce the behavior:

Although it can be triggered simply by expanding the object that represents the audible Authenticator object in debug mode in an IDE (that shows all the fields and their values). In some cases expanding the object merely shows a large stack trace like above instead of the fields of the object.

It can even be reproduced by an if check (mostly this in my case and the stacktrace above):

auth= <instantiate object>
if auth: -> RecursionError
 ...

Expected behavior Not throw a RecursionError as it does not in 0.8.2

Screenshots N/A

Desktop (please complete the following information):

Additional context Seems to be the change from:

def __len__(self):
    return len([i for i in self])

to

def __len__(self):
    return len(list(self))

I do not know specifically why though except for the latter is using recursion.

mkb79 commented 1 year ago

@CuriousEl3phant502 Thank your for your detailed information. This helps me find out the reason very quickly. I could reproduce this error.

I'm think I've solved this in this branch. It works for me! Maybe you can test this?

CuriousEl3phant502 commented 1 year ago

@mkb79 thanks for such a quick response. It looks like it's fixed as far as i can tell. I'm no longer able to reproduce this.

Also, one side note, another thing i noticed. For "quality" it looks like the api no longer allows "Extreme" as an option. For example, see your example code on line 63 https://github.com/mkb79/Audible/blob/master/examples/download_books_aaxc.py

From what i can tell, if you use anything other than "High" or "Normal" you get Bad Request (400) now.

mkb79 commented 1 year ago

@CuriousEl3phant502

Also, one side note, another thing i noticed. For "quality" it looks like the api no longer allows "Extreme" as an option.

Thank you for this information. I'll fix this in the readme!

Can I close this issue now?

Edit: This issue was closed automatically after merge the pull request. If this issue occurs again, please re-open this issue.