Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint does not crash when PYLINT_HOME does not exist #4884

Merged
merged 1 commit into from Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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