|
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 |
@@ -30,9 +30,7 @@ __all__ = [
|
|
11 |
"parse_json",
|
|
12 |
]
|
|
13 |
|
|
14 |
-MARSHMALLOW_VERSION_INFO = tuple(
|
|
15 |
- [int(part) for part in ma.__version__.split(".") if part.isdigit()]
|
|
16 |
-)
|
|
17 |
+MARSHMALLOW_VERSION_INFO = ma.__version__
|
|
18 |
|
|
19 |
DEFAULT_VALIDATION_STATUS = 422
|
|
20 |
|
|
21 |
@@ -98,7 +96,7 @@ def argmap2schema(argmap):
|
|
22 |
names to `Fields <marshmallow.fields.Field>`.
|
|
23 |
"""
|
|
24 |
attrs = argmap.copy()
|
|
25 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
|
26 |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b7":
|
|
27 |
|
|
28 |
class Meta(object):
|
|
29 |
strict = True
|
|
30 |
@@ -302,7 +300,7 @@ class Parser(object):
|
|
31 |
argdict = schema.fields
|
|
32 |
parsed = {}
|
|
33 |
for argname, field_obj in iteritems(argdict):
|
|
34 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
|
35 |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b8":
|
|
36 |
parsed_value = self.parse_arg(argname, field_obj, req, locations)
|
|
37 |
# If load_from is specified on the field, try to parse from that key
|
|
38 |
if parsed_value is missing and field_obj.load_from:
|
|
39 |
@@ -325,7 +323,7 @@ class Parser(object):
|
|
40 |
kwargs = getattr(error, "kwargs", {})
|
|
41 |
kwargs["field_names"] = error.field_names
|
|
42 |
kwargs["data"] = error.data
|
|
43 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
|
44 |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b12":
|
|
45 |
kwargs["fields"] = error.fields
|
|
46 |
if "status_code" not in kwargs:
|
|
47 |
kwargs["status_code"] = self.DEFAULT_VALIDATION_STATUS
|
|
48 |
@@ -358,7 +356,7 @@ class Parser(object):
|
|
49 |
schema = argmap(req)
|
|
50 |
else:
|
|
51 |
schema = argmap2schema(argmap)()
|
|
52 |
- if MARSHMALLOW_VERSION_INFO[0] < 3 and not schema.strict:
|
|
53 |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b7" and not schema.strict:
|
|
54 |
warnings.warn(
|
|
55 |
"It is highly recommended that you set strict=True on your schema "
|
|
56 |
"so that the parser's error handler will be invoked when expected.",
|
|
57 |
@@ -390,7 +388,7 @@ class Parser(object):
|
|
58 |
try:
|
|
59 |
parsed = self._parse_request(schema=schema, req=req, locations=locations)
|
|
60 |
result = schema.load(parsed)
|
|
61 |
- data = result.data if MARSHMALLOW_VERSION_INFO[0] < 3 else result
|
|
62 |
+ data = result.data if MARSHMALLOW_VERSION_INFO < "3.0.0b7" else result
|
|
63 |
self._validate_arguments(data, validators)
|
|
64 |
except ma.exceptions.ValidationError as error:
|
|
65 |
self._on_validation_error(error, req, schema)
|