File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ def __init__(
223223
224224 epath = epath or path or os .getcwd ()
225225 if not isinstance (epath , str ):
226- epath = str ( epath )
226+ epath = epath . __fspath__ ( )
227227 if expand_vars and re .search (self .re_envvars , epath ):
228228 warnings .warn (
229229 "The use of environment variables in paths is deprecated"
Original file line number Diff line number Diff line change 33# This module is part of GitPython and is released under the
44# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55
6+ from dataclasses import dataclass
67import gc
78import glob
89import io
@@ -105,6 +106,18 @@ def test_repo_creation_pathlib(self, rw_repo):
105106 r_from_gitdir = Repo (pathlib .Path (rw_repo .git_dir ))
106107 self .assertEqual (r_from_gitdir .git_dir , rw_repo .git_dir )
107108
109+ @with_rw_repo ("0.3.2.1" )
110+ def test_repo_creation_pathlike (self , rw_repo ):
111+ @dataclass
112+ class PathLikeMock :
113+ path : str
114+
115+ def __fspath__ (self ) -> str :
116+ return self .path
117+
118+ r_from_gitdir = Repo (PathLikeMock (rw_repo .git_dir ))
119+ self .assertEqual (r_from_gitdir .git_dir , rw_repo .git_dir )
120+
108121 def test_description (self ):
109122 txt = "Test repository"
110123 self .rorepo .description = txt
You can’t perform that action at this time.
0 commit comments