From 83de01b61c13bf2e4aa6b7307717e5d259d88e90 Mon Sep 17 00:00:00 2001 From: PyYoshi Date: Wed, 19 Sep 2012 18:45:04 +0900 Subject: [PATCH] changed few line. --- src/cchardet/_cchardet.pyx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cchardet/_cchardet.pyx b/src/cchardet/_cchardet.pyx index e7c866f..cac4151 100644 --- a/src/cchardet/_cchardet.pyx +++ b/src/cchardet/_cchardet.pyx @@ -1,4 +1,3 @@ -cimport cython from libc.stdlib cimport malloc, free import warnings @@ -28,9 +27,10 @@ def detect(char *msg): raise Exception("Error, signal with a negative number") elif result == 1: # Need more data warnings.warn("Need more data",UserWarning) - return csd_close(csd) + ret = csd_close(csd) elif result == 0: # Detected early - return csd_close(csd) + ret = csd_close(csd) + return ret def detect_with_confidence(char *msg): cdef csd_t csd = csd_open() @@ -45,14 +45,13 @@ def detect_with_confidence(char *msg): "encoding":detected_charset, "confidence":confidence } - return ret elif result == 0: # Detected early detected_charset = csd_close2(csd, &confidence) ret = { "encoding":detected_charset, "confidence":confidence } - return ret else: # Error, signal with a negative number raise Exception("Error, signal with a negative number") + return ret