ishepard / pydriller

Python Framework to analyse Git repositories

Home Page:http://pydriller.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Temp file cleanup error on Windows with OSError 145

totoroyyb opened this issue · comments

Describe the bug
Python 3.88 on Windows still seems to have some problems cleaning up temp files.

I've noticed a workaround already applied here:

except PermissionError:
# on Windows, Python 3.5, 3.6, 3.7 are not able to delete
# git directories because of read-only files.
# In this case, just ignore the errors.
shutil.rmtree(self._tmp_dir.name, ignore_errors=True)

However, it doesn't catch the case I encountered. On Python 3.88 + Windows, it throws WinError 145, "Not an empty folder" as an OSError.

To Reproduce

I encountered such error by running this:

from pydriller import Repository, Commit

url = "https://github.com/hyperledger/cactus.git"

for commit in Repository(url, filepath='GOVERNANCE.md').traverse_commits():
    for file in commit.modified_files:
        if file.filename == "GOVERNANCE.md":
            print(f"Author: {commit.author.name}, change type: {file.change_type.name}, diff: \n {file.diff_parsed}")

OS Version:
Windows
Python 3.88

#214 PR is submitted.