From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Tue, 10 Oct 2023 02:15:51 +0000 (-0700) Subject: Report all stacktraces in verbose mode (#3938) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/7aa37ea0adf864baf3ef3dfbcfaf5ff1ff780250?ds=sidebyside Report all stacktraces in verbose mode (#3938) Previously these were swallowed (unlike the ones in black/__init__.py) --- diff --git a/CHANGES.md b/CHANGES.md index fe4b621..6ad6308 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,6 +44,8 @@ - Black no longer attempts to provide special errors for attempting to format Python 2 code (#3933) +- Black will more consistently print stacktraces on internal errors in verbose mode + (#3938) ### _Blackd_ diff --git a/src/black/concurrency.py b/src/black/concurrency.py index ce01657..55c96b6 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -9,6 +9,7 @@ import logging import os import signal import sys +import traceback from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor from multiprocessing import Manager from pathlib import Path @@ -170,8 +171,10 @@ async def schedule_formatting( src = tasks.pop(task) if task.cancelled(): cancelled.append(task) - elif task.exception(): - report.failed(src, str(task.exception())) + elif exc := task.exception(): + if report.verbose: + traceback.print_exception(type(exc), exc, exc.__traceback__) + report.failed(src, str(exc)) else: changed = Changed.YES if task.result() else Changed.NO # If the file was written back or was successfully checked as