Repository: gitpython-developers/GitPython (python)

Issue:
Cloning to Path from pathlib no longer work
Since version 2.1.7 using `Path` from `pathlib` to declare path in `Repo.clone_from` doesn't work anymore - it was working fine on 2.1.6 and before.

How to reproduce:

```
pip install gitpython==2.1.7
```

Run

```
from pathlib import Path
from git import Repo

path = Path("test1").resolve()
repo = Repo.clone_from("https://github.com/gitpython-developers/async.git", path)
```

On 2.1.7 it raises `TypeError`

```
Traceback (most recent call last):
  File "script.py", line 6, in <module>
    repo = Repo.clone_from("https://github.com/gitpython-developers/async.git", path)
  File "/home/miki/.pyenv/versions/test_gitpython/lib/python3.6/site-packages/git/repo/base.py", line 972, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
  File "/home/miki/.pyenv/versions/test_gitpython/lib/python3.6/site-packages/git/repo/base.py", line 939, in _clone
    repo = cls(path, odbt=odbt)
  File "/home/miki/.pyenv/versions/test_gitpython/lib/python3.6/site-packages/git/repo/base.py", line 125, in __init__
    if expand_vars and ("%" in epath or "$" in epath):
TypeError: argument of type 'PosixPath' is not iterable
```

I am running this on python 3.6.2.

Pull request:
Converting path in _clone to str before any other operation
In case eg pathlib.Path is passed.

Fixed #684 

Patch:
diff --git a/AUTHORS b/AUTHORS
index 98167ea7..f9540907 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,5 +23,6 @@ Contributors are:
 -Ken Odegard <ken.odegard _at_ gmail.com>
 -Alexis Horgix Chotard
 -Piotr Babij <piotr.babij _at_ gmail.com>
+-Mikuláš Poul <mikulaspoul _at_ gmail.com>
 
 Portions derived from other open source works and are clearly marked.
diff --git a/git/repo/base.py b/git/repo/base.py
index 9ed3f714..6ee95aed 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -905,6 +905,10 @@ class Repo(object):
 
         odbt = kwargs.pop('odbt', odb_default_type)
 
+        # when pathlib.Path or other classbased path is passed
+        if not isinstance(path, str):
+            path = str(path)
+
         ## A bug win cygwin's Git, when `--bare` or `--separate-git-dir`
         #  it prepends the cwd or(?) the `url` into the `path, so::
         #        git clone --bare  /cygwin/d/foo.git  C:\\Work


Test patch:
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 86fb2f51..2c3ad957 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -16,6 +16,11 @@ try:
 except ImportError:
     from unittest2 import skipIf, SkipTest
 
+try:
+    import pathlib
+except ImportError:
+    pathlib = None
+
 from git import (
     InvalidGitRepositoryError,
     Repo,
@@ -210,6 +215,15 @@ class TestRepo(TestBase):
 
         assert_equal(environment, cloned.git.environment())
 
+    @with_rw_directory
+    def test_clone_from_pathlib(self, rw_dir):
+        if pathlib is None:  # pythons bellow 3.4 don't have pathlib
+            raise SkipTest("pathlib was introduced in 3.4")
+
+        original_repo = Repo.init(osp.join(rw_dir, "repo"))
+
+        Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib")
+
     def test_init(self):
         prev_cwd = os.getcwd()
         os.chdir(tempfile.gettempdir())