Check against 3.0.0rc1
to maintain compatibility with 3.0 beta
@@ -6,6 +6,7 @@ import functools
import inspect
import logging
import warnings
+from distutils.version import LooseVersion
try:
import simplejson as json
@@ -30,9 +31,7 @@ __all__ = [
"parse_json",
]
-MARSHMALLOW_VERSION_INFO = tuple(
- [int(part) for part in ma.__version__.split(".") if part.isdigit()]
-)
+MARSHMALLOW_VERSION_INFO = tuple(LooseVersion(ma.__version__).version)
DEFAULT_VALIDATION_STATUS = 422
@@ -326,6 +325,7 @@ class Parser(object):
kwargs["data"] = error.data
if MARSHMALLOW_VERSION_INFO[0] < 3:
kwargs["fields"] = error.fields
+ if LooseVersion(ma.__version__) < LooseVersion("3.0.0rc1"):
kwargs["field_names"] = error.field_names
else:
kwargs["field_name"] = error.field_name
