Skip to content

Commit

Permalink
Fix default config location resolution on Windows OS (#2017)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pczajka authored Aug 8, 2024
1 parent bc29756 commit 125a2db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne

- v3.12.1(TBD)
- Fixed a bug that session token is logged when renewing session.
- Use `pathlib` instead of `os` for default config file location resolution.
- Fixed a bug that disabling client telemetry does not work.

- v3.12.0(July 24,2024)
Expand Down
8 changes: 4 additions & 4 deletions src/snowflake/connector/sf_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def _resolve_platform_dirs() -> PlatformDirsProto:
"appname": "snowflake",
"appauthor": False,
}
snowflake_home = os.path.expanduser(
snowflake_home = pathlib.Path(
os.environ.get("SNOWFLAKE_HOME", "~/.snowflake/"),
)
if os.path.exists(snowflake_home):
).expanduser()
if snowflake_home.exists():
return SFPlatformDirs(
snowflake_home,
str(snowflake_home),
**platformdir_kwargs,
)
else:
Expand Down
8 changes: 5 additions & 3 deletions test/unit/test_configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ def test_sf_dirs(tmp_path, version):


def test_config_file_resolution_sfdirs_default():
default_loc = os.path.expanduser("~/.snowflake")
existed_before = os.path.exists(default_loc)
os.makedirs(default_loc, exist_ok=True)
from pathlib import Path

default_loc = Path("~/.snowflake").expanduser()
existed_before = default_loc.exists()
default_loc.mkdir(exist_ok=True)
try:
assert isinstance(_resolve_platform_dirs(), SFPlatformDirs)
finally:
Expand Down

0 comments on commit 125a2db

Please sign in to comment.