Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #27

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

ext_modules = cythonize(
extensions,
language="c++",
annotate=False,
compiler_directives=compiler_directives,
)
Expand Down
4 changes: 2 additions & 2 deletions src/_dictionary.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/dawg.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# cython: profile=False
# cython: embedsignature=True
# distutils: language=c++

cimport _dawg
cimport _dictionary_builder
Expand Down Expand Up @@ -580,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
Expand All @@ -604,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
Expand All @@ -622,7 +625,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
Expand Down Expand Up @@ -658,7 +661,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

Expand All @@ -676,14 +679,16 @@ 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)
return res

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()
Expand Down