Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit91d4cc5

Browse files
committed
Use os.fspath instead of __fspath__ for reading paths
1 parent59c3c80 commit91d4cc5

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

‎git/config.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def read(self) -> None: # type: ignore[override]
634634
self._read(file_path,file_path.name)
635635
else:
636636
# Assume a path if it is not a file-object.
637-
file_path=cast(PathLike,file_path)
637+
file_path=os.fspath(file_path)
638638
try:
639639
withopen(file_path,"rb")asfp:
640640
file_ok=True

‎git/repo/base.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,9 @@ def __init__(
219219
# Given how the tests are written, this seems more likely to catch Cygwin
220220
# git used from Windows than Windows git used from Cygwin. Therefore
221221
# changing to Cygwin-style paths is the relevant operation.
222-
epath=cygpath(epathifisinstance(epath,str)elseepath.__fspath__())
222+
epath=cygpath(os.fspath(epath))
223223

224-
epath=epathorpathoros.getcwd()
225-
ifnotisinstance(epath,str):
226-
epath=epath.__fspath__()
224+
epath=os.fspath(epath)
227225
ifexpand_varsandre.search(self.re_envvars,epath):
228226
warnings.warn(
229227
"The use of environment variables in paths is deprecated"
@@ -1361,11 +1359,8 @@ def _clone(
13611359
)->"Repo":
13621360
odbt=kwargs.pop("odbt",odb_default_type)
13631361

1364-
# When pathlib.Path or other class-based path is passed
1365-
ifnotisinstance(url,str):
1366-
url=url.__fspath__()
1367-
ifnotisinstance(path,str):
1368-
path=path.__fspath__()
1362+
url=os.fspath(url)
1363+
path=os.fspath(path)
13691364

13701365
## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
13711366
# it prepends the cwd or(?) the `url` into the `path, so::

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp