From b6f309fa3bd12f05f47bdc9084aafaefe5d823fb Mon Sep 17 00:00:00 2001 From: guidogiunchi <47217739+guidogiunchi@users.noreply.github.com> Date: Thu, 18 Sep 2025 13:58:14 +0200 Subject: [PATCH] Update DroopyFieldStorage __init__ args to be compatible with py 3.11+ --- droopy | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/droopy b/droopy index 5e3102c..9f0a46c 100755 --- a/droopy +++ b/droopy @@ -6,6 +6,7 @@ Copyright 2008-2013 (c) Pierre Duquesne Licensed under the New BSD License. Changelog + 20250918 * Update DroopyFieldStorage __init__ args to be compatible with py 3.11+ 20190628 * Added multi-user support 20190614 * Added various file sort options 20151025 * Global variables removed @@ -173,26 +174,29 @@ class DroopyFieldStorage(cgi.FieldStorage): # Would love to do a **kwargs job here but cgi has some recursive # magic that passes all possible arguments positionally.. - def __init__(self, fp=None, headers=None, outerboundary=b'', - environ=os.environ, keep_blank_values=0, strict_parsing=0, - limit=None, encoding='utf-8', errors='replace', - directory='.'): + # def __init__(self, fp=None, headers=None, outerboundary=b'', + # environ=os.environ, keep_blank_values=0, strict_parsing=0, + # limit=None, encoding='utf-8', errors='replace', + # directory='.'): + + def __init__(self, *args, directory='.', **kwargs): + self.directory = directory + super().__init__(*args, **kwargs) """ Adds 'directory' argument to FieldStorage.__init__. Retains compatibility with FieldStorage.__init__ (which involves magic) """ - self.directory = directory # Not only is cgi.FieldStorage full of magic, it's DIFFERENT # magic in Py2/Py3. Here's a case of the core library making # life difficult, in a class that's *supposed to be subclassed*! - if sys.version_info > (3,): - cgi.FieldStorage.__init__(self, fp, headers, outerboundary, - environ, keep_blank_values, - strict_parsing, limit, encoding, errors) - else: - cgi.FieldStorage.__init__(self, fp, headers, outerboundary, - environ, keep_blank_values, - strict_parsing) + #if sys.version_info > (3,): + # cgi.FieldStorage.__init__(self, fp, headers, outerboundary, + # environ, keep_blank_values, + # strict_parsing, limit, encoding, errors) + #else: + # cgi.FieldStorage.__init__(self, fp, headers, outerboundary, + # environ, keep_blank_values, + # strict_parsing) # Binary is passed in Py2 but not Py3. def make_file(self, binary=None):