From 2fef9139ea13819d0a5f91d97f5570bae0b7e4c2 Mon Sep 17 00:00:00 2001 From: rebeccaLinx <rebeccalin209@gmail.com> Date: Tue, 25 Apr 2023 12:10:48 +0800 Subject: [PATCH] support maya2024 py3 --- avalon/vendor/requests/cookies.py | 8 ++++++-- avalon/vendor/requests/models.py | 7 ++++++- avalon/vendor/requests/packages/urllib3/_collections.py | 7 ++++++- .../vendor/requests/packages/urllib3/util/selectors.py | 7 ++++++- avalon/vendor/requests/sessions.py | 6 +++++- avalon/vendor/requests/structures.py | 9 ++++++--- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/avalon/vendor/requests/cookies.py b/avalon/vendor/requests/cookies.py index 6484af6b4..2c5eead2a 100644 --- a/avalon/vendor/requests/cookies.py +++ b/avalon/vendor/requests/cookies.py @@ -12,7 +12,11 @@ import copy import time import calendar -import collections + +try: + from collections import MutableMapping +except Exception as e: + from _collections_abc import MutableMapping from ._internal_utils import to_native_string from .compat import cookielib, urlparse, urlunparse, Morsel @@ -169,7 +173,7 @@ class CookieConflictError(RuntimeError): """ -class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping): +class RequestsCookieJar(cookielib.CookieJar, MutableMapping): """Compatibility class; is a cookielib.CookieJar, but exposes a dict interface. diff --git a/avalon/vendor/requests/models.py b/avalon/vendor/requests/models.py index 75f16e327..8ca174d6d 100644 --- a/avalon/vendor/requests/models.py +++ b/avalon/vendor/requests/models.py @@ -8,6 +8,11 @@ """ import collections +try: + from collections import Mapping +except Exception as e: + from _collections_abc import Mapping + import datetime import sys @@ -464,7 +469,7 @@ def prepare_body(self, data, files, json=None): is_stream = all([ hasattr(data, '__iter__'), - not isinstance(data, (basestring, list, tuple, collections.Mapping)) + not isinstance(data, (basestring, list, tuple, Mapping)) ]) try: diff --git a/avalon/vendor/requests/packages/urllib3/_collections.py b/avalon/vendor/requests/packages/urllib3/_collections.py index 4849ddecd..5f5ed2558 100644 --- a/avalon/vendor/requests/packages/urllib3/_collections.py +++ b/avalon/vendor/requests/packages/urllib3/_collections.py @@ -1,5 +1,10 @@ from __future__ import absolute_import -from collections import Mapping, MutableMapping + +try: + from collections import Mapping, MutableMapping +except Exception as e: + from _collections_abc import Mapping, MutableMapping + try: from threading import RLock except ImportError: # Platform-specific: No threads available diff --git a/avalon/vendor/requests/packages/urllib3/util/selectors.py b/avalon/vendor/requests/packages/urllib3/util/selectors.py index d75cb266b..cc72bfb5b 100644 --- a/avalon/vendor/requests/packages/urllib3/util/selectors.py +++ b/avalon/vendor/requests/packages/urllib3/util/selectors.py @@ -11,7 +11,12 @@ import socket import sys import time -from collections import namedtuple, Mapping +from collections import namedtuple + +try: + from collections import Mapping +except Exception as e: + from _collections_abc import Mapping try: monotonic = time.monotonic diff --git a/avalon/vendor/requests/sessions.py b/avalon/vendor/requests/sessions.py index 3ae42f99d..b61d14cad 100644 --- a/avalon/vendor/requests/sessions.py +++ b/avalon/vendor/requests/sessions.py @@ -10,7 +10,11 @@ import os import platform import time -from collections import Mapping +try: + from collections import Mapping +except Exception as e: + from _collections_abc import Mapping + from datetime import timedelta from .auth import _basic_auth_str diff --git a/avalon/vendor/requests/structures.py b/avalon/vendor/requests/structures.py index 05d2b3f57..0dc0e4c61 100644 --- a/avalon/vendor/requests/structures.py +++ b/avalon/vendor/requests/structures.py @@ -7,12 +7,15 @@ Data structures that power Requests. """ -import collections +try: + from collections import Mapping, MutableMapping +except Exception as e: + from _collections_abc import Mapping, MutableMapping from .compat import OrderedDict -class CaseInsensitiveDict(collections.MutableMapping): +class CaseInsensitiveDict(MutableMapping): """A case-insensitive ``dict``-like object. Implements all methods and operations of @@ -71,7 +74,7 @@ def lower_items(self): ) def __eq__(self, other): - if isinstance(other, collections.Mapping): + if isinstance(other, Mapping): other = CaseInsensitiveDict(other) else: return NotImplemented