diff options
author | morpheus65535 <[email protected]> | 2021-12-01 15:47:00 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-12-01 15:47:00 -0500 |
commit | 402c82d84f7bd51353348bea7d1a876ad9ecc5b1 (patch) | |
tree | c0635920594b9220ed31a20948b684c3b5a8a001 /libs/flask_restful | |
parent | 2d214bfbd5f9d1598c01b2e2dd35efa67ccb43af (diff) | |
download | bazarr-402c82d84f7bd51353348bea7d1a876ad9ecc5b1.tar.gz bazarr-402c82d84f7bd51353348bea7d1a876ad9ecc5b1.zip |
Upgraded some embedded dependencies to be ready for Python 3.10. This doesn't mean that it's fully supported right now.
Diffstat (limited to 'libs/flask_restful')
-rw-r--r-- | libs/flask_restful/__init__.py | 17 | ||||
-rw-r--r-- | libs/flask_restful/__version__.py | 2 | ||||
-rw-r--r-- | libs/flask_restful/fields.py | 5 | ||||
-rw-r--r-- | libs/flask_restful/inputs.py | 2 | ||||
-rw-r--r-- | libs/flask_restful/reqparse.py | 9 | ||||
-rw-r--r-- | libs/flask_restful/utils/__init__.py | 4 |
6 files changed, 24 insertions, 15 deletions
diff --git a/libs/flask_restful/__init__.py b/libs/flask_restful/__init__.py index 365c068ad..e9f9d9f6f 100644 --- a/libs/flask_restful/__init__.py +++ b/libs/flask_restful/__init__.py @@ -11,10 +11,12 @@ from werkzeug.wrappers import Response as ResponseBase from flask_restful.utils import http_status_message, unpack, OrderedDict from flask_restful.representations.json import output_json import sys -from flask.helpers import _endpoint_from_view_func from types import MethodType import operator -from collections import Mapping +try: + from collections.abc import Mapping +except ImportError: + from collections import Mapping __all__ = ('Api', 'Resource', 'marshal', 'marshal_with', 'marshal_with_field', 'abort') @@ -58,7 +60,7 @@ class Api(object): to handle 404 errors throughout your app :param serve_challenge_on_401: Whether to serve a challenge response to clients on receiving 401. This usually leads to a username/password - popup in web browers. + popup in web browsers. :param url_part_order: A string that controls the order that the pieces of the url are concatenated when the full url is constructed. 'b' is the blueprint (or blueprint registration) prefix, 'a' is the api @@ -153,7 +155,7 @@ class Api(object): rule = blueprint_setup.url_prefix + rule options.setdefault('subdomain', blueprint_setup.subdomain) if endpoint is None: - endpoint = _endpoint_from_view_func(view_func) + endpoint = view_func.__name__ defaults = blueprint_setup.url_defaults if 'defaults' in options: defaults = dict(defaults, **options.pop('defaults')) @@ -287,6 +289,13 @@ class Api(object): headers = Headers() if isinstance(e, HTTPException): + if e.response is not None: + # If HTTPException is initialized with a response, then return e.get_response(). + # This prevents specified error response from being overridden. + # eg. HTTPException(response=Response("Hello World")) + resp = e.get_response() + return resp + code = e.code default_data = { 'message': getattr(e, 'description', http_status_message(code)) diff --git a/libs/flask_restful/__version__.py b/libs/flask_restful/__version__.py index ebac6ac55..d0ecbea71 100644 --- a/libs/flask_restful/__version__.py +++ b/libs/flask_restful/__version__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python -__version__ = '0.3.7' +__version__ = '0.3.9' diff --git a/libs/flask_restful/fields.py b/libs/flask_restful/fields.py index 27531d2cb..70a54060c 100644 --- a/libs/flask_restful/fields.py +++ b/libs/flask_restful/fields.py @@ -1,6 +1,4 @@ -from datetime import datetime from calendar import timegm -import pytz from decimal import Decimal as MyDecimal, ROUND_HALF_EVEN from email.utils import formatdate import six @@ -9,8 +7,7 @@ try: except ImportError: # python3 from urllib.parse import urlparse, urlunparse - -from flask_restful import inputs, marshal +from flask_restful import marshal from flask import url_for, request __all__ = ["String", "FormattedString", "Url", "DateTime", "Float", diff --git a/libs/flask_restful/inputs.py b/libs/flask_restful/inputs.py index 141fa9ad4..1b36c85e0 100644 --- a/libs/flask_restful/inputs.py +++ b/libs/flask_restful/inputs.py @@ -269,7 +269,7 @@ def datetime_from_rfc822(datetime_str): def datetime_from_iso8601(datetime_str): - """Turns an ISO8601 formatted date into a datetime object. + """Turns an ISO8601 formatted datetime into a datetime object. Example:: diff --git a/libs/flask_restful/reqparse.py b/libs/flask_restful/reqparse.py index 754f14c1e..9bb309914 100644 --- a/libs/flask_restful/reqparse.py +++ b/libs/flask_restful/reqparse.py @@ -1,6 +1,9 @@ from copy import deepcopy -import collections +try: + from collections.abc import MutableSequence +except ImportError: + from collections import MutableSequence from flask import current_app, request from werkzeug.datastructures import MultiDict, FileStorage from werkzeug import exceptions @@ -146,7 +149,7 @@ class Argument(object): except TypeError: try: if self.type is decimal.Decimal: - return self.type(str(value), self.name) + return self.type(str(value)) else: return self.type(value, self.name) except TypeError: @@ -194,7 +197,7 @@ class Argument(object): values = source.getlist(name) else: values = source.get(name) - if not (isinstance(values, collections.MutableSequence) and self.action == 'append'): + if not (isinstance(values, MutableSequence) and self.action == 'append'): values = [values] for value in values: diff --git a/libs/flask_restful/utils/__init__.py b/libs/flask_restful/utils/__init__.py index 7d6baecb0..8f267b9d2 100644 --- a/libs/flask_restful/utils/__init__.py +++ b/libs/flask_restful/utils/__init__.py @@ -1,9 +1,9 @@ import sys try: - from collections import OrderedDict + from collections.abc import OrderedDict except ImportError: - from ordereddict import OrderedDict + from collections import OrderedDict from werkzeug.http import HTTP_STATUS_CODES |