Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 #604

Closed
Vinfall opened this issue Nov 9, 2022 · 1 comment

Comments

@Vinfall
Copy link
Contributor

Vinfall commented Nov 9, 2022

I got the warning DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 after Void Linux bumped the default Python version from 3.10 to 3.11 (yet I don't know why Termux with Python 3.11 does not show the warning, maybe because I installed it from PyPI?).

Although it could take a lot of time for us to get our hands on 3.13, it's still better to get prepared in advance.

There are two ways:

  1. Suppress the warning like DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 beeware/briefcase#868, but I don't see buku use pyproject.toml
  2. Replace cgi.parse_header with email.message as was mentioned in DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 Pylons/webob#437 and https://peps.python.org/pep-0594/#cgi.

I took a brief look at the ToDo list, coding guideline and code base, it seems that cgi is rarely used so the fix should be simple.

Just these lines?

buku/buku

Lines 3809 to 3820 in 4384cbd

if soup.meta and soup.meta.get('charset') is not None:
charset = soup.meta.get('charset')
elif 'content-type' in resp.headers:
_, params = cgi.parse_header(resp.headers['content-type'])
if params.get('charset') is not None:
charset = params.get('charset')
if not charset and soup:
meta_tag = soup.find('meta', attrs={'http-equiv': 'Content-Type'})
if meta_tag:
_, params = cgi.parse_header(meta_tag.attrs['content'])
charset = params.get('charset', charset)

A sample fix: https://github.com/Vinfall/buku/commit/5de3c11e559c5700f62c8961460ce0497e3275fe.

If you'd liike to remove the warning for now, I can raise a PR 😆.

@jarun
Copy link
Owner

jarun commented Nov 9, 2022

Please raise the PR.

@jarun jarun closed this as completed in 80fc71c Nov 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants