Skip to content

Commit

Permalink
defer cgi import when ftp is not used (#13014)
Browse files Browse the repository at this point in the history
* defer cgi import

* deprecate ftp STOR functions; use function-level instead of module-level import.
  • Loading branch information
dholth committed Sep 5, 2023
1 parent f29c645 commit e9870cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion conda/gateways/connection/adapters/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
import cgi
import ftplib
import os
from base64 import b64decode
from io import BytesIO, StringIO
from logging import getLogger

from conda.deprecations import deprecated

from ....common.url import urlparse
from ....exceptions import AuthenticationError
from .. import BaseAdapter, Response, dispatch_hook
Expand Down Expand Up @@ -132,6 +133,7 @@ def retr(self, path, request):

return response

@deprecated("24.3", "24.9")
def stor(self, path, request):
"""Executes the FTP STOR command on the given path."""
# First, get the file handle. We assume (bravely)
Expand Down Expand Up @@ -266,10 +268,13 @@ def build_response(request, data, code, encoding):
return response


@deprecated("24.3", "24.9")
def parse_multipart_files(request):
"""Given a prepared request, return a file-like object containing the
original data. This is pretty hacky.
"""
import cgi

# Start by grabbing the pdict.
_, pdict = cgi.parse_header(request.headers["Content-Type"])

Expand Down
20 changes: 20 additions & 0 deletions news/13013-remove-cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* Remove import of deprecated cgi module by deprecating ftp STOR support
(#13013)

### Docs

* <news item>

### Other

* <news item>

0 comments on commit e9870cc

Please sign in to comment.