Skip to content

Commit

Permalink
Use os.replace for Windows compat
Browse files Browse the repository at this point in the history
Solves update script running on Windows, issue #23.
  • Loading branch information
ko-zu committed Jan 31, 2023
1 parent 07e8e87 commit 8ae0d58
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion publicsuffixlist/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def updatePSL(psl_file=PSLFILE):
with open(psl_file + ".swp", "rb") as f:
psl = PublicSuffixList(f)

os.rename(psl_file + ".swp", psl_file)
try:
os.replace(psl_file + ".swp", psl_file)
except AttributeError:
# will not work on python2 on Win.
os.rename(psl_file + ".swp", psl_file)

if lastmod:
t = calendar.timegm(parsedate(lastmod))
os.utime(psl_file, (t, t))
Expand Down

0 comments on commit 8ae0d58

Please sign in to comment.