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
1=== modified file 'breezy/bzr/_btree_serializer_pyx.pyx'
2--- breezy/bzr/_btree_serializer_pyx.pyx 2018-07-14 20:08:53 +0000
3+++ breezy/bzr/_btree_serializer_pyx.pyx 2019-09-22 02:39:00 +0000
4@@ -583,7 +583,7 @@
5 hi = self.num_records
6 local_n_cmp = 0
7 while lo < hi:
8- mid = (lo + hi) / 2
9+ mid = (lo + hi) // 2
10 the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
11 if the_cmp == 0:
12 return &self.records[mid]
13
14=== modified file 'breezy/bzr/_chk_map_pyx.pyx'
15--- breezy/bzr/_chk_map_pyx.pyx 2018-11-17 18:20:36 +0000
16+++ breezy/bzr/_chk_map_pyx.pyx 2019-09-22 02:39:00 +0000
17@@ -179,14 +179,22 @@
18 :param bytes: The bytes of the node.
19 :param key: The key that the serialised node has.
20 """
21- cdef char *c_bytes, *cur, *next, *end
22+ cdef char *c_bytes
23+ cdef char *cur
24+ cdef char *next
25+ cdef char *end
26 cdef char *next_line
27 cdef Py_ssize_t c_bytes_len, prefix_length, items_length
28 cdef int maximum_size, width, length, i, prefix_tail_len
29 cdef int num_value_lines, num_prefix_bits
30- cdef char *prefix, *value_start, *prefix_tail
31- cdef char *next_null, *last_null, *line_start
32- cdef char *c_entry, *entry_start
33+ cdef char *prefix
34+ cdef char *value_start
35+ cdef char *prefix_tail
36+ cdef char *next_null
37+ cdef char *last_null
38+ cdef char *line_start
39+ cdef char *c_entry
40+ cdef char *entry_start
41 cdef StaticTuple entry_bits
42
43 if _LeafNode is None:
44@@ -201,7 +209,7 @@
45 c_bytes = PyBytes_AS_STRING(data)
46 c_bytes_len = PyBytes_GET_SIZE(data)
47
48- if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:
49+ if c_bytes_len < 9 or memcmp(c_bytes, b"chkleaf:\n", 9) != 0:
50 raise ValueError("not a serialised leaf node: %r" % data)
51 if c_bytes[c_bytes_len - 1] != c'\n':
52 raise ValueError("bytes does not end in a newline")
53@@ -323,11 +331,16 @@
54
55
56 def _deserialise_internal_node(data, key, search_key_func=None):
57- cdef char *c_bytes, *cur, *end
58+ cdef char *c_bytes
59+ cdef char *cur
60+ cdef char *end
61 cdef char *next_line
62 cdef Py_ssize_t c_bytes_len, prefix_length
63 cdef int maximum_size, width, length, i, prefix_tail_len
64- cdef char *prefix, *line_prefix, *next_null, *c_item_prefix
65+ cdef char *prefix
66+ cdef char *line_prefix
67+ cdef char *next_null
68+ cdef char *c_item_prefix
69
70 if _InternalNode is None:
71 _import_globals()
72@@ -341,7 +354,7 @@
73 c_bytes = PyBytes_AS_STRING(data)
74 c_bytes_len = PyBytes_GET_SIZE(data)
75
76- if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:
77+ if c_bytes_len < 9 or memcmp(c_bytes, b"chknode:\n", 9) != 0:
78 raise ValueError("not a serialised internal node: %r" % data)
79 if c_bytes[c_bytes_len - 1] != c'\n':
80 raise ValueError("bytes does not end in a newline")
81@@ -396,7 +409,10 @@
82 def _bytes_to_text_key(data):
83 """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""
84 cdef StaticTuple key
85- cdef char *byte_str, *cur_end, *file_id_str, *byte_end
86+ cdef char *byte_str
87+ cdef char *cur_end
88+ cdef char *file_id_str
89+ cdef char *byte_end
90 cdef char *revision_str
91 cdef Py_ssize_t byte_size, pos, file_id_len
92
93
94=== modified file 'breezy/bzr/_dirstate_helpers_pyx.pyx'
95--- breezy/bzr/_dirstate_helpers_pyx.pyx 2019-09-21 18:32:14 +0000
96+++ breezy/bzr/_dirstate_helpers_pyx.pyx 2019-09-22 02:39:00 +0000
97@@ -397,7 +397,7 @@
98 path_size = PyBytes_Size(path)
99
100 while _lo < _hi:
101- _mid = (_lo + _hi) / 2
102+ _mid = (_lo + _hi) // 2
103 cur = PyList_GetItem_object_void(paths, _mid)
104 cur_cstr = PyBytes_AS_STRING_void(cur)
105 cur_size = PyBytes_GET_SIZE_void(cur)
106@@ -450,7 +450,7 @@
107 path_size = PyBytes_Size(path)
108
109 while _lo < _hi:
110- _mid = (_lo + _hi) / 2
111+ _mid = (_lo + _hi) // 2
112 cur = PyList_GetItem_object_void(paths, _mid)
113 cur_cstr = PyBytes_AS_STRING_void(cur)
114 cur_size = PyBytes_GET_SIZE_void(cur)
115@@ -497,7 +497,7 @@
116 dirname_size = PyBytes_Size(dirname)
117
118 while _lo < _hi:
119- _mid = (_lo + _hi) / 2
120+ _mid = (_lo + _hi) // 2
121 # Grab the dirname for the current dirblock
122 # cur = dirblocks[_mid][0]
123 cur = PyTuple_GetItem_void_void(

Subscribers

People subscribed via source and target branches