Skip to content

Commit 72c4f15

Browse files
SNOW-803639 bumped vendored libraries (#1540)
1 parent cec0e45 commit 72c4f15

File tree

20 files changed

+168
-98
lines changed

20 files changed

+168
-98
lines changed

DESCRIPTION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1111
- v3.0.4(TBD)
1212
- Fixed a bug in which `cursor.execute()` could modify the argument statement_params dictionary object when executing a multistatement query.
1313
- Fixed a bug in which we cannot call `SnowflakeCursor.nextset` before fetching the result of the first query if the cursor runs an async multistatement query.
14+
- Bumped vendored library urllib3 to 1.26.15
15+
- Bumped vendored library requests to 2.29.0
16+
1417

1518
- v3.0.3(April 20, 2023)
1619
- Fixed a bug that prints error in logs for GET command on GCS.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ install_requires =
5454
requests<3.0.0
5555
importlib-metadata; python_version < '3.8'
5656
packaging
57-
charset_normalizer>=2,<3
57+
charset_normalizer>=2,<4
5858
idna>=2.5,<4
5959
urllib3>=1.21.1,<1.27
6060
certifi>=2017.4.17

src/snowflake/connector/vendored/requests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_ver
8080
elif charset_normalizer_version:
8181
major, minor, patch = charset_normalizer_version.split(".")[:3]
8282
major, minor, patch = int(major), int(minor), int(patch)
83-
# charset_normalizer >= 2.0.0 < 3.0.0
84-
assert (2, 0, 0) <= (major, minor, patch) < (3, 0, 0)
83+
# charset_normalizer >= 2.0.0 < 4.0.0
84+
assert (2, 0, 0) <= (major, minor, patch) < (4, 0, 0)
8585
else:
8686
raise Exception("You need either charset_normalizer or chardet installed")
8787

src/snowflake/connector/vendored/requests/__version__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
__title__ = "requests"
66
__description__ = "Python HTTP for Humans."
77
__url__ = "https://requests.readthedocs.io"
8-
__version__ = "2.28.1"
9-
__build__ = 0x022801
8+
__version__ = "2.29.0"
9+
__build__ = 0x022900
1010
__author__ = "Kenneth Reitz"
1111
__author_email__ = "[email protected]"
1212
__license__ = "Apache 2.0"
13-
__copyright__ = "Copyright 2022 Kenneth Reitz"
13+
__copyright__ = "Copyright Kenneth Reitz"
1414
__cake__ = "\u2728 \U0001f370 \u2728"

src/snowflake/connector/vendored/requests/_internal_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
_VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$")
1515
_VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$")
1616

17+
_HEADER_VALIDATORS_STR = (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR)
18+
_HEADER_VALIDATORS_BYTE = (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE)
1719
HEADER_VALIDATORS = {
18-
bytes: (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE),
19-
str: (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR),
20+
bytes: _HEADER_VALIDATORS_BYTE,
21+
str: _HEADER_VALIDATORS_STR,
2022
}
2123

2224

src/snowflake/connector/vendored/requests/adapters.py

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ..urllib3.exceptions import ReadTimeoutError, ResponseError
2323
from ..urllib3.exceptions import SSLError as _SSLError
2424
from ..urllib3.poolmanager import PoolManager, proxy_from_url
25-
from ..urllib3.response import HTTPResponse
2625
from ..urllib3.util import Timeout as TimeoutSauce
2726
from ..urllib3.util import parse_url
2827
from ..urllib3.util.retry import Retry
@@ -485,63 +484,19 @@ def send(
485484
timeout = TimeoutSauce(connect=timeout, read=timeout)
486485

487486
try:
488-
if not chunked:
489-
resp = conn.urlopen(
490-
method=request.method,
491-
url=url,
492-
body=request.body,
493-
headers=request.headers,
494-
redirect=False,
495-
assert_same_host=False,
496-
preload_content=False,
497-
decode_content=False,
498-
retries=self.max_retries,
499-
timeout=timeout,
500-
)
501-
502-
# Send the request.
503-
else:
504-
if hasattr(conn, "proxy_pool"):
505-
conn = conn.proxy_pool
506-
507-
low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)
508-
509-
try:
510-
skip_host = "Host" in request.headers
511-
low_conn.putrequest(
512-
request.method,
513-
url,
514-
skip_accept_encoding=True,
515-
skip_host=skip_host,
516-
)
517-
518-
for header, value in request.headers.items():
519-
low_conn.putheader(header, value)
520-
521-
low_conn.endheaders()
522-
523-
for i in request.body:
524-
low_conn.send(hex(len(i))[2:].encode("utf-8"))
525-
low_conn.send(b"\r\n")
526-
low_conn.send(i)
527-
low_conn.send(b"\r\n")
528-
low_conn.send(b"0\r\n\r\n")
529-
530-
# Receive the response from the server
531-
r = low_conn.getresponse()
532-
533-
resp = HTTPResponse.from_httplib(
534-
r,
535-
pool=conn,
536-
connection=low_conn,
537-
preload_content=False,
538-
decode_content=False,
539-
)
540-
except Exception:
541-
# If we hit any problems here, clean up the connection.
542-
# Then, raise so that we can handle the actual exception.
543-
low_conn.close()
544-
raise
487+
resp = conn.urlopen(
488+
method=request.method,
489+
url=url,
490+
body=request.body,
491+
headers=request.headers,
492+
redirect=False,
493+
assert_same_host=False,
494+
preload_content=False,
495+
decode_content=False,
496+
retries=self.max_retries,
497+
timeout=timeout,
498+
chunked=chunked,
499+
)
545500

546501
except (ProtocolError, OSError) as err:
547502
raise ConnectionError(err, request=request)

src/snowflake/connector/vendored/requests/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def post(url, data=None, json=None, **kwargs):
106106
:param url: URL for the new :class:`Request` object.
107107
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
108108
object to send in the body of the :class:`Request`.
109-
:param json: (optional) json data to send in the body of the :class:`Request`.
109+
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
110110
:param \*\*kwargs: Optional arguments that ``request`` takes.
111111
:return: :class:`Response <Response>` object
112112
:rtype: requests.Response
@@ -121,7 +121,7 @@ def put(url, data=None, **kwargs):
121121
:param url: URL for the new :class:`Request` object.
122122
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
123123
object to send in the body of the :class:`Request`.
124-
:param json: (optional) json data to send in the body of the :class:`Request`.
124+
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
125125
:param \*\*kwargs: Optional arguments that ``request`` takes.
126126
:return: :class:`Response <Response>` object
127127
:rtype: requests.Response
@@ -136,7 +136,7 @@ def patch(url, data=None, **kwargs):
136136
:param url: URL for the new :class:`Request` object.
137137
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
138138
object to send in the body of the :class:`Request`.
139-
:param json: (optional) json data to send in the body of the :class:`Request`.
139+
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
140140
:param \*\*kwargs: Optional arguments that ``request`` takes.
141141
:return: :class:`Response <Response>` object
142142
:rtype: requests.Response

src/snowflake/connector/vendored/requests/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def prepare_url(self, url, params):
438438
if not scheme:
439439
raise MissingSchema(
440440
f"Invalid URL {url!r}: No scheme supplied. "
441-
f"Perhaps you meant http://{url}?"
441+
f"Perhaps you meant https://{url}?"
442442
)
443443

444444
if not host:

src/snowflake/connector/vendored/requests/utils.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
from .__version__ import __version__
2626

2727
# to_native_string is unused here, but imported here for backwards compatibility
28-
from ._internal_utils import HEADER_VALIDATORS, to_native_string # noqa: F401
28+
from ._internal_utils import ( # noqa: F401
29+
_HEADER_VALIDATORS_BYTE,
30+
_HEADER_VALIDATORS_STR,
31+
HEADER_VALIDATORS,
32+
to_native_string,
33+
)
2934
from .compat import (
3035
Mapping,
3136
basestring,
@@ -1031,20 +1036,23 @@ def check_header_validity(header):
10311036
:param header: tuple, in the format (name, value).
10321037
"""
10331038
name, value = header
1039+
_validate_header_part(header, name, 0)
1040+
_validate_header_part(header, value, 1)
10341041

1035-
for part in header:
1036-
if type(part) not in HEADER_VALIDATORS:
1037-
raise InvalidHeader(
1038-
f"Header part ({part!r}) from {{{name!r}: {value!r}}} must be "
1039-
f"of type str or bytes, not {type(part)}"
1040-
)
1041-
1042-
_validate_header_part(name, "name", HEADER_VALIDATORS[type(name)][0])
1043-
_validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])
10441042

1043+
def _validate_header_part(header, header_part, header_validator_index):
1044+
if isinstance(header_part, str):
1045+
validator = _HEADER_VALIDATORS_STR[header_validator_index]
1046+
elif isinstance(header_part, bytes):
1047+
validator = _HEADER_VALIDATORS_BYTE[header_validator_index]
1048+
else:
1049+
raise InvalidHeader(
1050+
f"Header part ({header_part!r}) from {header} "
1051+
f"must be of type str or bytes, not {type(header_part)}"
1052+
)
10451053

1046-
def _validate_header_part(header_part, header_kind, validator):
10471054
if not validator.match(header_part):
1055+
header_kind = "name" if header_validator_index == 0 else "value"
10481056
raise InvalidHeader(
10491057
f"Invalid leading whitespace, reserved character(s), or return"
10501058
f"character(s) in header {header_kind}: {header_part!r}"

src/snowflake/connector/vendored/urllib3/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
from .util.timeout import Timeout
2020
from .util.url import get_host
2121

22+
# === NOTE TO REPACKAGERS AND VENDORS ===
23+
# Please delete this block, this logic is only
24+
# for urllib3 being distributed via PyPI.
25+
# See: https://github.com/urllib3/urllib3/issues/2680
26+
try:
27+
import urllib3_secure_extra # type: ignore # noqa: F401
28+
except ImportError:
29+
pass
30+
else:
31+
warnings.warn(
32+
"'urllib3[secure]' extra is deprecated and will be removed "
33+
"in a future release of urllib3 2.x. Read more in this issue: "
34+
"https://github.com/urllib3/urllib3/issues/2680",
35+
category=DeprecationWarning,
36+
stacklevel=2,
37+
)
38+
2239
__author__ = "Andrey Petrov ([email protected])"
2340
__license__ = "MIT"
2441
__version__ = __version__

0 commit comments

Comments
 (0)