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

fix cgi deprecation warning #3939

Open
hboetes opened this issue Feb 14, 2024 · 0 comments
Open

fix cgi deprecation warning #3939

hboetes opened this issue Feb 14, 2024 · 0 comments

Comments

@hboetes
Copy link

hboetes commented Feb 14, 2024

I kept noticing this deprecation warning:

/home/han/.virtualenv/flexget/lib/python3.12/site-packages/flexget/plugins/cli/inject.py:2: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
import cgi

So I started digging around in the docs and came up with the following patch:

%  diff -u /home/han/.virtualenv/flexget/lib/python3.12/site-packages/flexget/plugins/cli/inject.py.orig /home/han/.virtualenv/flexget/lib/python3.12/site-packages/flexget/plugins/cli/inject.py
--- /home/han/.virtualenv/flexget/lib/python3.12/site-packages/flexget/plugins/cli/inject.py.orig	2024-02-14 18:56:24.723822371 +0100
+++ /home/han/.virtualenv/flexget/lib/python3.12/site-packages/flexget/plugins/cli/inject.py	2024-02-14 18:59:18.184871193 +0100
@@ -1,5 +1,5 @@
 import argparse
-import cgi
+from email.header import Header
 import random
 import string
 
@@ -23,7 +23,7 @@
     if options.url and not options.title:
         # Attempt to get a title from the URL response's headers
         try:
-            value, params = cgi.parse_header(
+            value, params = Header(
                 requests.head(options.url).headers['Content-Disposition']
             )
             options.title = params['filename']

I have no idea if this really fixes the issue, or just the symptom, so please double triple check before applying this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant