From c6c733d4a31eb4ee6324d64215a4492ab88dd75f Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sat, 8 Oct 2016 09:27:24 -0400 Subject: [PATCH 1/2] Print traceback when raising UnavailableVideoError An OSError or IOError generally indicates something a little more wrong than a "simple" UnavailableVideoError, so print the actual traceback that leads to the exception. Otherwise meaningful postmortem debugging a bug report is essentially infeasible. --- youtube_dl/YoutubeDL.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 99825e343..166fe8b15 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1701,6 +1701,7 @@ class YoutubeDL(object): self.report_error('unable to download video data: %s' % error_to_compat_str(err)) return except (OSError, IOError) as err: + traceback.print_exc() raise UnavailableVideoError(err) except (ContentTooShortError, ) as err: self.report_error('content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) From 9d92ac88053a320d48b448542dc2f9dc196d763f Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 9 Oct 2016 10:18:52 -0400 Subject: [PATCH 2/2] Send traceback to stderr explicitly Per @yan12125, traceback.print_exc() can send output to the wrong place under some circumstances (e.g. use of logger), so send it to stderr. Which requires a compat_str. --- youtube_dl/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 166fe8b15..28d0f1e78 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1701,7 +1701,7 @@ class YoutubeDL(object): self.report_error('unable to download video data: %s' % error_to_compat_str(err)) return except (OSError, IOError) as err: - traceback.print_exc() + self.to_stderr(encode_compat_str(traceback.format_exc())) raise UnavailableVideoError(err) except (ContentTooShortError, ) as err: self.report_error('content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))