Skip to content

Commit 27fa9f5

Browse files
Exchange vendored urllib to with newest 2.6.3 (#2757)
1 parent ace34bd commit 27fa9f5

17 files changed

Lines changed: 384 additions & 165 deletions

File tree

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1313
- Fix string representation of INTERVAL YEAR and INTERVAL MONTH types.
1414
- Log a warning when using http protocol for OAuth urls.
1515
- Deprecated support for custom revocation error classes in OCSP response cache deserialization. By default, only `RevocationCheckError` exceptions are deserialized from OCSP cache. Custom exception classes can be temporarily enabled by setting the `SNOWFLAKE_ENABLE_CUSTOM_REVOCATION_ERRORS` environment variable to `true` or `1`, but this support will be removed in a future release.
16+
- Bumped up vendored `urllib3` to `2.6.3`
1617

1718
- v4.2.0(January 07,2026)
1819
- Added `SnowflakeCursor.stats` property to expose granular DML statistics (rows inserted, deleted, updated, and duplicates) for operations like CTAS where `rowcount` is insufficient.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,19 @@ def __setitem__(self, key: str, val: str) -> None:
255255
self._container[key.lower()] = [key, val]
256256

257257
def __getitem__(self, key: str) -> str:
258+
if isinstance(key, bytes):
259+
key = key.decode("latin-1")
258260
val = self._container[key.lower()]
259261
return ", ".join(val[1:])
260262

261263
def __delitem__(self, key: str) -> None:
264+
if isinstance(key, bytes):
265+
key = key.decode("latin-1")
262266
del self._container[key.lower()]
263267

264268
def __contains__(self, key: object) -> bool:
269+
if isinstance(key, bytes):
270+
key = key.decode("latin-1")
265271
if isinstance(key, str):
266272
return key.lower() in self._container
267273
return False
@@ -376,6 +382,8 @@ def getlist(
376382
) -> list[str] | _DT:
377383
"""Returns a list of all the values for the named field. Returns an
378384
empty list if the key doesn't exist."""
385+
if isinstance(key, bytes):
386+
key = key.decode("latin-1")
379387
try:
380388
vals = self._container[key.lower()]
381389
except KeyError:
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
# file generated by setuptools-scm
22
# don't change, don't track in version control
33

4-
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4+
__all__ = [
5+
"__version__",
6+
"__version_tuple__",
7+
"version",
8+
"version_tuple",
9+
"__commit_id__",
10+
"commit_id",
11+
]
512

613
TYPE_CHECKING = False
714
if TYPE_CHECKING:
815
from typing import Tuple
916
from typing import Union
1017

1118
VERSION_TUPLE = Tuple[Union[int, str], ...]
19+
COMMIT_ID = Union[str, None]
1220
else:
1321
VERSION_TUPLE = object
22+
COMMIT_ID = object
1423

1524
version: str
1625
__version__: str
1726
__version_tuple__: VERSION_TUPLE
1827
version_tuple: VERSION_TUPLE
28+
commit_id: COMMIT_ID
29+
__commit_id__: COMMIT_ID
1930

20-
__version__ = version = '2.5.0'
21-
__version_tuple__ = version_tuple = (2, 5, 0)
31+
__version__ = version = '2.6.3'
32+
__version_tuple__ = version_tuple = (2, 6, 3)
33+
34+
__commit_id__ = commit_id = None

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ def __init__(
160160
self._tunnel_port: int | None = None
161161
self._tunnel_scheme: str | None = None
162162

163+
def __str__(self) -> str:
164+
return f"{type(self).__name__}(host={self.host!r}, port={self.port!r})"
165+
166+
def __repr__(self) -> str:
167+
return f"<{self} at {id(self):#x}>"
168+
163169
@property
164170
def host(self) -> str:
165171
"""

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ def inject_into_urllib3() -> None:
1414
HTTPSConnectionPool.ConnectionCls = EmscriptenHTTPSConnection
1515
snowflake.connector.vendored.urllib3.connection.HTTPConnection = EmscriptenHTTPConnection # type: ignore[misc,assignment]
1616
snowflake.connector.vendored.urllib3.connection.HTTPSConnection = EmscriptenHTTPSConnection # type: ignore[misc,assignment]
17+
snowflake.connector.vendored.urllib3.connection.VerifiedHTTPSConnection = EmscriptenHTTPSConnection # type: ignore[assignment]

src/snowflake/connector/vendored/urllib3/contrib/emscripten/connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class EmscriptenHTTPConnection:
4040
is_verified: bool = False
4141
proxy_is_verified: bool | None = None
4242

43+
response_class: type[BaseHTTPResponse] = EmscriptenHttpResponseWrapper
4344
_response: EmscriptenResponse | None
4445

4546
def __init__(
@@ -98,8 +99,12 @@ def request(
9899
) -> None:
99100
self._closed = False
100101
if url.startswith("/"):
102+
if self.port is not None:
103+
port = f":{self.port}"
104+
else:
105+
port = ""
101106
# no scheme / host / port included, make a full url
102-
url = f"{self.scheme}://{self.host}:{self.port}" + url
107+
url = f"{self.scheme}://{self.host}{port}{url}"
103108
request = EmscriptenRequest(
104109
url=url,
105110
method=method,

src/snowflake/connector/vendored/urllib3/contrib/emscripten/emscripten_fetch_worker.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ let Status = {
55
ERROR_EXCEPTION: -4,
66
};
77

8-
let connections = {};
8+
let connections = new Map();
99
let nextConnectionID = 1;
1010
const encoder = new TextEncoder();
1111

1212
self.addEventListener("message", async function (event) {
1313
if (event.data.close) {
1414
let connectionID = event.data.close;
15-
delete connections[connectionID];
15+
connections.delete(connectionID);
1616
return;
1717
} else if (event.data.getMore) {
1818
let connectionID = event.data.getMore;
1919
let { curOffset, value, reader, intBuffer, byteBuffer } =
20-
connections[connectionID];
20+
connections.get(connectionID);
2121
// if we still have some in buffer, then just send it back straight away
2222
if (!value || curOffset >= value.length) {
2323
// read another buffer if required
@@ -26,15 +26,15 @@ self.addEventListener("message", async function (event) {
2626

2727
if (readResponse.done) {
2828
// read everything - clear connection and return
29-
delete connections[connectionID];
29+
connections.delete(connectionID);
3030
Atomics.store(intBuffer, 0, Status.SUCCESS_EOF);
3131
Atomics.notify(intBuffer, 0);
3232
// finished reading successfully
3333
// return from event handler
3434
return;
3535
}
3636
curOffset = 0;
37-
connections[connectionID].value = readResponse.value;
37+
connections.get(connectionID).value = readResponse.value;
3838
value = readResponse.value;
3939
} catch (error) {
4040
console.log("Request exception:", error);
@@ -57,7 +57,7 @@ self.addEventListener("message", async function (event) {
5757
Atomics.store(intBuffer, 0, curLen); // store current length in bytes
5858
Atomics.notify(intBuffer, 0);
5959
curOffset += curLen;
60-
connections[connectionID].curOffset = curOffset;
60+
connections.get(connectionID).curOffset = curOffset;
6161

6262
return;
6363
} else {
@@ -84,13 +84,13 @@ self.addEventListener("message", async function (event) {
8484
byteBuffer.set(headerBytes);
8585
intBuffer[1] = written;
8686
// make a connection
87-
connections[connectionID] = {
87+
connections.set(connectionID, {
8888
reader: response.body.getReader(),
8989
intBuffer: intBuffer,
9090
byteBuffer: byteBuffer,
9191
value: undefined,
9292
curOffset: 0,
93-
};
93+
});
9494
// set header ready
9595
Atomics.store(intBuffer, 0, Status.SUCCESS_HEADER);
9696
Atomics.notify(intBuffer, 0);

src/snowflake/connector/vendored/urllib3/contrib/emscripten/fetch.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@
6767
ERROR_TIMEOUT = -3
6868
ERROR_EXCEPTION = -4
6969

70-
_STREAMING_WORKER_CODE = (
71-
files(__package__)
72-
.joinpath("emscripten_fetch_worker.js")
73-
.read_text(encoding="utf-8")
74-
)
75-
7670

7771
class _RequestError(Exception):
7872
def __init__(
@@ -207,9 +201,13 @@ class _StreamingFetcher:
207201
def __init__(self) -> None:
208202
# make web-worker and data buffer on startup
209203
self.streaming_ready = False
210-
204+
streaming_worker_code = (
205+
files(__package__)
206+
.joinpath("emscripten_fetch_worker.js")
207+
.read_text(encoding="utf-8")
208+
)
211209
js_data_blob = js.Blob.new(
212-
to_js([_STREAMING_WORKER_CODE], create_pyproxies=False),
210+
to_js([streaming_worker_code], create_pyproxies=False),
213211
_obj_from_dict({"type": "application/javascript"}),
214212
)
215213

src/snowflake/connector/vendored/urllib3/contrib/pyopenssl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
from __future__ import annotations
4242

43-
import OpenSSL.SSL # type: ignore[import-untyped]
43+
import OpenSSL.SSL # type: ignore[import-not-found]
4444
from cryptography import x509
4545

4646
try:
@@ -61,7 +61,7 @@ class UnsupportedExtension(Exception): # type: ignore[no-redef]
6161
from .. import util
6262

6363
if typing.TYPE_CHECKING:
64-
from OpenSSL.crypto import X509 # type: ignore[import-untyped]
64+
from OpenSSL.crypto import X509 # type: ignore[import-not-found]
6565

6666

6767
__all__ = ["inject_into_urllib3", "extract_from_urllib3"]

src/snowflake/connector/vendored/urllib3/contrib/socks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from __future__ import annotations
4242

4343
try:
44-
import socks # type: ignore[import-not-found]
44+
import socks # type: ignore[import-untyped]
4545
except ImportError:
4646
import warnings
4747

0 commit comments

Comments
 (0)