fix #4: segfault when no encoding detected

caused by trying to wrap 0 as a Python string
This commit is contained in:
Denis Bilenko 2013-08-03 17:13:43 +02:00
parent 1b10a34418
commit 1d2dea0207

View file

@ -30,6 +30,7 @@ def detect(char *msg):
ret = csd_close(csd)
elif result == 0: # Detected early
ret = csd_close(csd)
if ret:
return ret
def detect_with_confidence(char *msg):
@ -45,5 +46,7 @@ def detect_with_confidence(char *msg):
detected_charset = csd_close2(csd, &confidence)
else: # Error, signal with a negative number
raise Exception("Error, signal with a negative number")
return detected_charset,confidence
if detected_charset:
return detected_charset, confidence
else:
return None, None