Output detected encoding as well in the warning

This commit is contained in:
Kovid Goyal 2015-06-26 14:14:42 +05:30
parent e9c6dbc24b
commit 6482a66bb7

View File

@ -73,8 +73,8 @@ def force_encoding(raw, verbose, assume_utf8=False):
if chardet['confidence'] < 1 and assume_utf8:
encoding = 'utf-8'
if chardet['confidence'] < 1 and verbose:
print('WARNING: Encoding detection confidence %d%%'%(
chardet['confidence']*100))
print('WARNING: Encoding detection confidence for %s is %d%%'%(
chardet['encoding'], chardet['confidence']*100))
if not encoding:
encoding = preferred_encoding
encoding = encoding.lower()