Merge lp:~jelmer/brz/cython3 into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/cython3
Merge into: lp:brz
Diff against target: 123 lines (+29/-13)
3 files modified
breezy/bzr/_btree_serializer_pyx.pyx (+1/-1)
breezy/bzr/_chk_map_pyx.pyx (+25/-9)
breezy/bzr/_dirstate_helpers_pyx.pyx (+3/-3)
To merge this branch: bzr merge lp:~jelmer/brz/cython3
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+373059@code.launchpad.net

Description of the change

Fix Python3 compatibility in Cython files, and fix some warnings.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Changes all look reasonable. I thought we'd got all these in a previous round though...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bzr/_btree_serializer_pyx.pyx'
--- breezy/bzr/_btree_serializer_pyx.pyx 2018-07-14 20:08:53 +0000
+++ breezy/bzr/_btree_serializer_pyx.pyx 2019-09-22 02:39:00 +0000
@@ -583,7 +583,7 @@
583 hi = self.num_records583 hi = self.num_records
584 local_n_cmp = 0584 local_n_cmp = 0
585 while lo < hi:585 while lo < hi:
586 mid = (lo + hi) / 2586 mid = (lo + hi) // 2
587 the_cmp = memcmp(self.records[mid].sha1, sha1, 20)587 the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
588 if the_cmp == 0:588 if the_cmp == 0:
589 return &self.records[mid]589 return &self.records[mid]
590590
=== modified file 'breezy/bzr/_chk_map_pyx.pyx'
--- breezy/bzr/_chk_map_pyx.pyx 2018-11-17 18:20:36 +0000
+++ breezy/bzr/_chk_map_pyx.pyx 2019-09-22 02:39:00 +0000
@@ -179,14 +179,22 @@
179 :param bytes: The bytes of the node.179 :param bytes: The bytes of the node.
180 :param key: The key that the serialised node has.180 :param key: The key that the serialised node has.
181 """181 """
182 cdef char *c_bytes, *cur, *next, *end182 cdef char *c_bytes
183 cdef char *cur
184 cdef char *next
185 cdef char *end
183 cdef char *next_line186 cdef char *next_line
184 cdef Py_ssize_t c_bytes_len, prefix_length, items_length187 cdef Py_ssize_t c_bytes_len, prefix_length, items_length
185 cdef int maximum_size, width, length, i, prefix_tail_len188 cdef int maximum_size, width, length, i, prefix_tail_len
186 cdef int num_value_lines, num_prefix_bits189 cdef int num_value_lines, num_prefix_bits
187 cdef char *prefix, *value_start, *prefix_tail190 cdef char *prefix
188 cdef char *next_null, *last_null, *line_start191 cdef char *value_start
189 cdef char *c_entry, *entry_start192 cdef char *prefix_tail
193 cdef char *next_null
194 cdef char *last_null
195 cdef char *line_start
196 cdef char *c_entry
197 cdef char *entry_start
190 cdef StaticTuple entry_bits198 cdef StaticTuple entry_bits
191199
192 if _LeafNode is None:200 if _LeafNode is None:
@@ -201,7 +209,7 @@
201 c_bytes = PyBytes_AS_STRING(data)209 c_bytes = PyBytes_AS_STRING(data)
202 c_bytes_len = PyBytes_GET_SIZE(data)210 c_bytes_len = PyBytes_GET_SIZE(data)
203211
204 if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:212 if c_bytes_len < 9 or memcmp(c_bytes, b"chkleaf:\n", 9) != 0:
205 raise ValueError("not a serialised leaf node: %r" % data)213 raise ValueError("not a serialised leaf node: %r" % data)
206 if c_bytes[c_bytes_len - 1] != c'\n':214 if c_bytes[c_bytes_len - 1] != c'\n':
207 raise ValueError("bytes does not end in a newline")215 raise ValueError("bytes does not end in a newline")
@@ -323,11 +331,16 @@
323331
324332
325def _deserialise_internal_node(data, key, search_key_func=None):333def _deserialise_internal_node(data, key, search_key_func=None):
326 cdef char *c_bytes, *cur, *end334 cdef char *c_bytes
335 cdef char *cur
336 cdef char *end
327 cdef char *next_line337 cdef char *next_line
328 cdef Py_ssize_t c_bytes_len, prefix_length338 cdef Py_ssize_t c_bytes_len, prefix_length
329 cdef int maximum_size, width, length, i, prefix_tail_len339 cdef int maximum_size, width, length, i, prefix_tail_len
330 cdef char *prefix, *line_prefix, *next_null, *c_item_prefix340 cdef char *prefix
341 cdef char *line_prefix
342 cdef char *next_null
343 cdef char *c_item_prefix
331344
332 if _InternalNode is None:345 if _InternalNode is None:
333 _import_globals()346 _import_globals()
@@ -341,7 +354,7 @@
341 c_bytes = PyBytes_AS_STRING(data)354 c_bytes = PyBytes_AS_STRING(data)
342 c_bytes_len = PyBytes_GET_SIZE(data)355 c_bytes_len = PyBytes_GET_SIZE(data)
343356
344 if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:357 if c_bytes_len < 9 or memcmp(c_bytes, b"chknode:\n", 9) != 0:
345 raise ValueError("not a serialised internal node: %r" % data)358 raise ValueError("not a serialised internal node: %r" % data)
346 if c_bytes[c_bytes_len - 1] != c'\n':359 if c_bytes[c_bytes_len - 1] != c'\n':
347 raise ValueError("bytes does not end in a newline")360 raise ValueError("bytes does not end in a newline")
@@ -396,7 +409,10 @@
396def _bytes_to_text_key(data):409def _bytes_to_text_key(data):
397 """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""410 """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""
398 cdef StaticTuple key411 cdef StaticTuple key
399 cdef char *byte_str, *cur_end, *file_id_str, *byte_end412 cdef char *byte_str
413 cdef char *cur_end
414 cdef char *file_id_str
415 cdef char *byte_end
400 cdef char *revision_str416 cdef char *revision_str
401 cdef Py_ssize_t byte_size, pos, file_id_len417 cdef Py_ssize_t byte_size, pos, file_id_len
402418
403419
=== modified file 'breezy/bzr/_dirstate_helpers_pyx.pyx'
--- breezy/bzr/_dirstate_helpers_pyx.pyx 2019-09-21 18:32:14 +0000
+++ breezy/bzr/_dirstate_helpers_pyx.pyx 2019-09-22 02:39:00 +0000
@@ -397,7 +397,7 @@
397 path_size = PyBytes_Size(path)397 path_size = PyBytes_Size(path)
398398
399 while _lo < _hi:399 while _lo < _hi:
400 _mid = (_lo + _hi) / 2400 _mid = (_lo + _hi) // 2
401 cur = PyList_GetItem_object_void(paths, _mid)401 cur = PyList_GetItem_object_void(paths, _mid)
402 cur_cstr = PyBytes_AS_STRING_void(cur)402 cur_cstr = PyBytes_AS_STRING_void(cur)
403 cur_size = PyBytes_GET_SIZE_void(cur)403 cur_size = PyBytes_GET_SIZE_void(cur)
@@ -450,7 +450,7 @@
450 path_size = PyBytes_Size(path)450 path_size = PyBytes_Size(path)
451451
452 while _lo < _hi:452 while _lo < _hi:
453 _mid = (_lo + _hi) / 2453 _mid = (_lo + _hi) // 2
454 cur = PyList_GetItem_object_void(paths, _mid)454 cur = PyList_GetItem_object_void(paths, _mid)
455 cur_cstr = PyBytes_AS_STRING_void(cur)455 cur_cstr = PyBytes_AS_STRING_void(cur)
456 cur_size = PyBytes_GET_SIZE_void(cur)456 cur_size = PyBytes_GET_SIZE_void(cur)
@@ -497,7 +497,7 @@
497 dirname_size = PyBytes_Size(dirname)497 dirname_size = PyBytes_Size(dirname)
498498
499 while _lo < _hi:499 while _lo < _hi:
500 _mid = (_lo + _hi) / 2500 _mid = (_lo + _hi) // 2
501 # Grab the dirname for the current dirblock501 # Grab the dirname for the current dirblock
502 # cur = dirblocks[_mid][0]502 # cur = dirblocks[_mid][0]
503 cur = PyTuple_GetItem_void_void(503 cur = PyTuple_GetItem_void_void(

Subscribers

People subscribed via source and target branches