Skip to content

Commit d2ee8f4

Browse files
sfc-gh-stakedaankit-bhatnagar167
authored andcommitted
SNOW-76497: fixed python 2 issue on collections.abc
1 parent 6e12aea commit d2ee8f4

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@
3434
import httplib
3535
import Queue
3636
from HTMLParser import HTMLParser
37+
import collections
3738

3839
GET_CWD = os.getcwdu
3940
BASE_EXCEPTION_CLASS = StandardError # noqa: F821
4041
TO_UNICODE = unicode # noqa: F821
42+
ITERATOR = collections.Iterator
43+
MAPPING = collections.Mapping
4144

4245
urlsplit = urlparse.urlsplit
4346
urlunsplit = urlparse.urlunsplit
@@ -75,10 +78,13 @@
7578
import urllib.request
7679
import queue
7780
import html
81+
import collections.abc
7882

7983
GET_CWD = os.getcwd
8084
BASE_EXCEPTION_CLASS = Exception
8185
TO_UNICODE = str
86+
ITERATOR = collections.abc.Iterator
87+
MAPPING = collections.abc.Mapping
8288

8389
urlsplit = urllib.parse.urlsplit
8490
urlunsplit = urllib.parse.urlunsplit

network.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
6-
import collections.abc
6+
import collections
77
import contextlib
88
import gzip
99
import itertools
@@ -29,6 +29,7 @@
2929
from . import ssl_wrap_socket
3030
from .compat import (
3131
PY2,
32+
ITERATOR,
3233
METHOD_NOT_ALLOWED, BAD_REQUEST, SERVICE_UNAVAILABLE, GATEWAY_TIMEOUT,
3334
FORBIDDEN, BAD_GATEWAY, REQUEST_TIMEOUT,
3435
UNAUTHORIZED, INTERNAL_SERVER_ERROR, OK, BadStatusLine)
@@ -184,7 +185,7 @@ def __call__(self, r):
184185
return r
185186

186187

187-
class ResultIterWithTimings(collections.abc.Iterator):
188+
class ResultIterWithTimings(ITERATOR):
188189
DOWNLOAD = u"download"
189190
PARSE = u"parse"
190191

@@ -908,4 +909,5 @@ def _use_requests_session(self):
908909
"session doesn't exist in the active session pool. "
909910
"Ignored...")
910911
logger.debug("Active requests sessions: %s, idle: %s",
911-
len(self._active_sessions), len(self._idle_sessions))
912+
len(self._active_sessions),
913+
len(self._idle_sessions))

ssl_wrap_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import sys
2323
import time
2424
from collections import namedtuple
25-
from collections.abc import Mapping
25+
from .compat import MAPPING
2626

2727
try:
2828
monotonic = time.monotonic
@@ -138,7 +138,7 @@ def _syscall_wrapper(func, recalc_timeout, *args, **kwargs):
138138
SelectorKey = namedtuple('SelectorKey', ['fileobj', 'fd', 'events', 'data'])
139139

140140

141-
class _SelectorMapping(Mapping):
141+
class _SelectorMapping(MAPPING):
142142
""" Mapping of file objects to selector keys """
143143

144144
def __init__(self, selector):

0 commit comments

Comments
 (0)