aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-12-20 05:26:47 +0600
committerSergey M․ <dstftw@gmail.com>2015-12-20 05:26:47 +0600
commitfdae2358581be6f80ac5fd20b1062e87a8797f46 (patch)
treefe8d94c2d77853ab5440a153938cc0f4c1dc96d3 /youtube_dl
parent1deb710f26b0ccd14db13103cb400b663e243c57 (diff)
[utils] Add error_to_str
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 5b396ede8..6d3119760 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1806,6 +1806,15 @@ def args_to_str(args):
return ' '.join(shlex_quote(a) for a in args)
+def error_to_str(err):
+ err_str = str(err)
+ # On python 2 error byte string must be decoded with proper
+ # encoding rather than ascii
+ if sys.version_info[0] < 3:
+ err_str = err_str.decode(preferredencoding())
+ return err_str
+
+
def mimetype2ext(mt):
_, _, res = mt.rpartition('/')