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

Better error message when we cant write the crash files #5987

Merged
merged 2 commits into from
Mar 27, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pylint/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@
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
# Can't write in PYLINT_HOME ?
except Exception as exc: # pylint: disable=broad-except
print(
"Can't write the file that was supposed to "
f"prevent pylint.d deprecation spam in {PYLINT_HOME}."
f"prevent 'pylint.d' deprecation spam in {PYLINT_HOME} because of {exc}."
)


Expand Down
11 changes: 7 additions & 4 deletions pylint/lint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def prepare_crash_report(ex: Exception, filepath: str, crash_file_path: str) ->
pylint crashed with a ``{ex.__class__.__name__}`` and with the following stacktrace:
```
"""
template += traceback.format_exc()
template += "```\n"
try:
with open(issue_template_path, "a", encoding="utf8") as f:
f.write(template)
traceback.print_exc(file=f)
f.write("```\n")
except FileNotFoundError:
print(f"Can't write the issue template for the crash in {issue_template_path}.")
except Exception as exc: # pylint: disable=broad-except
print(
f"Can't write the issue template for the crash in {issue_template_path} "
f"because of: '{exc}'\nHere's the content anyway:\n{template}."
)
return issue_template_path


Expand Down