Protect cgi#176
Merged
Cito merged 1 commit intoformencode:mainfrom Nov 10, 2023
sqlobject:remove-cgi-py313
Merged
Conversation
Cito
reviewed
Nov 10, 2023
Member
Cito
left a comment
There was a problem hiding this comment.
Thanks. I made some suggestions.
Module `cgi` was declared obsolete in Python 3.11 and will be removed in 3.13. Fixes: #175.
Cito
approved these changes
Nov 10, 2023
lambacck
added a commit
that referenced
this pull request
Jan 31, 2025
In Python 3.13 and later the cgi module has been removed and this meant that importing the `cgi` module started making it so `formencode.validators` could not be imported. This was resolved in #176 by detecting the import error, setting `cgi` to `None`, and then skipping behaviour that used `cgi.FieldStorage`. Using `FieldStorageUploadConverter` without `cgi.FieldStorage` does not make sense. This change adds a check to `FieldStorageUploadConverter.__classinit__` to prevent instantiating it like we do for DNS validators so that using it doesn't silently do nothing. Probably if you are using FieldStorageUploadConverter then you'll have `legacy-cgi` installed because you are either already using it directly, or you are getting it transitively through something like WebOb.
lambacck
added a commit
that referenced
this pull request
Jan 31, 2025
In Python 3.13 and later the cgi module has been removed and this meant that importing the `cgi` module started making it so `formencode.validators` could not be imported. This was resolved in #176 by detecting the import error, setting `cgi` to `None`, and then skipping behaviour that used `cgi.FieldStorage`. Using `FieldStorageUploadConverter` without `cgi.FieldStorage` does not make sense. This change adds a check to `FieldStorageUploadConverter.__classinit__` to prevent instantiating it like we do for DNS validators so that using it doesn't silently do nothing. Probably if you are using FieldStorageUploadConverter then you'll have `legacy-cgi` installed because you are either already using it directly, or you are getting it transitively through something like WebOb.
lambacck
added a commit
that referenced
this pull request
Jan 31, 2025
In Python 3.13 and later the cgi module has been removed and this meant that importing the `cgi` module started making it so `formencode.validators` could not be imported. This was resolved in #176 by detecting the import error, setting `cgi` to `None`, and then skipping behaviour that used `cgi.FieldStorage`. Using `FieldStorageUploadConverter` without `cgi.FieldStorage` does not make sense. This change adds a check to `FieldStorageUploadConverter.__init_` to prevent instantiating it like we do for DNS validators so that using it doesn't silently do nothing. Probably if you are using FieldStorageUploadConverter then you'll have `legacy-cgi` installed because you are either already using it directly, or you are getting it transitively through something like WebOb.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Protect classes that requires
cgimoduleOnly define
FieldStorageUploadConverterandFileUploadKeeperifcgimodule exist. It was declared obsolete in Python 3.11 and will be removed in 3.13.