Skip to content

Commit

Permalink
pylint does not crash when PYLINT_HOME does not exist (#4884)
Browse files Browse the repository at this point in the history
Closes #4883
  • Loading branch information
AWhetter committed Aug 21, 2021
1 parent bbc4f66 commit d701a97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ChangeLog
Expand Up @@ -15,9 +15,9 @@ What's New in Pylint 2.10.1?
============================
Release date: TBA

..
Put bug fixes that should not wait for a new minor version here
* pylint does not crash when PYLINT_HOME does not exist.

Closes #4883


What's New in Pylint 2.10.0?
Expand Down
16 changes: 10 additions & 6 deletions pylint/config/__init__.py
Expand Up @@ -35,6 +35,7 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE

import os
import pathlib
import pickle
import sys
from datetime import datetime
Expand Down Expand Up @@ -86,14 +87,17 @@
file=sys.stderr,
)
# Remove old spam prevention file
for filename in os.listdir(PYLINT_HOME):
if prefix_spam_prevention in filename:
try:
os.remove(os.path.join(PYLINT_HOME, filename))
except OSError:
pass
if os.path.exists(PYLINT_HOME):
for filename in os.listdir(PYLINT_HOME):
if prefix_spam_prevention in filename:
try:
os.remove(os.path.join(PYLINT_HOME, filename))
except OSError:
pass

# Create spam prevention file for today
try:
pathlib.Path(PYLINT_HOME).mkdir(parents=True, exist_ok=True)
with open(spam_prevention_file, "w", encoding="utf8") as f:
f.write("")
except Exception: # pylint: disable=broad-except
Expand Down

0 comments on commit d701a97

Please sign in to comment.