Skip to content

Commit

Permalink
Merge pull request #125 from chardet/hotfix/debug_logging_crash
Browse files Browse the repository at this point in the history
Hotfix: Fix crash when debug logging is enabled and passed empty string
  • Loading branch information
dan-blanchard committed May 16, 2017
2 parents c47f6d7 + 780c3cd commit 7c9cf61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions chardet/universaldetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class a user of ``chardet`` should use.
import logging
import re

from .charsetgroupprober import CharSetGroupProber
from .enums import InputState, LanguageFilter, ProbingState
from .escprober import EscCharSetProber
from .latin1prober import Latin1Prober
Expand Down Expand Up @@ -268,11 +269,18 @@ def close(self):
if self.logger.getEffectiveLevel() == logging.DEBUG:
if self.result['encoding'] is None:
self.logger.debug('no probers hit minimum threshold')
for prober in self._charset_probers[0].probers:
if not prober:
for group_prober in self._charset_probers:
if not group_prober:
continue
self.logger.debug('%s %s confidence = %s',
prober.charset_name,
prober.language,
prober.get_confidence())
if isinstance(group_prober, CharSetGroupProber):
for prober in group_prober.probers:
self.logger.debug('%s %s confidence = %s',
prober.charset_name,
prober.language,
prober.get_confidence())
else:
self.logger.debug('%s %s confidence = %s',
prober.charset_name,
prober.language,
prober.get_confidence())
return self.result
2 changes: 1 addition & 1 deletion chardet/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
:author: Dan Blanchard (dan.blanchard@gmail.com)
"""

__version__ = "3.0.2"
__version__ = "3.0.3"
VERSION = __version__.split('.')

0 comments on commit 7c9cf61

Please sign in to comment.