Skip to content

Commit 3977689

Browse files
SNOW-2043523: Isabs fix
1 parent dec4e68 commit 3977689

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/snowflake/connector/file_transfer_agent.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from logging import getLogger
1515
from time import time
1616
from typing import IO, TYPE_CHECKING, Any, Callable, TypeVar
17+
from urllib.parse import urlparse
18+
from urllib.request import url2pathname
1719

1820
from .azure_storage_client import SnowflakeAzureRestClient
1921
from .compat import GET_CWD, IS_WINDOWS
@@ -837,10 +839,13 @@ def result(self) -> dict[str, Any]:
837839
def _expand_filenames(self, locations: list[str]) -> list[str]:
838840
canonical_locations = []
839841
for file_name in locations:
842+
# TODO: Since python 3.13 os.path.isabs returns other values for URI ... comment to be finished
843+
parsed = urlparse(file_name)
844+
if parsed.scheme == "file":
845+
file_name = url2pathname(parsed.path)
846+
840847
if self._command_type == CMD_TYPE_UPLOAD:
841848
file_name = os.path.expanduser(file_name)
842-
if not os.path.isabs(file_name):
843-
file_name = os.path.join(GET_CWD(), file_name)
844849
if (
845850
IS_WINDOWS
846851
and len(file_name) > 2
@@ -850,6 +855,10 @@ def _expand_filenames(self, locations: list[str]) -> list[str]:
850855
# Windows path: /C:/data/file1.txt where it starts with slash
851856
# followed by a drive letter and colon.
852857
file_name = file_name[1:]
858+
859+
if not os.path.isabs(file_name):
860+
file_name = os.path.join(GET_CWD(), file_name)
861+
853862
files = glob.glob(file_name)
854863
canonical_locations += files
855864
else:

src/snowflake/connector/log_configuration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def parse_config_file(self):
2626
self.level = log.get("level", "INFO")
2727
self.path = log.get("path", os.path.join(DIRS.user_config_path, "logs"))
2828

29+
# TODO: wont work in 3.13?
30+
# if not self.path.scheme and self.path.netloc and self.path.path.startswith("/"):
2931
if not os.path.isabs(self.path):
3032
raise FileNotFoundError(
3133
f"Log path must be an absolute file path: {self.path}"

test/integ/test_put_windows_path.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def test_abc(conn_cnx, tmpdir, db_parameters):
1414
f.write("test1,test2")
1515
f.write("test3,test4")
1616

17-
assert os.path.exists(tmp_dir), f"Temporary directory {tmp_dir} does not exist."
1817
assert os.path.exists(test_data), f"Test data {test_data} does not exist."
1918

2019
fileURI = pathlib.Path(test_data).as_uri()

0 commit comments

Comments
 (0)