Remove obsolete patch
Sophie Brun
4 years ago
0 | Description: Fix check marshmallow version | |
1 | Marshmallow has several beta releases(at least 13) with several backwards | |
2 | incompatible changes. We have for now 3.0.0b3 in Kali. Let's be more | |
3 | precise on the check to handle correctly the different issues with new | |
4 | API. | |
5 | Last-Update: 2018-08-28 | |
6 | --- | |
7 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
8 | --- a/webargs/core.py | |
9 | +++ b/webargs/core.py | |
10 | @@ -6,6 +6,7 @@ import inspect | |
11 | import logging | |
12 | import warnings | |
13 | from distutils.version import LooseVersion | |
14 | +from packaging import version | |
15 | ||
16 | try: | |
17 | from collections.abc import Mapping | |
18 | @@ -35,7 +36,7 @@ __all__ = [ | |
19 | "parse_json", | |
20 | ] | |
21 | ||
22 | -MARSHMALLOW_VERSION_INFO = tuple(LooseVersion(ma.__version__).version) # type: tuple | |
23 | +MARSHMALLOW_VERSION_INFO = ma.__version__ | |
24 | ||
25 | DEFAULT_VALIDATION_STATUS = 422 # type: int | |
26 | ||
27 | @@ -57,7 +58,7 @@ def dict2schema(dct): | |
28 | attrs = dct.copy() | |
29 | ||
30 | class Meta(object): | |
31 | - if MARSHMALLOW_VERSION_INFO[0] < 3: | |
32 | + if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0"): | |
33 | strict = True | |
34 | else: | |
35 | register = False | |
36 | @@ -265,7 +266,7 @@ class Parser(object): | |
37 | argdict = schema.fields | |
38 | parsed = {} | |
39 | for argname, field_obj in iteritems(argdict): | |
40 | - if MARSHMALLOW_VERSION_INFO[0] < 3: | |
41 | + if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b8"): | |
42 | parsed_value = self.parse_arg(argname, field_obj, req, locations) | |
43 | # If load_from is specified on the field, try to parse from that key | |
44 | if parsed_value is missing and field_obj.load_from: | |
45 | @@ -309,7 +310,7 @@ class Parser(object): | |
46 | schema = argmap(req) | |
47 | else: | |
48 | schema = dict2schema(argmap)() | |
49 | - if MARSHMALLOW_VERSION_INFO[0] < 3 and not schema.strict: | |
50 | + if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7") and not schema.strict: | |
51 | warnings.warn( | |
52 | "It is highly recommended that you set strict=True on your schema " | |
53 | "so that the parser's error handler will be invoked when expected.", | |
54 | @@ -355,7 +356,7 @@ class Parser(object): | |
55 | schema=schema, req=req, locations=locations or self.locations | |
56 | ) | |
57 | result = schema.load(parsed) | |
58 | - data = result.data if MARSHMALLOW_VERSION_INFO[0] < 3 else result | |
59 | + data = result.data if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7") else result | |
60 | self._validate_arguments(data, validators) | |
61 | except ma.exceptions.ValidationError as error: | |
62 | self._on_validation_error( |