Bug 263862 - www/py-tvdb_api: Fails to run after www/py-requests-cache update: ImportError: cannot import name '_to_bytes' from 'requests_cache.backends.base
Summary: www/py-tvdb_api: Fails to run after www/py-requests-cache update: ImportError...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Muhammad Moinur Rahman
URL:
Keywords: needs-patch, regression
Depends on:
Blocks:
 
Reported: 2022-05-08 10:15 UTC by huber.georg
Modified: 2022-05-08 23:29 UTC (History)
3 users (show)

See Also:
linimon: maintainer-feedback? (bofh)
koobs: maintainer-feedback? (sunpoet)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description huber.georg 2022-05-08 10:15:17 UTC
Hi, I recently upgraded from python3.8.12 to 3.8.13.

Now, when I use tvnamer (which uses tvdb_api) I get the following error:

#tvnamer .

Traceback (most recent call last):
  File "/usr/local/bin/tvnamer", line 33, in <module>
    sys.exit(load_entry_point('tvnamer==3.0.4', 'console_scripts', 'tvnamer')())
  File "/usr/local/bin/tvnamer", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/tvnamer/main.py", line 18, in <module>
    import tvdb_api
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 34, in <module>
    from requests_cache.backends.base import _to_bytes, _DEFAULT_HEADERS
ImportError: cannot import name '_to_bytes' from 'requests_cache.backends.base' (/usr/local/lib/python3.8/site-packages/requests_cache/backends/base.py)

I asked over at github, where tvnamer is maintained and was told that it is not an error in tvnamer but with tvdb_api, which might have been fixed in September 2021 (https://github.com/dbr/tvdb_api/commit/f8db8e91377b30a6da078a43467ebf2f3b38227e). The tvdb_api port available on freshports was not updated since May 2021 though.

Unfortunately I am not a coder myself, so I cannot apply the patch myself. Is there a way you can fix this?

Many thanks

Georg
Comment 1 commit-hook freebsd_committer 2022-05-08 14:25:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=27beb3553afb9e379d1b6d16fa6dce99f9a12a54

commit 27beb3553afb9e379d1b6d16fa6dce99f9a12a54
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2022-05-08 14:21:46 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2022-05-08 14:21:46 +0000

    www/py-tvdb_api: Runtime fix

    multimedia/py-tvnamer is failing to run after Python upgrade to 3.8.13.
    This update fix this runtime issue. py-tvdb_api is the core library used
    by py-tvnamer.

    PR:             263862
    Reported by:    huber.georg@gmail.com

 www/py-tvdb_api/Makefile | 8 ++++++--
 www/py-tvdb_api/distinfo | 4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)
Comment 2 huber.georg 2022-05-08 18:07:22 UTC
Many thanks for the speedy implementation. However, now I get the following:

Traceback (most recent call last):
  File "/usr/local/bin/tvnamer", line 33, in <module>
    sys.exit(load_entry_point('tvnamer==3.0.4', 'console_scripts', 'tvnamer')())
  File "/usr/local/lib/python3.8/site-packages/tvnamer/main.py", line 474, in main
    tvnamer(paths = sorted(args))
  File "/usr/local/lib/python3.8/site-packages/tvnamer/main.py", line 370, in tvnamer
    processFile(tvdb_instance, episode)
  File "/usr/local/lib/python3.8/site-packages/tvnamer/main.py", line 175, in processFile
    episode.populateFromTvdb(tvdb_instance, force_name=Config['force_name'], series_id=Config['series_id'])
  File "/usr/local/lib/python3.8/site-packages/tvnamer/utils.py", line 641, in populateFromTvdb
    show = tvdb_instance[force_name or self.seriesname]
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 1152, in __getitem__
    sid = self._nameToSid(key)
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 1136, in _nameToSid
    selected_series = self._getSeries(name)
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 935, in _getSeries
    all_series = self.search(series)
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 914, in search
    series_resp = self._getetsrc(self.config['url_getSeries'] % (series))
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 874, in _getetsrc
    src = self._loadUrl(url, language=language)
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 811, in _loadUrl
    self.authorize()
  File "/usr/local/lib/python3.8/site-packages/tvdb_api.py", line 859, in authorize
    r = self.session.post(
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 577, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests_cache/session.py", line 115, in request
    return super().request(method, url, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests_cache/session.py", line 127, in send
    cache_key = self.cache.create_key(request, **kwargs)
TypeError: create_key() got an unexpected keyword argument 'timeout'
Comment 3 Muhammad Moinur Rahman freebsd_committer 2022-05-08 22:21:58 UTC
(In reply to huber.georg from comment #2)
In previous I actually used to use this application a lot but now I don't use it anymore, but still maintaining it. So it's hard for me to troubleshoot this problem. However if you can dig some solution which needs to be translated to code I can take care of it.

And from what I can see from the error is that tvdb_api actually do not support latest version of requests_cache. Currently we have 0.9.4 on the tree(https://www.freshports.org/www/py-requests-cache/) which was just released 16 days ago.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-08 23:29:10 UTC
^Triage: www/py-requests-cache updated to 0.9.3 and 0.9.4 in ports 80923c7c2312 and ports c2a2614fd6d0 respectively, request feedback from sunpoet@