Родитель
f5b857b2bc
Коммит
c97db9df00
|
@ -20,6 +20,14 @@ To install:
|
||||||
Release History
|
Release History
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
2022-05-05 Version 0.7.0
|
||||||
|
+++++++++++++++++++++++++
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
|
||||||
|
- Add `azure-core` as installation requirement #247
|
||||||
|
- Replace `SerializationError` and `DeserializationError` in `msrest.exceptions` with those in `azure.core` #247
|
||||||
|
|
||||||
2021-01-26 Version 0.6.21
|
2021-01-26 Version 0.6.21
|
||||||
+++++++++++++++++++++++++
|
+++++++++++++++++++++++++
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,5 @@ pylint
|
||||||
aiohttp;python_full_version>="3.5.2"
|
aiohttp;python_full_version>="3.5.2"
|
||||||
# async in msrest was experimental, we won't update
|
# async in msrest was experimental, we won't update
|
||||||
trio==0.14.0;python_version == '3.5'
|
trio==0.14.0;python_version == '3.5'
|
||||||
trio==0.16.0;python_version >= '3.6'
|
trio==0.16.0;python_version >= '3.6' and python_version < '3.10'
|
||||||
|
trio==0.20.0;python_version >= '3.10'
|
||||||
|
|
|
@ -28,7 +28,7 @@ import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from typing import Callable, Any, Optional, TYPE_CHECKING
|
from typing import Callable, Any, Optional, TYPE_CHECKING
|
||||||
|
from azure.core.exceptions import SerializationError, DeserializationError
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -68,16 +68,6 @@ class ClientException(Exception):
|
||||||
super(ClientException, self).__init__(message, *args, **kwargs) # type: ignore
|
super(ClientException, self).__init__(message, *args, **kwargs) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class SerializationError(ClientException):
|
|
||||||
"""Error raised during request serialization."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DeserializationError(ClientException):
|
|
||||||
"""Error raised during response deserialization."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class TokenExpiredError(ClientException):
|
class TokenExpiredError(ClientException):
|
||||||
"""OAuth token expired, request failed."""
|
"""OAuth token expired, request failed."""
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -569,7 +569,9 @@ class Serializer(object):
|
||||||
_serialized.update(_new_attr)
|
_serialized.update(_new_attr)
|
||||||
_new_attr = _new_attr[k]
|
_new_attr = _new_attr[k]
|
||||||
_serialized = _serialized[k]
|
_serialized = _serialized[k]
|
||||||
except ValueError:
|
except ValueError as err:
|
||||||
|
if isinstance(err, SerializationError):
|
||||||
|
raise err
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except (AttributeError, KeyError, TypeError) as err:
|
except (AttributeError, KeyError, TypeError) as err:
|
||||||
|
@ -776,6 +778,8 @@ class Serializer(object):
|
||||||
data, data_type[1:-1], **kwargs)
|
data, data_type[1:-1], **kwargs)
|
||||||
|
|
||||||
except (ValueError, TypeError) as err:
|
except (ValueError, TypeError) as err:
|
||||||
|
if (isinstance(err, SerializationError)):
|
||||||
|
raise err # don't rewrap as SerializationError
|
||||||
msg = "Unable to serialize value: {!r} as type: {!r}."
|
msg = "Unable to serialize value: {!r} as type: {!r}."
|
||||||
raise_with_traceback(
|
raise_with_traceback(
|
||||||
SerializationError, msg.format(data, data_type), err)
|
SerializationError, msg.format(data, data_type), err)
|
||||||
|
@ -858,7 +862,9 @@ class Serializer(object):
|
||||||
for d in data:
|
for d in data:
|
||||||
try:
|
try:
|
||||||
serialized.append(self.serialize_data(d, iter_type, **kwargs))
|
serialized.append(self.serialize_data(d, iter_type, **kwargs))
|
||||||
except ValueError:
|
except ValueError as err:
|
||||||
|
if isinstance(err, SerializationError):
|
||||||
|
raise err
|
||||||
serialized.append(None)
|
serialized.append(None)
|
||||||
|
|
||||||
if div:
|
if div:
|
||||||
|
@ -914,7 +920,9 @@ class Serializer(object):
|
||||||
try:
|
try:
|
||||||
serialized[self.serialize_unicode(key)] = self.serialize_data(
|
serialized[self.serialize_unicode(key)] = self.serialize_data(
|
||||||
value, dict_type, **kwargs)
|
value, dict_type, **kwargs)
|
||||||
except ValueError:
|
except ValueError as err:
|
||||||
|
if isinstance(err, SerializationError):
|
||||||
|
raise err
|
||||||
serialized[self.serialize_unicode(key)] = None
|
serialized[self.serialize_unicode(key)] = None
|
||||||
|
|
||||||
if 'xml' in serialization_ctxt:
|
if 'xml' in serialization_ctxt:
|
||||||
|
|
|
@ -161,7 +161,7 @@ try:
|
||||||
|
|
||||||
async def __anext__(self):
|
async def __anext__(self):
|
||||||
try:
|
try:
|
||||||
chunk = await trio.run_sync_in_worker_thread(
|
chunk = await trio.to_thread.run_sync(
|
||||||
_msrest_next,
|
_msrest_next,
|
||||||
self.iter_content_func,
|
self.iter_content_func,
|
||||||
)
|
)
|
||||||
|
@ -209,7 +209,7 @@ try:
|
||||||
session = kwargs.pop('session', self.session)
|
session = kwargs.pop('session', self.session)
|
||||||
|
|
||||||
trio_limiter = kwargs.get("trio_limiter", None)
|
trio_limiter = kwargs.get("trio_limiter", None)
|
||||||
future = trio.run_sync_in_worker_thread(
|
future = trio.to_thread.run_sync(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
session.request,
|
session.request,
|
||||||
request.method,
|
request.method,
|
||||||
|
|
|
@ -25,4 +25,4 @@
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
#: version of this package. Use msrest.__version__ instead
|
#: version of this package. Use msrest.__version__ instead
|
||||||
msrest_version = "0.6.21"
|
msrest_version = "0.7.0"
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -28,7 +28,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='msrest',
|
name='msrest',
|
||||||
version='0.6.21',
|
version='0.7.0',
|
||||||
author='Microsoft Corporation',
|
author='Microsoft Corporation',
|
||||||
packages=find_packages(exclude=["tests", "tests.*"]),
|
packages=find_packages(exclude=["tests", "tests.*"]),
|
||||||
url=("https://github.com/Azure/msrest-for-python"),
|
url=("https://github.com/Azure/msrest-for-python"),
|
||||||
|
@ -53,6 +53,7 @@ setup(
|
||||||
"requests_oauthlib>=0.5.0",
|
"requests_oauthlib>=0.5.0",
|
||||||
"isodate>=0.6.0",
|
"isodate>=0.6.0",
|
||||||
"certifi>=2017.4.17",
|
"certifi>=2017.4.17",
|
||||||
|
"azure-core>=1.24.0",
|
||||||
],
|
],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
package_data={
|
package_data={
|
||||||
|
|
|
@ -42,6 +42,7 @@ from requests import Response
|
||||||
from msrest.serialization import Model, last_restapi_key_transformer, full_restapi_key_transformer, rest_key_extractor
|
from msrest.serialization import Model, last_restapi_key_transformer, full_restapi_key_transformer, rest_key_extractor
|
||||||
from msrest import Serializer, Deserializer
|
from msrest import Serializer, Deserializer
|
||||||
from msrest.exceptions import SerializationError, DeserializationError, ValidationError
|
from msrest.exceptions import SerializationError, DeserializationError, ValidationError
|
||||||
|
from azure.core.exceptions import SerializationError as AzureCoreSerializationError, DeserializationError as AzureCoreDeserializationError
|
||||||
|
|
||||||
from . import storage_models
|
from . import storage_models
|
||||||
|
|
||||||
|
@ -2579,5 +2580,11 @@ class TestModelInstanceEquality(unittest.TestCase):
|
||||||
self.assertTrue(animal1!=animal2)
|
self.assertTrue(animal1!=animal2)
|
||||||
self.assertTrue(animal1==animal3)
|
self.assertTrue(animal1==animal3)
|
||||||
|
|
||||||
|
class TestAzureCoreExceptions(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_azure_core_exceptions(self):
|
||||||
|
self.assertEqual(SerializationError, AzureCoreSerializationError)
|
||||||
|
self.assertEqual(DeserializationError, AzureCoreDeserializationError)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче