From b8ea04d1ea0c27efae8bd9effded202018384c3b Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:30:49 +0000 Subject: [PATCH 1/4] Fix warning about deprecated language='c++' --- setup.py | 1 - src/dawg.pyx | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b24b2f5..af06cca 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,6 @@ ext_modules = cythonize( extensions, - language="c++", annotate=False, compiler_directives=compiler_directives, ) diff --git a/src/dawg.pyx b/src/dawg.pyx index ec2b91e..d452274 100644 --- a/src/dawg.pyx +++ b/src/dawg.pyx @@ -1,5 +1,6 @@ # cython: profile=False # cython: embedsignature=True +# distutils: language=c++ cimport _dawg cimport _dictionary_builder From 09803656e46e8e49cb22380c48b0446b7c5768ef Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:34:29 +0000 Subject: [PATCH 2/4] Fix warnings about nogil before except --- src/_dictionary.pxd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_dictionary.pxd b/src/_dictionary.pxd index c9415c7..365ad5d 100644 --- a/src/_dictionary.pxd +++ b/src/_dictionary.pxd @@ -23,10 +23,10 @@ cdef extern from "../lib/dawgdic/src/dawgdic/dictionary.h" namespace "dawgdic": ValueType value(BaseType index) nogil # Reads a dictionary from an input stream. - bint Read(istream *input) nogil except + + bint Read(istream *input) except + nogil # Writes a dictionry to an output stream. - bint Write(ostream *output) nogil except + + bint Write(ostream *output) except + nogil # Exact matching. bint Contains(CharType *key) nogil From 94adb0fd68d931db2cd4eeb470bf008819921e99 Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:20:40 +0000 Subject: [PATCH 3/4] Make i variables unsigned --- src/dawg.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dawg.pyx b/src/dawg.pyx index d452274..7bfe475 100644 --- a/src/dawg.pyx +++ b/src/dawg.pyx @@ -581,7 +581,7 @@ cdef class BytesDAWG(CompletionDAWG): cpdef list items(self, unicode prefix=""): cdef bytes b_prefix = prefix.encode('utf8') cdef bytes value - cdef int i + cdef unsigned int i cdef list res = [] cdef char* raw_key cdef char* raw_value @@ -623,7 +623,7 @@ cdef class BytesDAWG(CompletionDAWG): def iteritems(self, unicode prefix=""): cdef bytes b_prefix = prefix.encode('utf8') cdef bytes value - cdef int i + cdef unsigned int i cdef char* raw_key cdef char* raw_value cdef int raw_value_len @@ -659,7 +659,7 @@ cdef class BytesDAWG(CompletionDAWG): cpdef list keys(self, unicode prefix=""): cdef bytes b_prefix = prefix.encode('utf8') - cdef int i + cdef unsigned int i cdef list res = [] cdef char* raw_key @@ -684,7 +684,7 @@ cdef class BytesDAWG(CompletionDAWG): def iterkeys(self, unicode prefix=""): cdef bytes b_prefix = prefix.encode('utf8') - cdef int i + cdef unsigned int i cdef char* raw_key cdef BaseType index = self.dct.root() From 9011b30be4d0b2007ed6c8e5380148113d0d9381 Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:33:46 +0000 Subject: [PATCH 4/4] Fix warning about possibly unitialized i variable --- src/dawg.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dawg.pyx b/src/dawg.pyx index 7bfe475..f94999b 100644 --- a/src/dawg.pyx +++ b/src/dawg.pyx @@ -605,6 +605,8 @@ cdef class BytesDAWG(CompletionDAWG): for i in range(0, completer.length()): if raw_key[i] == self._c_payload_separator: break + else: + continue raw_value = &(raw_key[i]) raw_value_len = completer.length() - i @@ -677,6 +679,8 @@ cdef class BytesDAWG(CompletionDAWG): for i in range(0, completer.length()): if raw_key[i] == self._c_payload_separator: break + else: + continue u_key = raw_key[:i].decode('utf8') res.append(u_key)