Revert "Bump cherrypy from 18.8.0 to 18.9.0 (#2266)"

This reverts commit faef9a94c4.
This commit is contained in:
JonnyWong16 2024-03-24 17:40:56 -07:00
parent fcd8ef11f4
commit 2fc618c01f
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
673 changed files with 11579 additions and 159846 deletions

View file

@ -452,6 +452,6 @@ class WSGIErrorHandler(logging.Handler):
class LazyRfc3339UtcTime(object):
def __str__(self):
"""Return utcnow() in RFC3339 UTC Format."""
iso_formatted_now = datetime.datetime.utcnow().isoformat('T')
return f'{iso_formatted_now!s}Z'
"""Return now() in RFC3339 UTC Format."""
now = datetime.datetime.now()
return now.isoformat('T') + 'Z'

View file

@ -622,15 +622,13 @@ def autovary(ignore=None, debug=False):
def convert_params(exception=ValueError, error=400):
"""Convert request params based on function annotations.
"""Convert request params based on function annotations, with error handling.
This function also processes errors that are subclasses of ``exception``.
exception
Exception class to catch.
:param BaseException exception: Exception class to catch.
:type exception: BaseException
:param error: The HTTP status code to return to the client on failure.
:type error: int
status
The HTTP error code to return to the client on failure.
"""
request = cherrypy.serving.request
types = request.handler.callable.__annotations__

View file

@ -47,9 +47,7 @@ try:
import pstats
def new_func_strip_path(func_name):
"""Add ``__init__`` modules' parents.
This makes the profiler output more readable.
"""Make profiler output more readable by adding `__init__` modules' parents
"""
filename, line, name = func_name
if filename.endswith('__init__.py'):

View file

@ -188,7 +188,7 @@ class Parser(configparser.ConfigParser):
def dict_from_file(self, file):
if hasattr(file, 'read'):
self.read_file(file)
self.readfp(file)
else:
self.read(file)
return self.as_dict()

View file

@ -1,18 +1,19 @@
"""Module with helpers for serving static files."""
import mimetypes
import os
import platform
import re
import stat
import unicodedata
import mimetypes
import urllib.parse
import unicodedata
from email.generator import _make_boundary as make_boundary
from io import UnsupportedOperation
import cherrypy
from cherrypy._cpcompat import ntob
from cherrypy.lib import cptools, file_generator_limited, httputil
from cherrypy.lib import cptools, httputil, file_generator_limited
def _setup_mimetypes():
@ -184,10 +185,7 @@ def serve_fileobj(fileobj, content_type=None, disposition=None, name=None,
def _serve_fileobj(fileobj, content_type, content_length, debug=False):
"""Set ``response.body`` to the given file object, perhaps ranged.
Internal helper.
"""
"""Internal. Set response.body to the given file object, perhaps ranged."""
response = cherrypy.serving.response
# HTTP/1.0 didn't have Range/Accept-Ranges headers, or the 206 code

View file

@ -494,7 +494,7 @@ class Bus(object):
"Cannot reconstruct command from '-c'. "
'Ref: https://github.com/cherrypy/cherrypy/issues/1545')
except AttributeError:
"""It looks Py_GetArgcArgv's completely absent in some environments
"""It looks Py_GetArgcArgv is completely absent in some environments
It is known, that there's no Py_GetArgcArgv in MS Windows and
``ctypes`` module is completely absent in Google AppEngine

View file

@ -136,9 +136,6 @@ class HTTPTests(helper.CPWebCase):
self.assertStatus(200)
self.assertBody(b'Hello world!')
response.close()
c.close()
# Now send a message that has no Content-Length, but does send a body.
# Verify that CP times out the socket and responds
# with 411 Length Required.
@ -162,9 +159,6 @@ class HTTPTests(helper.CPWebCase):
self.status = str(response.status)
self.assertStatus(411)
response.close()
c.close()
def test_post_multipart(self):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
# generate file contents for a large post
@ -190,9 +184,6 @@ class HTTPTests(helper.CPWebCase):
parts = ['%s * 65536' % ch for ch in alphabet]
self.assertBody(', '.join(parts))
response.close()
c.close()
def test_post_filename_with_special_characters(self):
"""Testing that we can handle filenames with special characters.
@ -226,9 +217,6 @@ class HTTPTests(helper.CPWebCase):
self.assertStatus(200)
self.assertBody(fname)
response.close()
c.close()
def test_malformed_request_line(self):
if getattr(cherrypy.server, 'using_apache', False):
return self.skip('skipped due to known Apache differences...')
@ -276,9 +264,6 @@ class HTTPTests(helper.CPWebCase):
self.body = response.fp.read(20)
self.assertBody('Illegal header line.')
response.close()
c.close()
def test_http_over_https(self):
if self.scheme != 'https':
return self.skip('skipped (not running HTTPS)... ')

View file

@ -150,8 +150,6 @@ class IteratorTest(helper.CPWebCase):
self.assertStatus(200)
self.assertBody('0')
itr_conn.close()
# Now we do the same check with streaming - some classes will
# be automatically closed, while others cannot.
stream_counts = {}

View file

@ -1,6 +1,5 @@
"""Basic tests for the CherryPy core: request handling."""
import datetime
import logging
from cheroot.test import webtest
@ -198,33 +197,6 @@ def test_custom_log_format(log_tracker, monkeypatch, server):
)
def test_utc_in_timez(monkeypatch):
"""Test that ``LazyRfc3339UtcTime`` is rendered as ``str`` using UTC timestamp."""
utcoffset8_local_time_in_naive_utc = (
datetime.datetime(
year=2020,
month=1,
day=1,
hour=1,
minute=23,
second=45,
tzinfo=datetime.timezone(datetime.timedelta(hours=8)),
)
.astimezone(datetime.timezone.utc)
.replace(tzinfo=None)
)
class mock_datetime:
@classmethod
def utcnow(cls):
return utcoffset8_local_time_in_naive_utc
monkeypatch.setattr('datetime.datetime', mock_datetime)
rfc3339_utc_time = str(cherrypy._cplogging.LazyRfc3339UtcTime())
expected_time = '2019-12-31T17:23:45Z'
assert rfc3339_utc_time == expected_time
def test_timez_log_format(log_tracker, monkeypatch, server):
"""Test a customized access_log_format string, which is a
feature of _cplogging.LogManager.access()."""